| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Copyright (c) 2007-2012 Patrick McHardy <kaber@trash.net> | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License version 2 as | ||
| 6 | * published by the Free Software Foundation. | ||
| 7 | * | ||
| 8 | * Development of this code funded by Astaro AG (http://www.astaro.com/) | ||
| 9 | */ | ||
| 10 | |||
| 11 | %{ | ||
| 12 | #include <nft.h> | ||
| 13 | |||
| 14 | #include <ctype.h> | ||
| 15 | #include <stddef.h> | ||
| 16 | #include <stdio.h> | ||
| 17 | #include <inttypes.h> | ||
| 18 | #include <syslog.h> | ||
| 19 | #include <net/if.h> | ||
| 20 | #include <netinet/ip.h> | ||
| 21 | #include <netinet/tcp.h> | ||
| 22 | #include <netinet/if_ether.h> | ||
| 23 | #include <linux/netfilter.h> | ||
| 24 | #include <linux/netfilter/nf_tables.h> | ||
| 25 | #include <linux/netfilter/nf_conntrack_tuple_common.h> | ||
| 26 | #include <linux/netfilter/nf_nat.h> | ||
| 27 | #include <linux/netfilter/nf_log.h> | ||
| 28 | #include <linux/netfilter/nfnetlink_osf.h> | ||
| 29 | #include <linux/netfilter/nf_synproxy.h> | ||
| 30 | #include <linux/xfrm.h> | ||
| 31 | #include <netinet/ip_icmp.h> | ||
| 32 | #include <netinet/icmp6.h> | ||
| 33 | #include <libnftnl/common.h> | ||
| 34 | #include <libnftnl/set.h> | ||
| 35 | #include <libnftnl/udata.h> | ||
| 36 | |||
| 37 | #include <rule.h> | ||
| 38 | #include <cmd.h> | ||
| 39 | #include <statement.h> | ||
| 40 | #include <expression.h> | ||
| 41 | #include <headers.h> | ||
| 42 | #include <utils.h> | ||
| 43 | #include <parser.h> | ||
| 44 | #include <erec.h> | ||
| 45 | #include <sctp_chunk.h> | ||
| 46 | |||
| 47 | #include "parser_bison.h" | ||
| 48 | |||
| 49 | 62780 | void parser_init(struct nft_ctx *nft, struct parser_state *state, | |
| 50 | struct list_head *msgs, struct list_head *cmds, | ||
| 51 | struct scope *top_scope) | ||
| 52 | { | ||
| 53 | 62780 | memset(state, 0, sizeof(*state)); | |
| 54 | 62780 | state->msgs = msgs; | |
| 55 | 62780 | state->cmds = cmds; | |
| 56 | 62780 | state->scopes[0] = scope_init(top_scope, NULL); | |
| 57 | 62780 | init_list_head(&state->indesc_list); | |
| 58 | 62780 | } | |
| 59 | |||
| 60 | 236 | static void yyerror(struct location *loc, struct nft_ctx *nft, void *scanner, | |
| 61 | struct parser_state *state, const char *s) | ||
| 62 | { | ||
| 63 | 236 | erec_queue(error(loc, "%s", s), state->msgs); | |
| 64 | 236 | } | |
| 65 | |||
| 66 | 1114349 | static struct scope *current_scope(const struct parser_state *state) | |
| 67 | { | ||
| 68 | 1114349 | return state->scopes[state->scope]; | |
| 69 | } | ||
| 70 | |||
| 71 | 5855 | static int open_scope(struct parser_state *state, struct scope *scope) | |
| 72 | { | ||
| 73 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→4) taken 5854 times.
|
5855 | if (state->scope >= array_size(state->scopes) - 1) { |
| 74 | 1 | state->scope_err = true; | |
| 75 | 1 | return -1; | |
| 76 | } | ||
| 77 | |||
| 78 | 5854 | scope_init(scope, current_scope(state)); | |
| 79 | 5854 | state->scopes[++state->scope] = scope; | |
| 80 | |||
| 81 | 5854 | return 0; | |
| 82 | } | ||
| 83 | |||
| 84 | 5855 | static void close_scope(struct parser_state *state) | |
| 85 | { | ||
| 86 |
3/4✓ Branch 0 (2→3) taken 5854 times.
✓ Branch 1 (2→4) taken 1 times.
✗ Branch 2 (3→4) not taken.
✓ Branch 3 (3→5) taken 5854 times.
|
5855 | if (state->scope_err || state->scope == 0) { |
| 87 | 1 | state->scope_err = false; | |
| 88 | 1 | return; | |
| 89 | } | ||
| 90 | |||
| 91 | 5854 | state->scope--; | |
| 92 | } | ||
| 93 | |||
| 94 | 49498 | static void location_init(void *scanner, struct parser_state *state, | |
| 95 | struct location *loc) | ||
| 96 | { | ||
| 97 | 49498 | memset(loc, 0, sizeof(*loc)); | |
| 98 | 49498 | loc->indesc = state->indesc; | |
| 99 | 49498 | } | |
| 100 | |||
| 101 | 20701601 | static void location_update(struct location *loc, struct location *rhs, int n) | |
| 102 | { | ||
| 103 |
2/2✓ Branch 0 (2→3) taken 18932622 times.
✓ Branch 1 (2→4) taken 1768979 times.
|
20701601 | if (n) { |
| 104 | 18932622 | loc->indesc = rhs[n].indesc; | |
| 105 | 18932622 | loc->line_offset = rhs[1].line_offset; | |
| 106 | 18932622 | loc->first_line = rhs[1].first_line; | |
| 107 | 18932622 | loc->first_column = rhs[1].first_column; | |
| 108 | 18932622 | loc->last_column = rhs[n].last_column; | |
| 109 | } else { | ||
| 110 | 1768979 | loc->indesc = rhs[0].indesc; | |
| 111 | 1768979 | loc->line_offset = rhs[0].line_offset; | |
| 112 | 1768979 | loc->first_line = rhs[0].first_line; | |
| 113 | 1768979 | loc->first_column = loc->last_column = rhs[0].last_column; | |
| 114 | } | ||
| 115 | 20701601 | } | |
| 116 | |||
| 117 | 85852 | static struct expr *handle_concat_expr(const struct location *loc, | |
| 118 | struct expr *expr, | ||
| 119 | struct expr *expr_l, struct expr *expr_r, | ||
| 120 | struct location loc_rhs[3]) | ||
| 121 | { | ||
| 122 |
2/2✓ Branch 0 (2→3) taken 81973 times.
✓ Branch 1 (2→5) taken 3879 times.
|
85852 | if (expr->etype != EXPR_CONCAT) { |
| 123 | 81973 | expr = concat_expr_alloc(loc); | |
| 124 | 81973 | concat_expr_add(expr, expr_l); | |
| 125 | } else { | ||
| 126 | 3879 | location_update(&expr_r->location, loc_rhs, 2); | |
| 127 | |||
| 128 | 3879 | expr = expr_l; | |
| 129 | 3879 | expr->location = *loc; | |
| 130 | } | ||
| 131 | |||
| 132 | 85852 | concat_expr_add(expr, expr_r); | |
| 133 | 85852 | return expr; | |
| 134 | } | ||
| 135 | |||
| 136 | 3513 | static bool already_set(const void *attr, const struct location *loc, | |
| 137 | struct parser_state *state) | ||
| 138 | { | ||
| 139 |
2/2✓ Branch 0 (2→3) taken 3506 times.
✓ Branch 1 (2→4) taken 7 times.
|
3513 | if (!attr) |
| 140 | 3506 | return false; | |
| 141 | |||
| 142 | 7 | erec_queue(error(loc, "You can only specify this once. This statement is duplicated."), | |
| 143 | state->msgs); | ||
| 144 | 7 | return true; | |
| 145 | } | ||
| 146 | |||
| 147 | 11 | static bool tunnel_set_type(const struct location *loc, | |
| 148 | struct obj *obj, enum tunnel_type type, const char *name, | ||
| 149 | struct parser_state *state) | ||
| 150 | { | ||
| 151 |
2/2✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→6) taken 10 times.
|
11 | if (obj->tunnel.type) { |
| 152 | 1 | erec_queue(error(loc, "Cannot create new %s section inside another tunnel", name), state->msgs); | |
| 153 | 1 | return false; | |
| 154 | } | ||
| 155 | |||
| 156 | 10 | obj->tunnel.type = type; | |
| 157 | 10 | return true; | |
| 158 | } | ||
| 159 | |||
| 160 | 1295 | static struct expr *ifname_expr_alloc(const struct location *location, | |
| 161 | struct list_head *queue, | ||
| 162 | const char *name) | ||
| 163 | { | ||
| 164 | 1295 | size_t length = strlen(name); | |
| 165 | struct expr *expr; | ||
| 166 | |||
| 167 |
2/2✓ Branch 0 (2→3) taken 3 times.
✓ Branch 1 (2→6) taken 1292 times.
|
1295 | if (length == 0) { |
| 168 | 3 | free_const(name); | |
| 169 | 3 | erec_queue(error(location, "empty interface name"), queue); | |
| 170 | 3 | return NULL; | |
| 171 | } | ||
| 172 | |||
| 173 |
2/2✓ Branch 0 (6→7) taken 1 times.
✓ Branch 1 (6→10) taken 1291 times.
|
1292 | if (length >= IFNAMSIZ) { |
| 174 | 1 | free_const(name); | |
| 175 | 1 | erec_queue(error(location, "interface name too long"), queue); | |
| 176 | 1 | return NULL; | |
| 177 | } | ||
| 178 | |||
| 179 | 1291 | expr = constant_expr_alloc(location, &ifname_type, BYTEORDER_HOST_ENDIAN, | |
| 180 | length * BITS_PER_BYTE, name); | ||
| 181 | |||
| 182 | 1291 | free_const(name); | |
| 183 | |||
| 184 | 1291 | return expr; | |
| 185 | } | ||
| 186 | |||
| 187 | 2 | static void timeout_state_free(struct timeout_state *s) | |
| 188 | { | ||
| 189 | 2 | free_const(s->timeout_str); | |
| 190 | 2 | free(s); | |
| 191 | 2 | } | |
| 192 | |||
| 193 | 1 | static void timeout_states_free(struct list_head *list) | |
| 194 | { | ||
| 195 | struct timeout_state *ts, *next; | ||
| 196 | |||
| 197 |
2/2✓ Branch 0 (6→3) taken 2 times.
✓ Branch 1 (6→7) taken 1 times.
|
3 | list_for_each_entry_safe(ts, next, list, head) { |
| 198 | 2 | list_del(&ts->head); | |
| 199 | 2 | timeout_state_free(ts); | |
| 200 | } | ||
| 201 | |||
| 202 | 1 | free(list); | |
| 203 | 1 | } | |
| 204 | |||
| 205 | #define YYLLOC_DEFAULT(Current, Rhs, N) location_update(&Current, Rhs, N) | ||
| 206 | |||
| 207 | #define symbol_value(loc, str) \ | ||
| 208 | symbol_expr_alloc(loc, SYMBOL_VALUE, current_scope(state), str) | ||
| 209 | |||
| 210 | /* Declare those here to avoid compiler warnings */ | ||
| 211 | void nft_set_debug(int, void *); | ||
| 212 | int nft_lex(void *, void *, void *); | ||
| 213 | %} | ||
| 214 | |||
| 215 | /* Declaration section */ | ||
| 216 | |||
| 217 | %name-prefix "nft_" | ||
| 218 | %debug | ||
| 219 | %define api.pure | ||
| 220 | %parse-param { struct nft_ctx *nft } | ||
| 221 | %parse-param { void *scanner } | ||
| 222 | %parse-param { struct parser_state *state } | ||
| 223 | %lex-param { scanner } | ||
| 224 | %define parse.error custom | ||
| 225 | %define parse.lac full | ||
| 226 | %locations | ||
| 227 | |||
| 228 | %initial-action { | ||
| 229 | 49499 | location_init(scanner, state, &yylloc); | |
| 230 |
1/2✗ Branch 0 (5→6) not taken.
✓ Branch 1 (5→7) taken 49499 times.
|
49499 | if (nft->debug_mask & NFT_DEBUG_SCANNER) |
| 231 | ✗ | nft_set_debug(1, scanner); | |
| 232 |
1/2✗ Branch 0 (7→8) not taken.
✓ Branch 1 (7→9) taken 49499 times.
|
49499 | if (nft->debug_mask & NFT_DEBUG_PARSER) |
| 233 | ✗ | yydebug = 1; | |
| 234 | } | ||
| 235 | |||
| 236 | %union { | ||
| 237 | uint64_t val; | ||
| 238 | uint32_t val32; | ||
| 239 | uint8_t val8; | ||
| 240 | const char * string; | ||
| 241 | |||
| 242 | struct list_head *list; | ||
| 243 | struct cmd *cmd; | ||
| 244 | struct handle handle; | ||
| 245 | struct table *table; | ||
| 246 | struct chain *chain; | ||
| 247 | struct rule *rule; | ||
| 248 | struct stmt *stmt; | ||
| 249 | struct expr *expr; | ||
| 250 | struct set *set; | ||
| 251 | struct obj *obj; | ||
| 252 | struct flowtable *flowtable; | ||
| 253 | struct ct *ct; | ||
| 254 | const struct datatype *datatype; | ||
| 255 | struct handle_spec handle_spec; | ||
| 256 | struct position_spec position_spec; | ||
| 257 | struct prio_spec prio_spec; | ||
| 258 | struct limit_rate limit_rate; | ||
| 259 | struct tcp_kind_field { | ||
| 260 | uint16_t kind; /* must allow > 255 for SACK1, 2.. hack */ | ||
| 261 | uint8_t field; | ||
| 262 | } tcp_kind_field; | ||
| 263 | struct timeout_state *timeout_state; | ||
| 264 | } | ||
| 265 | |||
| 266 | %token TOKEN_EOF 0 "end of file" | ||
| 267 | %token JUNK "junk" | ||
| 268 | %token CRLF "CRLF line terminators" | ||
| 269 | |||
| 270 | %token NEWLINE "newline" | ||
| 271 | %token COLON "colon" | ||
| 272 | %token SEMICOLON "semicolon" | ||
| 273 | %token COMMA "comma" | ||
| 274 | %token DOT "." | ||
| 275 | |||
| 276 | %token EQ "==" | ||
| 277 | %token NEQ "!=" | ||
| 278 | %token LT "<" | ||
| 279 | %token GT ">" | ||
| 280 | %token GTE ">=" | ||
| 281 | %token LTE "<=" | ||
| 282 | %token LSHIFT "<<" | ||
| 283 | %token RSHIFT ">>" | ||
| 284 | %token AMPERSAND "&" | ||
| 285 | %token CARET "^" | ||
| 286 | %token NOT "!" | ||
| 287 | %token SLASH "/" | ||
| 288 | %token ASTERISK "*" | ||
| 289 | %token DASH "-" | ||
| 290 | %token AT "@" | ||
| 291 | %token VMAP "vmap" | ||
| 292 | |||
| 293 | %token PLUS "+" | ||
| 294 | |||
| 295 | %token INCLUDE "include" | ||
| 296 | %token DEFINE "define" | ||
| 297 | %token REDEFINE "redefine" | ||
| 298 | %token UNDEFINE "undefine" | ||
| 299 | |||
| 300 | %token FIB "fib" | ||
| 301 | %token CHECK "check" | ||
| 302 | |||
| 303 | %token SOCKET "socket" | ||
| 304 | %token TRANSPARENT "transparent" | ||
| 305 | %token WILDCARD "wildcard" | ||
| 306 | %token CGROUPV2 "cgroupv2" | ||
| 307 | |||
| 308 | %token TPROXY "tproxy" | ||
| 309 | |||
| 310 | %token OSF "osf" | ||
| 311 | |||
| 312 | %token SYNPROXY "synproxy" | ||
| 313 | %token MSS "mss" | ||
| 314 | %token WSCALE "wscale" | ||
| 315 | |||
| 316 | %token TYPEOF "typeof" | ||
| 317 | |||
| 318 | %token HOOK "hook" | ||
| 319 | %token HOOKS "hooks" | ||
| 320 | %token DEVICE "device" | ||
| 321 | %token DEVICES "devices" | ||
| 322 | %token TABLE "table" | ||
| 323 | %token TABLES "tables" | ||
| 324 | %token CHAIN "chain" | ||
| 325 | %token CHAINS "chains" | ||
| 326 | %token RULE "rule" | ||
| 327 | %token RULES "rules" | ||
| 328 | %token SETS "sets" | ||
| 329 | %token SET "set" | ||
| 330 | %token ELEMENT "element" | ||
| 331 | %token MAP "map" | ||
| 332 | %token MAPS "maps" | ||
| 333 | %token FLOWTABLE "flowtable" | ||
| 334 | %token HANDLE "handle" | ||
| 335 | %token RULESET "ruleset" | ||
| 336 | %token TRACE "trace" | ||
| 337 | |||
| 338 | %token PATH "path" | ||
| 339 | |||
| 340 | %token INET "inet" | ||
| 341 | %token NETDEV "netdev" | ||
| 342 | |||
| 343 | %token ADD "add" | ||
| 344 | %token UPDATE "update" | ||
| 345 | %token REPLACE "replace" | ||
| 346 | %token CREATE "create" | ||
| 347 | %token INSERT "insert" | ||
| 348 | %token DELETE "delete" | ||
| 349 | %token GET "get" | ||
| 350 | %token LIST "list" | ||
| 351 | %token RESET "reset" | ||
| 352 | %token FLUSH "flush" | ||
| 353 | %token RENAME "rename" | ||
| 354 | %token DESCRIBE "describe" | ||
| 355 | %token IMPORT "import" | ||
| 356 | %token EXPORT "export" | ||
| 357 | %token NEW "new" | ||
| 358 | %token DESTROY "destroy" | ||
| 359 | |||
| 360 | %token MONITOR "monitor" | ||
| 361 | |||
| 362 | %token ALL "all" | ||
| 363 | |||
| 364 | %token ACCEPT "accept" | ||
| 365 | %token DROP "drop" | ||
| 366 | %token CONTINUE "continue" | ||
| 367 | %token JUMP "jump" | ||
| 368 | %token GOTO "goto" | ||
| 369 | %token RETURN "return" | ||
| 370 | %token TO "to" | ||
| 371 | |||
| 372 | %token CONSTANT "constant" | ||
| 373 | %token INTERVAL "interval" | ||
| 374 | %token DYNAMIC "dynamic" | ||
| 375 | %token AUTOMERGE "auto-merge" | ||
| 376 | %token TIMEOUT "timeout" | ||
| 377 | %token GC_INTERVAL "gc-interval" | ||
| 378 | %token ELEMENTS "elements" | ||
| 379 | %token EXPIRES "expires" | ||
| 380 | |||
| 381 | %token POLICY "policy" | ||
| 382 | %token MEMORY "memory" | ||
| 383 | %token PERFORMANCE "performance" | ||
| 384 | %token SIZE "size" | ||
| 385 | |||
| 386 | %token FLOW "flow" | ||
| 387 | %token OFFLOAD "offload" | ||
| 388 | %token METER "meter" | ||
| 389 | %token METERS "meters" | ||
| 390 | |||
| 391 | %token FLOWTABLES "flowtables" | ||
| 392 | |||
| 393 | %token <val> NUM "number" | ||
| 394 | %token <string> STRING "string" | ||
| 395 | %token <string> QUOTED_STRING "quoted string" | ||
| 396 | %token <string> ASTERISK_STRING "string with a trailing asterisk" | ||
| 397 | 146 | %destructor { free_const($$); } STRING QUOTED_STRING ASTERISK_STRING | |
| 398 | |||
| 399 | %token LL_HDR "ll" | ||
| 400 | %token NETWORK_HDR "nh" | ||
| 401 | %token TRANSPORT_HDR "th" | ||
| 402 | |||
| 403 | %token BRIDGE "bridge" | ||
| 404 | |||
| 405 | %token ETHER "ether" | ||
| 406 | %token SADDR "saddr" | ||
| 407 | %token DADDR "daddr" | ||
| 408 | %token TYPE "type" | ||
| 409 | |||
| 410 | %token VLAN "vlan" | ||
| 411 | %token ID "id" | ||
| 412 | %token CFI "cfi" | ||
| 413 | %token DEI "dei" | ||
| 414 | %token PCP "pcp" | ||
| 415 | |||
| 416 | %token ARP "arp" | ||
| 417 | %token HTYPE "htype" | ||
| 418 | %token PTYPE "ptype" | ||
| 419 | %token HLEN "hlen" | ||
| 420 | %token PLEN "plen" | ||
| 421 | %token OPERATION "operation" | ||
| 422 | |||
| 423 | %token IP "ip" | ||
| 424 | %token HDRVERSION "version" | ||
| 425 | %token HDRLENGTH "hdrlength" | ||
| 426 | %token DSCP "dscp" | ||
| 427 | %token ECN "ecn" | ||
| 428 | %token LENGTH "length" | ||
| 429 | %token FRAG_OFF "frag-off" | ||
| 430 | %token TTL "ttl" | ||
| 431 | %token TOS "tos" | ||
| 432 | %token PROTOCOL "protocol" | ||
| 433 | %token CHECKSUM "checksum" | ||
| 434 | |||
| 435 | %token PTR "ptr" | ||
| 436 | %token VALUE "value" | ||
| 437 | |||
| 438 | %token LSRR "lsrr" | ||
| 439 | %token RR "rr" | ||
| 440 | %token SSRR "ssrr" | ||
| 441 | %token RA "ra" | ||
| 442 | |||
| 443 | %token ICMP "icmp" | ||
| 444 | %token CODE "code" | ||
| 445 | %token SEQUENCE "seq" | ||
| 446 | %token GATEWAY "gateway" | ||
| 447 | %token MTU "mtu" | ||
| 448 | |||
| 449 | %token IGMP "igmp" | ||
| 450 | %token MRT "mrt" | ||
| 451 | |||
| 452 | %token OPTIONS "options" | ||
| 453 | |||
| 454 | %token IP6 "ip6" | ||
| 455 | %token PRIORITY "priority" | ||
| 456 | %token FLOWLABEL "flowlabel" | ||
| 457 | %token NEXTHDR "nexthdr" | ||
| 458 | %token HOPLIMIT "hoplimit" | ||
| 459 | |||
| 460 | %token ICMP6 "icmpv6" | ||
| 461 | %token PPTR "param-problem" | ||
| 462 | %token MAXDELAY "max-delay" | ||
| 463 | %token TADDR "taddr" | ||
| 464 | |||
| 465 | %token AH "ah" | ||
| 466 | %token RESERVED "reserved" | ||
| 467 | %token SPI "spi" | ||
| 468 | |||
| 469 | %token ESP "esp" | ||
| 470 | |||
| 471 | %token COMP "comp" | ||
| 472 | %token FLAGS "flags" | ||
| 473 | %token CPI "cpi" | ||
| 474 | |||
| 475 | %token PORT "port" | ||
| 476 | %token UDP "udp" | ||
| 477 | %token SPORT "sport" | ||
| 478 | %token DPORT "dport" | ||
| 479 | %token UDPLITE "udplite" | ||
| 480 | %token CSUMCOV "csumcov" | ||
| 481 | |||
| 482 | %token TCP "tcp" | ||
| 483 | %token ACKSEQ "ackseq" | ||
| 484 | %token DOFF "doff" | ||
| 485 | %token WINDOW "window" | ||
| 486 | %token URGPTR "urgptr" | ||
| 487 | %token OPTION "option" | ||
| 488 | %token ECHO "echo" | ||
| 489 | %token EOL "eol" | ||
| 490 | %token MPTCP "mptcp" | ||
| 491 | %token NOP "nop" | ||
| 492 | %token SACK "sack" | ||
| 493 | %token SACK0 "sack0" | ||
| 494 | %token SACK1 "sack1" | ||
| 495 | %token SACK2 "sack2" | ||
| 496 | %token SACK3 "sack3" | ||
| 497 | %token SACK_PERM "sack-permitted" | ||
| 498 | %token FASTOPEN "fastopen" | ||
| 499 | %token MD5SIG "md5sig" | ||
| 500 | %token TIMESTAMP "timestamp" | ||
| 501 | %token COUNT "count" | ||
| 502 | %token LEFT "left" | ||
| 503 | %token RIGHT "right" | ||
| 504 | %token TSVAL "tsval" | ||
| 505 | %token TSECR "tsecr" | ||
| 506 | %token SUBTYPE "subtype" | ||
| 507 | |||
| 508 | %token DCCP "dccp" | ||
| 509 | |||
| 510 | %token VXLAN "vxlan" | ||
| 511 | %token VNI "vni" | ||
| 512 | |||
| 513 | %token GRE "gre" | ||
| 514 | %token GRETAP "gretap" | ||
| 515 | |||
| 516 | %token GENEVE "geneve" | ||
| 517 | |||
| 518 | %token SCTP "sctp" | ||
| 519 | %token CHUNK "chunk" | ||
| 520 | %token DATA "data" | ||
| 521 | %token INIT "init" | ||
| 522 | %token INIT_ACK "init-ack" | ||
| 523 | %token HEARTBEAT "heartbeat" | ||
| 524 | %token HEARTBEAT_ACK "heartbeat-ack" | ||
| 525 | %token ABORT "abort" | ||
| 526 | %token SHUTDOWN "shutdown" | ||
| 527 | %token SHUTDOWN_ACK "shutdown-ack" | ||
| 528 | %token ERROR "error" | ||
| 529 | %token COOKIE_ECHO "cookie-echo" | ||
| 530 | %token COOKIE_ACK "cookie-ack" | ||
| 531 | %token ECNE "ecne" | ||
| 532 | %token CWR "cwr" | ||
| 533 | %token SHUTDOWN_COMPLETE "shutdown-complete" | ||
| 534 | %token ASCONF_ACK "asconf-ack" | ||
| 535 | %token FORWARD_TSN "forward-tsn" | ||
| 536 | %token ASCONF "asconf" | ||
| 537 | %token TSN "tsn" | ||
| 538 | %token STREAM "stream" | ||
| 539 | %token SSN "ssn" | ||
| 540 | %token PPID "ppid" | ||
| 541 | %token INIT_TAG "init-tag" | ||
| 542 | %token A_RWND "a-rwnd" | ||
| 543 | %token NUM_OSTREAMS "num-outbound-streams" | ||
| 544 | %token NUM_ISTREAMS "num-inbound-streams" | ||
| 545 | %token INIT_TSN "initial-tsn" | ||
| 546 | %token CUM_TSN_ACK "cum-tsn-ack" | ||
| 547 | %token NUM_GACK_BLOCKS "num-gap-ack-blocks" | ||
| 548 | %token NUM_DUP_TSNS "num-dup-tsns" | ||
| 549 | %token LOWEST_TSN "lowest-tsn" | ||
| 550 | %token SEQNO "seqno" | ||
| 551 | %token NEW_CUM_TSN "new-cum-tsn" | ||
| 552 | |||
| 553 | %token VTAG "vtag" | ||
| 554 | |||
| 555 | %token RT "rt" | ||
| 556 | %token RT0 "rt0" | ||
| 557 | %token RT2 "rt2" | ||
| 558 | %token RT4 "srh" | ||
| 559 | %token SEG_LEFT "seg-left" | ||
| 560 | %token ADDR "addr" | ||
| 561 | %token LAST_ENT "last-entry" | ||
| 562 | %token TAG "tag" | ||
| 563 | %token SID "sid" | ||
| 564 | |||
| 565 | %token HBH "hbh" | ||
| 566 | |||
| 567 | %token FRAG "frag" | ||
| 568 | %token RESERVED2 "reserved2" | ||
| 569 | %token MORE_FRAGMENTS "more-fragments" | ||
| 570 | |||
| 571 | %token DST "dst" | ||
| 572 | |||
| 573 | %token MH "mh" | ||
| 574 | |||
| 575 | %token META "meta" | ||
| 576 | %token MARK "mark" | ||
| 577 | %token IIF "iif" | ||
| 578 | %token IIFNAME "iifname" | ||
| 579 | %token IIFTYPE "iiftype" | ||
| 580 | %token OIF "oif" | ||
| 581 | %token OIFNAME "oifname" | ||
| 582 | %token OIFTYPE "oiftype" | ||
| 583 | %token SKUID "skuid" | ||
| 584 | %token SKGID "skgid" | ||
| 585 | %token NFTRACE "nftrace" | ||
| 586 | %token RTCLASSID "rtclassid" | ||
| 587 | %token IBRIPORT "ibriport" | ||
| 588 | %token OBRIPORT "obriport" | ||
| 589 | %token IBRIDGENAME "ibrname" | ||
| 590 | %token OBRIDGENAME "obrname" | ||
| 591 | %token PKTTYPE "pkttype" | ||
| 592 | %token CPU "cpu" | ||
| 593 | %token IIFGROUP "iifgroup" | ||
| 594 | %token OIFGROUP "oifgroup" | ||
| 595 | %token CGROUP "cgroup" | ||
| 596 | %token TIME "time" | ||
| 597 | |||
| 598 | %token CLASSID "classid" | ||
| 599 | %token NEXTHOP "nexthop" | ||
| 600 | |||
| 601 | %token CT "ct" | ||
| 602 | %token L3PROTOCOL "l3proto" | ||
| 603 | %token PROTO_SRC "proto-src" | ||
| 604 | %token PROTO_DST "proto-dst" | ||
| 605 | %token ZONE "zone" | ||
| 606 | %token DIRECTION "direction" | ||
| 607 | %token EVENT "event" | ||
| 608 | %token EXPECTATION "expectation" | ||
| 609 | %token EXPIRATION "expiration" | ||
| 610 | %token HELPER "helper" | ||
| 611 | %token LABEL "label" | ||
| 612 | %token STATE "state" | ||
| 613 | %token STATUS "status" | ||
| 614 | %token ORIGINAL "original" | ||
| 615 | %token REPLY "reply" | ||
| 616 | |||
| 617 | %token COUNTER "counter" | ||
| 618 | %token NAME "name" | ||
| 619 | %token PACKETS "packets" | ||
| 620 | %token BYTES "bytes" | ||
| 621 | %token KBYTES "kbytes" | ||
| 622 | %token MBYTES "mbytes" | ||
| 623 | %token AVGPKT "avgpkt" | ||
| 624 | |||
| 625 | %token LAST "last" | ||
| 626 | %token NEVER "never" | ||
| 627 | |||
| 628 | %token TUNNEL "tunnel" | ||
| 629 | %token ERSPAN "erspan" | ||
| 630 | %token EGRESS "egress" | ||
| 631 | %token INGRESS "ingress" | ||
| 632 | %token GBP "gbp" | ||
| 633 | %token CLASS "class" | ||
| 634 | %token OPTTYPE "opt-type" | ||
| 635 | |||
| 636 | %token COUNTERS "counters" | ||
| 637 | %token QUOTAS "quotas" | ||
| 638 | %token LIMITS "limits" | ||
| 639 | %token TUNNELS "tunnels" | ||
| 640 | %token SYNPROXYS "synproxys" | ||
| 641 | %token HELPERS "helpers" | ||
| 642 | |||
| 643 | %token LOG "log" | ||
| 644 | %token PREFIX "prefix" | ||
| 645 | %token GROUP "group" | ||
| 646 | %token SNAPLEN "snaplen" | ||
| 647 | %token QUEUE_THRESHOLD "queue-threshold" | ||
| 648 | %token LEVEL "level" | ||
| 649 | %token EMERG "emerg" | ||
| 650 | %token ALERT "alert" | ||
| 651 | %token CRIT "crit" | ||
| 652 | %token ERR "err" | ||
| 653 | %token WARN "warn" | ||
| 654 | %token NOTICE "notice" | ||
| 655 | %token INFO "info" | ||
| 656 | %token DEBUG_TOKEN "debug" | ||
| 657 | %token AUDIT "audit" | ||
| 658 | |||
| 659 | %token LIMIT "limit" | ||
| 660 | %token RATE "rate" | ||
| 661 | %token BURST "burst" | ||
| 662 | %token OVER "over" | ||
| 663 | %token UNTIL "until" | ||
| 664 | |||
| 665 | %token QUOTA "quota" | ||
| 666 | %token USED "used" | ||
| 667 | |||
| 668 | %token SECMARK "secmark" | ||
| 669 | %token SECMARKS "secmarks" | ||
| 670 | |||
| 671 | %token SECOND "second" | ||
| 672 | %token MINUTE "minute" | ||
| 673 | %token HOUR "hour" | ||
| 674 | %token DAY "day" | ||
| 675 | %token WEEK "week" | ||
| 676 | |||
| 677 | %token _REJECT "reject" | ||
| 678 | %token WITH "with" | ||
| 679 | %token ICMPX "icmpx" | ||
| 680 | |||
| 681 | %token SNAT "snat" | ||
| 682 | %token DNAT "dnat" | ||
| 683 | %token MASQUERADE "masquerade" | ||
| 684 | %token REDIRECT "redirect" | ||
| 685 | %token RANDOM "random" | ||
| 686 | %token FULLY_RANDOM "fully-random" | ||
| 687 | %token PERSISTENT "persistent" | ||
| 688 | |||
| 689 | %token QUEUE "queue" | ||
| 690 | %token QUEUENUM "num" | ||
| 691 | %token BYPASS "bypass" | ||
| 692 | %token FANOUT "fanout" | ||
| 693 | |||
| 694 | %token DUP "dup" | ||
| 695 | %token FWD "fwd" | ||
| 696 | |||
| 697 | %token NUMGEN "numgen" | ||
| 698 | %token INC "inc" | ||
| 699 | %token MOD "mod" | ||
| 700 | %token OFFSET "offset" | ||
| 701 | |||
| 702 | %token JHASH "jhash" | ||
| 703 | %token SYMHASH "symhash" | ||
| 704 | %token SEED "seed" | ||
| 705 | |||
| 706 | %token POSITION "position" | ||
| 707 | %token INDEX "index" | ||
| 708 | %token COMMENT "comment" | ||
| 709 | |||
| 710 | %token XML "xml" | ||
| 711 | %token JSON "json" | ||
| 712 | %token VM "vm" | ||
| 713 | |||
| 714 | %token NOTRACK "notrack" | ||
| 715 | |||
| 716 | %token EXISTS "exists" | ||
| 717 | %token MISSING "missing" | ||
| 718 | |||
| 719 | %token EXTHDR "exthdr" | ||
| 720 | |||
| 721 | %token IPSEC "ipsec" | ||
| 722 | %token REQID "reqid" | ||
| 723 | %token SPNUM "spnum" | ||
| 724 | |||
| 725 | %token IN "in" | ||
| 726 | %token OUT "out" | ||
| 727 | |||
| 728 | %token XT "xt" | ||
| 729 | |||
| 730 | %token FILTER "filter" | ||
| 731 | %token NAT "nat" | ||
| 732 | %token ROUTE "route" | ||
| 733 | |||
| 734 | %token LOOSE "loose" | ||
| 735 | %token SKIP "skip" | ||
| 736 | |||
| 737 | %type <limit_rate> limit_rate_pkts | ||
| 738 | %type <limit_rate> limit_rate_bytes | ||
| 739 | |||
| 740 | %type <string> identifier type_identifier string comment_spec | ||
| 741 | 6 | %destructor { free_const($$); } identifier type_identifier string comment_spec | |
| 742 | |||
| 743 | %type <val> time_spec time_spec_or_num_s set_elem_time_spec quota_used | ||
| 744 | |||
| 745 | %type <expr> data_type_expr data_type_atom_expr | ||
| 746 | 3 | %destructor { expr_free($$); } data_type_expr data_type_atom_expr | |
| 747 | |||
| 748 | %type <cmd> line | ||
| 749 | ✗ | %destructor { cmd_free($$); } line | |
| 750 | |||
| 751 | %type <cmd> base_cmd add_cmd replace_cmd create_cmd insert_cmd delete_cmd get_cmd list_cmd reset_cmd flush_cmd rename_cmd export_cmd monitor_cmd describe_cmd import_cmd destroy_cmd | ||
| 752 | 2 | %destructor { cmd_free($$); } base_cmd add_cmd replace_cmd create_cmd insert_cmd delete_cmd get_cmd list_cmd reset_cmd flush_cmd rename_cmd export_cmd monitor_cmd describe_cmd import_cmd destroy_cmd | |
| 753 | |||
| 754 | %type <handle> table_spec tableid_spec table_or_id_spec | ||
| 755 | 7 | %destructor { handle_free(&$$); } table_spec tableid_spec table_or_id_spec | |
| 756 | %type <handle> chain_spec chainid_spec chain_or_id_spec | ||
| 757 | 4 | %destructor { handle_free(&$$); } chain_spec chainid_spec chain_or_id_spec | |
| 758 | |||
| 759 | %type <handle> flowtable_spec chain_identifier ruleid_spec handle_spec position_spec rule_position ruleset_spec index_spec | ||
| 760 | 203 | %destructor { handle_free(&$$); } flowtable_spec chain_identifier ruleid_spec handle_spec position_spec rule_position ruleset_spec index_spec | |
| 761 | %type <handle> set_spec setid_spec set_or_id_spec | ||
| 762 | 4 | %destructor { handle_free(&$$); } set_spec setid_spec set_or_id_spec | |
| 763 | %type <handle> obj_spec objid_spec obj_or_id_spec | ||
| 764 | ✗ | %destructor { handle_free(&$$); } obj_spec objid_spec obj_or_id_spec | |
| 765 | |||
| 766 | %type <handle> set_identifier flowtableid_spec flowtable_identifier obj_identifier | ||
| 767 | 8 | %destructor { handle_free(&$$); } set_identifier flowtableid_spec flowtable_identifier obj_identifier | |
| 768 | |||
| 769 | %type <handle> basehook_spec | ||
| 770 | ✗ | %destructor { handle_free(&$$); } basehook_spec | |
| 771 | |||
| 772 | %type <handle> list_cmd_spec_any list_cmd_spec_table | ||
| 773 | ✗ | %destructor { handle_free(&$$); } list_cmd_spec_any list_cmd_spec_table | |
| 774 | |||
| 775 | %type <val> family_spec family_spec_explicit | ||
| 776 | %type <val32> int_num chain_policy | ||
| 777 | %type <prio_spec> extended_prio_spec prio_spec | ||
| 778 | ✗ | %destructor { expr_free($$.expr); } extended_prio_spec prio_spec | |
| 779 | |||
| 780 | %type <string> extended_prio_name basehook_device_name | ||
| 781 | ✗ | %destructor { free_const($$); } extended_prio_name basehook_device_name | |
| 782 | |||
| 783 | %type <expr> dev_spec | ||
| 784 | 1 | %destructor { free($$); } dev_spec | |
| 785 | |||
| 786 | %type <table> table_block_alloc table_block | ||
| 787 | 4 | %destructor { close_scope(state); table_free($$); } table_block_alloc | |
| 788 | %type <chain> chain_block_alloc chain_block subchain_block | ||
| 789 | 6 | %destructor { close_scope(state); chain_free($$); } chain_block_alloc | |
| 790 | %type <rule> rule rule_alloc | ||
| 791 | ✗ | %destructor { rule_free($$); } rule | |
| 792 | |||
| 793 | %type <val> table_flags table_flag | ||
| 794 | |||
| 795 | %type <val> set_flag_list set_flag | ||
| 796 | |||
| 797 | %type <val> set_policy_spec | ||
| 798 | |||
| 799 | %type <set> set_block_alloc set_block | ||
| 800 | 1 | %destructor { set_free($$); } set_block_alloc | |
| 801 | |||
| 802 | %type <set> map_block_alloc map_block | ||
| 803 | ✗ | %destructor { set_free($$); } map_block_alloc | |
| 804 | %type <val> map_block_obj_type map_block_obj_typeof map_block_data_interval | ||
| 805 | |||
| 806 | %type <flowtable> flowtable_block_alloc flowtable_block | ||
| 807 | 2 | %destructor { flowtable_free($$); } flowtable_block_alloc | |
| 808 | |||
| 809 | %type <obj> obj_block_alloc counter_block quota_block ct_helper_block ct_timeout_block ct_expect_block limit_block secmark_block synproxy_block tunnel_block erspan_block erspan_block_alloc vxlan_block vxlan_block_alloc geneve_block geneve_block_alloc | ||
| 810 | 7 | %destructor { obj_free($$); } obj_block_alloc | |
| 811 | |||
| 812 | %type <list> stmt_list stateful_stmt_list set_elem_stmt_list | ||
| 813 | 15 | %destructor { stmt_list_free($$); free($$); } stmt_list stateful_stmt_list set_elem_stmt_list | |
| 814 | %type <stmt> stmt match_stmt verdict_stmt set_elem_stmt | ||
| 815 | ✗ | %destructor { stmt_free($$); } stmt match_stmt verdict_stmt set_elem_stmt | |
| 816 | %type <stmt> counter_stmt counter_stmt_alloc stateful_stmt last_stmt | ||
| 817 | 2 | %destructor { stmt_free($$); } counter_stmt counter_stmt_alloc stateful_stmt last_stmt | |
| 818 | %type <stmt> limit_stmt_alloc quota_stmt_alloc last_stmt_alloc ct_limit_stmt_alloc | ||
| 819 | 27 | %destructor { stmt_free($$); } limit_stmt_alloc quota_stmt_alloc last_stmt_alloc ct_limit_stmt_alloc | |
| 820 | %type <stmt> objref_stmt objref_stmt_counter objref_stmt_limit objref_stmt_quota objref_stmt_ct objref_stmt_synproxy objref_stmt_tunnel | ||
| 821 | ✗ | %destructor { stmt_free($$); } objref_stmt objref_stmt_counter objref_stmt_limit objref_stmt_quota objref_stmt_ct objref_stmt_synproxy objref_stmt_tunnel | |
| 822 | |||
| 823 | %type <stmt> payload_stmt | ||
| 824 | ✗ | %destructor { stmt_free($$); } payload_stmt | |
| 825 | %type <stmt> ct_stmt | ||
| 826 | ✗ | %destructor { stmt_free($$); } ct_stmt | |
| 827 | %type <stmt> meta_stmt | ||
| 828 | ✗ | %destructor { stmt_free($$); } meta_stmt | |
| 829 | %type <stmt> log_stmt log_stmt_alloc | ||
| 830 | ✗ | %destructor { stmt_free($$); } log_stmt log_stmt_alloc | |
| 831 | %type <val> level_type log_flags log_flags_tcp log_flag_tcp | ||
| 832 | %type <stmt> limit_stmt quota_stmt connlimit_stmt | ||
| 833 | ✗ | %destructor { stmt_free($$); } limit_stmt quota_stmt connlimit_stmt | |
| 834 | %type <val> limit_burst_pkts limit_burst_bytes limit_mode bytes_unit time_unit quota_mode | ||
| 835 | %type <stmt> reject_stmt reject_stmt_alloc | ||
| 836 | ✗ | %destructor { stmt_free($$); } reject_stmt reject_stmt_alloc | |
| 837 | %type <stmt> nat_stmt nat_stmt_alloc masq_stmt masq_stmt_alloc redir_stmt redir_stmt_alloc | ||
| 838 | 4 | %destructor { stmt_free($$); } nat_stmt nat_stmt_alloc masq_stmt masq_stmt_alloc redir_stmt redir_stmt_alloc | |
| 839 | %type <val> nf_nat_flags nf_nat_flag offset_opt | ||
| 840 | %type <stmt> tproxy_stmt | ||
| 841 | ✗ | %destructor { stmt_free($$); } tproxy_stmt | |
| 842 | %type <stmt> synproxy_stmt synproxy_stmt_alloc | ||
| 843 | ✗ | %destructor { stmt_free($$); } synproxy_stmt synproxy_stmt_alloc | |
| 844 | %type <stmt> chain_stmt | ||
| 845 | ✗ | %destructor { stmt_free($$); } chain_stmt | |
| 846 | %type <val> chain_stmt_type | ||
| 847 | |||
| 848 | %type <stmt> queue_stmt queue_stmt_alloc queue_stmt_compat | ||
| 849 | 8 | %destructor { stmt_free($$); } queue_stmt queue_stmt_alloc queue_stmt_compat | |
| 850 | %type <expr> queue_stmt_expr_simple queue_stmt_expr queue_expr reject_with_expr | ||
| 851 | ✗ | %destructor { expr_free($$); } queue_stmt_expr_simple queue_stmt_expr queue_expr reject_with_expr | |
| 852 | %type <val> queue_stmt_flags queue_stmt_flag | ||
| 853 | %type <stmt> dup_stmt | ||
| 854 | ✗ | %destructor { stmt_free($$); } dup_stmt | |
| 855 | %type <stmt> fwd_stmt | ||
| 856 | ✗ | %destructor { stmt_free($$); } fwd_stmt | |
| 857 | %type <stmt> set_stmt | ||
| 858 | ✗ | %destructor { stmt_free($$); } set_stmt | |
| 859 | %type <val> set_stmt_op | ||
| 860 | %type <stmt> map_stmt | ||
| 861 | ✗ | %destructor { stmt_free($$); } map_stmt | |
| 862 | %type <stmt> meter_stmt | ||
| 863 | ✗ | %destructor { stmt_free($$); } meter_stmt | |
| 864 | |||
| 865 | %type <expr> symbol_expr verdict_expr integer_expr variable_expr chain_expr policy_expr | ||
| 866 | 4 | %destructor { expr_free($$); } symbol_expr verdict_expr integer_expr variable_expr chain_expr policy_expr | |
| 867 | %type <expr> primary_expr shift_expr and_expr primary_typeof_expr typeof_expr typeof_data_expr typeof_key_expr typeof_verdict_expr selector_expr | ||
| 868 | 17 | %destructor { expr_free($$); } primary_expr shift_expr and_expr primary_typeof_expr typeof_expr typeof_data_expr typeof_key_expr typeof_verdict_expr selector_expr | |
| 869 | %type <expr> exclusive_or_expr inclusive_or_expr | ||
| 870 | ✗ | %destructor { expr_free($$); } exclusive_or_expr inclusive_or_expr | |
| 871 | %type <expr> basic_expr | ||
| 872 | ✗ | %destructor { expr_free($$); } basic_expr | |
| 873 | %type <expr> set_ref_expr set_ref_symbol_expr | ||
| 874 | ✗ | %destructor { expr_free($$); } set_ref_expr set_ref_symbol_expr | |
| 875 | |||
| 876 | %type <expr> multiton_rhs_expr | ||
| 877 | ✗ | %destructor { expr_free($$); } multiton_rhs_expr | |
| 878 | %type <expr> prefix_rhs_expr range_rhs_expr | ||
| 879 | ✗ | %destructor { expr_free($$); } prefix_rhs_expr range_rhs_expr | |
| 880 | |||
| 881 | %type <expr> stmt_expr concat_stmt_expr map_stmt_expr map_stmt_expr_set | ||
| 882 | ✗ | %destructor { expr_free($$); } stmt_expr concat_stmt_expr map_stmt_expr map_stmt_expr_set | |
| 883 | |||
| 884 | %type <expr> multiton_stmt_expr | ||
| 885 | ✗ | %destructor { expr_free($$); } multiton_stmt_expr | |
| 886 | %type <expr> prefix_stmt_expr range_stmt_expr | ||
| 887 | ✗ | %destructor { expr_free($$); } prefix_stmt_expr range_stmt_expr | |
| 888 | |||
| 889 | %type <expr> primary_stmt_expr basic_stmt_expr | ||
| 890 | ✗ | %destructor { expr_free($$); } primary_stmt_expr basic_stmt_expr | |
| 891 | %type <expr> list_stmt_expr shift_stmt_expr | ||
| 892 | 1 | %destructor { expr_free($$); } list_stmt_expr shift_stmt_expr | |
| 893 | %type <expr> and_stmt_expr exclusive_or_stmt_expr inclusive_or_stmt_expr | ||
| 894 | ✗ | %destructor { expr_free($$); } and_stmt_expr exclusive_or_stmt_expr inclusive_or_stmt_expr | |
| 895 | |||
| 896 | %type <expr> concat_expr | ||
| 897 | 4 | %destructor { expr_free($$); } concat_expr | |
| 898 | |||
| 899 | %type <expr> map_expr | ||
| 900 | ✗ | %destructor { expr_free($$); } map_expr | |
| 901 | |||
| 902 | %type <expr> verdict_map_stmt | ||
| 903 | ✗ | %destructor { expr_free($$); } verdict_map_stmt | |
| 904 | |||
| 905 | %type <expr> verdict_map_expr verdict_map_list_expr verdict_map_list_member_expr | ||
| 906 | ✗ | %destructor { expr_free($$); } verdict_map_expr verdict_map_list_expr verdict_map_list_member_expr | |
| 907 | |||
| 908 | %type <expr> set_expr set_block_expr set_list_expr set_list_member_expr flowtable_expr flowtable_list_expr flowtable_expr_member | ||
| 909 | 4 | %destructor { expr_free($$); } set_expr set_block_expr set_list_expr set_list_member_expr flowtable_expr flowtable_list_expr flowtable_expr_member | |
| 910 | %type <expr> set_elem_expr set_elem_expr_alloc set_lhs_expr set_rhs_expr | ||
| 911 | 7 | %destructor { expr_free($$); } set_elem_expr set_elem_expr_alloc set_lhs_expr set_rhs_expr | |
| 912 | %type <expr> set_elem_expr_stmt set_elem_expr_stmt_alloc | ||
| 913 | ✗ | %destructor { expr_free($$); } set_elem_expr_stmt set_elem_expr_stmt_alloc | |
| 914 | |||
| 915 | %type <expr> meter_key_expr meter_key_expr_alloc | ||
| 916 | ✗ | %destructor { expr_free($$); } meter_key_expr meter_key_expr_alloc | |
| 917 | |||
| 918 | %type <expr> expr initializer_expr keyword_expr | ||
| 919 | 12 | %destructor { expr_free($$); } expr initializer_expr keyword_expr | |
| 920 | |||
| 921 | %type <expr> rhs_expr concat_rhs_expr basic_rhs_expr | ||
| 922 | ✗ | %destructor { expr_free($$); } rhs_expr concat_rhs_expr basic_rhs_expr | |
| 923 | %type <expr> primary_rhs_expr list_rhs_expr shift_rhs_expr symbol_stmt_expr | ||
| 924 | 12 | %destructor { expr_free($$); } primary_rhs_expr list_rhs_expr shift_rhs_expr symbol_stmt_expr | |
| 925 | %type <expr> and_rhs_expr exclusive_or_rhs_expr inclusive_or_rhs_expr | ||
| 926 | ✗ | %destructor { expr_free($$); } and_rhs_expr exclusive_or_rhs_expr inclusive_or_rhs_expr | |
| 927 | |||
| 928 | %type <obj> counter_obj quota_obj ct_obj_alloc limit_obj secmark_obj synproxy_obj tunnel_obj | ||
| 929 | ✗ | %destructor { obj_free($$); } counter_obj quota_obj ct_obj_alloc limit_obj secmark_obj synproxy_obj tunnel_obj | |
| 930 | |||
| 931 | %type <expr> relational_expr | ||
| 932 | ✗ | %destructor { expr_free($$); } relational_expr | |
| 933 | %type <val> relational_op | ||
| 934 | |||
| 935 | %type <expr> payload_expr payload_raw_expr | ||
| 936 | 19 | %destructor { expr_free($$); } payload_expr payload_raw_expr | |
| 937 | %type <val> payload_base_spec | ||
| 938 | %type <val> payload_raw_len | ||
| 939 | |||
| 940 | %type <expr> eth_hdr_expr vlan_hdr_expr | ||
| 941 | ✗ | %destructor { expr_free($$); } eth_hdr_expr vlan_hdr_expr | |
| 942 | %type <val> eth_hdr_field vlan_hdr_field | ||
| 943 | %type <expr> arp_hdr_expr | ||
| 944 | ✗ | %destructor { expr_free($$); } arp_hdr_expr | |
| 945 | %type <val> arp_hdr_field | ||
| 946 | %type <expr> ip_hdr_expr icmp_hdr_expr igmp_hdr_expr numgen_expr hash_expr | ||
| 947 | ✗ | %destructor { expr_free($$); } ip_hdr_expr icmp_hdr_expr igmp_hdr_expr numgen_expr hash_expr | |
| 948 | %type <val> ip_hdr_field icmp_hdr_field igmp_hdr_field | ||
| 949 | %type <val> ip_option_type ip_option_field | ||
| 950 | %type <expr> ip6_hdr_expr icmp6_hdr_expr | ||
| 951 | ✗ | %destructor { expr_free($$); } ip6_hdr_expr icmp6_hdr_expr | |
| 952 | %type <val> ip6_hdr_field icmp6_hdr_field | ||
| 953 | %type <expr> auth_hdr_expr esp_hdr_expr comp_hdr_expr | ||
| 954 | ✗ | %destructor { expr_free($$); } auth_hdr_expr esp_hdr_expr comp_hdr_expr | |
| 955 | %type <val> auth_hdr_field esp_hdr_field comp_hdr_field | ||
| 956 | %type <expr> udp_hdr_expr udplite_hdr_expr | ||
| 957 | ✗ | %destructor { expr_free($$); } udp_hdr_expr udplite_hdr_expr | |
| 958 | %type <val> udp_hdr_field udplite_hdr_field | ||
| 959 | %type <expr> dccp_hdr_expr sctp_hdr_expr sctp_chunk_alloc | ||
| 960 | ✗ | %destructor { expr_free($$); } dccp_hdr_expr sctp_hdr_expr sctp_chunk_alloc | |
| 961 | %type <val> dccp_hdr_field sctp_hdr_field | ||
| 962 | %type <val> sctp_chunk_type sctp_chunk_common_field | ||
| 963 | %type <val> sctp_chunk_data_field sctp_chunk_init_field | ||
| 964 | %type <val> sctp_chunk_sack_field | ||
| 965 | %type <expr> th_hdr_expr | ||
| 966 | ✗ | %destructor { expr_free($$); } th_hdr_expr | |
| 967 | %type <val> th_hdr_field | ||
| 968 | |||
| 969 | %type <expr> exthdr_expr | ||
| 970 | ✗ | %destructor { expr_free($$); } exthdr_expr | |
| 971 | %type <expr> hbh_hdr_expr frag_hdr_expr dst_hdr_expr | ||
| 972 | ✗ | %destructor { expr_free($$); } hbh_hdr_expr frag_hdr_expr dst_hdr_expr | |
| 973 | %type <val> hbh_hdr_field frag_hdr_field dst_hdr_field | ||
| 974 | %type <expr> rt_hdr_expr rt0_hdr_expr rt2_hdr_expr rt4_hdr_expr | ||
| 975 | ✗ | %destructor { expr_free($$); } rt_hdr_expr rt0_hdr_expr rt2_hdr_expr rt4_hdr_expr | |
| 976 | %type <val> rt_hdr_field rt0_hdr_field rt2_hdr_field rt4_hdr_field | ||
| 977 | %type <expr> mh_hdr_expr | ||
| 978 | ✗ | %destructor { expr_free($$); } mh_hdr_expr | |
| 979 | %type <val> mh_hdr_field | ||
| 980 | |||
| 981 | %type <expr> meta_expr tunnel_expr | ||
| 982 | ✗ | %destructor { expr_free($$); } meta_expr tunnel_expr | |
| 983 | %type <val> meta_key meta_key_qualified meta_key_unqualified numgen_type tunnel_key | ||
| 984 | |||
| 985 | %type <expr> socket_expr | ||
| 986 | ✗ | %destructor { expr_free($$); } socket_expr | |
| 987 | %type<val> socket_key | ||
| 988 | |||
| 989 | %type <val> nf_key_proto | ||
| 990 | |||
| 991 | %type <expr> rt_expr | ||
| 992 | ✗ | %destructor { expr_free($$); } rt_expr | |
| 993 | %type <val> rt_key | ||
| 994 | |||
| 995 | %type <expr> ct_expr | ||
| 996 | ✗ | %destructor { expr_free($$); } ct_expr | |
| 997 | %type <val> ct_key ct_dir ct_key_dir_optional ct_key_dir ct_key_proto_field | ||
| 998 | |||
| 999 | %type <expr> fib_expr | ||
| 1000 | ✗ | %destructor { expr_free($$); } fib_expr | |
| 1001 | %type <val> fib_tuple fib_result fib_flag | ||
| 1002 | |||
| 1003 | %type <expr> osf_expr | ||
| 1004 | %type <val> osf_ttl | ||
| 1005 | ✗ | %destructor { expr_free($$); } osf_expr | |
| 1006 | |||
| 1007 | %type <val> markup_format | ||
| 1008 | %type <val> monitor_event monitor_object monitor_format | ||
| 1009 | |||
| 1010 | %type <val> synproxy_ts synproxy_sack | ||
| 1011 | |||
| 1012 | %type <expr> tcp_hdr_expr | ||
| 1013 | ✗ | %destructor { expr_free($$); } tcp_hdr_expr | |
| 1014 | %type <val> tcp_hdr_field | ||
| 1015 | %type <val> tcp_hdr_option_type | ||
| 1016 | %type <val> tcp_hdr_option_sack | ||
| 1017 | %type <val> tcpopt_field_maxseg tcpopt_field_mptcp tcpopt_field_sack tcpopt_field_tsopt tcpopt_field_window | ||
| 1018 | %type <tcp_kind_field> tcp_hdr_option_kind_and_field | ||
| 1019 | |||
| 1020 | %type <expr> inner_eth_expr inner_inet_expr inner_expr | ||
| 1021 | ✗ | %destructor { expr_free($$); } inner_eth_expr inner_inet_expr inner_expr | |
| 1022 | |||
| 1023 | %type <expr> vxlan_hdr_expr geneve_hdr_expr gre_hdr_expr gretap_hdr_expr | ||
| 1024 | ✗ | %destructor { expr_free($$); } vxlan_hdr_expr geneve_hdr_expr gre_hdr_expr gretap_hdr_expr | |
| 1025 | %type <val> vxlan_hdr_field geneve_hdr_field gre_hdr_field | ||
| 1026 | |||
| 1027 | %type <stmt> optstrip_stmt | ||
| 1028 | ✗ | %destructor { stmt_free($$); } optstrip_stmt | |
| 1029 | |||
| 1030 | %type <stmt> xt_stmt | ||
| 1031 | ✗ | %destructor { stmt_free($$); } xt_stmt | |
| 1032 | |||
| 1033 | %type <expr> boolean_expr | ||
| 1034 | ✗ | %destructor { expr_free($$); } boolean_expr | |
| 1035 | %type <val8> boolean_keys | ||
| 1036 | |||
| 1037 | %type <expr> exthdr_exists_expr | ||
| 1038 | ✗ | %destructor { expr_free($$); } exthdr_exists_expr | |
| 1039 | %type <val> exthdr_key | ||
| 1040 | |||
| 1041 | %type <val> ct_l4protoname ct_obj_type ct_cmd_type ct_obj_type_map | ||
| 1042 | |||
| 1043 | %type <timeout_state> timeout_state | ||
| 1044 | ✗ | %destructor { timeout_state_free($$); } timeout_state | |
| 1045 | |||
| 1046 | %type <list> timeout_states | ||
| 1047 | 1 | %destructor { timeout_states_free($$); } timeout_states | |
| 1048 | |||
| 1049 | %type <val> xfrm_state_key xfrm_state_proto_key xfrm_dir xfrm_spnum | ||
| 1050 | %type <expr> xfrm_expr | ||
| 1051 | ✗ | %destructor { expr_free($$); } xfrm_expr | |
| 1052 | |||
| 1053 | %type <expr> set_elem_key_expr | ||
| 1054 | 1 | %destructor { expr_free($$); } set_elem_key_expr | |
| 1055 | |||
| 1056 | %type <string> chain_type | ||
| 1057 | 4 | %destructor { free_const($$); } chain_type | |
| 1058 | |||
| 1059 | %% | ||
| 1060 | |||
| 1061 | input : /* empty */ | ||
| 1062 | | input line | ||
| 1063 | { | ||
| 1064 |
2/2✓ Branch 0 (91→92) taken 81492 times.
✓ Branch 1 (91→93) taken 28798 times.
|
110290 | if ($2 != NULL) { |
| 1065 | 81492 | $2->location = @2; | |
| 1066 | 81492 | list_add_tail(&$2->list, state->cmds); | |
| 1067 | } | ||
| 1068 | } | ||
| 1069 | ; | ||
| 1070 | |||
| 1071 | stmt_separator : NEWLINE | ||
| 1072 | | SEMICOLON | ||
| 1073 | ; | ||
| 1074 | |||
| 1075 | opt_newline : NEWLINE | ||
| 1076 | | /* empty */ | ||
| 1077 | ; | ||
| 1078 | |||
| 1079 | 154 | close_scope_ah : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_AH); }; | |
| 1080 | 2190 | close_scope_arp : { scanner_pop_start_cond(nft->scanner, PARSER_SC_ARP); }; | |
| 1081 | 3115 | close_scope_at : { scanner_pop_start_cond(nft->scanner, PARSER_SC_AT); }; | |
| 1082 | 101 | close_scope_comp : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_COMP); }; | |
| 1083 | 963 | close_scope_ct : { scanner_pop_start_cond(nft->scanner, PARSER_SC_CT); }; | |
| 1084 | 3012 | close_scope_counter : { scanner_pop_start_cond(nft->scanner, PARSER_SC_COUNTER); }; | |
| 1085 | 27 | close_scope_last : { scanner_pop_start_cond(nft->scanner, PARSER_SC_LAST); }; | |
| 1086 | 95 | close_scope_dccp : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_DCCP); }; | |
| 1087 | 27 | close_scope_destroy : { scanner_pop_start_cond(nft->scanner, PARSER_SC_CMD_DESTROY); }; | |
| 1088 | 39 | close_scope_dst : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_DST); }; | |
| 1089 | 12 | close_scope_dup : { scanner_pop_start_cond(nft->scanner, PARSER_SC_STMT_DUP); }; | |
| 1090 | 106 | close_scope_esp : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_ESP); }; | |
| 1091 | 3936 | close_scope_eth : { scanner_pop_start_cond(nft->scanner, PARSER_SC_ETH); }; | |
| 1092 | ✗ | close_scope_export : { scanner_pop_start_cond(nft->scanner, PARSER_SC_CMD_EXPORT); }; | |
| 1093 | 46 | close_scope_fib : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_FIB); }; | |
| 1094 | 141 | close_scope_frag : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_FRAG); }; | |
| 1095 | 7 | close_scope_fwd : { scanner_pop_start_cond(nft->scanner, PARSER_SC_STMT_FWD); }; | |
| 1096 | 105 | close_scope_gre : { scanner_pop_start_cond(nft->scanner, PARSER_SC_GRE); }; | |
| 1097 | 32 | close_scope_hash : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_HASH); }; | |
| 1098 | 52 | close_scope_hbh : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_HBH); }; | |
| 1099 | 13791 | close_scope_ip : { scanner_pop_start_cond(nft->scanner, PARSER_SC_IP); }; | |
| 1100 | 8931 | close_scope_ip6 : { scanner_pop_start_cond(nft->scanner, PARSER_SC_IP6); }; | |
| 1101 | 1864 | close_scope_vlan : { scanner_pop_start_cond(nft->scanner, PARSER_SC_VLAN); }; | |
| 1102 | 892 | close_scope_icmp : { scanner_pop_start_cond(nft->scanner, PARSER_SC_ICMP); }; | |
| 1103 | 15 | close_scope_igmp : { scanner_pop_start_cond(nft->scanner, PARSER_SC_IGMP); }; | |
| 1104 | ✗ | close_scope_import : { scanner_pop_start_cond(nft->scanner, PARSER_SC_CMD_IMPORT); }; | |
| 1105 | 67 | close_scope_ipsec : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_IPSEC); }; | |
| 1106 | 16408 | close_scope_list : { scanner_pop_start_cond(nft->scanner, PARSER_SC_CMD_LIST); }; | |
| 1107 | 477 | close_scope_limit : { scanner_pop_start_cond(nft->scanner, PARSER_SC_LIMIT); }; | |
| 1108 | 2643 | close_scope_meta : { scanner_pop_start_cond(nft->scanner, PARSER_SC_META); }; | |
| 1109 | 75 | close_scope_mh : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_MH); }; | |
| 1110 | ✗ | close_scope_monitor : { scanner_pop_start_cond(nft->scanner, PARSER_SC_CMD_MONITOR); }; | |
| 1111 | 463 | close_scope_nat : { scanner_pop_start_cond(nft->scanner, PARSER_SC_STMT_NAT); }; | |
| 1112 | 46 | close_scope_numgen : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_NUMGEN); }; | |
| 1113 | 42 | close_scope_osf : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_OSF); }; | |
| 1114 | 2045 | close_scope_policy : { scanner_pop_start_cond(nft->scanner, PARSER_SC_POLICY); }; | |
| 1115 | 183 | close_scope_quota : { scanner_pop_start_cond(nft->scanner, PARSER_SC_QUOTA); }; | |
| 1116 | 135 | close_scope_queue : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_QUEUE); }; | |
| 1117 | 453 | close_scope_rate : { scanner_pop_start_cond(nft->scanner, PARSER_SC_RATE); }; | |
| 1118 | 201 | close_scope_reject : { scanner_pop_start_cond(nft->scanner, PARSER_SC_STMT_REJECT); }; | |
| 1119 | 961 | close_scope_reset : { scanner_pop_start_cond(nft->scanner, PARSER_SC_CMD_RESET); }; | |
| 1120 | 115 | close_scope_rt : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_RT); }; | |
| 1121 | 648 | close_scope_sctp : { scanner_pop_start_cond(nft->scanner, PARSER_SC_SCTP); }; | |
| 1122 | 160 | close_scope_sctp_chunk : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_SCTP_CHUNK); }; | |
| 1123 | 12 | close_scope_secmark : { scanner_pop_start_cond(nft->scanner, PARSER_SC_SECMARK); }; | |
| 1124 | 22 | close_scope_socket : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_SOCKET); } | |
| 1125 | 2424 | close_scope_tcp : { scanner_pop_start_cond(nft->scanner, PARSER_SC_TCP); }; | |
| 1126 | 45 | close_scope_tproxy : { scanner_pop_start_cond(nft->scanner, PARSER_SC_STMT_TPROXY); }; | |
| 1127 | 4841 | close_scope_type : { scanner_pop_start_cond(nft->scanner, PARSER_SC_TYPE); }; | |
| 1128 | 109 | close_scope_th : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_TH); }; | |
| 1129 | 1389 | close_scope_udp : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_UDP); }; | |
| 1130 | 140 | close_scope_udplite : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_UDPLITE); }; | |
| 1131 | |||
| 1132 | 192 | close_scope_log : { scanner_pop_start_cond(nft->scanner, PARSER_SC_STMT_LOG); } | |
| 1133 | 41 | close_scope_synproxy : { scanner_pop_start_cond(nft->scanner, PARSER_SC_STMT_SYNPROXY); } | |
| 1134 | 15 | close_scope_tunnel : { scanner_pop_start_cond(nft->scanner, PARSER_SC_TUNNEL); } | |
| 1135 | ✗ | close_scope_xt : { scanner_pop_start_cond(nft->scanner, PARSER_SC_XT); } | |
| 1136 | |||
| 1137 | common_block : INCLUDE QUOTED_STRING stmt_separator | ||
| 1138 | { | ||
| 1139 |
2/2✓ Branch 0 (207→208) taken 4 times.
✓ Branch 1 (207→209) taken 41 times.
|
45 | if (scanner_include_file(nft, scanner, $2, &@$) < 0) { |
| 1140 | 4 | free_const($2); | |
| 1141 | 4 | YYERROR; | |
| 1142 | } | ||
| 1143 | 41 | free_const($2); | |
| 1144 | } | ||
| 1145 | | DEFINE identifier '=' initializer_expr stmt_separator | ||
| 1146 | { | ||
| 1147 | 20116 | struct scope *scope = current_scope(state); | |
| 1148 | |||
| 1149 |
2/2✓ Branch 0 (212→213) taken 1 times.
✓ Branch 1 (212→217) taken 20115 times.
|
20116 | if (symbol_lookup(scope, $2) != NULL) { |
| 1150 | 1 | erec_queue(error(&@2, "redefinition of symbol '%s'", $2), | |
| 1151 | state->msgs); | ||
| 1152 | 1 | expr_free($4); | |
| 1153 | 1 | free_const($2); | |
| 1154 | 1 | YYERROR; | |
| 1155 | } | ||
| 1156 | |||
| 1157 | 20115 | symbol_bind(scope, $2, $4); | |
| 1158 | 20115 | free_const($2); | |
| 1159 | } | ||
| 1160 | | REDEFINE identifier '=' initializer_expr stmt_separator | ||
| 1161 | { | ||
| 1162 | 2 | struct scope *scope = current_scope(state); | |
| 1163 | |||
| 1164 | 2 | symbol_bind(scope, $2, $4); | |
| 1165 | 2 | free_const($2); | |
| 1166 | } | ||
| 1167 | | UNDEFINE identifier stmt_separator | ||
| 1168 | { | ||
| 1169 | 2 | struct scope *scope = current_scope(state); | |
| 1170 | |||
| 1171 |
1/2✗ Branch 0 (224→225) not taken.
✓ Branch 1 (224→228) taken 2 times.
|
2 | if (symbol_unbind(scope, $2) < 0) { |
| 1172 | ✗ | erec_queue(error(&@2, "undefined symbol '%s'", $2), | |
| 1173 | state->msgs); | ||
| 1174 | ✗ | free_const($2); | |
| 1175 | ✗ | YYERROR; | |
| 1176 | } | ||
| 1177 | 2 | free_const($2); | |
| 1178 | } | ||
| 1179 | | error stmt_separator | ||
| 1180 | { | ||
| 1181 |
2/2✓ Branch 0 (229→230) taken 1 times.
✓ Branch 1 (229→231) taken 286 times.
|
287 | if (++state->nerrs == nft->parser_max_errors) |
| 1182 | 1 | YYABORT; | |
| 1183 | 286 | yyerrok; | |
| 1184 | } | ||
| 1185 | ; | ||
| 1186 | |||
| 1187 | 20383 | line : common_block { $$ = NULL; } | |
| 1188 | 835 | | stmt_separator { $$ = NULL; } | |
| 1189 | 89072 | | base_cmd stmt_separator { $$ = $1; } | |
| 1190 | | base_cmd TOKEN_EOF | ||
| 1191 | { | ||
| 1192 | /* | ||
| 1193 | * Very hackish workaround for bison >= 2.4: previous versions | ||
| 1194 | * terminated parsing after EOF, 2.4+ tries to get further input | ||
| 1195 | * in 'input' and calls the scanner again, causing a crash when | ||
| 1196 | * the final input buffer has been popped. Terminate manually to | ||
| 1197 | * avoid this. The correct fix should be to adjust the grammar | ||
| 1198 | * to accept EOF in input, but for unknown reasons it does not | ||
| 1199 | * work. | ||
| 1200 | */ | ||
| 1201 |
1/2✓ Branch 0 (235→236) taken 1 times.
✗ Branch 1 (235→237) not taken.
|
1 | if ($1 != NULL) { |
| 1202 | 1 | $1->location = @1; | |
| 1203 | 1 | list_add_tail(&$1->list, state->cmds); | |
| 1204 | } | ||
| 1205 | 1 | $$ = NULL; | |
| 1206 | 1 | YYACCEPT; | |
| 1207 | } | ||
| 1208 | ; | ||
| 1209 | |||
| 1210 | 1438 | base_cmd : /* empty */ add_cmd { $$ = $1; } | |
| 1211 | 50313 | | ADD add_cmd { $$ = $2; } | |
| 1212 | 10 | | REPLACE replace_cmd { $$ = $2; } | |
| 1213 | 225 | | CREATE create_cmd { $$ = $2; } | |
| 1214 | 150 | | INSERT insert_cmd { $$ = $2; } | |
| 1215 | 2839 | | DELETE delete_cmd { $$ = $2; } | |
| 1216 | 1064 | | GET get_cmd { $$ = $2; } | |
| 1217 | 16408 | | LIST list_cmd close_scope_list { $$ = $2; } | |
| 1218 | 917 | | RESET reset_cmd close_scope_reset { $$ = $2; } | |
| 1219 | 15695 | | FLUSH flush_cmd { $$ = $2; } | |
| 1220 | 4 | | RENAME rename_cmd { $$ = $2; } | |
| 1221 | ✗ | | IMPORT import_cmd close_scope_import { $$ = $2; } | |
| 1222 | ✗ | | EXPORT export_cmd close_scope_export { $$ = $2; } | |
| 1223 | ✗ | | MONITOR monitor_cmd close_scope_monitor { $$ = $2; } | |
| 1224 | ✗ | | DESCRIBE describe_cmd { $$ = $2; } | |
| 1225 | 12 | | DESTROY destroy_cmd close_scope_destroy { $$ = $2; } | |
| 1226 | ; | ||
| 1227 | |||
| 1228 | add_cmd : TABLE table_spec | ||
| 1229 | { | ||
| 1230 | 1118 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_TABLE, &$2, &@$, NULL); | |
| 1231 | } | ||
| 1232 | | TABLE table_spec table_block_alloc | ||
| 1233 | '{' table_block '}' | ||
| 1234 | { | ||
| 1235 | 1440 | handle_merge(&$3->handle, &$2); | |
| 1236 | 1440 | close_scope(state); | |
| 1237 | 1440 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_TABLE, &$2, &@$, $5); | |
| 1238 | } | ||
| 1239 | | CHAIN chain_spec | ||
| 1240 | { | ||
| 1241 | 736 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_CHAIN, &$2, &@$, NULL); | |
| 1242 | } | ||
| 1243 | | CHAIN chain_spec chain_block_alloc | ||
| 1244 | '{' chain_block '}' | ||
| 1245 | { | ||
| 1246 | 1814 | $5->location = @5; | |
| 1247 | 1814 | handle_merge(&$3->handle, &$2); | |
| 1248 | 1810 | close_scope(state); | |
| 1249 | 1810 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_CHAIN, &$2, &@$, $5); | |
| 1250 | } | ||
| 1251 | | RULE rule_position rule | ||
| 1252 | { | ||
| 1253 | 14847 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_RULE, &$2, &@$, $3); | |
| 1254 | } | ||
| 1255 | | /* empty */ rule_position rule | ||
| 1256 | { | ||
| 1257 | 14 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_RULE, &$1, &@$, $2); | |
| 1258 | } | ||
| 1259 | | SET set_spec set_block_alloc | ||
| 1260 | '{' set_block '}' | ||
| 1261 | { | ||
| 1262 | 1294 | $5->location = @5; | |
| 1263 | 1294 | handle_merge(&$3->handle, &$2); | |
| 1264 | 1266 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_SET, &$2, &@$, $5); | |
| 1265 | } | ||
| 1266 | | MAP set_spec map_block_alloc | ||
| 1267 | '{' map_block '}' | ||
| 1268 | { | ||
| 1269 | 194 | $5->location = @5; | |
| 1270 | 194 | handle_merge(&$3->handle, &$2); | |
| 1271 | 162 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_SET, &$2, &@$, $5); | |
| 1272 | } | ||
| 1273 | | ELEMENT set_spec set_block_expr | ||
| 1274 | { | ||
| 1275 |
2/2✓ Branch 0 (277→278) taken 58 times.
✓ Branch 1 (277→281) taken 23142 times.
|
30190 | if (nft_cmd_collapse_elems(CMD_ADD, state->cmds, &$2, $3)) { |
| 1276 | 58 | handle_free(&$2); | |
| 1277 | 58 | expr_free($3); | |
| 1278 | 58 | $$ = NULL; | |
| 1279 | 58 | break; | |
| 1280 | } | ||
| 1281 | 23142 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_ELEMENTS, &$2, &@$, $3); | |
| 1282 | } | ||
| 1283 | | FLOWTABLE flowtable_spec flowtable_block_alloc | ||
| 1284 | '{' flowtable_block '}' | ||
| 1285 | { | ||
| 1286 | 34 | $5->location = @5; | |
| 1287 | 34 | handle_merge(&$3->handle, &$2); | |
| 1288 | 34 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_FLOWTABLE, &$2, &@$, $5); | |
| 1289 | } | ||
| 1290 | | COUNTER obj_spec close_scope_counter | ||
| 1291 | { | ||
| 1292 | struct obj *obj; | ||
| 1293 | |||
| 1294 | 18 | obj = obj_alloc(&@$); | |
| 1295 | 18 | obj->type = NFT_OBJECT_COUNTER; | |
| 1296 | 18 | handle_merge(&obj->handle, &$2); | |
| 1297 | 18 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_COUNTER, &$2, &@$, obj); | |
| 1298 | } | ||
| 1299 | | COUNTER obj_spec counter_obj counter_config close_scope_counter | ||
| 1300 | { | ||
| 1301 | ✗ | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_COUNTER, &$2, &@$, $3); | |
| 1302 | } | ||
| 1303 | | COUNTER obj_spec counter_obj '{' counter_block '}' close_scope_counter | ||
| 1304 | { | ||
| 1305 | ✗ | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_COUNTER, &$2, &@$, $3); | |
| 1306 | } | ||
| 1307 | | QUOTA obj_spec quota_obj quota_config close_scope_quota | ||
| 1308 | { | ||
| 1309 | 17 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_QUOTA, &$2, &@$, $3); | |
| 1310 | } | ||
| 1311 | | QUOTA obj_spec quota_obj '{' quota_block '}' close_scope_quota | ||
| 1312 | { | ||
| 1313 | ✗ | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_QUOTA, &$2, &@$, $3); | |
| 1314 | } | ||
| 1315 | | CT HELPER obj_spec ct_obj_alloc '{' ct_helper_block '}' close_scope_ct | ||
| 1316 | { | ||
| 1317 | 9 | $$ = cmd_alloc_obj_ct(CMD_ADD, NFT_OBJECT_CT_HELPER, &$3, &@$, $4); | |
| 1318 | } | ||
| 1319 | | CT TIMEOUT obj_spec ct_obj_alloc '{' ct_timeout_block '}' close_scope_ct | ||
| 1320 | { | ||
| 1321 | 10 | $$ = cmd_alloc_obj_ct(CMD_ADD, NFT_OBJECT_CT_TIMEOUT, &$3, &@$, $4); | |
| 1322 | } | ||
| 1323 | | CT EXPECTATION obj_spec ct_obj_alloc '{' ct_expect_block '}' close_scope_ct | ||
| 1324 | { | ||
| 1325 | 6 | $$ = cmd_alloc_obj_ct(CMD_ADD, NFT_OBJECT_CT_EXPECT, &$3, &@$, $4); | |
| 1326 | } | ||
| 1327 | | LIMIT obj_spec limit_obj limit_config close_scope_limit | ||
| 1328 | { | ||
| 1329 | 8 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_LIMIT, &$2, &@$, $3); | |
| 1330 | } | ||
| 1331 | | LIMIT obj_spec limit_obj '{' limit_block '}' close_scope_limit | ||
| 1332 | { | ||
| 1333 | ✗ | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_LIMIT, &$2, &@$, $3); | |
| 1334 | } | ||
| 1335 | | SECMARK obj_spec secmark_obj secmark_config close_scope_secmark | ||
| 1336 | { | ||
| 1337 | ✗ | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_SECMARK, &$2, &@$, $3); | |
| 1338 | } | ||
| 1339 | | SECMARK obj_spec secmark_obj '{' secmark_block '}' close_scope_secmark | ||
| 1340 | { | ||
| 1341 | ✗ | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_SECMARK, &$2, &@$, $3); | |
| 1342 | } | ||
| 1343 | | SYNPROXY obj_spec synproxy_obj synproxy_config close_scope_synproxy | ||
| 1344 | { | ||
| 1345 | 2 | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_SYNPROXY, &$2, &@$, $3); | |
| 1346 | } | ||
| 1347 | | SYNPROXY obj_spec synproxy_obj '{' synproxy_block '}' close_scope_synproxy | ||
| 1348 | { | ||
| 1349 | ✗ | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_SYNPROXY, &$2, &@$, $3); | |
| 1350 | } | ||
| 1351 | | TUNNEL obj_spec tunnel_obj '{' tunnel_block '}' close_scope_tunnel | ||
| 1352 | { | ||
| 1353 | ✗ | $$ = cmd_alloc(CMD_ADD, CMD_OBJ_TUNNEL, &$2, &@$, $3); | |
| 1354 | } | ||
| 1355 | ; | ||
| 1356 | |||
| 1357 | replace_cmd : RULE ruleid_spec rule | ||
| 1358 | { | ||
| 1359 | 10 | $$ = cmd_alloc(CMD_REPLACE, CMD_OBJ_RULE, &$2, &@$, $3); | |
| 1360 | } | ||
| 1361 | ; | ||
| 1362 | |||
| 1363 | create_cmd : TABLE table_spec | ||
| 1364 | { | ||
| 1365 | 3 | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_TABLE, &$2, &@$, NULL); | |
| 1366 | } | ||
| 1367 | | TABLE table_spec table_block_alloc | ||
| 1368 | '{' table_block '}' | ||
| 1369 | { | ||
| 1370 | ✗ | handle_merge(&$3->handle, &$2); | |
| 1371 | ✗ | close_scope(state); | |
| 1372 | ✗ | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_TABLE, &$2, &@$, $5); | |
| 1373 | } | ||
| 1374 | | CHAIN chain_spec | ||
| 1375 | { | ||
| 1376 | 2 | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_CHAIN, &$2, &@$, NULL); | |
| 1377 | } | ||
| 1378 | | CHAIN chain_spec chain_block_alloc | ||
| 1379 | '{' chain_block '}' | ||
| 1380 | { | ||
| 1381 | 2 | $5->location = @5; | |
| 1382 | 2 | handle_merge(&$3->handle, &$2); | |
| 1383 | 2 | close_scope(state); | |
| 1384 | 2 | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_CHAIN, &$2, &@$, $5); | |
| 1385 | } | ||
| 1386 | | SET set_spec set_block_alloc | ||
| 1387 | '{' set_block '}' | ||
| 1388 | { | ||
| 1389 | 2 | $5->location = @5; | |
| 1390 | 2 | handle_merge(&$3->handle, &$2); | |
| 1391 | 2 | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_SET, &$2, &@$, $5); | |
| 1392 | } | ||
| 1393 | | MAP set_spec map_block_alloc | ||
| 1394 | '{' map_block '}' | ||
| 1395 | { | ||
| 1396 | ✗ | $5->location = @5; | |
| 1397 | ✗ | handle_merge(&$3->handle, &$2); | |
| 1398 | ✗ | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_SET, &$2, &@$, $5); | |
| 1399 | } | ||
| 1400 | | ELEMENT set_spec set_block_expr | ||
| 1401 | { | ||
| 1402 |
1/2✗ Branch 0 (339→340) not taken.
✓ Branch 1 (339→343) taken 215 times.
|
215 | if (nft_cmd_collapse_elems(CMD_CREATE, state->cmds, &$2, $3)) { |
| 1403 | ✗ | handle_free(&$2); | |
| 1404 | ✗ | expr_free($3); | |
| 1405 | ✗ | $$ = NULL; | |
| 1406 | ✗ | break; | |
| 1407 | } | ||
| 1408 | 215 | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_ELEMENTS, &$2, &@$, $3); | |
| 1409 | } | ||
| 1410 | | FLOWTABLE flowtable_spec flowtable_block_alloc | ||
| 1411 | '{' flowtable_block '}' | ||
| 1412 | { | ||
| 1413 | 1 | $5->location = @5; | |
| 1414 | 1 | handle_merge(&$3->handle, &$2); | |
| 1415 | 1 | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_FLOWTABLE, &$2, &@$, $5); | |
| 1416 | } | ||
| 1417 | | COUNTER obj_spec close_scope_counter | ||
| 1418 | { | ||
| 1419 | struct obj *obj; | ||
| 1420 | |||
| 1421 | ✗ | obj = obj_alloc(&@$); | |
| 1422 | ✗ | obj->type = NFT_OBJECT_COUNTER; | |
| 1423 | ✗ | handle_merge(&obj->handle, &$2); | |
| 1424 | ✗ | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_COUNTER, &$2, &@$, obj); | |
| 1425 | } | ||
| 1426 | | COUNTER obj_spec counter_obj counter_config close_scope_counter | ||
| 1427 | { | ||
| 1428 | ✗ | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_COUNTER, &$2, &@$, $3); | |
| 1429 | } | ||
| 1430 | | QUOTA obj_spec quota_obj quota_config close_scope_quota | ||
| 1431 | { | ||
| 1432 | ✗ | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_QUOTA, &$2, &@$, $3); | |
| 1433 | } | ||
| 1434 | | CT HELPER obj_spec ct_obj_alloc '{' ct_helper_block '}' close_scope_ct | ||
| 1435 | { | ||
| 1436 | ✗ | $$ = cmd_alloc_obj_ct(CMD_CREATE, NFT_OBJECT_CT_HELPER, &$3, &@$, $4); | |
| 1437 | } | ||
| 1438 | | CT TIMEOUT obj_spec ct_obj_alloc '{' ct_timeout_block '}' close_scope_ct | ||
| 1439 | { | ||
| 1440 | ✗ | $$ = cmd_alloc_obj_ct(CMD_CREATE, NFT_OBJECT_CT_TIMEOUT, &$3, &@$, $4); | |
| 1441 | } | ||
| 1442 | | CT EXPECTATION obj_spec ct_obj_alloc '{' ct_expect_block '}' close_scope_ct | ||
| 1443 | { | ||
| 1444 | ✗ | $$ = cmd_alloc_obj_ct(CMD_CREATE, NFT_OBJECT_CT_EXPECT, &$3, &@$, $4); | |
| 1445 | } | ||
| 1446 | | LIMIT obj_spec limit_obj limit_config close_scope_limit | ||
| 1447 | { | ||
| 1448 | ✗ | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_LIMIT, &$2, &@$, $3); | |
| 1449 | } | ||
| 1450 | | SECMARK obj_spec secmark_obj secmark_config close_scope_secmark | ||
| 1451 | { | ||
| 1452 | ✗ | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_SECMARK, &$2, &@$, $3); | |
| 1453 | } | ||
| 1454 | | SYNPROXY obj_spec synproxy_obj synproxy_config close_scope_synproxy | ||
| 1455 | { | ||
| 1456 | ✗ | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_SYNPROXY, &$2, &@$, $3); | |
| 1457 | } | ||
| 1458 | | TUNNEL obj_spec tunnel_obj '{' tunnel_block '}' close_scope_tunnel | ||
| 1459 | { | ||
| 1460 | ✗ | $$ = cmd_alloc(CMD_CREATE, CMD_OBJ_TUNNEL, &$2, &@$, $3); | |
| 1461 | } | ||
| 1462 | ; | ||
| 1463 | |||
| 1464 | insert_cmd : RULE rule_position rule | ||
| 1465 | { | ||
| 1466 | 150 | $$ = cmd_alloc(CMD_INSERT, CMD_OBJ_RULE, &$2, &@$, $3); | |
| 1467 | } | ||
| 1468 | ; | ||
| 1469 | |||
| 1470 | table_or_id_spec : table_spec | ||
| 1471 | | tableid_spec | ||
| 1472 | ; | ||
| 1473 | |||
| 1474 | chain_or_id_spec : chain_spec | ||
| 1475 | | chainid_spec | ||
| 1476 | ; | ||
| 1477 | |||
| 1478 | set_or_id_spec : set_spec | ||
| 1479 | | setid_spec | ||
| 1480 | ; | ||
| 1481 | |||
| 1482 | obj_or_id_spec : obj_spec | ||
| 1483 | | objid_spec | ||
| 1484 | ; | ||
| 1485 | |||
| 1486 | delete_cmd : TABLE table_or_id_spec | ||
| 1487 | { | ||
| 1488 | 270 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_TABLE, &$2, &@$, NULL); | |
| 1489 | } | ||
| 1490 | | CHAIN chain_or_id_spec | ||
| 1491 | { | ||
| 1492 | 345 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_CHAIN, &$2, &@$, NULL); | |
| 1493 | } | ||
| 1494 | | CHAIN chain_spec chain_block_alloc | ||
| 1495 | '{' chain_block '}' | ||
| 1496 | { | ||
| 1497 | 7 | $5->location = @5; | |
| 1498 | 7 | handle_merge(&$3->handle, &$2); | |
| 1499 | 7 | close_scope(state); | |
| 1500 | 7 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_CHAIN, &$2, &@$, $5); | |
| 1501 | } | ||
| 1502 | | RULE ruleid_spec | ||
| 1503 | { | ||
| 1504 | 8 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_RULE, &$2, &@$, NULL); | |
| 1505 | } | ||
| 1506 | | SET set_or_id_spec | ||
| 1507 | { | ||
| 1508 | 78 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_SET, &$2, &@$, NULL); | |
| 1509 | } | ||
| 1510 | | MAP set_or_id_spec | ||
| 1511 | { | ||
| 1512 | 7 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_SET, &$2, &@$, NULL); | |
| 1513 | } | ||
| 1514 | | ELEMENT set_spec set_block_expr | ||
| 1515 | { | ||
| 1516 | 2063 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_ELEMENTS, &$2, &@$, $3); | |
| 1517 | } | ||
| 1518 | | FLOWTABLE flowtable_spec | ||
| 1519 | { | ||
| 1520 | 19 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_FLOWTABLE, &$2, &@$, NULL); | |
| 1521 | } | ||
| 1522 | | FLOWTABLE flowtableid_spec | ||
| 1523 | { | ||
| 1524 | 3 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_FLOWTABLE, &$2, &@$, NULL); | |
| 1525 | } | ||
| 1526 | | FLOWTABLE flowtable_spec flowtable_block_alloc | ||
| 1527 | '{' flowtable_block '}' | ||
| 1528 | { | ||
| 1529 | 12 | $5->location = @5; | |
| 1530 | 12 | handle_merge(&$3->handle, &$2); | |
| 1531 | 12 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_FLOWTABLE, &$2, &@$, $5); | |
| 1532 | } | ||
| 1533 | | COUNTER obj_or_id_spec close_scope_counter | ||
| 1534 | { | ||
| 1535 | 8 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_COUNTER, &$2, &@$, NULL); | |
| 1536 | } | ||
| 1537 | | QUOTA obj_or_id_spec close_scope_quota | ||
| 1538 | { | ||
| 1539 | 6 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_QUOTA, &$2, &@$, NULL); | |
| 1540 | } | ||
| 1541 | | CT ct_obj_type obj_spec ct_obj_alloc close_scope_ct | ||
| 1542 | { | ||
| 1543 | 9 | $$ = cmd_alloc_obj_ct(CMD_DELETE, $2, &$3, &@$, $4); | |
| 1544 |
2/2✓ Branch 0 (400→401) taken 4 times.
✓ Branch 1 (400→402) taken 5 times.
|
9 | if ($2 == NFT_OBJECT_CT_TIMEOUT) |
| 1545 | 4 | init_list_head(&$4->ct_timeout.timeout_list); | |
| 1546 | } | ||
| 1547 | | LIMIT obj_or_id_spec close_scope_limit | ||
| 1548 | { | ||
| 1549 | 4 | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_LIMIT, &$2, &@$, NULL); | |
| 1550 | } | ||
| 1551 | | SECMARK obj_or_id_spec close_scope_secmark | ||
| 1552 | { | ||
| 1553 | ✗ | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_SECMARK, &$2, &@$, NULL); | |
| 1554 | } | ||
| 1555 | | SYNPROXY obj_or_id_spec close_scope_synproxy | ||
| 1556 | { | ||
| 1557 | ✗ | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_SYNPROXY, &$2, &@$, NULL); | |
| 1558 | } | ||
| 1559 | | TUNNEL obj_or_id_spec close_scope_tunnel | ||
| 1560 | { | ||
| 1561 | ✗ | $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_TUNNEL, &$2, &@$, NULL); | |
| 1562 | } | ||
| 1563 | ; | ||
| 1564 | |||
| 1565 | destroy_cmd : TABLE table_or_id_spec | ||
| 1566 | { | ||
| 1567 | 2 | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_TABLE, &$2, &@$, NULL); | |
| 1568 | } | ||
| 1569 | | CHAIN chain_or_id_spec | ||
| 1570 | { | ||
| 1571 | 2 | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_CHAIN, &$2, &@$, NULL); | |
| 1572 | } | ||
| 1573 | | RULE ruleid_spec | ||
| 1574 | { | ||
| 1575 | 2 | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_RULE, &$2, &@$, NULL); | |
| 1576 | } | ||
| 1577 | | SET set_or_id_spec | ||
| 1578 | { | ||
| 1579 | 2 | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_SET, &$2, &@$, NULL); | |
| 1580 | } | ||
| 1581 | | MAP set_spec | ||
| 1582 | { | ||
| 1583 | 2 | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_SET, &$2, &@$, NULL); | |
| 1584 | } | ||
| 1585 | | ELEMENT set_spec set_block_expr | ||
| 1586 | { | ||
| 1587 | ✗ | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_ELEMENTS, &$2, &@$, $3); | |
| 1588 | } | ||
| 1589 | | FLOWTABLE flowtable_spec | ||
| 1590 | { | ||
| 1591 | 2 | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_FLOWTABLE, &$2, &@$, NULL); | |
| 1592 | } | ||
| 1593 | | FLOWTABLE flowtableid_spec | ||
| 1594 | { | ||
| 1595 | ✗ | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_FLOWTABLE, &$2, &@$, NULL); | |
| 1596 | } | ||
| 1597 | | FLOWTABLE flowtable_spec flowtable_block_alloc | ||
| 1598 | '{' flowtable_block '}' | ||
| 1599 | { | ||
| 1600 | ✗ | $5->location = @5; | |
| 1601 | ✗ | handle_merge(&$3->handle, &$2); | |
| 1602 | ✗ | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_FLOWTABLE, &$2, &@$, $5); | |
| 1603 | } | ||
| 1604 | | COUNTER obj_or_id_spec close_scope_counter | ||
| 1605 | { | ||
| 1606 | ✗ | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_COUNTER, &$2, &@$, NULL); | |
| 1607 | } | ||
| 1608 | | QUOTA obj_or_id_spec close_scope_quota | ||
| 1609 | { | ||
| 1610 | ✗ | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_QUOTA, &$2, &@$, NULL); | |
| 1611 | } | ||
| 1612 | | CT ct_obj_type obj_spec ct_obj_alloc close_scope_ct | ||
| 1613 | { | ||
| 1614 | ✗ | $$ = cmd_alloc_obj_ct(CMD_DESTROY, $2, &$3, &@$, $4); | |
| 1615 | ✗ | if ($2 == NFT_OBJECT_CT_TIMEOUT) | |
| 1616 | ✗ | init_list_head(&$4->ct_timeout.timeout_list); | |
| 1617 | } | ||
| 1618 | | LIMIT obj_or_id_spec close_scope_limit | ||
| 1619 | { | ||
| 1620 | ✗ | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_LIMIT, &$2, &@$, NULL); | |
| 1621 | } | ||
| 1622 | | SECMARK obj_or_id_spec close_scope_secmark | ||
| 1623 | { | ||
| 1624 | ✗ | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_SECMARK, &$2, &@$, NULL); | |
| 1625 | } | ||
| 1626 | | SYNPROXY obj_or_id_spec close_scope_synproxy | ||
| 1627 | { | ||
| 1628 | ✗ | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_SYNPROXY, &$2, &@$, NULL); | |
| 1629 | } | ||
| 1630 | | TUNNEL obj_or_id_spec close_scope_tunnel | ||
| 1631 | { | ||
| 1632 | ✗ | $$ = cmd_alloc(CMD_DESTROY, CMD_OBJ_TUNNEL, &$2, &@$, NULL); | |
| 1633 | } | ||
| 1634 | ; | ||
| 1635 | |||
| 1636 | |||
| 1637 | get_cmd : ELEMENT set_spec set_block_expr | ||
| 1638 | { | ||
| 1639 | 1064 | $$ = cmd_alloc(CMD_GET, CMD_OBJ_ELEMENTS, &$2, &@$, $3); | |
| 1640 | } | ||
| 1641 | ; | ||
| 1642 | |||
| 1643 | 1 | list_cmd_spec_table : TABLE table_spec { $$ = $2; } | |
| 1644 | | table_spec | ||
| 1645 | ; | ||
| 1646 | list_cmd_spec_any : list_cmd_spec_table | ||
| 1647 | | ruleset_spec | ||
| 1648 | ; | ||
| 1649 | |||
| 1650 | list_cmd : TABLE table_spec | ||
| 1651 | { | ||
| 1652 | 12606 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_TABLE, &$2, &@$, NULL); | |
| 1653 | } | ||
| 1654 | | TABLES ruleset_spec | ||
| 1655 | { | ||
| 1656 | 2 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_TABLE, &$2, &@$, NULL); | |
| 1657 | } | ||
| 1658 | | CHAIN chain_spec | ||
| 1659 | { | ||
| 1660 | 1275 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_CHAIN, &$2, &@$, NULL); | |
| 1661 | } | ||
| 1662 | | CHAINS ruleset_spec | ||
| 1663 | { | ||
| 1664 | 1 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_CHAINS, &$2, &@$, NULL); | |
| 1665 | } | ||
| 1666 | | SETS list_cmd_spec_any | ||
| 1667 | { | ||
| 1668 | 4 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_SETS, &$2, &@$, NULL); | |
| 1669 | } | ||
| 1670 | | SET set_spec | ||
| 1671 | { | ||
| 1672 | 773 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_SET, &$2, &@$, NULL); | |
| 1673 | } | ||
| 1674 | | COUNTERS list_cmd_spec_any | ||
| 1675 | { | ||
| 1676 | 4 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_COUNTERS, &$2, &@$, NULL); | |
| 1677 | } | ||
| 1678 | | COUNTER obj_spec close_scope_counter | ||
| 1679 | { | ||
| 1680 | 280 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_COUNTER, &$2, &@$, NULL); | |
| 1681 | } | ||
| 1682 | | QUOTAS list_cmd_spec_any | ||
| 1683 | { | ||
| 1684 | 4 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_QUOTAS, &$2, &@$, NULL); | |
| 1685 | } | ||
| 1686 | | QUOTA obj_spec close_scope_quota | ||
| 1687 | { | ||
| 1688 | 9 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_QUOTA, &$2, &@$, NULL); | |
| 1689 | } | ||
| 1690 | | LIMITS list_cmd_spec_any | ||
| 1691 | { | ||
| 1692 | ✗ | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_LIMITS, &$2, &@$, NULL); | |
| 1693 | } | ||
| 1694 | | LIMIT obj_spec close_scope_limit | ||
| 1695 | { | ||
| 1696 | 8 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_LIMIT, &$2, &@$, NULL); | |
| 1697 | } | ||
| 1698 | | SECMARKS list_cmd_spec_any | ||
| 1699 | { | ||
| 1700 | ✗ | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_SECMARKS, &$2, &@$, NULL); | |
| 1701 | } | ||
| 1702 | | SECMARK obj_spec close_scope_secmark | ||
| 1703 | { | ||
| 1704 | ✗ | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_SECMARK, &$2, &@$, NULL); | |
| 1705 | } | ||
| 1706 | | SYNPROXYS list_cmd_spec_any | ||
| 1707 | { | ||
| 1708 | ✗ | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_SYNPROXYS, &$2, &@$, NULL); | |
| 1709 | } | ||
| 1710 | | SYNPROXY obj_spec close_scope_synproxy | ||
| 1711 | { | ||
| 1712 | 4 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_SYNPROXY, &$2, &@$, NULL); | |
| 1713 | } | ||
| 1714 | | RULESET ruleset_spec | ||
| 1715 | { | ||
| 1716 | 1146 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_RULESET, &$2, &@$, NULL); | |
| 1717 | } | ||
| 1718 | | FLOW TABLES ruleset_spec | ||
| 1719 | { | ||
| 1720 | ✗ | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_METERS, &$3, &@$, NULL); | |
| 1721 | } | ||
| 1722 | | FLOW TABLE set_spec | ||
| 1723 | { | ||
| 1724 | ✗ | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_METER, &$3, &@$, NULL); | |
| 1725 | } | ||
| 1726 | | METERS ruleset_spec | ||
| 1727 | { | ||
| 1728 | 2 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_METERS, &$2, &@$, NULL); | |
| 1729 | } | ||
| 1730 | | METER set_spec | ||
| 1731 | { | ||
| 1732 | ✗ | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_METER, &$2, &@$, NULL); | |
| 1733 | } | ||
| 1734 | | FLOWTABLES list_cmd_spec_any | ||
| 1735 | { | ||
| 1736 | 1 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_FLOWTABLES, &$2, &@$, NULL); | |
| 1737 | } | ||
| 1738 | | FLOWTABLE flowtable_spec | ||
| 1739 | { | ||
| 1740 | 2 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_FLOWTABLE, &$2, &@$, NULL); | |
| 1741 | } | ||
| 1742 | | MAPS list_cmd_spec_any | ||
| 1743 | { | ||
| 1744 | ✗ | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_MAPS, &$2, &@$, NULL); | |
| 1745 | } | ||
| 1746 | | MAP set_spec | ||
| 1747 | { | ||
| 1748 | 248 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_MAP, &$2, &@$, NULL); | |
| 1749 | } | ||
| 1750 | | CT ct_obj_type obj_spec close_scope_ct | ||
| 1751 | { | ||
| 1752 | 24 | $$ = cmd_alloc_obj_ct(CMD_LIST, $2, &$3, &@$, NULL); | |
| 1753 | } | ||
| 1754 | | CT ct_cmd_type TABLE table_spec close_scope_ct | ||
| 1755 | { | ||
| 1756 | ✗ | $$ = cmd_alloc(CMD_LIST, $2, &$4, &@$, NULL); | |
| 1757 | } | ||
| 1758 | | HOOKS basehook_spec | ||
| 1759 | { | ||
| 1760 | 15 | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_HOOKS, &$2, &@$, NULL); | |
| 1761 | } | ||
| 1762 | | TUNNELS list_cmd_spec_any | ||
| 1763 | { | ||
| 1764 | ✗ | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_TUNNELS, &$2, &@$, NULL); | |
| 1765 | } | ||
| 1766 | | TUNNEL obj_spec close_scope_tunnel | ||
| 1767 | { | ||
| 1768 | ✗ | $$ = cmd_alloc(CMD_LIST, CMD_OBJ_TUNNEL, &$2, &@$, NULL); | |
| 1769 | } | ||
| 1770 | ; | ||
| 1771 | |||
| 1772 | basehook_device_name : DEVICE STRING | ||
| 1773 | { | ||
| 1774 | 7 | $$ = $2; | |
| 1775 | } | ||
| 1776 | ; | ||
| 1777 | |||
| 1778 | basehook_spec : ruleset_spec | ||
| 1779 | { | ||
| 1780 | 8 | $$ = $1; | |
| 1781 | } | ||
| 1782 | | ruleset_spec basehook_device_name | ||
| 1783 | { | ||
| 1784 |
1/2✓ Branch 0 (511→512) taken 7 times.
✗ Branch 1 (511→513) not taken.
|
7 | if ($2) { |
| 1785 | 7 | $1.obj.name = $2; | |
| 1786 | 7 | $1.obj.location = @2; | |
| 1787 | } | ||
| 1788 | 7 | $$ = $1; | |
| 1789 | } | ||
| 1790 | ; | ||
| 1791 | |||
| 1792 | reset_cmd : COUNTERS list_cmd_spec_any | ||
| 1793 | { | ||
| 1794 | 2 | $$ = cmd_alloc(CMD_RESET, CMD_OBJ_COUNTERS, &$2, &@$, NULL); | |
| 1795 | } | ||
| 1796 | | COUNTER obj_spec close_scope_counter | ||
| 1797 | { | ||
| 1798 | 78 | $$ = cmd_alloc(CMD_RESET, CMD_OBJ_COUNTER, &$2,&@$, NULL); | |
| 1799 | } | ||
| 1800 | | QUOTAS list_cmd_spec_any | ||
| 1801 | { | ||
| 1802 | 2 | $$ = cmd_alloc(CMD_RESET, CMD_OBJ_QUOTAS, &$2, &@$, NULL); | |
| 1803 | } | ||
| 1804 | | QUOTA obj_spec close_scope_quota | ||
| 1805 | { | ||
| 1806 | 1 | $$ = cmd_alloc(CMD_RESET, CMD_OBJ_QUOTA, &$2, &@$, NULL); | |
| 1807 | } | ||
| 1808 | | RULES ruleset_spec | ||
| 1809 | { | ||
| 1810 | 4 | $$ = cmd_alloc(CMD_RESET, CMD_OBJ_RULES, &$2, &@$, NULL); | |
| 1811 | } | ||
| 1812 | | RULES list_cmd_spec_table | ||
| 1813 | { | ||
| 1814 | 1 | $$ = cmd_alloc(CMD_RESET, CMD_OBJ_TABLE, &$2, &@$, NULL); | |
| 1815 | } | ||
| 1816 | | RULES chain_spec | ||
| 1817 | { | ||
| 1818 | ✗ | $$ = cmd_alloc(CMD_RESET, CMD_OBJ_CHAIN, &$2, &@$, NULL); | |
| 1819 | } | ||
| 1820 | | RULES CHAIN chain_spec | ||
| 1821 | { | ||
| 1822 | /* alias of previous rule. */ | ||
| 1823 | 3 | $$ = cmd_alloc(CMD_RESET, CMD_OBJ_CHAIN, &$3, &@$, NULL); | |
| 1824 | } | ||
| 1825 | | RULE ruleid_spec | ||
| 1826 | { | ||
| 1827 | 1 | $$ = cmd_alloc(CMD_RESET, CMD_OBJ_RULE, &$2, &@$, NULL); | |
| 1828 | } | ||
| 1829 | | ELEMENT set_spec set_block_expr | ||
| 1830 | { | ||
| 1831 | 821 | $$ = cmd_alloc(CMD_RESET, CMD_OBJ_ELEMENTS, &$2, &@$, $3); | |
| 1832 | } | ||
| 1833 | | SET set_spec | ||
| 1834 | { | ||
| 1835 | 3 | $$ = cmd_alloc(CMD_RESET, CMD_OBJ_SET, &$2, &@$, NULL); | |
| 1836 | } | ||
| 1837 | | MAP set_spec | ||
| 1838 | { | ||
| 1839 | 1 | $$ = cmd_alloc(CMD_RESET, CMD_OBJ_MAP, &$2, &@$, NULL); | |
| 1840 | } | ||
| 1841 | ; | ||
| 1842 | |||
| 1843 | flush_cmd : TABLE table_spec | ||
| 1844 | { | ||
| 1845 | 13677 | $$ = cmd_alloc(CMD_FLUSH, CMD_OBJ_TABLE, &$2, &@$, NULL); | |
| 1846 | } | ||
| 1847 | | CHAIN chain_spec | ||
| 1848 | { | ||
| 1849 | 428 | $$ = cmd_alloc(CMD_FLUSH, CMD_OBJ_CHAIN, &$2, &@$, NULL); | |
| 1850 | } | ||
| 1851 | | SET set_spec | ||
| 1852 | { | ||
| 1853 | 195 | $$ = cmd_alloc(CMD_FLUSH, CMD_OBJ_SET, &$2, &@$, NULL); | |
| 1854 | } | ||
| 1855 | | MAP set_spec | ||
| 1856 | { | ||
| 1857 | 12 | $$ = cmd_alloc(CMD_FLUSH, CMD_OBJ_MAP, &$2, &@$, NULL); | |
| 1858 | } | ||
| 1859 | | FLOW TABLE set_spec | ||
| 1860 | { | ||
| 1861 | ✗ | $$ = cmd_alloc(CMD_FLUSH, CMD_OBJ_METER, &$3, &@$, NULL); | |
| 1862 | } | ||
| 1863 | | METER set_spec | ||
| 1864 | { | ||
| 1865 | 2 | $$ = cmd_alloc(CMD_FLUSH, CMD_OBJ_METER, &$2, &@$, NULL); | |
| 1866 | } | ||
| 1867 | | RULESET ruleset_spec | ||
| 1868 | { | ||
| 1869 | 1381 | $$ = cmd_alloc(CMD_FLUSH, CMD_OBJ_RULESET, &$2, &@$, NULL); | |
| 1870 | } | ||
| 1871 | ; | ||
| 1872 | |||
| 1873 | rename_cmd : CHAIN chain_spec identifier | ||
| 1874 | { | ||
| 1875 | 4 | $$ = cmd_alloc(CMD_RENAME, CMD_OBJ_CHAIN, &$2, &@$, NULL); | |
| 1876 | 4 | $$->arg = $3; | |
| 1877 | } | ||
| 1878 | ; | ||
| 1879 | |||
| 1880 | import_cmd : RULESET markup_format | ||
| 1881 | { | ||
| 1882 | ✗ | struct handle h = { .family = NFPROTO_UNSPEC }; | |
| 1883 | ✗ | struct markup *markup = markup_alloc($2); | |
| 1884 | ✗ | $$ = cmd_alloc(CMD_IMPORT, CMD_OBJ_MARKUP, &h, &@$, markup); | |
| 1885 | } | ||
| 1886 | | markup_format | ||
| 1887 | { | ||
| 1888 | ✗ | struct handle h = { .family = NFPROTO_UNSPEC }; | |
| 1889 | ✗ | struct markup *markup = markup_alloc($1); | |
| 1890 | ✗ | $$ = cmd_alloc(CMD_IMPORT, CMD_OBJ_MARKUP, &h, &@$, markup); | |
| 1891 | } | ||
| 1892 | ; | ||
| 1893 | |||
| 1894 | export_cmd : RULESET markup_format | ||
| 1895 | { | ||
| 1896 | ✗ | struct handle h = { .family = NFPROTO_UNSPEC }; | |
| 1897 | ✗ | struct markup *markup = markup_alloc($2); | |
| 1898 | ✗ | $$ = cmd_alloc(CMD_EXPORT, CMD_OBJ_MARKUP, &h, &@$, markup); | |
| 1899 | } | ||
| 1900 | | markup_format | ||
| 1901 | { | ||
| 1902 | ✗ | struct handle h = { .family = NFPROTO_UNSPEC }; | |
| 1903 | ✗ | struct markup *markup = markup_alloc($1); | |
| 1904 | ✗ | $$ = cmd_alloc(CMD_EXPORT, CMD_OBJ_MARKUP, &h, &@$, markup); | |
| 1905 | } | ||
| 1906 | ; | ||
| 1907 | |||
| 1908 | monitor_cmd : monitor_event monitor_object monitor_format | ||
| 1909 | { | ||
| 1910 | ✗ | struct handle h = { .family = NFPROTO_UNSPEC }; | |
| 1911 | ✗ | struct monitor *m = monitor_alloc($3, $2, $1); | |
| 1912 | ✗ | m->location = @1; | |
| 1913 | ✗ | $$ = cmd_alloc(CMD_MONITOR, CMD_OBJ_MONITOR, &h, &@$, m); | |
| 1914 | } | ||
| 1915 | ; | ||
| 1916 | |||
| 1917 | ✗ | monitor_event : /* empty */ { $$ = CMD_MONITOR_EVENT_ANY; } | |
| 1918 | ✗ | | NEW { $$ = CMD_MONITOR_EVENT_NEW; } | |
| 1919 | ✗ | | DESTROY { $$ = CMD_MONITOR_EVENT_DEL; } | |
| 1920 | ; | ||
| 1921 | |||
| 1922 | ✗ | monitor_object : /* empty */ { $$ = CMD_MONITOR_OBJ_ANY; } | |
| 1923 | ✗ | | TABLES { $$ = CMD_MONITOR_OBJ_TABLES; } | |
| 1924 | ✗ | | CHAINS { $$ = CMD_MONITOR_OBJ_CHAINS; } | |
| 1925 | ✗ | | SETS { $$ = CMD_MONITOR_OBJ_SETS; } | |
| 1926 | ✗ | | RULES { $$ = CMD_MONITOR_OBJ_RULES; } | |
| 1927 | ✗ | | ELEMENTS { $$ = CMD_MONITOR_OBJ_ELEMS; } | |
| 1928 | ✗ | | RULESET { $$ = CMD_MONITOR_OBJ_RULESET; } | |
| 1929 | ✗ | | TRACE { $$ = CMD_MONITOR_OBJ_TRACE; } | |
| 1930 | ; | ||
| 1931 | |||
| 1932 | ✗ | monitor_format : /* empty */ { $$ = NFTNL_OUTPUT_DEFAULT; } | |
| 1933 | | markup_format | ||
| 1934 | ; | ||
| 1935 | |||
| 1936 | ✗ | markup_format : XML { $$ = __NFT_OUTPUT_NOTSUPP; } | |
| 1937 | ✗ | | JSON { $$ = NFTNL_OUTPUT_JSON; } | |
| 1938 | ✗ | | VM JSON { $$ = NFTNL_OUTPUT_JSON; } | |
| 1939 | ; | ||
| 1940 | |||
| 1941 | describe_cmd : primary_expr | ||
| 1942 | { | ||
| 1943 | ✗ | struct handle h = { .family = NFPROTO_UNSPEC }; | |
| 1944 | ✗ | $$ = cmd_alloc(CMD_DESCRIBE, CMD_OBJ_EXPR, &h, &@$, NULL); | |
| 1945 | ✗ | $$->expr = $1; | |
| 1946 | } | ||
| 1947 | ; | ||
| 1948 | |||
| 1949 | table_block_alloc : /* empty */ | ||
| 1950 | { | ||
| 1951 | 1444 | $$ = table_alloc(); | |
| 1952 |
1/2✗ Branch 0 (588→589) not taken.
✓ Branch 1 (588→592) taken 1444 times.
|
1444 | if (open_scope(state, &$$->scope) < 0) { |
| 1953 | ✗ | erec_queue(error(&@$, "too many levels of nesting"), | |
| 1954 | state->msgs); | ||
| 1955 | ✗ | state->nerrs++; | |
| 1956 | } | ||
| 1957 | } | ||
| 1958 | ; | ||
| 1959 | |||
| 1960 | table_options : FLAGS table_flags | ||
| 1961 | { | ||
| 1962 | 25 | $<table>0->flags |= $2; | |
| 1963 | } | ||
| 1964 | | comment_spec | ||
| 1965 | { | ||
| 1966 |
1/2✗ Branch 0 (595→596) not taken.
✓ Branch 1 (595→597) taken 6 times.
|
6 | if (already_set($<table>0->comment, &@$, state)) { |
| 1967 | ✗ | free_const($1); | |
| 1968 | ✗ | YYERROR; | |
| 1969 | } | ||
| 1970 | 6 | $<table>0->comment = $1; | |
| 1971 | } | ||
| 1972 | ; | ||
| 1973 | |||
| 1974 | table_flags : table_flag | ||
| 1975 | | table_flags COMMA table_flag | ||
| 1976 | { | ||
| 1977 | 5 | $$ = $1 | $3; | |
| 1978 | } | ||
| 1979 | ; | ||
| 1980 | table_flag : STRING | ||
| 1981 | { | ||
| 1982 | 30 | $$ = parse_table_flag($1); | |
| 1983 |
1/2✗ Branch 0 (600→601) not taken.
✓ Branch 1 (600→604) taken 30 times.
|
30 | if ($$ == 0) { |
| 1984 | ✗ | erec_queue(error(&@1, "unknown table option %s", $1), | |
| 1985 | state->msgs); | ||
| 1986 | ✗ | free_const($1); | |
| 1987 | ✗ | YYERROR; | |
| 1988 | } | ||
| 1989 | |||
| 1990 | 30 | free_const($1); | |
| 1991 | } | ||
| 1992 | ; | ||
| 1993 | |||
| 1994 | 1444 | table_block : /* empty */ { $$ = $<table>-1; } | |
| 1995 | | table_block common_block | ||
| 1996 | | table_block stmt_separator | ||
| 1997 | | table_block table_options stmt_separator | ||
| 1998 | | table_block CHAIN chain_identifier | ||
| 1999 | chain_block_alloc '{' chain_block '}' | ||
| 2000 | stmt_separator | ||
| 2001 | { | ||
| 2002 | 2522 | $4->location = @3; | |
| 2003 | 2522 | handle_merge(&$4->handle, &$3); | |
| 2004 | 2522 | handle_free(&$3); | |
| 2005 | 2522 | close_scope(state); | |
| 2006 | 2522 | list_add_tail(&$4->list, &$1->chains); | |
| 2007 | 2522 | $$ = $1; | |
| 2008 | } | ||
| 2009 | | table_block SET set_identifier | ||
| 2010 | set_block_alloc '{' set_block '}' | ||
| 2011 | stmt_separator | ||
| 2012 | { | ||
| 2013 | 554 | $4->location = @3; | |
| 2014 | 554 | handle_merge(&$4->handle, &$3); | |
| 2015 | 554 | handle_free(&$3); | |
| 2016 | 554 | list_add_tail(&$4->list, &$1->sets); | |
| 2017 | 554 | $$ = $1; | |
| 2018 | } | ||
| 2019 | | table_block MAP set_identifier | ||
| 2020 | map_block_alloc '{' map_block '}' | ||
| 2021 | stmt_separator | ||
| 2022 | { | ||
| 2023 | 321 | $4->location = @3; | |
| 2024 | 321 | handle_merge(&$4->handle, &$3); | |
| 2025 | 321 | handle_free(&$3); | |
| 2026 | 321 | list_add_tail(&$4->list, &$1->sets); | |
| 2027 | 321 | $$ = $1; | |
| 2028 | } | ||
| 2029 | |||
| 2030 | | table_block FLOWTABLE flowtable_identifier | ||
| 2031 | flowtable_block_alloc '{' flowtable_block '}' | ||
| 2032 | stmt_separator | ||
| 2033 | { | ||
| 2034 | 37 | $4->location = @3; | |
| 2035 | 37 | handle_merge(&$4->handle, &$3); | |
| 2036 | 37 | handle_free(&$3); | |
| 2037 | 37 | list_add_tail(&$4->list, &$1->flowtables); | |
| 2038 | 37 | $$ = $1; | |
| 2039 | } | ||
| 2040 | | table_block COUNTER obj_identifier | ||
| 2041 | obj_block_alloc '{' counter_block '}' | ||
| 2042 | stmt_separator close_scope_counter | ||
| 2043 | { | ||
| 2044 | 181 | $4->location = @3; | |
| 2045 | 181 | $4->type = NFT_OBJECT_COUNTER; | |
| 2046 | 181 | handle_merge(&$4->handle, &$3); | |
| 2047 | 181 | handle_free(&$3); | |
| 2048 | 181 | list_add_tail(&$4->list, &$1->objs); | |
| 2049 | 181 | $$ = $1; | |
| 2050 | } | ||
| 2051 | | table_block QUOTA obj_identifier | ||
| 2052 | obj_block_alloc '{' quota_block '}' | ||
| 2053 | stmt_separator close_scope_quota | ||
| 2054 | { | ||
| 2055 | 25 | $4->location = @3; | |
| 2056 | 25 | $4->type = NFT_OBJECT_QUOTA; | |
| 2057 | 25 | handle_merge(&$4->handle, &$3); | |
| 2058 | 25 | handle_free(&$3); | |
| 2059 | 25 | list_add_tail(&$4->list, &$1->objs); | |
| 2060 | 25 | $$ = $1; | |
| 2061 | } | ||
| 2062 | | table_block CT HELPER obj_identifier obj_block_alloc '{' ct_helper_block '}' stmt_separator close_scope_ct | ||
| 2063 | { | ||
| 2064 | 18 | $5->location = @4; | |
| 2065 | 18 | $5->type = NFT_OBJECT_CT_HELPER; | |
| 2066 | 18 | handle_merge(&$5->handle, &$4); | |
| 2067 | 18 | handle_free(&$4); | |
| 2068 | 18 | list_add_tail(&$5->list, &$1->objs); | |
| 2069 | 18 | $$ = $1; | |
| 2070 | } | ||
| 2071 | | table_block CT TIMEOUT obj_identifier obj_block_alloc '{' ct_timeout_block '}' stmt_separator close_scope_ct | ||
| 2072 | { | ||
| 2073 | 7 | $5->location = @4; | |
| 2074 | 7 | $5->type = NFT_OBJECT_CT_TIMEOUT; | |
| 2075 | 7 | handle_merge(&$5->handle, &$4); | |
| 2076 | 7 | handle_free(&$4); | |
| 2077 | 7 | list_add_tail(&$5->list, &$1->objs); | |
| 2078 | 7 | $$ = $1; | |
| 2079 | } | ||
| 2080 | | table_block CT EXPECTATION obj_identifier obj_block_alloc '{' ct_expect_block '}' stmt_separator close_scope_ct | ||
| 2081 | { | ||
| 2082 | 11 | $5->location = @4; | |
| 2083 | 11 | $5->type = NFT_OBJECT_CT_EXPECT; | |
| 2084 | 11 | handle_merge(&$5->handle, &$4); | |
| 2085 | 11 | handle_free(&$4); | |
| 2086 | 11 | list_add_tail(&$5->list, &$1->objs); | |
| 2087 | 11 | $$ = $1; | |
| 2088 | } | ||
| 2089 | | table_block LIMIT obj_identifier | ||
| 2090 | obj_block_alloc '{' limit_block '}' | ||
| 2091 | stmt_separator close_scope_limit | ||
| 2092 | { | ||
| 2093 | 12 | $4->location = @3; | |
| 2094 | 12 | $4->type = NFT_OBJECT_LIMIT; | |
| 2095 | 12 | handle_merge(&$4->handle, &$3); | |
| 2096 | 12 | handle_free(&$3); | |
| 2097 | 12 | list_add_tail(&$4->list, &$1->objs); | |
| 2098 | 12 | $$ = $1; | |
| 2099 | } | ||
| 2100 | | table_block SECMARK obj_identifier | ||
| 2101 | obj_block_alloc '{' secmark_block '}' | ||
| 2102 | stmt_separator close_scope_secmark | ||
| 2103 | { | ||
| 2104 | 2 | $4->location = @3; | |
| 2105 | 2 | $4->type = NFT_OBJECT_SECMARK; | |
| 2106 | 2 | handle_merge(&$4->handle, &$3); | |
| 2107 | 2 | handle_free(&$3); | |
| 2108 | 2 | list_add_tail(&$4->list, &$1->objs); | |
| 2109 | 2 | $$ = $1; | |
| 2110 | } | ||
| 2111 | | table_block SYNPROXY obj_identifier | ||
| 2112 | obj_block_alloc '{' synproxy_block '}' | ||
| 2113 | stmt_separator close_scope_synproxy | ||
| 2114 | { | ||
| 2115 | 9 | $4->location = @3; | |
| 2116 | 9 | $4->type = NFT_OBJECT_SYNPROXY; | |
| 2117 | 9 | handle_merge(&$4->handle, &$3); | |
| 2118 | 9 | handle_free(&$3); | |
| 2119 | 9 | list_add_tail(&$4->list, &$1->objs); | |
| 2120 | 9 | $$ = $1; | |
| 2121 | } | ||
| 2122 | | table_block TUNNEL obj_identifier | ||
| 2123 | obj_block_alloc '{' tunnel_block '}' | ||
| 2124 | stmt_separator close_scope_tunnel | ||
| 2125 | { | ||
| 2126 | 13 | $4->location = @3; | |
| 2127 | 13 | $4->type = NFT_OBJECT_TUNNEL; | |
| 2128 | 13 | handle_merge(&$4->handle, &$3); | |
| 2129 | 13 | handle_free(&$3); | |
| 2130 | 13 | list_add_tail(&$4->list, &$1->objs); | |
| 2131 | 13 | $$ = $1; | |
| 2132 | } | ||
| 2133 | ; | ||
| 2134 | |||
| 2135 | chain_block_alloc : /* empty */ | ||
| 2136 | { | ||
| 2137 | 4423 | $$ = chain_alloc(); | |
| 2138 |
2/2✓ Branch 0 (661→662) taken 1 times.
✓ Branch 1 (661→665) taken 4410 times.
|
4411 | if (open_scope(state, &$$->scope) < 0) { |
| 2139 | 1 | erec_queue(error(&@$, "too many levels of nesting"), | |
| 2140 | state->msgs); | ||
| 2141 | 1 | state->nerrs++; | |
| 2142 | } | ||
| 2143 | } | ||
| 2144 | ; | ||
| 2145 | |||
| 2146 | 4349 | chain_block : /* empty */ { $$ = $<chain>-1; } | |
| 2147 | | chain_block common_block | ||
| 2148 | | chain_block stmt_separator | ||
| 2149 | | chain_block hook_spec stmt_separator | ||
| 2150 | | chain_block policy_spec stmt_separator | ||
| 2151 | | chain_block flags_spec stmt_separator | ||
| 2152 | | chain_block rule stmt_separator | ||
| 2153 | { | ||
| 2154 | 43166 | list_add_tail(&$2->list, &$1->rules); | |
| 2155 | 43166 | $$ = $1; | |
| 2156 | } | ||
| 2157 | | chain_block DEVICES '=' flowtable_expr stmt_separator | ||
| 2158 | { | ||
| 2159 |
1/2✗ Branch 0 (669→670) not taken.
✓ Branch 1 (669→677) taken 21 times.
|
21 | if ($$->dev_expr) { |
| 2160 | ✗ | list_splice_init(&expr_list($4)->expressions, &expr_list($$->dev_expr)->expressions); | |
| 2161 | ✗ | expr_free($4); | |
| 2162 | ✗ | break; | |
| 2163 | } | ||
| 2164 | 21 | $$->dev_expr = $4; | |
| 2165 | } | ||
| 2166 | | chain_block comment_spec stmt_separator | ||
| 2167 | { | ||
| 2168 |
1/2✗ Branch 0 (679→680) not taken.
✓ Branch 1 (679→681) taken 3 times.
|
3 | if (already_set($1->comment, &@2, state)) { |
| 2169 | ✗ | free_const($2); | |
| 2170 | ✗ | YYERROR; | |
| 2171 | } | ||
| 2172 | 3 | $1->comment = $2; | |
| 2173 | } | ||
| 2174 | ; | ||
| 2175 | |||
| 2176 | 74 | subchain_block : /* empty */ { $$ = $<chain>-1; } | |
| 2177 | | subchain_block stmt_separator | ||
| 2178 | | subchain_block rule stmt_separator | ||
| 2179 | { | ||
| 2180 | 130 | list_add_tail(&$2->list, &$1->rules); | |
| 2181 | 114 | $$ = $1; | |
| 2182 | } | ||
| 2183 | ; | ||
| 2184 | |||
| 2185 | typeof_verdict_expr : selector_expr | ||
| 2186 | { | ||
| 2187 | 107 | struct expr *e = $1; | |
| 2188 | |||
| 2189 |
1/2✗ Branch 0 (686→687) not taken.
✓ Branch 1 (686→692) taken 91 times.
|
107 | if (expr_ops(e)->build_udata == NULL) { |
| 2190 | ✗ | erec_queue(error(&@1, "map data type '%s' lacks typeof serialization", expr_ops(e)->name), | |
| 2191 | state->msgs); | ||
| 2192 | ✗ | expr_free(e); | |
| 2193 | ✗ | YYERROR; | |
| 2194 | } | ||
| 2195 | 91 | $$ = e; | |
| 2196 | } | ||
| 2197 | | typeof_expr DOT selector_expr | ||
| 2198 | { | ||
| 2199 | 10 | struct location rhs[] = { | |
| 2200 | [1] = @2, | ||
| 2201 | [2] = @3, | ||
| 2202 | }; | ||
| 2203 | |||
| 2204 | 10 | $$ = handle_concat_expr(&@$, $$, $1, $3, rhs); | |
| 2205 | } | ||
| 2206 | ; | ||
| 2207 | |||
| 2208 | typeof_data_expr : INTERVAL typeof_expr | ||
| 2209 | { | ||
| 2210 | 4 | $2->flags |= EXPR_F_INTERVAL; | |
| 2211 | 4 | $$ = $2; | |
| 2212 | } | ||
| 2213 | | typeof_verdict_expr | ||
| 2214 | { | ||
| 2215 | 117 | $$ = $1; | |
| 2216 | } | ||
| 2217 | | QUEUE | ||
| 2218 | { | ||
| 2219 | 2 | $$ = constant_expr_alloc(&@$, &queue_type, BYTEORDER_HOST_ENDIAN, 16, NULL); | |
| 2220 | } | ||
| 2221 | | STRING | ||
| 2222 | { | ||
| 2223 | struct expr *verdict; | ||
| 2224 | |||
| 2225 |
1/2✗ Branch 0 (699→700) not taken.
✓ Branch 1 (699→703) taken 91 times.
|
91 | if (strcmp("verdict", $1) != 0) { |
| 2226 | ✗ | erec_queue(error(&@1, "map data type '%s' lacks typeof serialization", $1), | |
| 2227 | state->msgs); | ||
| 2228 | ✗ | free_const($1); | |
| 2229 | ✗ | YYERROR; | |
| 2230 | } | ||
| 2231 | 91 | verdict = verdict_expr_alloc(&@1, NF_ACCEPT, NULL); | |
| 2232 | 75 | verdict->flags &= ~EXPR_F_CONSTANT; | |
| 2233 | 75 | $$ = verdict; | |
| 2234 | 75 | free_const($1); | |
| 2235 | } | ||
| 2236 | ; | ||
| 2237 | |||
| 2238 | primary_typeof_expr : selector_expr | ||
| 2239 | { | ||
| 2240 |
1/2✗ Branch 0 (706→707) not taken.
✓ Branch 1 (706→712) taken 2027 times.
|
2111 | if (expr_ops($1)->build_udata == NULL) { |
| 2241 | ✗ | erec_queue(error(&@1, "primary expression type '%s' lacks typeof serialization", expr_ops($1)->name), | |
| 2242 | state->msgs); | ||
| 2243 | ✗ | expr_free($1); | |
| 2244 | ✗ | YYERROR; | |
| 2245 | } | ||
| 2246 | |||
| 2247 | 2027 | $$ = $1; | |
| 2248 | } | ||
| 2249 | ; | ||
| 2250 | |||
| 2251 | typeof_expr : primary_typeof_expr | ||
| 2252 | { | ||
| 2253 | 1436 | $$ = $1; | |
| 2254 | } | ||
| 2255 | | typeof_expr DOT primary_typeof_expr | ||
| 2256 | { | ||
| 2257 | 675 | struct location rhs[] = { | |
| 2258 | [1] = @2, | ||
| 2259 | [2] = @3, | ||
| 2260 | }; | ||
| 2261 | |||
| 2262 | 675 | $$ = handle_concat_expr(&@$, $$, $1, $3, rhs); | |
| 2263 | } | ||
| 2264 | ; | ||
| 2265 | |||
| 2266 | |||
| 2267 | set_block_alloc : /* empty */ | ||
| 2268 | { | ||
| 2269 | 1851 | $$ = set_alloc(&internal_location); | |
| 2270 | } | ||
| 2271 | ; | ||
| 2272 | |||
| 2273 | 1194 | typeof_key_expr : TYPEOF typeof_expr { $$ = $2; } | |
| 2274 | 652 | | TYPE data_type_expr close_scope_type { $$ = $2; } | |
| 2275 | ; | ||
| 2276 | |||
| 2277 | 1850 | set_block : /* empty */ { $$ = $<set>-1; } | |
| 2278 | | set_block common_block | ||
| 2279 | | set_block stmt_separator | ||
| 2280 | | set_block typeof_key_expr stmt_separator | ||
| 2281 | { | ||
| 2282 |
1/2✗ Branch 0 (722→723) not taken.
✓ Branch 1 (722→725) taken 1818 times.
|
1846 | if (already_set($1->key, &@2, state)) { |
| 2283 | ✗ | expr_free($2); | |
| 2284 | ✗ | YYERROR; | |
| 2285 | } | ||
| 2286 | |||
| 2287 | 1818 | $1->key = $2; | |
| 2288 | 1818 | $$ = $1; | |
| 2289 | } | ||
| 2290 | | set_block FLAGS set_flag_list stmt_separator | ||
| 2291 | { | ||
| 2292 | 1462 | $1->flags = $3; | |
| 2293 | 1462 | $$ = $1; | |
| 2294 | } | ||
| 2295 | | set_block TIMEOUT time_spec stmt_separator | ||
| 2296 | { | ||
| 2297 | 73 | $1->timeout = $3; | |
| 2298 | 73 | $$ = $1; | |
| 2299 | } | ||
| 2300 | | set_block GC_INTERVAL time_spec stmt_separator | ||
| 2301 | { | ||
| 2302 | 5 | $1->gc_int = $3; | |
| 2303 | 5 | $$ = $1; | |
| 2304 | } | ||
| 2305 | | set_block stateful_stmt_list stmt_separator | ||
| 2306 | { | ||
| 2307 | 45 | list_splice_tail($2, &$1->stmt_list); | |
| 2308 | 45 | $$ = $1; | |
| 2309 | 45 | free($2); | |
| 2310 | } | ||
| 2311 | | set_block ELEMENTS '=' set_block_expr | ||
| 2312 | { | ||
| 2313 |
1/2✗ Branch 0 (732→733) not taken.
✓ Branch 1 (732→735) taken 447 times.
|
459 | if (already_set($1->init, &@2, state)) { |
| 2314 | ✗ | expr_free($4); | |
| 2315 | ✗ | YYERROR; | |
| 2316 | } | ||
| 2317 | 447 | $1->init = $4; | |
| 2318 | 447 | $$ = $1; | |
| 2319 | } | ||
| 2320 | | set_block AUTOMERGE | ||
| 2321 | { | ||
| 2322 | 17 | $1->automerge = true; | |
| 2323 | 17 | $$ = $1; | |
| 2324 | } | ||
| 2325 | | set_block set_mechanism stmt_separator | ||
| 2326 | | set_block comment_spec stmt_separator | ||
| 2327 | { | ||
| 2328 |
1/2✗ Branch 0 (738→739) not taken.
✓ Branch 1 (738→740) taken 2 times.
|
2 | if (already_set($1->comment, &@2, state)) { |
| 2329 | ✗ | free_const($2); | |
| 2330 | ✗ | YYERROR; | |
| 2331 | } | ||
| 2332 | 2 | $1->comment = $2; | |
| 2333 | 2 | $$ = $1; | |
| 2334 | } | ||
| 2335 | ; | ||
| 2336 | |||
| 2337 | set_block_expr : set_expr | ||
| 2338 | | variable_expr | ||
| 2339 | ; | ||
| 2340 | |||
| 2341 | set_flag_list : set_flag_list COMMA set_flag | ||
| 2342 | { | ||
| 2343 | 1280 | $$ = $1 | $3; | |
| 2344 | } | ||
| 2345 | | set_flag | ||
| 2346 | ; | ||
| 2347 | |||
| 2348 | 60 | set_flag : CONSTANT { $$ = NFT_SET_CONSTANT; } | |
| 2349 | 575 | | INTERVAL { $$ = NFT_SET_INTERVAL; } | |
| 2350 | 1274 | | TIMEOUT { $$ = NFT_SET_TIMEOUT; } | |
| 2351 | 1090 | | DYNAMIC { $$ = NFT_SET_EVAL; } | |
| 2352 | ; | ||
| 2353 | |||
| 2354 | map_block_alloc : /* empty */ | ||
| 2355 | { | ||
| 2356 | 515 | $$ = set_alloc(&internal_location); | |
| 2357 | } | ||
| 2358 | ; | ||
| 2359 | |||
| 2360 | 2 | ct_obj_type_map : TIMEOUT { $$ = NFT_OBJECT_CT_TIMEOUT; } | |
| 2361 | 5 | | EXPECTATION { $$ = NFT_OBJECT_CT_EXPECT; } | |
| 2362 | ; | ||
| 2363 | |||
| 2364 | 16 | map_block_obj_type : COUNTER close_scope_counter { $$ = NFT_OBJECT_COUNTER; } | |
| 2365 | 4 | | QUOTA close_scope_quota { $$ = NFT_OBJECT_QUOTA; } | |
| 2366 | 4 | | LIMIT close_scope_limit { $$ = NFT_OBJECT_LIMIT; } | |
| 2367 | ✗ | | SECMARK close_scope_secmark { $$ = NFT_OBJECT_SECMARK; } | |
| 2368 | 2 | | SYNPROXY close_scope_synproxy { $$ = NFT_OBJECT_SYNPROXY; } | |
| 2369 | ; | ||
| 2370 | |||
| 2371 | map_block_obj_typeof : map_block_obj_type | ||
| 2372 | 7 | | CT ct_obj_type_map close_scope_ct { $$ = $2; } | |
| 2373 | ; | ||
| 2374 | |||
| 2375 | 8 | map_block_data_interval : INTERVAL { $$ = EXPR_F_INTERVAL; } | |
| 2376 | 256 | | { $$ = 0; } | |
| 2377 | ; | ||
| 2378 | |||
| 2379 | 515 | map_block : /* empty */ { $$ = $<set>-1; } | |
| 2380 | | map_block common_block | ||
| 2381 | | map_block stmt_separator | ||
| 2382 | | map_block TIMEOUT time_spec stmt_separator | ||
| 2383 | { | ||
| 2384 | 82 | $1->timeout = $3; | |
| 2385 | 82 | $$ = $1; | |
| 2386 | } | ||
| 2387 | | map_block GC_INTERVAL time_spec stmt_separator | ||
| 2388 | { | ||
| 2389 | 4 | $1->gc_int = $3; | |
| 2390 | 4 | $$ = $1; | |
| 2391 | } | ||
| 2392 | | map_block TYPE | ||
| 2393 | data_type_expr COLON map_block_data_interval data_type_expr | ||
| 2394 | stmt_separator close_scope_type | ||
| 2395 | { | ||
| 2396 |
1/2✗ Branch 0 (762→763) not taken.
✓ Branch 1 (762→766) taken 263 times.
|
263 | if (already_set($1->key, &@2, state)) { |
| 2397 | ✗ | expr_free($3); | |
| 2398 | ✗ | expr_free($6); | |
| 2399 | ✗ | YYERROR; | |
| 2400 | } | ||
| 2401 | |||
| 2402 | 263 | $1->key = $3; | |
| 2403 | 263 | $1->data = $6; | |
| 2404 | 263 | $1->data->flags |= $5; | |
| 2405 | |||
| 2406 | 263 | $1->flags |= NFT_SET_MAP; | |
| 2407 | 263 | $$ = $1; | |
| 2408 | } | ||
| 2409 | | map_block TYPEOF | ||
| 2410 | typeof_expr COLON typeof_data_expr | ||
| 2411 | stmt_separator | ||
| 2412 | { | ||
| 2413 |
1/2✗ Branch 0 (768→769) not taken.
✓ Branch 1 (768→772) taken 182 times.
|
214 | if (already_set($1->key, &@2, state)) { |
| 2414 | ✗ | expr_free($3); | |
| 2415 | ✗ | expr_free($5); | |
| 2416 | ✗ | YYERROR; | |
| 2417 | } | ||
| 2418 | |||
| 2419 | 182 | $1->key = $3; | |
| 2420 | |||
| 2421 |
4/4✓ Branch 0 (772→773) taken 8 times.
✓ Branch 1 (772→775) taken 174 times.
✓ Branch 2 (773→774) taken 2 times.
✓ Branch 3 (773→775) taken 6 times.
|
182 | if ($5->etype == EXPR_CT && $5->ct.key == NFT_CT_HELPER) { |
| 2422 | 2 | $1->objtype = NFT_OBJECT_CT_HELPER; | |
| 2423 | 2 | $1->flags |= NFT_SET_OBJECT; | |
| 2424 | 2 | expr_free($5); | |
| 2425 | } else { | ||
| 2426 | 180 | $1->data = $5; | |
| 2427 | 180 | $1->flags |= NFT_SET_MAP; | |
| 2428 | } | ||
| 2429 | |||
| 2430 | 182 | $$ = $1; | |
| 2431 | } | ||
| 2432 | | map_block TYPE | ||
| 2433 | data_type_expr COLON map_block_obj_type | ||
| 2434 | stmt_separator close_scope_type | ||
| 2435 | { | ||
| 2436 |
1/2✗ Branch 0 (778→779) not taken.
✓ Branch 1 (778→781) taken 22 times.
|
22 | if (already_set($1->key, &@2, state)) { |
| 2437 | ✗ | expr_free($3); | |
| 2438 | ✗ | YYERROR; | |
| 2439 | } | ||
| 2440 | |||
| 2441 | 22 | $1->key = $3; | |
| 2442 | 22 | $1->objtype = $5; | |
| 2443 | 22 | $1->flags |= NFT_SET_OBJECT; | |
| 2444 | 22 | $$ = $1; | |
| 2445 | } | ||
| 2446 | | map_block TYPEOF | ||
| 2447 | typeof_expr COLON map_block_obj_typeof | ||
| 2448 | stmt_separator | ||
| 2449 | { | ||
| 2450 | 11 | $1->key = $3; | |
| 2451 | 11 | $1->objtype = $5; | |
| 2452 | 11 | $1->flags |= NFT_SET_OBJECT; | |
| 2453 | 11 | $$ = $1; | |
| 2454 | } | ||
| 2455 | | map_block FLAGS set_flag_list stmt_separator | ||
| 2456 | { | ||
| 2457 | 257 | $1->flags |= $3; | |
| 2458 | 257 | $$ = $1; | |
| 2459 | } | ||
| 2460 | | map_block stateful_stmt_list stmt_separator | ||
| 2461 | { | ||
| 2462 | 20 | list_splice_tail($2, &$1->stmt_list); | |
| 2463 | 20 | $$ = $1; | |
| 2464 | 20 | free($2); | |
| 2465 | } | ||
| 2466 | | map_block ELEMENTS '=' set_block_expr | ||
| 2467 | { | ||
| 2468 | 254 | $1->init = $4; | |
| 2469 | 254 | $$ = $1; | |
| 2470 | } | ||
| 2471 | | map_block comment_spec stmt_separator | ||
| 2472 | { | ||
| 2473 |
1/2✗ Branch 0 (788→789) not taken.
✓ Branch 1 (788→790) taken 2 times.
|
2 | if (already_set($1->comment, &@2, state)) { |
| 2474 | ✗ | free_const($2); | |
| 2475 | ✗ | YYERROR; | |
| 2476 | } | ||
| 2477 | 2 | $1->comment = $2; | |
| 2478 | 2 | $$ = $1; | |
| 2479 | } | ||
| 2480 | | map_block set_mechanism stmt_separator | ||
| 2481 | ; | ||
| 2482 | |||
| 2483 | set_mechanism : POLICY set_policy_spec close_scope_policy | ||
| 2484 | { | ||
| 2485 | ✗ | $<set>0->policy = $2; | |
| 2486 | } | ||
| 2487 | | SIZE NUM | ||
| 2488 | { | ||
| 2489 | 1153 | $<set>0->desc.size = $2; | |
| 2490 | } | ||
| 2491 | ; | ||
| 2492 | |||
| 2493 | ✗ | set_policy_spec : PERFORMANCE { $$ = NFT_SET_POL_PERFORMANCE; } | |
| 2494 | ✗ | | MEMORY { $$ = NFT_SET_POL_MEMORY; } | |
| 2495 | ; | ||
| 2496 | |||
| 2497 | flowtable_block_alloc : /* empty */ | ||
| 2498 | { | ||
| 2499 | 86 | $$ = flowtable_alloc(&internal_location); | |
| 2500 | } | ||
| 2501 | ; | ||
| 2502 | |||
| 2503 | 86 | flowtable_block : /* empty */ { $$ = $<flowtable>-1; } | |
| 2504 | | flowtable_block common_block | ||
| 2505 | | flowtable_block stmt_separator | ||
| 2506 | | flowtable_block HOOK STRING prio_spec stmt_separator | ||
| 2507 | { | ||
| 2508 | 73 | $$->hook.loc = @3; | |
| 2509 | 73 | $$->hook.name = chain_hookname_lookup($3); | |
| 2510 |
2/2✓ Branch 0 (799→800) taken 1 times.
✓ Branch 1 (799→804) taken 72 times.
|
73 | if ($$->hook.name == NULL) { |
| 2511 | 1 | erec_queue(error(&@3, "unknown chain hook"), | |
| 2512 | state->msgs); | ||
| 2513 | 1 | free_const($3); | |
| 2514 | 1 | expr_free($4.expr); | |
| 2515 | 1 | YYERROR; | |
| 2516 | } | ||
| 2517 | 72 | free_const($3); | |
| 2518 | |||
| 2519 | 72 | $$->priority = $4; | |
| 2520 | } | ||
| 2521 | | flowtable_block DEVICES '=' flowtable_expr stmt_separator | ||
| 2522 | { | ||
| 2523 | 79 | $$->dev_expr = $4; | |
| 2524 | } | ||
| 2525 | | flowtable_block COUNTER close_scope_counter | ||
| 2526 | { | ||
| 2527 | 12 | $$->flags |= NFT_FLOWTABLE_COUNTER; | |
| 2528 | } | ||
| 2529 | | flowtable_block FLAGS OFFLOAD stmt_separator | ||
| 2530 | { | ||
| 2531 | ✗ | $$->flags |= FLOWTABLE_F_HW_OFFLOAD; | |
| 2532 | } | ||
| 2533 | ; | ||
| 2534 | |||
| 2535 | flowtable_expr : '{' flowtable_list_expr '}' | ||
| 2536 | { | ||
| 2537 | 1114 | $2->location = @$; | |
| 2538 | 1114 | $$ = $2; | |
| 2539 | } | ||
| 2540 | | variable_expr | ||
| 2541 | { | ||
| 2542 | 4 | $1->location = @$; | |
| 2543 | 4 | $$ = $1; | |
| 2544 | } | ||
| 2545 | ; | ||
| 2546 | |||
| 2547 | flowtable_list_expr : flowtable_expr_member | ||
| 2548 | { | ||
| 2549 | 1115 | $$ = list_expr_alloc(&@$); | |
| 2550 | 1115 | list_expr_add($$, $1); | |
| 2551 | } | ||
| 2552 | | flowtable_list_expr COMMA flowtable_expr_member | ||
| 2553 | { | ||
| 2554 | 37 | list_expr_add($1, $3); | |
| 2555 | 37 | $$ = $1; | |
| 2556 | } | ||
| 2557 | | flowtable_list_expr COMMA opt_newline | ||
| 2558 | ; | ||
| 2559 | |||
| 2560 | flowtable_expr_member : string | ||
| 2561 | { | ||
| 2562 | 1150 | struct expr *expr = ifname_expr_alloc(&@$, state->msgs, $1); | |
| 2563 | |||
| 2564 |
2/2✓ Branch 0 (816→817) taken 2 times.
✓ Branch 1 (816→818) taken 1148 times.
|
1150 | if (!expr) |
| 2565 | 2 | YYERROR; | |
| 2566 | |||
| 2567 | 1148 | $$ = expr; | |
| 2568 | } | ||
| 2569 | | variable_expr | ||
| 2570 | { | ||
| 2571 | 4 | datatype_set($1->sym->expr, &ifname_type); | |
| 2572 | 4 | $$ = $1; | |
| 2573 | } | ||
| 2574 | ; | ||
| 2575 | |||
| 2576 | data_type_atom_expr : type_identifier | ||
| 2577 | { | ||
| 2578 | 1797 | const struct datatype *dtype = datatype_lookup_byname($1); | |
| 2579 |
2/2✓ Branch 0 (822→823) taken 1 times.
✓ Branch 1 (822→826) taken 1796 times.
|
1797 | if (dtype == NULL) { |
| 2580 | 1 | erec_queue(error(&@1, "unknown datatype %s", $1), | |
| 2581 | state->msgs); | ||
| 2582 | 1 | free_const($1); | |
| 2583 | 1 | YYERROR; | |
| 2584 | } | ||
| 2585 | 3592 | $$ = constant_expr_alloc(&@1, dtype, dtype->byteorder, | |
| 2586 | 1796 | dtype->size, NULL); | |
| 2587 | 1796 | free_const($1); | |
| 2588 | } | ||
| 2589 | | TIME | ||
| 2590 | { | ||
| 2591 | 6 | $$ = constant_expr_alloc(&@1, &time_type, time_type.byteorder, | |
| 2592 | 6 | time_type.size, NULL); | |
| 2593 | } | ||
| 2594 | ; | ||
| 2595 | |||
| 2596 | data_type_expr : data_type_atom_expr | ||
| 2597 | | data_type_expr DOT data_type_atom_expr | ||
| 2598 | { | ||
| 2599 | 599 | struct location rhs[] = { | |
| 2600 | [1] = @2, | ||
| 2601 | [2] = @3, | ||
| 2602 | }; | ||
| 2603 | |||
| 2604 | 599 | $$ = handle_concat_expr(&@$, $$, $1, $3, rhs); | |
| 2605 | } | ||
| 2606 | ; | ||
| 2607 | |||
| 2608 | obj_block_alloc : /* empty */ | ||
| 2609 | { | ||
| 2610 | 285 | $$ = obj_alloc(&internal_location); | |
| 2611 | } | ||
| 2612 | ; | ||
| 2613 | |||
| 2614 | 182 | counter_block : /* empty */ { $$ = $<obj>-1; } | |
| 2615 | | counter_block common_block | ||
| 2616 | | counter_block stmt_separator | ||
| 2617 | | counter_block counter_config | ||
| 2618 | { | ||
| 2619 | 30 | $$ = $1; | |
| 2620 | } | ||
| 2621 | | counter_block comment_spec | ||
| 2622 | { | ||
| 2623 |
2/2✓ Branch 0 (837→838) taken 1 times.
✓ Branch 1 (837→839) taken 4 times.
|
5 | if (already_set($<obj>1->comment, &@2, state)) { |
| 2624 | 1 | free_const($2); | |
| 2625 | 1 | YYERROR; | |
| 2626 | } | ||
| 2627 | 4 | $<obj>1->comment = $2; | |
| 2628 | } | ||
| 2629 | ; | ||
| 2630 | |||
| 2631 | 26 | quota_block : /* empty */ { $$ = $<obj>-1; } | |
| 2632 | | quota_block common_block | ||
| 2633 | | quota_block stmt_separator | ||
| 2634 | | quota_block quota_config | ||
| 2635 | { | ||
| 2636 | 24 | $$ = $1; | |
| 2637 | } | ||
| 2638 | | quota_block comment_spec | ||
| 2639 | { | ||
| 2640 |
2/2✓ Branch 0 (843→844) taken 1 times.
✓ Branch 1 (843→845) taken 6 times.
|
7 | if (already_set($<obj>1->comment, &@2, state)) { |
| 2641 | 1 | free_const($2); | |
| 2642 | 1 | YYERROR; | |
| 2643 | } | ||
| 2644 | 6 | $<obj>1->comment = $2; | |
| 2645 | } | ||
| 2646 | ; | ||
| 2647 | |||
| 2648 | 28 | ct_helper_block : /* empty */ { $$ = $<obj>-1; } | |
| 2649 | | ct_helper_block common_block | ||
| 2650 | | ct_helper_block stmt_separator | ||
| 2651 | | ct_helper_block ct_helper_config | ||
| 2652 | { | ||
| 2653 | 45 | $$ = $1; | |
| 2654 | } | ||
| 2655 | | ct_helper_block comment_spec | ||
| 2656 | { | ||
| 2657 |
2/2✓ Branch 0 (849→850) taken 1 times.
✓ Branch 1 (849→851) taken 3 times.
|
4 | if (already_set($<obj>1->comment, &@2, state)) { |
| 2658 | 1 | free_const($2); | |
| 2659 | 1 | YYERROR; | |
| 2660 | } | ||
| 2661 | 3 | $<obj>1->comment = $2; | |
| 2662 | } | ||
| 2663 | ; | ||
| 2664 | |||
| 2665 | ct_timeout_block : /*empty */ | ||
| 2666 | { | ||
| 2667 | 18 | $$ = $<obj>-1; | |
| 2668 | 18 | init_list_head(&$$->ct_timeout.timeout_list); | |
| 2669 | 18 | $$->type = NFT_OBJECT_CT_TIMEOUT; | |
| 2670 | } | ||
| 2671 | | ct_timeout_block common_block | ||
| 2672 | | ct_timeout_block stmt_separator | ||
| 2673 | | ct_timeout_block ct_timeout_config | ||
| 2674 | { | ||
| 2675 | 47 | $$ = $1; | |
| 2676 | } | ||
| 2677 | | ct_timeout_block comment_spec | ||
| 2678 | { | ||
| 2679 | ✗ | if (already_set($<obj>1->comment, &@2, state)) { | |
| 2680 | ✗ | free_const($2); | |
| 2681 | ✗ | YYERROR; | |
| 2682 | } | ||
| 2683 | ✗ | $<obj>1->comment = $2; | |
| 2684 | } | ||
| 2685 | ; | ||
| 2686 | |||
| 2687 | 18 | ct_expect_block : /*empty */ { $$ = $<obj>-1; } | |
| 2688 | | ct_expect_block common_block | ||
| 2689 | | ct_expect_block stmt_separator | ||
| 2690 | | ct_expect_block ct_expect_config | ||
| 2691 | { | ||
| 2692 | 76 | $$ = $1; | |
| 2693 | } | ||
| 2694 | | ct_expect_block comment_spec | ||
| 2695 | { | ||
| 2696 |
2/2✓ Branch 0 (862→863) taken 1 times.
✓ Branch 1 (862→864) taken 3 times.
|
4 | if (already_set($<obj>1->comment, &@2, state)) { |
| 2697 | 1 | free_const($2); | |
| 2698 | 1 | YYERROR; | |
| 2699 | } | ||
| 2700 | 3 | $<obj>1->comment = $2; | |
| 2701 | } | ||
| 2702 | ; | ||
| 2703 | |||
| 2704 | 13 | limit_block : /* empty */ { $$ = $<obj>-1; } | |
| 2705 | | limit_block common_block | ||
| 2706 | | limit_block stmt_separator | ||
| 2707 | | limit_block limit_config | ||
| 2708 | { | ||
| 2709 | 13 | $$ = $1; | |
| 2710 | } | ||
| 2711 | | limit_block comment_spec | ||
| 2712 | { | ||
| 2713 |
2/2✓ Branch 0 (868→869) taken 1 times.
✓ Branch 1 (868→870) taken 3 times.
|
4 | if (already_set($<obj>1->comment, &@2, state)) { |
| 2714 | 1 | free_const($2); | |
| 2715 | 1 | YYERROR; | |
| 2716 | } | ||
| 2717 | 3 | $<obj>1->comment = $2; | |
| 2718 | } | ||
| 2719 | ; | ||
| 2720 | |||
| 2721 | 2 | secmark_block : /* empty */ { $$ = $<obj>-1; } | |
| 2722 | | secmark_block common_block | ||
| 2723 | | secmark_block stmt_separator | ||
| 2724 | | secmark_block secmark_config | ||
| 2725 | { | ||
| 2726 | 2 | $$ = $1; | |
| 2727 | } | ||
| 2728 | | secmark_block comment_spec | ||
| 2729 | { | ||
| 2730 | ✗ | if (already_set($<obj>1->comment, &@2, state)) { | |
| 2731 | ✗ | free_const($2); | |
| 2732 | ✗ | YYERROR; | |
| 2733 | } | ||
| 2734 | ✗ | $<obj>1->comment = $2; | |
| 2735 | } | ||
| 2736 | ; | ||
| 2737 | |||
| 2738 | 10 | synproxy_block : /* empty */ { $$ = $<obj>-1; } | |
| 2739 | | synproxy_block common_block | ||
| 2740 | | synproxy_block stmt_separator | ||
| 2741 | | synproxy_block synproxy_config | ||
| 2742 | { | ||
| 2743 | 10 | $$ = $1; | |
| 2744 | } | ||
| 2745 | | synproxy_block comment_spec | ||
| 2746 | { | ||
| 2747 |
2/2✓ Branch 0 (880→881) taken 1 times.
✓ Branch 1 (880→882) taken 3 times.
|
4 | if (already_set($<obj>1->comment, &@2, state)) { |
| 2748 | 1 | free_const($2); | |
| 2749 | 1 | YYERROR; | |
| 2750 | } | ||
| 2751 | 3 | $<obj>1->comment = $2; | |
| 2752 | } | ||
| 2753 | ; | ||
| 2754 | |||
| 2755 | 1549 | type_identifier : STRING { $$ = $1; } | |
| 2756 | 236 | | MARK { $$ = xstrdup("mark"); } | |
| 2757 | 8 | | DSCP { $$ = xstrdup("dscp"); } | |
| 2758 | ✗ | | ECN { $$ = xstrdup("ecn"); } | |
| 2759 | 4 | | CLASSID { $$ = xstrdup("classid"); } | |
| 2760 | ; | ||
| 2761 | |||
| 2762 | hook_spec : TYPE chain_type close_scope_type HOOK STRING dev_spec prio_spec | ||
| 2763 | { | ||
| 2764 | 2926 | $<chain>0->type.loc = @3; | |
| 2765 | 2926 | $<chain>0->type.str = $2; | |
| 2766 | |||
| 2767 | 2926 | $<chain>0->loc = @$; | |
| 2768 | 2926 | $<chain>0->hook.loc = @5; | |
| 2769 | 2926 | $<chain>0->hook.name = chain_hookname_lookup($5); | |
| 2770 |
1/2✗ Branch 0 (893→894) not taken.
✓ Branch 1 (893→899) taken 2922 times.
|
2922 | if ($<chain>0->hook.name == NULL) { |
| 2771 | ✗ | erec_queue(error(&@5, "unknown chain hook"), | |
| 2772 | state->msgs); | ||
| 2773 | ✗ | free_const($5); | |
| 2774 | ✗ | expr_free($6); | |
| 2775 | ✗ | expr_free($7.expr); | |
| 2776 | ✗ | YYERROR; | |
| 2777 | } | ||
| 2778 | 2922 | free_const($5); | |
| 2779 | |||
| 2780 | 2922 | $<chain>0->dev_expr = $6; | |
| 2781 | 2922 | $<chain>0->priority = $7; | |
| 2782 | 2922 | $<chain>0->flags |= CHAIN_F_BASECHAIN; | |
| 2783 | } | ||
| 2784 | ; | ||
| 2785 | |||
| 2786 | 2820 | chain_type : FILTER { $$ = xstrdup("filter"); } | |
| 2787 | 104 | | NAT { $$ = xstrdup("nat"); } | |
| 2788 | 6 | | ROUTE { $$ = xstrdup("route"); } | |
| 2789 | ; | ||
| 2790 | |||
| 2791 | prio_spec : PRIORITY extended_prio_spec | ||
| 2792 | { | ||
| 2793 | 2999 | $$ = $2; | |
| 2794 | 2999 | $$.loc = @$; | |
| 2795 | } | ||
| 2796 | ; | ||
| 2797 | |||
| 2798 | extended_prio_name : OUT | ||
| 2799 | { | ||
| 2800 | ✗ | $$ = strdup("out"); | |
| 2801 | } | ||
| 2802 | | STRING | ||
| 2803 | ; | ||
| 2804 | |||
| 2805 | extended_prio_spec : int_num | ||
| 2806 | { | ||
| 2807 | 979 | struct prio_spec spec = {0}; | |
| 2808 | |||
| 2809 | 1954 | spec.expr = constant_expr_alloc(&@$, &integer_type, | |
| 2810 | BYTEORDER_HOST_ENDIAN, | ||
| 2811 | sizeof(int) * | ||
| 2812 | 979 | BITS_PER_BYTE, &$1); | |
| 2813 | 975 | $$ = spec; | |
| 2814 | } | ||
| 2815 | | variable_expr | ||
| 2816 | { | ||
| 2817 | 5 | struct prio_spec spec = {0}; | |
| 2818 | |||
| 2819 | 5 | spec.expr = $1; | |
| 2820 | 5 | $$ = spec; | |
| 2821 | } | ||
| 2822 | | extended_prio_name | ||
| 2823 | { | ||
| 2824 | 1508 | struct prio_spec spec = {0}; | |
| 2825 | |||
| 2826 | 3016 | spec.expr = constant_expr_alloc(&@$, &string_type, | |
| 2827 | BYTEORDER_HOST_ENDIAN, | ||
| 2828 | 1508 | strlen($1) * BITS_PER_BYTE, | |
| 2829 | 1508 | $1); | |
| 2830 | 1508 | free_const($1); | |
| 2831 | 1508 | $$ = spec; | |
| 2832 | } | ||
| 2833 | | extended_prio_name PLUS NUM | ||
| 2834 | { | ||
| 2835 | 263 | struct prio_spec spec = {0}; | |
| 2836 | |||
| 2837 | char str[NFT_NAME_MAXLEN]; | ||
| 2838 | 263 | snprintf(str, sizeof(str), "%s + %" PRIu64, $1, $3); | |
| 2839 | 526 | spec.expr = constant_expr_alloc(&@$, &string_type, | |
| 2840 | BYTEORDER_HOST_ENDIAN, | ||
| 2841 | 263 | strlen(str) * BITS_PER_BYTE, | |
| 2842 | str); | ||
| 2843 | 263 | free_const($1); | |
| 2844 | 263 | $$ = spec; | |
| 2845 | } | ||
| 2846 | | extended_prio_name DASH NUM | ||
| 2847 | { | ||
| 2848 | 244 | struct prio_spec spec = {0}; | |
| 2849 | char str[NFT_NAME_MAXLEN]; | ||
| 2850 | |||
| 2851 | 244 | snprintf(str, sizeof(str), "%s - %" PRIu64, $1, $3); | |
| 2852 | 488 | spec.expr = constant_expr_alloc(&@$, &string_type, | |
| 2853 | BYTEORDER_HOST_ENDIAN, | ||
| 2854 | 244 | strlen(str) * BITS_PER_BYTE, | |
| 2855 | str); | ||
| 2856 | 244 | free_const($1); | |
| 2857 | 244 | $$ = spec; | |
| 2858 | } | ||
| 2859 | ; | ||
| 2860 | |||
| 2861 | 844 | int_num : NUM { $$ = $1; } | |
| 2862 | 135 | | DASH NUM { $$ = -$2; } | |
| 2863 | ; | ||
| 2864 | |||
| 2865 | dev_spec : DEVICE string | ||
| 2866 | { | ||
| 2867 | 145 | struct expr *expr = ifname_expr_alloc(&@$, state->msgs, $2); | |
| 2868 | |||
| 2869 |
2/2✓ Branch 0 (920→921) taken 2 times.
✓ Branch 1 (920→922) taken 143 times.
|
145 | if (!expr) |
| 2870 | 2 | YYERROR; | |
| 2871 | |||
| 2872 | 143 | $$ = list_expr_alloc(&@$); | |
| 2873 | 143 | list_expr_add($$, expr); | |
| 2874 | |||
| 2875 | } | ||
| 2876 | | DEVICE variable_expr | ||
| 2877 | { | ||
| 2878 | 1 | datatype_set($2->sym->expr, &ifname_type); | |
| 2879 | 1 | $$ = list_expr_alloc(&@$); | |
| 2880 | 1 | list_expr_add($$, $2); | |
| 2881 | } | ||
| 2882 | | DEVICES '=' flowtable_expr | ||
| 2883 | { | ||
| 2884 | 1017 | $$ = $3; | |
| 2885 | } | ||
| 2886 | 1766 | | /* empty */ { $$ = NULL; } | |
| 2887 | ; | ||
| 2888 | |||
| 2889 | flags_spec : FLAGS OFFLOAD | ||
| 2890 | { | ||
| 2891 | ✗ | $<chain>0->flags |= CHAIN_F_HW_OFFLOAD; | |
| 2892 | } | ||
| 2893 | ; | ||
| 2894 | |||
| 2895 | policy_spec : POLICY policy_expr close_scope_policy | ||
| 2896 | { | ||
| 2897 |
1/2✗ Branch 0 (932→933) not taken.
✓ Branch 1 (932→937) taken 2028 times.
|
2028 | if ($<chain>0->policy) { |
| 2898 | ✗ | erec_queue(error(&@$, "you cannot set chain policy twice"), | |
| 2899 | state->msgs); | ||
| 2900 | ✗ | expr_free($2); | |
| 2901 | ✗ | YYERROR; | |
| 2902 | } | ||
| 2903 | 2028 | $<chain>0->policy = $2; | |
| 2904 | 2028 | $<chain>0->policy->location = @$; | |
| 2905 | 2028 | $<chain>0->flags |= CHAIN_F_BASECHAIN; | |
| 2906 | } | ||
| 2907 | ; | ||
| 2908 | |||
| 2909 | policy_expr : variable_expr | ||
| 2910 | { | ||
| 2911 | 5 | datatype_set($1->sym->expr, &policy_type); | |
| 2912 | 5 | $$ = $1; | |
| 2913 | } | ||
| 2914 | | chain_policy | ||
| 2915 | { | ||
| 2916 | 2023 | $$ = constant_expr_alloc(&@$, &integer_type, | |
| 2917 | BYTEORDER_HOST_ENDIAN, | ||
| 2918 | sizeof(int) * | ||
| 2919 | 2023 | BITS_PER_BYTE, &$1); | |
| 2920 | } | ||
| 2921 | ; | ||
| 2922 | |||
| 2923 | 1970 | chain_policy : ACCEPT { $$ = NF_ACCEPT; } | |
| 2924 | 53 | | DROP { $$ = NF_DROP; } | |
| 2925 | ; | ||
| 2926 | |||
| 2927 | identifier : STRING | ||
| 2928 | ✗ | | LAST { $$ = xstrdup("last"); } | |
| 2929 | ; | ||
| 2930 | |||
| 2931 | string : STRING | ||
| 2932 | | QUOTED_STRING | ||
| 2933 | | ASTERISK_STRING | ||
| 2934 | ; | ||
| 2935 | |||
| 2936 | time_spec : STRING | ||
| 2937 | { | ||
| 2938 | struct error_record *erec; | ||
| 2939 | uint64_t res; | ||
| 2940 | |||
| 2941 | 75541 | erec = time_parse(&@1, $1, &res); | |
| 2942 | 74368 | free_const($1); | |
| 2943 |
2/2✓ Branch 0 (947→948) taken 6 times.
✓ Branch 1 (947→950) taken 74362 times.
|
74368 | if (erec != NULL) { |
| 2944 | 6 | erec_queue(erec, state->msgs); | |
| 2945 | 6 | YYERROR; | |
| 2946 | } | ||
| 2947 | 74362 | $$ = res; | |
| 2948 | } | ||
| 2949 | ; | ||
| 2950 | |||
| 2951 | /* compatibility kludge to allow either 60, 60s, 1m, ... */ | ||
| 2952 | time_spec_or_num_s : NUM | ||
| 2953 | 17 | | time_spec { $$ = $1 / 1000u; } | |
| 2954 | ; | ||
| 2955 | |||
| 2956 | 2732 | family_spec : /* empty */ { $$ = NFPROTO_IPV4; } | |
| 2957 | | family_spec_explicit | ||
| 2958 | ; | ||
| 2959 | |||
| 2960 | 10891 | family_spec_explicit : IP close_scope_ip { $$ = NFPROTO_IPV4; } | |
| 2961 | 7908 | | IP6 close_scope_ip6 { $$ = NFPROTO_IPV6; } | |
| 2962 | 44717 | | INET { $$ = NFPROTO_INET; } | |
| 2963 | 1985 | | ARP close_scope_arp { $$ = NFPROTO_ARP; } | |
| 2964 | 3212 | | BRIDGE { $$ = NFPROTO_BRIDGE; } | |
| 2965 | 15338 | | NETDEV { $$ = NFPROTO_NETDEV; } | |
| 2966 | ; | ||
| 2967 | |||
| 2968 | table_spec : family_spec identifier | ||
| 2969 | { | ||
| 2970 | 86720 | memset(&$$, 0, sizeof($$)); | |
| 2971 | 86720 | $$.family = $1; | |
| 2972 | 86720 | $$.table.location = @2; | |
| 2973 | 86720 | $$.table.name = $2; | |
| 2974 | } | ||
| 2975 | ; | ||
| 2976 | |||
| 2977 | tableid_spec : family_spec HANDLE NUM | ||
| 2978 | { | ||
| 2979 | 3 | memset(&$$, 0, sizeof($$)); | |
| 2980 | 3 | $$.family = $1; | |
| 2981 | 3 | $$.handle.id = $3; | |
| 2982 | 3 | $$.handle.location = @3; | |
| 2983 | } | ||
| 2984 | ; | ||
| 2985 | |||
| 2986 | chain_spec : table_spec identifier | ||
| 2987 | { | ||
| 2988 | 19850 | $$ = $1; | |
| 2989 | 19850 | $$.chain.name = $2; | |
| 2990 | 19850 | $$.chain.location = @2; | |
| 2991 | } | ||
| 2992 | ; | ||
| 2993 | |||
| 2994 | chainid_spec : table_spec HANDLE NUM | ||
| 2995 | { | ||
| 2996 | 4 | $$ = $1; | |
| 2997 | 4 | $$.handle.location = @3; | |
| 2998 | 4 | $$.handle.id = $3; | |
| 2999 | } | ||
| 3000 | ; | ||
| 3001 | |||
| 3002 | chain_identifier : identifier | ||
| 3003 | { | ||
| 3004 | 2524 | memset(&$$, 0, sizeof($$)); | |
| 3005 | 2524 | $$.chain.name = $1; | |
| 3006 | 2524 | $$.chain.location = @1; | |
| 3007 | } | ||
| 3008 | ; | ||
| 3009 | |||
| 3010 | set_spec : table_spec identifier | ||
| 3011 | { | ||
| 3012 | 37165 | $$ = $1; | |
| 3013 | 37165 | $$.set.name = $2; | |
| 3014 | 37165 | $$.set.location = @2; | |
| 3015 | } | ||
| 3016 | ; | ||
| 3017 | |||
| 3018 | setid_spec : table_spec HANDLE NUM | ||
| 3019 | { | ||
| 3020 | 5 | $$ = $1; | |
| 3021 | 5 | $$.handle.location = @3; | |
| 3022 | 5 | $$.handle.id = $3; | |
| 3023 | } | ||
| 3024 | ; | ||
| 3025 | |||
| 3026 | set_identifier : identifier | ||
| 3027 | { | ||
| 3028 | 875 | memset(&$$, 0, sizeof($$)); | |
| 3029 | 875 | $$.set.name = $1; | |
| 3030 | 875 | $$.set.location = @1; | |
| 3031 | } | ||
| 3032 | ; | ||
| 3033 | |||
| 3034 | flowtable_spec : table_spec identifier | ||
| 3035 | { | ||
| 3036 | 71 | $$ = $1; | |
| 3037 | 71 | $$.flowtable.name = $2; | |
| 3038 | 71 | $$.flowtable.location = @2; | |
| 3039 | } | ||
| 3040 | ; | ||
| 3041 | |||
| 3042 | flowtableid_spec : table_spec HANDLE NUM | ||
| 3043 | { | ||
| 3044 | 3 | $$ = $1; | |
| 3045 | 3 | $$.handle.location = @3; | |
| 3046 | 3 | $$.handle.id = $3; | |
| 3047 | } | ||
| 3048 | ; | ||
| 3049 | |||
| 3050 | flowtable_identifier : identifier | ||
| 3051 | { | ||
| 3052 | 38 | memset(&$$, 0, sizeof($$)); | |
| 3053 | 38 | $$.flowtable.name = $1; | |
| 3054 | 38 | $$.flowtable.location = @1; | |
| 3055 | } | ||
| 3056 | ; | ||
| 3057 | |||
| 3058 | obj_spec : table_spec identifier | ||
| 3059 | { | ||
| 3060 | 497 | $$ = $1; | |
| 3061 | 497 | $$.obj.name = $2; | |
| 3062 | 497 | $$.obj.location = @2; | |
| 3063 | } | ||
| 3064 | ; | ||
| 3065 | |||
| 3066 | objid_spec : table_spec HANDLE NUM | ||
| 3067 | { | ||
| 3068 | 4 | $$ = $1; | |
| 3069 | 4 | $$.handle.location = @3; | |
| 3070 | 4 | $$.handle.id = $3; | |
| 3071 | } | ||
| 3072 | ; | ||
| 3073 | |||
| 3074 | obj_identifier : identifier | ||
| 3075 | { | ||
| 3076 | 285 | memset(&$$, 0, sizeof($$)); | |
| 3077 | 285 | $$.obj.name = $1; | |
| 3078 | 285 | $$.obj.location = @1; | |
| 3079 | } | ||
| 3080 | ; | ||
| 3081 | |||
| 3082 | handle_spec : HANDLE NUM | ||
| 3083 | { | ||
| 3084 | 28 | memset(&$$, 0, sizeof($$)); | |
| 3085 | 28 | $$.handle.location = @2; | |
| 3086 | 28 | $$.handle.id = $2; | |
| 3087 | } | ||
| 3088 | ; | ||
| 3089 | |||
| 3090 | position_spec : POSITION NUM | ||
| 3091 | { | ||
| 3092 | 6 | memset(&$$, 0, sizeof($$)); | |
| 3093 | 6 | $$.position.location = @$; | |
| 3094 | 6 | $$.position.id = $2; | |
| 3095 | } | ||
| 3096 | ; | ||
| 3097 | |||
| 3098 | index_spec : INDEX NUM | ||
| 3099 | { | ||
| 3100 | 22 | memset(&$$, 0, sizeof($$)); | |
| 3101 | 22 | $$.index.location = @$; | |
| 3102 | 22 | $$.index.id = $2 + 1; | |
| 3103 | } | ||
| 3104 | ; | ||
| 3105 | |||
| 3106 | rule_position : chain_spec | ||
| 3107 | { | ||
| 3108 | 15176 | $$ = $1; | |
| 3109 | } | ||
| 3110 | | chain_spec position_spec | ||
| 3111 | { | ||
| 3112 | 6 | handle_merge(&$1, &$2); | |
| 3113 | 6 | $$ = $1; | |
| 3114 | } | ||
| 3115 | | chain_spec handle_spec | ||
| 3116 | { | ||
| 3117 | 7 | $2.position.location = $2.handle.location; | |
| 3118 | 7 | $2.position.id = $2.handle.id; | |
| 3119 | 7 | $2.handle.id = 0; | |
| 3120 | 7 | handle_merge(&$1, &$2); | |
| 3121 | 7 | $$ = $1; | |
| 3122 | } | ||
| 3123 | | chain_spec index_spec | ||
| 3124 | { | ||
| 3125 | 22 | handle_merge(&$1, &$2); | |
| 3126 | 22 | $$ = $1; | |
| 3127 | } | ||
| 3128 | ; | ||
| 3129 | |||
| 3130 | ruleid_spec : chain_spec handle_spec | ||
| 3131 | { | ||
| 3132 | 21 | handle_merge(&$1, &$2); | |
| 3133 | 21 | $$ = $1; | |
| 3134 | } | ||
| 3135 | ; | ||
| 3136 | |||
| 3137 | comment_spec : COMMENT string | ||
| 3138 | { | ||
| 3139 |
2/2✓ Branch 0 (986→987) taken 1 times.
✓ Branch 1 (986→990) taken 3890 times.
|
3891 | if (strlen($2) > NFTNL_UDATA_COMMENT_MAXLEN) { |
| 3140 | 1 | erec_queue(error(&@2, "comment too long, %d characters maximum allowed", | |
| 3141 | NFTNL_UDATA_COMMENT_MAXLEN), | ||
| 3142 | state->msgs); | ||
| 3143 | 1 | free_const($2); | |
| 3144 | 1 | YYERROR; | |
| 3145 | } | ||
| 3146 | 3890 | $$ = $2; | |
| 3147 | } | ||
| 3148 | ; | ||
| 3149 | |||
| 3150 | ruleset_spec : /* empty */ | ||
| 3151 | { | ||
| 3152 | 2549 | memset(&$$, 0, sizeof($$)); | |
| 3153 | 2549 | $$.family = NFPROTO_UNSPEC; | |
| 3154 | } | ||
| 3155 | | family_spec_explicit | ||
| 3156 | { | ||
| 3157 | 19 | memset(&$$, 0, sizeof($$)); | |
| 3158 | 19 | $$.family = $1; | |
| 3159 | } | ||
| 3160 | ; | ||
| 3161 | |||
| 3162 | rule : rule_alloc | ||
| 3163 | { | ||
| 3164 | 55188 | $$->comment = NULL; | |
| 3165 | } | ||
| 3166 | | rule_alloc comment_spec | ||
| 3167 | { | ||
| 3168 | 3129 | $$->comment = $2; | |
| 3169 | } | ||
| 3170 | ; | ||
| 3171 | |||
| 3172 | rule_alloc : stmt_list | ||
| 3173 | { | ||
| 3174 | struct stmt *i; | ||
| 3175 | |||
| 3176 | 58317 | $$ = rule_alloc(&@$, NULL); | |
| 3177 |
2/2✓ Branch 0 (998→997) taken 66091 times.
✓ Branch 1 (998→999) taken 57947 times.
|
124038 | list_for_each_entry(i, $1, list) |
| 3178 | 66091 | $$->num_stmts++; | |
| 3179 | 57947 | list_splice_tail($1, &$$->stmts); | |
| 3180 | 57947 | free($1); | |
| 3181 | } | ||
| 3182 | ; | ||
| 3183 | |||
| 3184 | stmt_list : stmt | ||
| 3185 | { | ||
| 3186 | 58332 | $$ = xmalloc(sizeof(*$$)); | |
| 3187 | 57962 | init_list_head($$); | |
| 3188 | 57962 | list_add_tail(&$1->list, $$); | |
| 3189 | } | ||
| 3190 | | stmt_list stmt | ||
| 3191 | { | ||
| 3192 | 8498 | $$ = $1; | |
| 3193 | 8498 | list_add_tail(&$2->list, $1); | |
| 3194 | } | ||
| 3195 | ; | ||
| 3196 | |||
| 3197 | stateful_stmt_list : stateful_stmt | ||
| 3198 | { | ||
| 3199 | 82 | $$ = xmalloc(sizeof(*$$)); | |
| 3200 | 82 | init_list_head($$); | |
| 3201 | 82 | list_add_tail(&$1->list, $$); | |
| 3202 | } | ||
| 3203 | | stateful_stmt_list stateful_stmt | ||
| 3204 | { | ||
| 3205 | 7 | $$ = $1; | |
| 3206 | 7 | list_add_tail(&$2->list, $1); | |
| 3207 | } | ||
| 3208 | ; | ||
| 3209 | |||
| 3210 | objref_stmt_counter : COUNTER NAME stmt_expr close_scope_counter | ||
| 3211 | { | ||
| 3212 | 176 | $$ = objref_stmt_alloc(&@$); | |
| 3213 | 176 | $$->objref.type = NFT_OBJECT_COUNTER; | |
| 3214 | 176 | $$->objref.expr = $3; | |
| 3215 | } | ||
| 3216 | ; | ||
| 3217 | |||
| 3218 | objref_stmt_limit : LIMIT NAME stmt_expr close_scope_limit | ||
| 3219 | { | ||
| 3220 | 9 | $$ = objref_stmt_alloc(&@$); | |
| 3221 | 9 | $$->objref.type = NFT_OBJECT_LIMIT; | |
| 3222 | 9 | $$->objref.expr = $3; | |
| 3223 | } | ||
| 3224 | ; | ||
| 3225 | |||
| 3226 | objref_stmt_quota : QUOTA NAME stmt_expr close_scope_quota | ||
| 3227 | { | ||
| 3228 | 7 | $$ = objref_stmt_alloc(&@$); | |
| 3229 | 7 | $$->objref.type = NFT_OBJECT_QUOTA; | |
| 3230 | 7 | $$->objref.expr = $3; | |
| 3231 | } | ||
| 3232 | ; | ||
| 3233 | |||
| 3234 | objref_stmt_synproxy : SYNPROXY NAME stmt_expr close_scope_synproxy | ||
| 3235 | { | ||
| 3236 | 4 | $$ = objref_stmt_alloc(&@$); | |
| 3237 | 4 | $$->objref.type = NFT_OBJECT_SYNPROXY; | |
| 3238 | 4 | $$->objref.expr = $3; | |
| 3239 | } | ||
| 3240 | ; | ||
| 3241 | |||
| 3242 | objref_stmt_tunnel : TUNNEL NAME stmt_expr close_scope_tunnel | ||
| 3243 | { | ||
| 3244 | 2 | $$ = objref_stmt_alloc(&@$); | |
| 3245 | 2 | $$->objref.type = NFT_OBJECT_TUNNEL; | |
| 3246 | 2 | $$->objref.expr = $3; | |
| 3247 | } | ||
| 3248 | ; | ||
| 3249 | |||
| 3250 | objref_stmt_ct : CT TIMEOUT SET stmt_expr close_scope_ct | ||
| 3251 | { | ||
| 3252 | 13 | $$ = objref_stmt_alloc(&@$); | |
| 3253 | 13 | $$->objref.type = NFT_OBJECT_CT_TIMEOUT; | |
| 3254 | 13 | $$->objref.expr = $4; | |
| 3255 | |||
| 3256 | } | ||
| 3257 | | CT EXPECTATION SET stmt_expr close_scope_ct | ||
| 3258 | { | ||
| 3259 | 11 | $$ = objref_stmt_alloc(&@$); | |
| 3260 | 11 | $$->objref.type = NFT_OBJECT_CT_EXPECT; | |
| 3261 | 11 | $$->objref.expr = $4; | |
| 3262 | } | ||
| 3263 | ; | ||
| 3264 | |||
| 3265 | objref_stmt : objref_stmt_counter | ||
| 3266 | | objref_stmt_limit | ||
| 3267 | | objref_stmt_quota | ||
| 3268 | | objref_stmt_synproxy | ||
| 3269 | | objref_stmt_ct | ||
| 3270 | | objref_stmt_tunnel | ||
| 3271 | ; | ||
| 3272 | |||
| 3273 | stateful_stmt : counter_stmt close_scope_counter | ||
| 3274 | | limit_stmt close_scope_limit | ||
| 3275 | | quota_stmt close_scope_quota | ||
| 3276 | | connlimit_stmt close_scope_ct | ||
| 3277 | | last_stmt close_scope_last | ||
| 3278 | ; | ||
| 3279 | |||
| 3280 | stmt : verdict_stmt | ||
| 3281 | | match_stmt | ||
| 3282 | | meter_stmt | ||
| 3283 | | payload_stmt | ||
| 3284 | | stateful_stmt | ||
| 3285 | | meta_stmt | ||
| 3286 | | log_stmt close_scope_log | ||
| 3287 | | reject_stmt close_scope_reject | ||
| 3288 | | nat_stmt close_scope_nat | ||
| 3289 | | tproxy_stmt close_scope_tproxy | ||
| 3290 | | queue_stmt | ||
| 3291 | | ct_stmt | ||
| 3292 | | masq_stmt close_scope_nat | ||
| 3293 | | redir_stmt close_scope_nat | ||
| 3294 | | dup_stmt close_scope_dup | ||
| 3295 | | fwd_stmt close_scope_fwd | ||
| 3296 | | set_stmt | ||
| 3297 | | map_stmt | ||
| 3298 | | synproxy_stmt close_scope_synproxy | ||
| 3299 | | chain_stmt | ||
| 3300 | | optstrip_stmt | ||
| 3301 | | xt_stmt close_scope_xt | ||
| 3302 | | objref_stmt | ||
| 3303 | ; | ||
| 3304 | |||
| 3305 | xt_stmt : XT STRING string | ||
| 3306 | { | ||
| 3307 | ✗ | $$ = NULL; | |
| 3308 | ✗ | free_const($2); | |
| 3309 | ✗ | free_const($3); | |
| 3310 | ✗ | erec_queue(error(&@$, "unsupported xtables compat expression, use iptables-nft with this ruleset"), | |
| 3311 | state->msgs); | ||
| 3312 | ✗ | YYERROR; | |
| 3313 | } | ||
| 3314 | ; | ||
| 3315 | |||
| 3316 | 53 | chain_stmt_type : JUMP { $$ = NFT_JUMP; } | |
| 3317 | 21 | | GOTO { $$ = NFT_GOTO; } | |
| 3318 | ; | ||
| 3319 | |||
| 3320 | chain_stmt : chain_stmt_type chain_block_alloc '{' subchain_block '}' | ||
| 3321 | { | ||
| 3322 | 72 | $2->location = @2; | |
| 3323 | 72 | close_scope(state); | |
| 3324 | 64 | $4->location = @4; | |
| 3325 | 64 | $$ = chain_stmt_alloc(&@$, $4, $1); | |
| 3326 | } | ||
| 3327 | ; | ||
| 3328 | |||
| 3329 | verdict_stmt : verdict_expr | ||
| 3330 | { | ||
| 3331 | 9351 | $$ = verdict_stmt_alloc(&@$, $1); | |
| 3332 | } | ||
| 3333 | | verdict_map_stmt | ||
| 3334 | { | ||
| 3335 | 475 | $$ = verdict_stmt_alloc(&@$, $1); | |
| 3336 | } | ||
| 3337 | ; | ||
| 3338 | |||
| 3339 | verdict_map_stmt : concat_expr VMAP verdict_map_expr | ||
| 3340 | { | ||
| 3341 | 475 | $$ = map_expr_alloc(&@$, $1, $3); | |
| 3342 | } | ||
| 3343 | ; | ||
| 3344 | |||
| 3345 | verdict_map_expr : '{' verdict_map_list_expr '}' | ||
| 3346 | { | ||
| 3347 | 426 | $2->location = @$; | |
| 3348 | 426 | $$ = $2; | |
| 3349 | } | ||
| 3350 | | set_ref_expr | ||
| 3351 | ; | ||
| 3352 | |||
| 3353 | verdict_map_list_expr : verdict_map_list_member_expr | ||
| 3354 | { | ||
| 3355 | 426 | $$ = set_expr_alloc(&@$, NULL); | |
| 3356 | 426 | set_expr_add($$, $1); | |
| 3357 | } | ||
| 3358 | | verdict_map_list_expr COMMA verdict_map_list_member_expr | ||
| 3359 | { | ||
| 3360 | 255 | set_expr_add($1, $3); | |
| 3361 | 255 | $$ = $1; | |
| 3362 | } | ||
| 3363 | | verdict_map_list_expr COMMA opt_newline | ||
| 3364 | ; | ||
| 3365 | |||
| 3366 | verdict_map_list_member_expr: opt_newline set_elem_expr COLON verdict_expr opt_newline | ||
| 3367 | { | ||
| 3368 | 681 | $$ = mapping_expr_alloc(&@2, $2, $4); | |
| 3369 | } | ||
| 3370 | ; | ||
| 3371 | |||
| 3372 | ct_limit_stmt_alloc : CT COUNT | ||
| 3373 | { | ||
| 3374 | 18 | $$ = connlimit_stmt_alloc(&@$); | |
| 3375 | } | ||
| 3376 | ; | ||
| 3377 | |||
| 3378 | connlimit_stmt : ct_limit_stmt_alloc ct_limit_args | ||
| 3379 | ; | ||
| 3380 | |||
| 3381 | ct_limit_args : NUM | ||
| 3382 | { | ||
| 3383 |
1/2✗ Branch 0 (1051→1052) not taken.
✓ Branch 1 (1051→1053) taken 3 times.
|
3 | assert($<stmt>0->type == STMT_CONNLIMIT); |
| 3384 | |||
| 3385 | 3 | $<stmt>0->connlimit.count = $1; | |
| 3386 | } | ||
| 3387 | | OVER NUM | ||
| 3388 | { | ||
| 3389 |
1/2✗ Branch 0 (1054→1055) not taken.
✓ Branch 1 (1054→1056) taken 15 times.
|
15 | assert($<stmt>0->type == STMT_CONNLIMIT); |
| 3390 | |||
| 3391 | 15 | $<stmt>0->connlimit.count = $2; | |
| 3392 | 15 | $<stmt>0->connlimit.flags = NFT_CONNLIMIT_F_INV; | |
| 3393 | } | ||
| 3394 | ; | ||
| 3395 | |||
| 3396 | counter_stmt : counter_stmt_alloc | ||
| 3397 | | counter_stmt_alloc counter_args | ||
| 3398 | |||
| 3399 | counter_stmt_alloc : COUNTER | ||
| 3400 | { | ||
| 3401 | 2245 | $$ = counter_stmt_alloc(&@$); | |
| 3402 | } | ||
| 3403 | ; | ||
| 3404 | |||
| 3405 | counter_args : counter_arg | ||
| 3406 | { | ||
| 3407 | 270 | $<stmt>$ = $<stmt>0; | |
| 3408 | } | ||
| 3409 | | counter_args counter_arg | ||
| 3410 | ; | ||
| 3411 | |||
| 3412 | counter_arg : PACKETS NUM | ||
| 3413 | { | ||
| 3414 |
1/2✗ Branch 0 (1060→1061) not taken.
✓ Branch 1 (1060→1062) taken 271 times.
|
271 | assert($<stmt>0->type == STMT_COUNTER); |
| 3415 | 271 | $<stmt>0->counter.packets = $2; | |
| 3416 | } | ||
| 3417 | | BYTES NUM | ||
| 3418 | { | ||
| 3419 |
1/2✗ Branch 0 (1063→1064) not taken.
✓ Branch 1 (1063→1065) taken 270 times.
|
270 | assert($<stmt>0->type == STMT_COUNTER); |
| 3420 | 270 | $<stmt>0->counter.bytes = $2; | |
| 3421 | } | ||
| 3422 | ; | ||
| 3423 | |||
| 3424 | last_stmt_alloc : LAST | ||
| 3425 | { | ||
| 3426 | 33 | $$ = last_stmt_alloc(&@$); | |
| 3427 | } | ||
| 3428 | ; | ||
| 3429 | |||
| 3430 | last_stmt : last_stmt_alloc | ||
| 3431 | | last_stmt_alloc last_args | ||
| 3432 | ; | ||
| 3433 | |||
| 3434 | last_args : USED NEVER | ||
| 3435 | | USED time_spec | ||
| 3436 | { | ||
| 3437 | struct last_stmt *last; | ||
| 3438 | |||
| 3439 |
1/2✗ Branch 0 (1068→1069) not taken.
✓ Branch 1 (1068→1070) taken 6 times.
|
6 | assert($<stmt>0->type == STMT_LAST); |
| 3440 | 6 | last = &$<stmt>0->last; | |
| 3441 | 6 | last->used = $2; | |
| 3442 | 6 | last->set = true; | |
| 3443 | } | ||
| 3444 | ; | ||
| 3445 | |||
| 3446 | log_stmt : log_stmt_alloc | ||
| 3447 | | log_stmt_alloc log_args | ||
| 3448 | ; | ||
| 3449 | |||
| 3450 | log_stmt_alloc : LOG | ||
| 3451 | { | ||
| 3452 | 192 | $$ = log_stmt_alloc(&@$); | |
| 3453 | } | ||
| 3454 | ; | ||
| 3455 | |||
| 3456 | log_args : log_arg | ||
| 3457 | { | ||
| 3458 | 159 | $<stmt>$ = $<stmt>0; | |
| 3459 | } | ||
| 3460 | | log_args log_arg | ||
| 3461 | ; | ||
| 3462 | |||
| 3463 | log_arg : PREFIX string | ||
| 3464 | { | ||
| 3465 | 46 | struct scope *scope = current_scope(state); | |
| 3466 | struct error_record *erec; | ||
| 3467 | const char *prefix; | ||
| 3468 | |||
| 3469 | 46 | prefix = str_preprocess(state, &@2, scope, $2, &erec); | |
| 3470 |
1/2✗ Branch 0 (1076→1077) not taken.
✓ Branch 1 (1076→1079) taken 46 times.
|
46 | if (!prefix) { |
| 3471 | ✗ | erec_queue(erec, state->msgs); | |
| 3472 | ✗ | free_const($2); | |
| 3473 | ✗ | YYERROR; | |
| 3474 | } | ||
| 3475 | |||
| 3476 | 46 | free_const($2); | |
| 3477 | 46 | $<stmt>0->log.prefix = prefix; | |
| 3478 | 46 | $<stmt>0->log.flags |= STMT_LOG_PREFIX; | |
| 3479 | } | ||
| 3480 | | GROUP NUM | ||
| 3481 | { | ||
| 3482 | 50 | $<stmt>0->log.group = $2; | |
| 3483 | 50 | $<stmt>0->log.flags |= STMT_LOG_GROUP; | |
| 3484 | } | ||
| 3485 | | SNAPLEN NUM | ||
| 3486 | { | ||
| 3487 | 20 | $<stmt>0->log.snaplen = $2; | |
| 3488 | 20 | $<stmt>0->log.flags |= STMT_LOG_SNAPLEN; | |
| 3489 | } | ||
| 3490 | | QUEUE_THRESHOLD NUM | ||
| 3491 | { | ||
| 3492 | 10 | $<stmt>0->log.qthreshold = $2; | |
| 3493 | 10 | $<stmt>0->log.flags |= STMT_LOG_QTHRESHOLD; | |
| 3494 | } | ||
| 3495 | | LEVEL level_type | ||
| 3496 | { | ||
| 3497 | 86 | $<stmt>0->log.level = $2; | |
| 3498 | 86 | $<stmt>0->log.flags |= STMT_LOG_LEVEL; | |
| 3499 | } | ||
| 3500 | | FLAGS log_flags | ||
| 3501 | { | ||
| 3502 | 79 | $<stmt>0->log.logflags |= $2; | |
| 3503 | } | ||
| 3504 | ; | ||
| 3505 | |||
| 3506 | 10 | level_type : EMERG { $$ = NFT_LOGLEVEL_EMERG; } | |
| 3507 | 10 | | ALERT { $$ = NFT_LOGLEVEL_ALERT; } | |
| 3508 | 5 | | CRIT { $$ = NFT_LOGLEVEL_CRIT; } | |
| 3509 | 5 | | ERR { $$ = NFT_LOGLEVEL_ERR; } | |
| 3510 | 5 | | WARN { $$ = NFT_LOGLEVEL_WARNING; } | |
| 3511 | 5 | | NOTICE { $$ = NFT_LOGLEVEL_NOTICE; } | |
| 3512 | 5 | | INFO { $$ = NFT_LOGLEVEL_INFO; } | |
| 3513 | 11 | | DEBUG_TOKEN { $$ = NFT_LOGLEVEL_DEBUG; } | |
| 3514 | 30 | | AUDIT { $$ = NFT_LOGLEVEL_AUDIT; } | |
| 3515 | ; | ||
| 3516 | |||
| 3517 | log_flags : TCP log_flags_tcp close_scope_tcp | ||
| 3518 | { | ||
| 3519 | 12 | $$ = $2; | |
| 3520 | } | ||
| 3521 | | IP OPTIONS close_scope_ip | ||
| 3522 | { | ||
| 3523 | 20 | $$ = NF_LOG_IPOPT; | |
| 3524 | } | ||
| 3525 | | SKUID | ||
| 3526 | { | ||
| 3527 | 10 | $$ = NF_LOG_UID; | |
| 3528 | } | ||
| 3529 | | ETHER close_scope_eth | ||
| 3530 | { | ||
| 3531 | 15 | $$ = NF_LOG_MACDECODE; | |
| 3532 | } | ||
| 3533 | | ALL | ||
| 3534 | { | ||
| 3535 | 22 | $$ = NF_LOG_MASK; | |
| 3536 | } | ||
| 3537 | ; | ||
| 3538 | |||
| 3539 | log_flags_tcp : log_flags_tcp COMMA log_flag_tcp | ||
| 3540 | { | ||
| 3541 | 11 | $$ = $1 | $3; | |
| 3542 | } | ||
| 3543 | | log_flag_tcp | ||
| 3544 | ; | ||
| 3545 | |||
| 3546 | log_flag_tcp : SEQUENCE | ||
| 3547 | { | ||
| 3548 | 12 | $$ = NF_LOG_TCPSEQ; | |
| 3549 | } | ||
| 3550 | | OPTIONS | ||
| 3551 | { | ||
| 3552 | 11 | $$ = NF_LOG_TCPOPT; | |
| 3553 | } | ||
| 3554 | ; | ||
| 3555 | |||
| 3556 | limit_stmt_alloc : LIMIT RATE | ||
| 3557 | { | ||
| 3558 | 453 | $$ = limit_stmt_alloc(&@$); | |
| 3559 | } | ||
| 3560 | ; | ||
| 3561 | |||
| 3562 | limit_stmt : limit_stmt_alloc limit_args close_scope_rate | ||
| 3563 | ; | ||
| 3564 | |||
| 3565 | limit_args : limit_mode limit_rate_pkts limit_burst_pkts | ||
| 3566 | { | ||
| 3567 | struct limit_stmt *limit; | ||
| 3568 | |||
| 3569 |
1/2✗ Branch 0 (1105→1106) not taken.
✓ Branch 1 (1105→1107) taken 202 times.
|
202 | assert($<stmt>0->type == STMT_LIMIT); |
| 3570 | |||
| 3571 |
1/2✗ Branch 0 (1107→1108) not taken.
✓ Branch 1 (1107→1111) taken 202 times.
|
202 | if ($3 == 0) { |
| 3572 | ✗ | erec_queue(error(&@3, "packet limit burst must be > 0"), | |
| 3573 | state->msgs); | ||
| 3574 | ✗ | YYERROR; | |
| 3575 | } | ||
| 3576 | 202 | limit = &$<stmt>0->limit; | |
| 3577 | 202 | limit->rate = $2.rate; | |
| 3578 | 202 | limit->unit = $2.unit; | |
| 3579 | 202 | limit->burst = $3; | |
| 3580 | 202 | limit->type = NFT_LIMIT_PKTS; | |
| 3581 | 202 | limit->flags = $1; | |
| 3582 | } | ||
| 3583 | | limit_mode limit_rate_bytes limit_burst_bytes | ||
| 3584 | { | ||
| 3585 | struct limit_stmt *limit; | ||
| 3586 | |||
| 3587 |
1/2✗ Branch 0 (1112→1113) not taken.
✓ Branch 1 (1112→1114) taken 230 times.
|
230 | assert($<stmt>0->type == STMT_LIMIT); |
| 3588 | |||
| 3589 | 230 | limit = &$<stmt>0->limit; | |
| 3590 | 230 | limit->rate = $2.rate; | |
| 3591 | 230 | limit->unit = $2.unit; | |
| 3592 | 230 | limit->burst = $3; | |
| 3593 | 230 | limit->type = NFT_LIMIT_PKT_BYTES; | |
| 3594 | 230 | limit->flags = $1; | |
| 3595 | } | ||
| 3596 | ; | ||
| 3597 | |||
| 3598 | 66 | quota_mode : OVER { $$ = NFT_QUOTA_F_INV; } | |
| 3599 | ✗ | | UNTIL { $$ = 0; } | |
| 3600 | 89 | | /* empty */ { $$ = 0; } | |
| 3601 | ; | ||
| 3602 | |||
| 3603 | 236 | bytes_unit : BYTES { $$ = 1; } | |
| 3604 | 154 | | KBYTES { $$ = 1024; } | |
| 3605 | 138 | | MBYTES { $$ = 1024 * 1024; } | |
| 3606 | ; | ||
| 3607 | |||
| 3608 | 141 | quota_used : /* empty */ { $$ = 0; } | |
| 3609 | | USED NUM bytes_unit | ||
| 3610 | { | ||
| 3611 | 14 | $$ = $2 * $3; | |
| 3612 | } | ||
| 3613 | ; | ||
| 3614 | |||
| 3615 | quota_stmt_alloc : QUOTA | ||
| 3616 | { | ||
| 3617 | 114 | $$ = quota_stmt_alloc(&@$); | |
| 3618 | } | ||
| 3619 | ; | ||
| 3620 | |||
| 3621 | quota_stmt : quota_stmt_alloc quota_args | ||
| 3622 | ; | ||
| 3623 | |||
| 3624 | quota_args : quota_mode NUM bytes_unit quota_used | ||
| 3625 | { | ||
| 3626 | struct quota_stmt *quota; | ||
| 3627 | |||
| 3628 |
1/2✗ Branch 0 (1125→1126) not taken.
✓ Branch 1 (1125→1127) taken 114 times.
|
114 | assert($<stmt>0->type == STMT_QUOTA); |
| 3629 | |||
| 3630 | 114 | quota = &$<stmt>0->quota; | |
| 3631 | 114 | quota->bytes = $2 * $3; | |
| 3632 | 114 | quota->used = $4; | |
| 3633 | 114 | quota->flags = $1; | |
| 3634 | } | ||
| 3635 | ; | ||
| 3636 | |||
| 3637 | 216 | limit_mode : OVER { $$ = NFT_LIMIT_F_INV; } | |
| 3638 | ✗ | | UNTIL { $$ = 0; } | |
| 3639 | 258 | | /* empty */ { $$ = 0; } | |
| 3640 | ; | ||
| 3641 | |||
| 3642 | 100 | limit_burst_pkts : /* empty */ { $$ = 5; } | |
| 3643 | 115 | | BURST NUM PACKETS { $$ = $2; } | |
| 3644 | ; | ||
| 3645 | |||
| 3646 | limit_rate_pkts : NUM SLASH time_unit | ||
| 3647 | { | ||
| 3648 | 222 | $$.rate = $1; | |
| 3649 | 222 | $$.unit = $3; | |
| 3650 | } | ||
| 3651 | ; | ||
| 3652 | |||
| 3653 | 124 | limit_burst_bytes : /* empty */ { $$ = 0; } | |
| 3654 | 114 | | BURST NUM bytes_unit { $$ = $2 * $3; } | |
| 3655 | ; | ||
| 3656 | |||
| 3657 | limit_rate_bytes : NUM bytes_unit SLASH time_unit | ||
| 3658 | { | ||
| 3659 | 245 | $$.rate = $1 * $2; | |
| 3660 | 245 | $$.unit = $4; | |
| 3661 | } | ||
| 3662 | ; | ||
| 3663 | |||
| 3664 | 344 | time_unit : SECOND { $$ = 1ULL; } | |
| 3665 | 36 | | MINUTE { $$ = 1ULL * 60; } | |
| 3666 | 31 | | HOUR { $$ = 1ULL * 60 * 60; } | |
| 3667 | 28 | | DAY { $$ = 1ULL * 60 * 60 * 24; } | |
| 3668 | 28 | | WEEK { $$ = 1ULL * 60 * 60 * 24 * 7; } | |
| 3669 | ; | ||
| 3670 | |||
| 3671 | reject_stmt : reject_stmt_alloc reject_opts | ||
| 3672 | ; | ||
| 3673 | |||
| 3674 | reject_stmt_alloc : _REJECT | ||
| 3675 | { | ||
| 3676 | 201 | $$ = reject_stmt_alloc(&@$); | |
| 3677 | } | ||
| 3678 | ; | ||
| 3679 | |||
| 3680 | reject_with_expr : STRING | ||
| 3681 | { | ||
| 3682 | 116 | $$ = symbol_expr_alloc(&@$, SYMBOL_VALUE, | |
| 3683 | current_scope(state), $1); | ||
| 3684 | 116 | free_const($1); | |
| 3685 | } | ||
| 3686 | 4 | | integer_expr { $$ = $1; } | |
| 3687 | ; | ||
| 3688 | |||
| 3689 | reject_opts : /* empty */ | ||
| 3690 | { | ||
| 3691 | 47 | $<stmt>0->reject.type = -1; | |
| 3692 | 47 | $<stmt>0->reject.icmp_code = -1; | |
| 3693 | } | ||
| 3694 | | WITH ICMP TYPE reject_with_expr close_scope_type close_scope_icmp | ||
| 3695 | { | ||
| 3696 | ✗ | $<stmt>0->reject.family = NFPROTO_IPV4; | |
| 3697 | ✗ | $<stmt>0->reject.type = NFT_REJECT_ICMP_UNREACH; | |
| 3698 | ✗ | $<stmt>0->reject.expr = $4; | |
| 3699 | ✗ | datatype_set($<stmt>0->reject.expr, &reject_icmp_code_type); | |
| 3700 | } | ||
| 3701 | | WITH ICMP reject_with_expr | ||
| 3702 | { | ||
| 3703 | 49 | $<stmt>0->reject.family = NFPROTO_IPV4; | |
| 3704 | 49 | $<stmt>0->reject.type = NFT_REJECT_ICMP_UNREACH; | |
| 3705 | 49 | $<stmt>0->reject.expr = $3; | |
| 3706 | 49 | datatype_set($<stmt>0->reject.expr, &reject_icmp_code_type); | |
| 3707 | } | ||
| 3708 | | WITH ICMP6 TYPE reject_with_expr close_scope_type close_scope_icmp | ||
| 3709 | { | ||
| 3710 | ✗ | $<stmt>0->reject.family = NFPROTO_IPV6; | |
| 3711 | ✗ | $<stmt>0->reject.type = NFT_REJECT_ICMP_UNREACH; | |
| 3712 | ✗ | $<stmt>0->reject.expr = $4; | |
| 3713 | ✗ | datatype_set($<stmt>0->reject.expr, &reject_icmpv6_code_type); | |
| 3714 | } | ||
| 3715 | | WITH ICMP6 reject_with_expr | ||
| 3716 | { | ||
| 3717 | 40 | $<stmt>0->reject.family = NFPROTO_IPV6; | |
| 3718 | 40 | $<stmt>0->reject.type = NFT_REJECT_ICMP_UNREACH; | |
| 3719 | 40 | $<stmt>0->reject.expr = $3; | |
| 3720 | 40 | datatype_set($<stmt>0->reject.expr, &reject_icmpv6_code_type); | |
| 3721 | } | ||
| 3722 | | WITH ICMPX TYPE reject_with_expr close_scope_type | ||
| 3723 | { | ||
| 3724 | 5 | $<stmt>0->reject.type = NFT_REJECT_ICMPX_UNREACH; | |
| 3725 | 5 | $<stmt>0->reject.expr = $4; | |
| 3726 | 5 | datatype_set($<stmt>0->reject.expr, &reject_icmpx_code_type); | |
| 3727 | } | ||
| 3728 | | WITH ICMPX reject_with_expr | ||
| 3729 | { | ||
| 3730 | 26 | $<stmt>0->reject.type = NFT_REJECT_ICMPX_UNREACH; | |
| 3731 | 26 | $<stmt>0->reject.expr = $3; | |
| 3732 | 26 | datatype_set($<stmt>0->reject.expr, &reject_icmpx_code_type); | |
| 3733 | } | ||
| 3734 | | WITH TCP close_scope_tcp RESET close_scope_reset | ||
| 3735 | { | ||
| 3736 | 34 | $<stmt>0->reject.type = NFT_REJECT_TCP_RST; | |
| 3737 | } | ||
| 3738 | ; | ||
| 3739 | |||
| 3740 | nat_stmt : nat_stmt_alloc nat_stmt_args | ||
| 3741 | ; | ||
| 3742 | |||
| 3743 | 71 | nat_stmt_alloc : SNAT { $$ = nat_stmt_alloc(&@$, __NFT_NAT_SNAT); } | |
| 3744 | 182 | | DNAT { $$ = nat_stmt_alloc(&@$, __NFT_NAT_DNAT); } | |
| 3745 | ; | ||
| 3746 | |||
| 3747 | tproxy_stmt : TPROXY TO stmt_expr | ||
| 3748 | { | ||
| 3749 | 9 | $$ = tproxy_stmt_alloc(&@$); | |
| 3750 | 9 | $$->tproxy.family = NFPROTO_UNSPEC; | |
| 3751 | 9 | $$->tproxy.addr = $3; | |
| 3752 | } | ||
| 3753 | | TPROXY nf_key_proto TO stmt_expr | ||
| 3754 | { | ||
| 3755 | 6 | $$ = tproxy_stmt_alloc(&@$); | |
| 3756 | 6 | $$->tproxy.family = $2; | |
| 3757 | 6 | $$->tproxy.addr = $4; | |
| 3758 | } | ||
| 3759 | | TPROXY TO COLON stmt_expr | ||
| 3760 | { | ||
| 3761 | 11 | $$ = tproxy_stmt_alloc(&@$); | |
| 3762 | 11 | $$->tproxy.family = NFPROTO_UNSPEC; | |
| 3763 | 11 | $$->tproxy.port = $4; | |
| 3764 | } | ||
| 3765 | | TPROXY TO stmt_expr COLON stmt_expr | ||
| 3766 | { | ||
| 3767 | 9 | $$ = tproxy_stmt_alloc(&@$); | |
| 3768 | 9 | $$->tproxy.family = NFPROTO_UNSPEC; | |
| 3769 | 9 | $$->tproxy.addr = $3; | |
| 3770 | 9 | $$->tproxy.port = $5; | |
| 3771 | } | ||
| 3772 | | TPROXY nf_key_proto TO stmt_expr COLON stmt_expr | ||
| 3773 | { | ||
| 3774 | 5 | $$ = tproxy_stmt_alloc(&@$); | |
| 3775 | 5 | $$->tproxy.family = $2; | |
| 3776 | 5 | $$->tproxy.addr = $4; | |
| 3777 | 5 | $$->tproxy.port = $6; | |
| 3778 | } | ||
| 3779 | | TPROXY nf_key_proto TO COLON stmt_expr | ||
| 3780 | { | ||
| 3781 | 5 | $$ = tproxy_stmt_alloc(&@$); | |
| 3782 | 5 | $$->tproxy.family = $2; | |
| 3783 | 5 | $$->tproxy.port = $5; | |
| 3784 | } | ||
| 3785 | ; | ||
| 3786 | |||
| 3787 | synproxy_stmt : synproxy_stmt_alloc | ||
| 3788 | | synproxy_stmt_alloc synproxy_args | ||
| 3789 | ; | ||
| 3790 | |||
| 3791 | synproxy_stmt_alloc : SYNPROXY | ||
| 3792 | { | ||
| 3793 | 20 | $$ = synproxy_stmt_alloc(&@$); | |
| 3794 | } | ||
| 3795 | ; | ||
| 3796 | |||
| 3797 | synproxy_args : synproxy_arg | ||
| 3798 | { | ||
| 3799 | 17 | $<stmt>$ = $<stmt>0; | |
| 3800 | } | ||
| 3801 | | synproxy_args synproxy_arg | ||
| 3802 | ; | ||
| 3803 | |||
| 3804 | synproxy_arg : MSS NUM | ||
| 3805 | { | ||
| 3806 | 6 | $<stmt>0->synproxy.mss = $2; | |
| 3807 | 6 | $<stmt>0->synproxy.flags |= NF_SYNPROXY_OPT_MSS; | |
| 3808 | } | ||
| 3809 | | WSCALE NUM | ||
| 3810 | { | ||
| 3811 | 6 | $<stmt>0->synproxy.wscale = $2; | |
| 3812 | 6 | $<stmt>0->synproxy.flags |= NF_SYNPROXY_OPT_WSCALE; | |
| 3813 | } | ||
| 3814 | | TIMESTAMP | ||
| 3815 | { | ||
| 3816 | 10 | $<stmt>0->synproxy.flags |= NF_SYNPROXY_OPT_TIMESTAMP; | |
| 3817 | } | ||
| 3818 | | SACK_PERM | ||
| 3819 | { | ||
| 3820 | 11 | $<stmt>0->synproxy.flags |= NF_SYNPROXY_OPT_SACK_PERM; | |
| 3821 | } | ||
| 3822 | ; | ||
| 3823 | |||
| 3824 | synproxy_config : MSS NUM WSCALE NUM synproxy_ts synproxy_sack | ||
| 3825 | { | ||
| 3826 | struct synproxy *synproxy; | ||
| 3827 | 2 | uint32_t flags = 0; | |
| 3828 | |||
| 3829 | 2 | synproxy = &$<obj>0->synproxy; | |
| 3830 | 2 | synproxy->mss = $2; | |
| 3831 | 2 | flags |= NF_SYNPROXY_OPT_MSS; | |
| 3832 | 2 | synproxy->wscale = $4; | |
| 3833 | 2 | flags |= NF_SYNPROXY_OPT_WSCALE; | |
| 3834 |
2/2✓ Branch 0 (1185→1186) taken 1 times.
✓ Branch 1 (1185→1187) taken 1 times.
|
2 | if ($5) |
| 3835 | 1 | flags |= $5; | |
| 3836 |
2/2✓ Branch 0 (1187→1188) taken 1 times.
✓ Branch 1 (1187→1189) taken 1 times.
|
2 | if ($6) |
| 3837 | 1 | flags |= $6; | |
| 3838 | 2 | synproxy->flags = flags; | |
| 3839 | } | ||
| 3840 | | MSS NUM stmt_separator WSCALE NUM stmt_separator synproxy_ts synproxy_sack | ||
| 3841 | { | ||
| 3842 | struct synproxy *synproxy; | ||
| 3843 | 10 | uint32_t flags = 0; | |
| 3844 | |||
| 3845 | 10 | synproxy = &$<obj>0->synproxy; | |
| 3846 | 10 | synproxy->mss = $2; | |
| 3847 | 10 | flags |= NF_SYNPROXY_OPT_MSS; | |
| 3848 | 10 | synproxy->wscale = $5; | |
| 3849 | 10 | flags |= NF_SYNPROXY_OPT_WSCALE; | |
| 3850 |
2/2✓ Branch 0 (1190→1191) taken 4 times.
✓ Branch 1 (1190→1192) taken 6 times.
|
10 | if ($7) |
| 3851 | 4 | flags |= $7; | |
| 3852 |
2/2✓ Branch 0 (1192→1193) taken 5 times.
✓ Branch 1 (1192→1194) taken 5 times.
|
10 | if ($8) |
| 3853 | 5 | flags |= $8; | |
| 3854 | 10 | synproxy->flags = flags; | |
| 3855 | } | ||
| 3856 | ; | ||
| 3857 | |||
| 3858 | synproxy_obj : /* empty */ | ||
| 3859 | { | ||
| 3860 | 2 | $$ = obj_alloc(&@$); | |
| 3861 | 2 | $$->type = NFT_OBJECT_SYNPROXY; | |
| 3862 | } | ||
| 3863 | ; | ||
| 3864 | |||
| 3865 | 7 | synproxy_ts : /* empty */ { $$ = 0; } | |
| 3866 | | TIMESTAMP | ||
| 3867 | { | ||
| 3868 | 5 | $$ = NF_SYNPROXY_OPT_TIMESTAMP; | |
| 3869 | } | ||
| 3870 | ; | ||
| 3871 | |||
| 3872 | 6 | synproxy_sack : /* empty */ { $$ = 0; } | |
| 3873 | | SACK_PERM | ||
| 3874 | { | ||
| 3875 | 6 | $$ = NF_SYNPROXY_OPT_SACK_PERM; | |
| 3876 | } | ||
| 3877 | ; | ||
| 3878 | |||
| 3879 | 527 | primary_stmt_expr : symbol_expr { $$ = $1; } | |
| 3880 | 739 | | integer_expr { $$ = $1; } | |
| 3881 | ✗ | | boolean_expr { $$ = $1; } | |
| 3882 | 206 | | meta_expr { $$ = $1; } | |
| 3883 | 5 | | rt_expr { $$ = $1; } | |
| 3884 | ✗ | | tunnel_expr { $$ = $1; } | |
| 3885 | 59 | | ct_expr { $$ = $1; } | |
| 3886 | 25 | | numgen_expr { $$ = $1; } | |
| 3887 | 8 | | hash_expr { $$ = $1; } | |
| 3888 | 594 | | payload_expr { $$ = $1; } | |
| 3889 | 14 | | keyword_expr { $$ = $1; } | |
| 3890 | ✗ | | socket_expr { $$ = $1; } | |
| 3891 | 2 | | fib_expr { $$ = $1; } | |
| 3892 | 8 | | osf_expr { $$ = $1; } | |
| 3893 | 13 | | '(' basic_stmt_expr ')' { $$ = $2; } | |
| 3894 | ; | ||
| 3895 | |||
| 3896 | shift_stmt_expr : primary_stmt_expr | ||
| 3897 | | shift_stmt_expr LSHIFT primary_stmt_expr | ||
| 3898 | { | ||
| 3899 | 38 | $$ = binop_expr_alloc(&@$, OP_LSHIFT, $1, $3); | |
| 3900 | } | ||
| 3901 | | shift_stmt_expr RSHIFT primary_stmt_expr | ||
| 3902 | { | ||
| 3903 | 6 | $$ = binop_expr_alloc(&@$, OP_RSHIFT, $1, $3); | |
| 3904 | } | ||
| 3905 | ; | ||
| 3906 | |||
| 3907 | and_stmt_expr : shift_stmt_expr | ||
| 3908 | | and_stmt_expr AMPERSAND shift_stmt_expr | ||
| 3909 | { | ||
| 3910 | 103 | $$ = binop_expr_alloc(&@$, OP_AND, $1, $3); | |
| 3911 | } | ||
| 3912 | ; | ||
| 3913 | |||
| 3914 | exclusive_or_stmt_expr : and_stmt_expr | ||
| 3915 | | exclusive_or_stmt_expr CARET and_stmt_expr | ||
| 3916 | { | ||
| 3917 | 27 | $$ = binop_expr_alloc(&@$, OP_XOR, $1, $3); | |
| 3918 | } | ||
| 3919 | ; | ||
| 3920 | |||
| 3921 | inclusive_or_stmt_expr : exclusive_or_stmt_expr | ||
| 3922 | | inclusive_or_stmt_expr '|' exclusive_or_stmt_expr | ||
| 3923 | { | ||
| 3924 | 219 | $$ = binop_expr_alloc(&@$, OP_OR, $1, $3); | |
| 3925 | } | ||
| 3926 | ; | ||
| 3927 | |||
| 3928 | basic_stmt_expr : inclusive_or_stmt_expr | ||
| 3929 | ; | ||
| 3930 | |||
| 3931 | concat_stmt_expr : basic_stmt_expr | ||
| 3932 | | concat_stmt_expr DOT primary_stmt_expr | ||
| 3933 | { | ||
| 3934 | 256 | struct location rhs[] = { | |
| 3935 | [1] = @2, | ||
| 3936 | [2] = @3, | ||
| 3937 | }; | ||
| 3938 | |||
| 3939 | 256 | $$ = handle_concat_expr(&@$, $$, $1, $3, rhs); | |
| 3940 | } | ||
| 3941 | ; | ||
| 3942 | |||
| 3943 | map_stmt_expr_set : set_expr | ||
| 3944 | | set_ref_expr | ||
| 3945 | ; | ||
| 3946 | |||
| 3947 | map_stmt_expr : concat_stmt_expr MAP map_stmt_expr_set | ||
| 3948 | { | ||
| 3949 | 394 | $$ = map_expr_alloc(&@$, $1, $3); | |
| 3950 | } | ||
| 3951 | 1084 | | concat_stmt_expr { $$ = $1; } | |
| 3952 | ; | ||
| 3953 | |||
| 3954 | prefix_stmt_expr : basic_stmt_expr SLASH NUM | ||
| 3955 | { | ||
| 3956 | 7 | $$ = prefix_expr_alloc(&@$, $1, $3); | |
| 3957 | } | ||
| 3958 | ; | ||
| 3959 | |||
| 3960 | range_stmt_expr : basic_stmt_expr DASH basic_stmt_expr | ||
| 3961 | { | ||
| 3962 | 26 | $$ = range_expr_alloc(&@$, $1, $3); | |
| 3963 | } | ||
| 3964 | ; | ||
| 3965 | |||
| 3966 | multiton_stmt_expr : prefix_stmt_expr | ||
| 3967 | | range_stmt_expr | ||
| 3968 | ; | ||
| 3969 | |||
| 3970 | stmt_expr : map_stmt_expr | ||
| 3971 | | multiton_stmt_expr | ||
| 3972 | | list_stmt_expr | ||
| 3973 | ; | ||
| 3974 | |||
| 3975 | nat_stmt_args : stmt_expr | ||
| 3976 | { | ||
| 3977 | 8 | $<stmt>0->nat.addr = $1; | |
| 3978 | } | ||
| 3979 | | TO stmt_expr | ||
| 3980 | { | ||
| 3981 | 81 | $<stmt>0->nat.addr = $2; | |
| 3982 | } | ||
| 3983 | | nf_key_proto TO stmt_expr | ||
| 3984 | { | ||
| 3985 | 75 | $<stmt>0->nat.family = $1; | |
| 3986 | 75 | $<stmt>0->nat.addr = $3; | |
| 3987 | } | ||
| 3988 | | stmt_expr COLON stmt_expr | ||
| 3989 | { | ||
| 3990 | ✗ | $<stmt>0->nat.addr = $1; | |
| 3991 | ✗ | $<stmt>0->nat.proto = $3; | |
| 3992 | } | ||
| 3993 | | TO stmt_expr COLON stmt_expr | ||
| 3994 | { | ||
| 3995 | 49 | $<stmt>0->nat.addr = $2; | |
| 3996 | 49 | $<stmt>0->nat.proto = $4; | |
| 3997 | } | ||
| 3998 | | nf_key_proto TO stmt_expr COLON stmt_expr | ||
| 3999 | { | ||
| 4000 | 18 | $<stmt>0->nat.family = $1; | |
| 4001 | 18 | $<stmt>0->nat.addr = $3; | |
| 4002 | 18 | $<stmt>0->nat.proto = $5; | |
| 4003 | } | ||
| 4004 | | COLON stmt_expr | ||
| 4005 | { | ||
| 4006 | ✗ | $<stmt>0->nat.proto = $2; | |
| 4007 | } | ||
| 4008 | | TO COLON stmt_expr | ||
| 4009 | { | ||
| 4010 | 2 | $<stmt>0->nat.proto = $3; | |
| 4011 | } | ||
| 4012 | | nat_stmt_args nf_nat_flags | ||
| 4013 | { | ||
| 4014 | 2 | $<stmt>0->nat.flags = $2; | |
| 4015 | } | ||
| 4016 | | nf_key_proto ADDR DOT PORT TO stmt_expr | ||
| 4017 | { | ||
| 4018 | 13 | $<stmt>0->nat.family = $1; | |
| 4019 | 13 | $<stmt>0->nat.addr = $6; | |
| 4020 | 13 | $<stmt>0->nat.type_flags = STMT_NAT_F_CONCAT; | |
| 4021 | } | ||
| 4022 | | nf_key_proto INTERVAL TO stmt_expr | ||
| 4023 | { | ||
| 4024 | ✗ | $<stmt>0->nat.family = $1; | |
| 4025 | ✗ | $<stmt>0->nat.addr = $4; | |
| 4026 | } | ||
| 4027 | | INTERVAL TO stmt_expr | ||
| 4028 | { | ||
| 4029 | ✗ | $<stmt>0->nat.addr = $3; | |
| 4030 | } | ||
| 4031 | | nf_key_proto PREFIX TO stmt_expr | ||
| 4032 | { | ||
| 4033 | 7 | $<stmt>0->nat.family = $1; | |
| 4034 | 7 | $<stmt>0->nat.addr = $4; | |
| 4035 | 7 | $<stmt>0->nat.type_flags = | |
| 4036 | STMT_NAT_F_PREFIX; | ||
| 4037 | 7 | $<stmt>0->nat.flags |= NF_NAT_RANGE_NETMAP; | |
| 4038 | } | ||
| 4039 | | PREFIX TO stmt_expr | ||
| 4040 | { | ||
| 4041 | ✗ | $<stmt>0->nat.addr = $3; | |
| 4042 | ✗ | $<stmt>0->nat.type_flags = | |
| 4043 | STMT_NAT_F_PREFIX; | ||
| 4044 | ✗ | $<stmt>0->nat.flags |= NF_NAT_RANGE_NETMAP; | |
| 4045 | } | ||
| 4046 | ; | ||
| 4047 | |||
| 4048 | masq_stmt : masq_stmt_alloc masq_stmt_args | ||
| 4049 | | masq_stmt_alloc | ||
| 4050 | ; | ||
| 4051 | |||
| 4052 | 80 | masq_stmt_alloc : MASQUERADE { $$ = nat_stmt_alloc(&@$, NFT_NAT_MASQ); } | |
| 4053 | ; | ||
| 4054 | |||
| 4055 | masq_stmt_args : TO COLON stmt_expr | ||
| 4056 | { | ||
| 4057 | 4 | $<stmt>0->nat.proto = $3; | |
| 4058 | } | ||
| 4059 | | TO COLON stmt_expr nf_nat_flags | ||
| 4060 | { | ||
| 4061 | ✗ | $<stmt>0->nat.proto = $3; | |
| 4062 | ✗ | $<stmt>0->nat.flags = $4; | |
| 4063 | } | ||
| 4064 | | nf_nat_flags | ||
| 4065 | { | ||
| 4066 | 33 | $<stmt>0->nat.flags = $1; | |
| 4067 | } | ||
| 4068 | ; | ||
| 4069 | |||
| 4070 | redir_stmt : redir_stmt_alloc redir_stmt_arg | ||
| 4071 | | redir_stmt_alloc | ||
| 4072 | ; | ||
| 4073 | |||
| 4074 | 106 | redir_stmt_alloc : REDIRECT { $$ = nat_stmt_alloc(&@$, NFT_NAT_REDIR); } | |
| 4075 | ; | ||
| 4076 | |||
| 4077 | redir_stmt_arg : TO stmt_expr | ||
| 4078 | { | ||
| 4079 | ✗ | $<stmt>0->nat.proto = $2; | |
| 4080 | } | ||
| 4081 | | TO COLON stmt_expr | ||
| 4082 | { | ||
| 4083 | 42 | $<stmt>0->nat.proto = $3; | |
| 4084 | } | ||
| 4085 | | nf_nat_flags | ||
| 4086 | { | ||
| 4087 | 30 | $<stmt>0->nat.flags = $1; | |
| 4088 | } | ||
| 4089 | | TO stmt_expr nf_nat_flags | ||
| 4090 | { | ||
| 4091 | ✗ | $<stmt>0->nat.proto = $2; | |
| 4092 | ✗ | $<stmt>0->nat.flags = $3; | |
| 4093 | } | ||
| 4094 | | TO COLON stmt_expr nf_nat_flags | ||
| 4095 | { | ||
| 4096 | 6 | $<stmt>0->nat.proto = $3; | |
| 4097 | 6 | $<stmt>0->nat.flags = $4; | |
| 4098 | } | ||
| 4099 | ; | ||
| 4100 | |||
| 4101 | dup_stmt : DUP TO stmt_expr | ||
| 4102 | { | ||
| 4103 | 7 | $$ = dup_stmt_alloc(&@$); | |
| 4104 | 7 | $$->dup.to = $3; | |
| 4105 | } | ||
| 4106 | | DUP TO stmt_expr DEVICE stmt_expr | ||
| 4107 | { | ||
| 4108 | 5 | $$ = dup_stmt_alloc(&@$); | |
| 4109 | 5 | $$->dup.to = $3; | |
| 4110 | 5 | $$->dup.dev = $5; | |
| 4111 | } | ||
| 4112 | ; | ||
| 4113 | |||
| 4114 | fwd_stmt : FWD TO stmt_expr | ||
| 4115 | { | ||
| 4116 | 5 | $$ = fwd_stmt_alloc(&@$); | |
| 4117 | 5 | $$->fwd.dev = $3; | |
| 4118 | } | ||
| 4119 | | FWD nf_key_proto TO stmt_expr DEVICE stmt_expr | ||
| 4120 | { | ||
| 4121 | 2 | $$ = fwd_stmt_alloc(&@$); | |
| 4122 | 2 | $$->fwd.family = $2; | |
| 4123 | 2 | $$->fwd.addr = $4; | |
| 4124 | 2 | $$->fwd.dev = $6; | |
| 4125 | } | ||
| 4126 | ; | ||
| 4127 | |||
| 4128 | nf_nat_flags : nf_nat_flag | ||
| 4129 | | nf_nat_flags COMMA nf_nat_flag | ||
| 4130 | { | ||
| 4131 | 85 | $$ = $1 | $3; | |
| 4132 | } | ||
| 4133 | ; | ||
| 4134 | |||
| 4135 | 55 | nf_nat_flag : RANDOM { $$ = NF_NAT_RANGE_PROTO_RANDOM; } | |
| 4136 | 45 | | FULLY_RANDOM { $$ = NF_NAT_RANGE_PROTO_RANDOM_FULLY; } | |
| 4137 | 60 | | PERSISTENT { $$ = NF_NAT_RANGE_PERSISTENT; } | |
| 4138 | ; | ||
| 4139 | |||
| 4140 | queue_stmt : queue_stmt_compat close_scope_queue | ||
| 4141 | | QUEUE TO queue_stmt_expr close_scope_queue | ||
| 4142 | { | ||
| 4143 | 47 | $$ = queue_stmt_alloc(&@$, $3, 0); | |
| 4144 | } | ||
| 4145 | | QUEUE FLAGS queue_stmt_flags TO queue_stmt_expr close_scope_queue | ||
| 4146 | { | ||
| 4147 | 49 | $$ = queue_stmt_alloc(&@$, $5, $3); | |
| 4148 | } | ||
| 4149 | | QUEUE FLAGS queue_stmt_flags QUEUENUM queue_stmt_expr_simple close_scope_queue | ||
| 4150 | { | ||
| 4151 | 1 | $$ = queue_stmt_alloc(&@$, $5, $3); | |
| 4152 | } | ||
| 4153 | ; | ||
| 4154 | |||
| 4155 | queue_stmt_compat : queue_stmt_alloc | ||
| 4156 | | queue_stmt_alloc queue_stmt_args | ||
| 4157 | ; | ||
| 4158 | |||
| 4159 | queue_stmt_alloc : QUEUE | ||
| 4160 | { | ||
| 4161 | 46 | $$ = queue_stmt_alloc(&@$, NULL, 0); | |
| 4162 | } | ||
| 4163 | ; | ||
| 4164 | |||
| 4165 | queue_stmt_args : queue_stmt_arg | ||
| 4166 | { | ||
| 4167 | 34 | $<stmt>$ = $<stmt>0; | |
| 4168 | } | ||
| 4169 | | queue_stmt_args queue_stmt_arg | ||
| 4170 | ; | ||
| 4171 | |||
| 4172 | queue_stmt_arg : QUEUENUM queue_stmt_expr_simple | ||
| 4173 | { | ||
| 4174 | 34 | $<stmt>0->queue.queue = $2; | |
| 4175 | 34 | $<stmt>0->queue.queue->location = @$; | |
| 4176 | } | ||
| 4177 | | queue_stmt_flags | ||
| 4178 | { | ||
| 4179 | 17 | $<stmt>0->queue.flags |= $1; | |
| 4180 | } | ||
| 4181 | ; | ||
| 4182 | |||
| 4183 | queue_expr : variable_expr | ||
| 4184 | | integer_expr | ||
| 4185 | ; | ||
| 4186 | |||
| 4187 | queue_stmt_expr_simple : integer_expr | ||
| 4188 | | variable_expr | ||
| 4189 | | queue_expr DASH queue_expr | ||
| 4190 | { | ||
| 4191 | 57 | $$ = range_expr_alloc(&@$, $1, $3); | |
| 4192 | } | ||
| 4193 | ; | ||
| 4194 | |||
| 4195 | queue_stmt_expr : numgen_expr | ||
| 4196 | | hash_expr | ||
| 4197 | | map_expr | ||
| 4198 | | queue_stmt_expr_simple | ||
| 4199 | ; | ||
| 4200 | |||
| 4201 | queue_stmt_flags : queue_stmt_flag | ||
| 4202 | | queue_stmt_flags COMMA queue_stmt_flag | ||
| 4203 | { | ||
| 4204 | 16 | $$ = $1 | $3; | |
| 4205 | } | ||
| 4206 | ; | ||
| 4207 | |||
| 4208 | 51 | queue_stmt_flag : BYPASS { $$ = NFT_QUEUE_FLAG_BYPASS; } | |
| 4209 | 32 | | FANOUT { $$ = NFT_QUEUE_FLAG_CPU_FANOUT; } | |
| 4210 | ; | ||
| 4211 | |||
| 4212 | set_elem_expr_stmt : set_elem_expr_stmt_alloc | ||
| 4213 | | set_elem_expr_stmt_alloc set_elem_options | ||
| 4214 | ; | ||
| 4215 | |||
| 4216 | set_elem_expr_stmt_alloc: concat_expr | ||
| 4217 | { | ||
| 4218 | 1160 | $$ = set_elem_expr_alloc(&@1, $1); | |
| 4219 | } | ||
| 4220 | ; | ||
| 4221 | |||
| 4222 | set_stmt : SET set_stmt_op set_elem_expr_stmt set_ref_expr | ||
| 4223 | { | ||
| 4224 | 2 | $$ = set_stmt_alloc(&@$); | |
| 4225 | 2 | $$->set.op = $2; | |
| 4226 | 2 | $$->set.key = $3; | |
| 4227 | 2 | $$->set.set = $4; | |
| 4228 | } | ||
| 4229 | | set_stmt_op set_ref_expr '{' set_elem_expr_stmt '}' | ||
| 4230 | { | ||
| 4231 | 1067 | $$ = set_stmt_alloc(&@$); | |
| 4232 | 1067 | $$->set.op = $1; | |
| 4233 | 1067 | $$->set.key = $4; | |
| 4234 | 1067 | $$->set.set = $2; | |
| 4235 | } | ||
| 4236 | | set_stmt_op set_ref_expr '{' set_elem_expr_stmt stateful_stmt_list '}' | ||
| 4237 | { | ||
| 4238 | 17 | $$ = set_stmt_alloc(&@$); | |
| 4239 | 17 | $$->set.op = $1; | |
| 4240 | 17 | $$->set.key = $4; | |
| 4241 | 17 | $$->set.set = $2; | |
| 4242 | 17 | list_splice_tail($5, &$$->set.stmt_list); | |
| 4243 | 17 | free($5); | |
| 4244 | } | ||
| 4245 | ; | ||
| 4246 | |||
| 4247 | 67 | set_stmt_op : ADD { $$ = NFT_DYNSET_OP_ADD; } | |
| 4248 | 1049 | | UPDATE { $$ = NFT_DYNSET_OP_UPDATE; } | |
| 4249 | 8 | | DELETE { $$ = NFT_DYNSET_OP_DELETE; } | |
| 4250 | ; | ||
| 4251 | |||
| 4252 | map_stmt : set_stmt_op set_ref_expr '{' set_elem_expr_stmt COLON set_elem_expr_stmt '}' | ||
| 4253 | { | ||
| 4254 | 37 | $$ = map_stmt_alloc(&@$); | |
| 4255 | 37 | $$->map.op = $1; | |
| 4256 | 37 | $$->map.key = $4; | |
| 4257 | 37 | $$->map.data = $6; | |
| 4258 | 37 | $$->map.set = $2; | |
| 4259 | } | ||
| 4260 | | set_stmt_op set_ref_expr '{' set_elem_expr_stmt stateful_stmt_list COLON set_elem_expr_stmt '}' | ||
| 4261 | { | ||
| 4262 | ✗ | $$ = map_stmt_alloc(&@$); | |
| 4263 | ✗ | $$->map.op = $1; | |
| 4264 | ✗ | $$->map.key = $4; | |
| 4265 | ✗ | $$->map.data = $7; | |
| 4266 | ✗ | $$->map.set = $2; | |
| 4267 | ✗ | list_splice_tail($5, &$$->map.stmt_list); | |
| 4268 | ✗ | free($5); | |
| 4269 | } | ||
| 4270 | ; | ||
| 4271 | |||
| 4272 | meter_stmt : METER identifier '{' meter_key_expr stmt '}' | ||
| 4273 | { | ||
| 4274 | 2 | $$ = meter_stmt_alloc(&@$); | |
| 4275 | 2 | $$->meter.name = $2; | |
| 4276 | 2 | $$->meter.size = 0; | |
| 4277 | 2 | $$->meter.key = $4; | |
| 4278 | 2 | $$->meter.stmt = $5; | |
| 4279 | 2 | $$->location = @$; | |
| 4280 | } | ||
| 4281 | | METER identifier SIZE NUM '{' meter_key_expr stmt '}' | ||
| 4282 | { | ||
| 4283 | 5 | $$ = meter_stmt_alloc(&@$); | |
| 4284 | 5 | $$->meter.name = $2; | |
| 4285 | 5 | $$->meter.size = $4; | |
| 4286 | 5 | $$->meter.key = $6; | |
| 4287 | 5 | $$->meter.stmt = $7; | |
| 4288 | 5 | $$->location = @$; | |
| 4289 | } | ||
| 4290 | ; | ||
| 4291 | |||
| 4292 | match_stmt : relational_expr | ||
| 4293 | { | ||
| 4294 | 51045 | $$ = expr_stmt_alloc(&@$, $1); | |
| 4295 | } | ||
| 4296 | ; | ||
| 4297 | |||
| 4298 | variable_expr : '$' identifier | ||
| 4299 | { | ||
| 4300 | 20221 | struct scope *scope = current_scope(state); | |
| 4301 | struct symbol *sym; | ||
| 4302 | |||
| 4303 | 20221 | sym = symbol_get(scope, $2); | |
| 4304 |
2/2✓ Branch 0 (1314→1315) taken 9 times.
✓ Branch 1 (1314→1322) taken 20212 times.
|
20221 | if (!sym) { |
| 4305 | 9 | sym = symbol_lookup_fuzzy(scope, $2); | |
| 4306 |
2/2✓ Branch 0 (1316→1317) taken 1 times.
✓ Branch 1 (1316→1319) taken 8 times.
|
9 | if (sym) { |
| 4307 | 1 | erec_queue(error(&@2, "unknown identifier '%s'; " | |
| 4308 | "did you mean identifier '%s'?", | ||
| 4309 | $2, sym->identifier), | ||
| 4310 | state->msgs); | ||
| 4311 | } else { | ||
| 4312 | 8 | erec_queue(error(&@2, "unknown identifier '%s'", $2), | |
| 4313 | state->msgs); | ||
| 4314 | } | ||
| 4315 | 9 | free_const($2); | |
| 4316 | 9 | YYERROR; | |
| 4317 | } | ||
| 4318 | |||
| 4319 | 20212 | $$ = variable_expr_alloc(&@$, scope, sym); | |
| 4320 | 20212 | free_const($2); | |
| 4321 | } | ||
| 4322 | ; | ||
| 4323 | |||
| 4324 | symbol_expr : variable_expr | ||
| 4325 | | string | ||
| 4326 | { | ||
| 4327 | 825849 | $$ = symbol_expr_alloc(&@$, SYMBOL_VALUE, | |
| 4328 | current_scope(state), | ||
| 4329 | $1); | ||
| 4330 | 815271 | free_const($1); | |
| 4331 | } | ||
| 4332 | ; | ||
| 4333 | |||
| 4334 | set_ref_expr : set_ref_symbol_expr | ||
| 4335 | | variable_expr | ||
| 4336 | ; | ||
| 4337 | |||
| 4338 | set_ref_symbol_expr : AT identifier close_scope_at | ||
| 4339 | { | ||
| 4340 | 2937 | $$ = symbol_expr_alloc(&@$, SYMBOL_SET, | |
| 4341 | current_scope(state), | ||
| 4342 | 2937 | $2); | |
| 4343 | 2937 | free_const($2); | |
| 4344 | } | ||
| 4345 | ; | ||
| 4346 | |||
| 4347 | integer_expr : NUM | ||
| 4348 | { | ||
| 4349 | char str[64]; | ||
| 4350 | |||
| 4351 | 255179 | snprintf(str, sizeof(str), "%" PRIu64, $1); | |
| 4352 | 255179 | $$ = symbol_expr_alloc(&@$, SYMBOL_VALUE, | |
| 4353 | current_scope(state), | ||
| 4354 | str); | ||
| 4355 | } | ||
| 4356 | ; | ||
| 4357 | |||
| 4358 | 12248 | selector_expr : payload_expr { $$ = $1; } | |
| 4359 | 377 | | exthdr_expr { $$ = $1; } | |
| 4360 | 16 | | exthdr_exists_expr { $$ = $1; } | |
| 4361 | 43081 | | meta_expr { $$ = $1; } | |
| 4362 | 3 | | tunnel_expr { $$ = $1; } | |
| 4363 | 22 | | socket_expr { $$ = $1; } | |
| 4364 | 24 | | rt_expr { $$ = $1; } | |
| 4365 | 580 | | ct_expr { $$ = $1; } | |
| 4366 | 17 | | numgen_expr { $$ = $1; } | |
| 4367 | ✗ | | hash_expr { $$ = $1; } | |
| 4368 | 38 | | fib_expr { $$ = $1; } | |
| 4369 | 34 | | osf_expr { $$ = $1; } | |
| 4370 | 47 | | xfrm_expr { $$ = $1; } | |
| 4371 | ; | ||
| 4372 | |||
| 4373 | 61 | primary_expr : symbol_expr { $$ = $1; } | |
| 4374 | 46 | | integer_expr { $$ = $1; } | |
| 4375 | 54259 | | selector_expr { $$ = $1; } | |
| 4376 | ✗ | | '(' basic_expr ')' { $$ = $2; } | |
| 4377 | ; | ||
| 4378 | |||
| 4379 | fib_expr : FIB fib_tuple fib_result close_scope_fib | ||
| 4380 | { | ||
| 4381 | 46 | uint32_t flags = $2, result = $3; | |
| 4382 | |||
| 4383 |
2/2✓ Branch 0 (1350→1351) taken 13 times.
✓ Branch 1 (1350→1352) taken 33 times.
|
46 | if (result == __NFT_FIB_RESULT_MAX) { |
| 4384 | 13 | result = NFT_FIB_RESULT_OIF; | |
| 4385 | 13 | flags |= NFTA_FIB_F_PRESENT; | |
| 4386 | } | ||
| 4387 | |||
| 4388 |
2/2✓ Branch 0 (1352→1353) taken 2 times.
✓ Branch 1 (1352→1356) taken 44 times.
|
46 | if ((flags & (NFTA_FIB_F_SADDR|NFTA_FIB_F_DADDR)) == 0) { |
| 4389 | 2 | erec_queue(error(&@2, "fib: need either saddr or daddr"), state->msgs); | |
| 4390 | 2 | YYERROR; | |
| 4391 | } | ||
| 4392 | |||
| 4393 |
2/2✓ Branch 0 (1356→1357) taken 2 times.
✓ Branch 1 (1356→1360) taken 42 times.
|
44 | if ((flags & (NFTA_FIB_F_SADDR|NFTA_FIB_F_DADDR)) == |
| 4394 | (NFTA_FIB_F_SADDR|NFTA_FIB_F_DADDR)) { | ||
| 4395 | 2 | erec_queue(error(&@2, "fib: saddr and daddr are mutually exclusive"), state->msgs); | |
| 4396 | 2 | YYERROR; | |
| 4397 | } | ||
| 4398 | |||
| 4399 |
2/2✓ Branch 0 (1360→1361) taken 2 times.
✓ Branch 1 (1360→1364) taken 40 times.
|
42 | if ((flags & (NFTA_FIB_F_IIF|NFTA_FIB_F_OIF)) == |
| 4400 | (NFTA_FIB_F_IIF|NFTA_FIB_F_OIF)) { | ||
| 4401 | 2 | erec_queue(error(&@2, "fib: iif and oif are mutually exclusive"), state->msgs); | |
| 4402 | 2 | YYERROR; | |
| 4403 | } | ||
| 4404 | |||
| 4405 | 40 | $$ = fib_expr_alloc(&@$, flags, result); | |
| 4406 | } | ||
| 4407 | ; | ||
| 4408 | |||
| 4409 | 14 | fib_result : OIF { $$ =NFT_FIB_RESULT_OIF; } | |
| 4410 | 4 | | OIFNAME { $$ =NFT_FIB_RESULT_OIFNAME; } | |
| 4411 | 15 | | TYPE close_scope_type { $$ =NFT_FIB_RESULT_ADDRTYPE; } | |
| 4412 | 13 | | CHECK { $$ = __NFT_FIB_RESULT_MAX; } /* actually, NFT_FIB_F_PRESENT. */ | |
| 4413 | ; | ||
| 4414 | |||
| 4415 | 18 | fib_flag : SADDR { $$ = NFTA_FIB_F_SADDR; } | |
| 4416 | 28 | | DADDR { $$ = NFTA_FIB_F_DADDR; } | |
| 4417 | 2 | | MARK { $$ = NFTA_FIB_F_MARK; } | |
| 4418 | 18 | | IIF { $$ = NFTA_FIB_F_IIF; } | |
| 4419 | 5 | | OIF { $$ = NFTA_FIB_F_OIF; } | |
| 4420 | ; | ||
| 4421 | |||
| 4422 | fib_tuple : fib_flag DOT fib_tuple | ||
| 4423 | { | ||
| 4424 | 25 | $$ = $1 | $3; | |
| 4425 | } | ||
| 4426 | | fib_flag | ||
| 4427 | ; | ||
| 4428 | |||
| 4429 | osf_expr : OSF osf_ttl HDRVERSION close_scope_osf | ||
| 4430 | { | ||
| 4431 | 12 | $$ = osf_expr_alloc(&@$, $2, NFT_OSF_F_VERSION); | |
| 4432 | } | ||
| 4433 | | OSF osf_ttl NAME close_scope_osf | ||
| 4434 | { | ||
| 4435 | 30 | $$ = osf_expr_alloc(&@$, $2, 0); | |
| 4436 | } | ||
| 4437 | ; | ||
| 4438 | |||
| 4439 | 30 | osf_ttl : /* empty */ { $$ = NF_OSF_TTL_TRUE; } | |
| 4440 | 3 | | TTL LOOSE { $$ = NF_OSF_TTL_LESS; } | |
| 4441 | 9 | | TTL SKIP { $$ = NF_OSF_TTL_NOCHECK; } | |
| 4442 | ; | ||
| 4443 | |||
| 4444 | shift_expr : primary_expr | ||
| 4445 | | shift_expr LSHIFT primary_rhs_expr | ||
| 4446 | { | ||
| 4447 | 1 | $$ = binop_expr_alloc(&@$, OP_LSHIFT, $1, $3); | |
| 4448 | } | ||
| 4449 | | shift_expr RSHIFT primary_rhs_expr | ||
| 4450 | { | ||
| 4451 | 2 | $$ = binop_expr_alloc(&@$, OP_RSHIFT, $1, $3); | |
| 4452 | } | ||
| 4453 | ; | ||
| 4454 | |||
| 4455 | and_expr : shift_expr | ||
| 4456 | | and_expr AMPERSAND shift_rhs_expr | ||
| 4457 | { | ||
| 4458 | 240 | $$ = binop_expr_alloc(&@$, OP_AND, $1, $3); | |
| 4459 | } | ||
| 4460 | ; | ||
| 4461 | |||
| 4462 | exclusive_or_expr : and_expr | ||
| 4463 | | exclusive_or_expr CARET and_rhs_expr | ||
| 4464 | { | ||
| 4465 | 82 | $$ = binop_expr_alloc(&@$, OP_XOR, $1, $3); | |
| 4466 | } | ||
| 4467 | ; | ||
| 4468 | |||
| 4469 | inclusive_or_expr : exclusive_or_expr | ||
| 4470 | | inclusive_or_expr '|' exclusive_or_rhs_expr | ||
| 4471 | { | ||
| 4472 | 40 | $$ = binop_expr_alloc(&@$, OP_OR, $1, $3); | |
| 4473 | } | ||
| 4474 | ; | ||
| 4475 | |||
| 4476 | basic_expr : inclusive_or_expr | ||
| 4477 | ; | ||
| 4478 | |||
| 4479 | concat_expr : basic_expr | ||
| 4480 | | concat_expr DOT basic_expr | ||
| 4481 | { | ||
| 4482 | 1631 | struct location rhs[] = { | |
| 4483 | [1] = @2, | ||
| 4484 | [2] = @3, | ||
| 4485 | }; | ||
| 4486 | |||
| 4487 | 1631 | $$ = handle_concat_expr(&@$, $$, $1, $3, rhs); | |
| 4488 | } | ||
| 4489 | ; | ||
| 4490 | |||
| 4491 | prefix_rhs_expr : basic_rhs_expr SLASH NUM | ||
| 4492 | { | ||
| 4493 | 143568 | $$ = prefix_expr_alloc(&@$, $1, $3); | |
| 4494 | } | ||
| 4495 | ; | ||
| 4496 | |||
| 4497 | range_rhs_expr : basic_rhs_expr DASH basic_rhs_expr | ||
| 4498 | { | ||
| 4499 |
3/4✓ Branch 0 (1397→1398) taken 15557 times.
✓ Branch 1 (1397→1404) taken 3559 times.
✓ Branch 2 (1398→1399) taken 15557 times.
✗ Branch 3 (1398→1404) not taken.
|
19116 | if (is_symbol_value_expr($1) && |
| 4500 |
3/4✓ Branch 0 (1399→1400) taken 15556 times.
✓ Branch 1 (1399→1404) taken 1 times.
✓ Branch 2 (1400→1401) taken 15556 times.
✗ Branch 3 (1400→1404) not taken.
|
15557 | is_symbol_value_expr($3)) { |
| 4501 | 15556 | $$ = symbol_range_expr_alloc(&@$, $1->symtype, $1->scope, $1->identifier, $3->identifier); | |
| 4502 | 15556 | expr_free($1); | |
| 4503 | 15556 | expr_free($3); | |
| 4504 | } else { | ||
| 4505 | 3560 | $$ = range_expr_alloc(&@$, $1, $3); | |
| 4506 | } | ||
| 4507 | } | ||
| 4508 | ; | ||
| 4509 | |||
| 4510 | multiton_rhs_expr : prefix_rhs_expr | ||
| 4511 | | range_rhs_expr | ||
| 4512 | ; | ||
| 4513 | |||
| 4514 | map_expr : concat_expr MAP rhs_expr | ||
| 4515 | { | ||
| 4516 | 10 | $$ = map_expr_alloc(&@$, $1, $3); | |
| 4517 | } | ||
| 4518 | ; | ||
| 4519 | |||
| 4520 | expr : concat_expr | ||
| 4521 | | set_expr | ||
| 4522 | | map_expr | ||
| 4523 | ; | ||
| 4524 | |||
| 4525 | set_expr : '{' set_list_expr '}' | ||
| 4526 | { | ||
| 4527 | 38390 | $2->location = @$; | |
| 4528 | 38390 | $$ = $2; | |
| 4529 | } | ||
| 4530 | ; | ||
| 4531 | |||
| 4532 | set_list_expr : set_list_member_expr | ||
| 4533 | { | ||
| 4534 | 38392 | $$ = set_expr_alloc(&@$, NULL); | |
| 4535 | 31362 | set_expr_add($$, $1); | |
| 4536 | } | ||
| 4537 | | set_list_expr COMMA set_list_member_expr | ||
| 4538 | { | ||
| 4539 | 865712 | set_expr_add($1, $3); | |
| 4540 | 865660 | $$ = $1; | |
| 4541 | } | ||
| 4542 | | set_list_expr COMMA opt_newline | ||
| 4543 | ; | ||
| 4544 | |||
| 4545 | set_list_member_expr : opt_newline set_expr opt_newline | ||
| 4546 | { | ||
| 4547 | 1262 | $$ = $2; | |
| 4548 | } | ||
| 4549 | | opt_newline set_elem_expr opt_newline | ||
| 4550 | { | ||
| 4551 | 739224 | $$ = $2; | |
| 4552 | } | ||
| 4553 | | opt_newline set_elem_expr COLON set_rhs_expr opt_newline | ||
| 4554 | { | ||
| 4555 | 163618 | $$ = mapping_expr_alloc(&@2, $2, $4); | |
| 4556 | } | ||
| 4557 | ; | ||
| 4558 | |||
| 4559 | meter_key_expr : meter_key_expr_alloc | ||
| 4560 | | meter_key_expr_alloc set_elem_options | ||
| 4561 | { | ||
| 4562 | 3 | $$->location = @$; | |
| 4563 | 3 | $$ = $1; | |
| 4564 | } | ||
| 4565 | ; | ||
| 4566 | |||
| 4567 | meter_key_expr_alloc : concat_expr | ||
| 4568 | { | ||
| 4569 | 7 | $$ = set_elem_expr_alloc(&@1, $1); | |
| 4570 | } | ||
| 4571 | ; | ||
| 4572 | |||
| 4573 | set_elem_expr : set_elem_expr_alloc | ||
| 4574 | | set_elem_expr_alloc set_elem_expr_options | ||
| 4575 | | set_elem_expr_alloc set_elem_expr_options set_elem_stmt_list | ||
| 4576 | { | ||
| 4577 | 1 | $$ = $1; | |
| 4578 | 1 | list_splice_tail($3, &$$->stmt_list); | |
| 4579 | 1 | free($3); | |
| 4580 | } | ||
| 4581 | ; | ||
| 4582 | |||
| 4583 | 903473 | set_elem_key_expr : set_lhs_expr { $$ = $1; } | |
| 4584 | 58 | | ASTERISK { $$ = set_elem_catchall_expr_alloc(&@1); } | |
| 4585 | ; | ||
| 4586 | |||
| 4587 | set_elem_expr_alloc : set_elem_key_expr set_elem_stmt_list | ||
| 4588 | { | ||
| 4589 | 106 | $$ = set_elem_expr_alloc(&@1, $1); | |
| 4590 | 106 | list_splice_tail($2, &$$->stmt_list); | |
| 4591 | 106 | free($2); | |
| 4592 | } | ||
| 4593 | | set_elem_key_expr | ||
| 4594 | { | ||
| 4595 | 903424 | $$ = set_elem_expr_alloc(&@1, $1); | |
| 4596 | } | ||
| 4597 | ; | ||
| 4598 | |||
| 4599 | set_elem_options : set_elem_option | ||
| 4600 | { | ||
| 4601 | 1046 | $<expr>$ = $<expr>0; | |
| 4602 | } | ||
| 4603 | | set_elem_options set_elem_option | ||
| 4604 | ; | ||
| 4605 | |||
| 4606 | set_elem_time_spec : STRING | ||
| 4607 | { | ||
| 4608 | struct error_record *erec; | ||
| 4609 | uint64_t res; | ||
| 4610 | |||
| 4611 |
1/2✗ Branch 0 (1433→1434) not taken.
✓ Branch 1 (1433→1435) taken 138304 times.
|
138304 | if (!strcmp("never", $1)) { |
| 4612 | ✗ | free_const($1); | |
| 4613 | ✗ | $$ = NFT_NEVER_TIMEOUT; | |
| 4614 | ✗ | break; | |
| 4615 | } | ||
| 4616 | |||
| 4617 | 138304 | erec = time_parse(&@1, $1, &res); | |
| 4618 | 135993 | free_const($1); | |
| 4619 |
1/2✗ Branch 0 (1436→1437) not taken.
✓ Branch 1 (1436→1439) taken 135993 times.
|
135993 | if (erec != NULL) { |
| 4620 | ✗ | erec_queue(erec, state->msgs); | |
| 4621 | ✗ | YYERROR; | |
| 4622 | } | ||
| 4623 | 135993 | $$ = res; | |
| 4624 | } | ||
| 4625 | ; | ||
| 4626 | |||
| 4627 | set_elem_option : TIMEOUT time_spec | ||
| 4628 | { | ||
| 4629 | 1046 | $<expr>0->timeout = $2; | |
| 4630 | } | ||
| 4631 | | EXPIRES time_spec | ||
| 4632 | { | ||
| 4633 | ✗ | $<expr>0->expiration = $2; | |
| 4634 | } | ||
| 4635 | | comment_spec | ||
| 4636 | { | ||
| 4637 | ✗ | if (already_set($<expr>0->comment, &@1, state)) { | |
| 4638 | ✗ | free_const($1); | |
| 4639 | ✗ | YYERROR; | |
| 4640 | } | ||
| 4641 | ✗ | $<expr>0->comment = $1; | |
| 4642 | } | ||
| 4643 | ; | ||
| 4644 | |||
| 4645 | set_elem_expr_options : set_elem_expr_option | ||
| 4646 | { | ||
| 4647 | 139053 | $<expr>$ = $<expr>0; | |
| 4648 | } | ||
| 4649 | | set_elem_expr_options set_elem_expr_option | ||
| 4650 | ; | ||
| 4651 | |||
| 4652 | set_elem_stmt_list : set_elem_stmt | ||
| 4653 | { | ||
| 4654 | 107 | $$ = xmalloc(sizeof(*$$)); | |
| 4655 | 107 | init_list_head($$); | |
| 4656 | 107 | list_add_tail(&$1->list, $$); | |
| 4657 | } | ||
| 4658 | | set_elem_stmt_list set_elem_stmt | ||
| 4659 | { | ||
| 4660 | 13 | $$ = $1; | |
| 4661 | 13 | list_add_tail(&$2->list, $1); | |
| 4662 | } | ||
| 4663 | ; | ||
| 4664 | |||
| 4665 | set_elem_stmt : counter_stmt close_scope_counter | ||
| 4666 | | limit_stmt close_scope_limit | ||
| 4667 | | connlimit_stmt close_scope_ct | ||
| 4668 | | quota_stmt close_scope_quota | ||
| 4669 | | last_stmt close_scope_last | ||
| 4670 | ; | ||
| 4671 | |||
| 4672 | set_elem_expr_option : TIMEOUT set_elem_time_spec | ||
| 4673 | { | ||
| 4674 | 138304 | $<expr>0->timeout = $2; | |
| 4675 | } | ||
| 4676 | | EXPIRES time_spec | ||
| 4677 | { | ||
| 4678 | 74287 | $<expr>0->expiration = $2; | |
| 4679 | } | ||
| 4680 | | comment_spec | ||
| 4681 | { | ||
| 4682 |
1/2✗ Branch 0 (1457→1458) not taken.
✓ Branch 1 (1457→1459) taken 720 times.
|
720 | if (already_set($<expr>0->comment, &@1, state)) { |
| 4683 | ✗ | free_const($1); | |
| 4684 | ✗ | YYERROR; | |
| 4685 | } | ||
| 4686 | 720 | $<expr>0->comment = $1; | |
| 4687 | } | ||
| 4688 | ; | ||
| 4689 | |||
| 4690 | set_lhs_expr : concat_rhs_expr | ||
| 4691 | ; | ||
| 4692 | |||
| 4693 | set_rhs_expr : concat_rhs_expr | ||
| 4694 | | verdict_expr | ||
| 4695 | ; | ||
| 4696 | |||
| 4697 | initializer_expr : rhs_expr | ||
| 4698 | | list_rhs_expr | ||
| 4699 | 2 | | '{' '}' { $$ = set_expr_alloc(&@$, NULL); } | |
| 4700 | | DASH NUM | ||
| 4701 | { | ||
| 4702 | 1 | int32_t num = -$2; | |
| 4703 | |||
| 4704 | 1 | $$ = constant_expr_alloc(&@$, &integer_type, | |
| 4705 | BYTEORDER_HOST_ENDIAN, | ||
| 4706 | sizeof(num) * BITS_PER_BYTE, | ||
| 4707 | &num); | ||
| 4708 | } | ||
| 4709 | ; | ||
| 4710 | |||
| 4711 | counter_config : PACKETS NUM BYTES NUM | ||
| 4712 | { | ||
| 4713 | struct counter *counter; | ||
| 4714 | |||
| 4715 | 30 | counter = &$<obj>0->counter; | |
| 4716 | 30 | counter->packets = $2; | |
| 4717 | 30 | counter->bytes = $4; | |
| 4718 | } | ||
| 4719 | ; | ||
| 4720 | |||
| 4721 | counter_obj : /* empty */ | ||
| 4722 | { | ||
| 4723 | ✗ | $$ = obj_alloc(&@$); | |
| 4724 | ✗ | $$->type = NFT_OBJECT_COUNTER; | |
| 4725 | } | ||
| 4726 | ; | ||
| 4727 | |||
| 4728 | quota_config : quota_mode NUM bytes_unit quota_used | ||
| 4729 | { | ||
| 4730 | struct quota *quota; | ||
| 4731 | |||
| 4732 | 41 | quota = &$<obj>0->quota; | |
| 4733 | 41 | quota->bytes = $2 * $3; | |
| 4734 | 41 | quota->used = $4; | |
| 4735 | 41 | quota->flags = $1; | |
| 4736 | } | ||
| 4737 | ; | ||
| 4738 | |||
| 4739 | quota_obj : /* empty */ | ||
| 4740 | { | ||
| 4741 | 17 | $$ = obj_alloc(&@$); | |
| 4742 | 17 | $$->type = NFT_OBJECT_QUOTA; | |
| 4743 | } | ||
| 4744 | ; | ||
| 4745 | |||
| 4746 | secmark_config : string | ||
| 4747 | { | ||
| 4748 | int ret; | ||
| 4749 | struct secmark *secmark; | ||
| 4750 | |||
| 4751 | 2 | secmark = &$<obj>0->secmark; | |
| 4752 | 2 | ret = snprintf(secmark->ctx, sizeof(secmark->ctx), "%s", $1); | |
| 4753 |
2/4✓ Branch 0 (1470→1471) taken 2 times.
✗ Branch 1 (1470→1472) not taken.
✗ Branch 2 (1471→1472) not taken.
✓ Branch 3 (1471→1475) taken 2 times.
|
2 | if (ret <= 0 || ret >= (int)sizeof(secmark->ctx)) { |
| 4754 | ✗ | erec_queue(error(&@1, "invalid context '%s', max length is %u\n", $1, (int)sizeof(secmark->ctx)), state->msgs); | |
| 4755 | ✗ | free_const($1); | |
| 4756 | ✗ | YYERROR; | |
| 4757 | } | ||
| 4758 | 2 | free_const($1); | |
| 4759 | } | ||
| 4760 | ; | ||
| 4761 | |||
| 4762 | secmark_obj : /* empty */ | ||
| 4763 | { | ||
| 4764 | ✗ | $$ = obj_alloc(&@$); | |
| 4765 | ✗ | $$->type = NFT_OBJECT_SECMARK; | |
| 4766 | } | ||
| 4767 | ; | ||
| 4768 | |||
| 4769 | 9 | ct_obj_type : HELPER { $$ = NFT_OBJECT_CT_HELPER; } | |
| 4770 | 14 | | TIMEOUT { $$ = NFT_OBJECT_CT_TIMEOUT; } | |
| 4771 | 10 | | EXPECTATION { $$ = NFT_OBJECT_CT_EXPECT; } | |
| 4772 | ; | ||
| 4773 | |||
| 4774 | ✗ | ct_cmd_type : HELPERS { $$ = CMD_OBJ_CT_HELPERS; } | |
| 4775 | ✗ | | TIMEOUT { $$ = CMD_OBJ_CT_TIMEOUTS; } | |
| 4776 | ✗ | | EXPECTATION { $$ = CMD_OBJ_CT_EXPECTATIONS; } | |
| 4777 | ; | ||
| 4778 | |||
| 4779 | 52 | ct_l4protoname : TCP close_scope_tcp { $$ = IPPROTO_TCP; } | |
| 4780 | 13 | | UDP close_scope_udp { $$ = IPPROTO_UDP; } | |
| 4781 | ; | ||
| 4782 | |||
| 4783 | ct_helper_config : TYPE QUOTED_STRING PROTOCOL ct_l4protoname stmt_separator close_scope_type | ||
| 4784 | { | ||
| 4785 | struct ct_helper *ct; | ||
| 4786 | int ret; | ||
| 4787 | |||
| 4788 | 29 | ct = &$<obj>0->ct_helper; | |
| 4789 | |||
| 4790 |
2/2✓ Branch 0 (1486→1487) taken 1 times.
✓ Branch 1 (1486→1490) taken 28 times.
|
29 | if (ct->l4proto) { |
| 4791 | 1 | erec_queue(error(&@2, "You can only specify this once. This statement is already set for %s.", ct->name), state->msgs); | |
| 4792 | 1 | free_const($2); | |
| 4793 | 1 | YYERROR; | |
| 4794 | } | ||
| 4795 | |||
| 4796 | 28 | ret = snprintf(ct->name, sizeof(ct->name), "%s", $2); | |
| 4797 |
2/4✓ Branch 0 (1490→1491) taken 28 times.
✗ Branch 1 (1490→1492) not taken.
✗ Branch 2 (1491→1492) not taken.
✓ Branch 3 (1491→1495) taken 28 times.
|
28 | if (ret <= 0 || ret >= (int)sizeof(ct->name)) { |
| 4798 | ✗ | erec_queue(error(&@2, "invalid name '%s', max length is %u\n", $2, (int)sizeof(ct->name)), state->msgs); | |
| 4799 | ✗ | free_const($2); | |
| 4800 | ✗ | YYERROR; | |
| 4801 | } | ||
| 4802 | 28 | free_const($2); | |
| 4803 | |||
| 4804 | 28 | ct->l4proto = $4; | |
| 4805 | } | ||
| 4806 | | L3PROTOCOL family_spec_explicit stmt_separator | ||
| 4807 | { | ||
| 4808 | 17 | $<obj>0->ct_helper.l3proto = $2; | |
| 4809 | } | ||
| 4810 | ; | ||
| 4811 | |||
| 4812 | timeout_states : timeout_state | ||
| 4813 | { | ||
| 4814 | 18 | $$ = xmalloc(sizeof(*$$)); | |
| 4815 | 18 | init_list_head($$); | |
| 4816 | 18 | list_add_tail(&$1->head, $$); | |
| 4817 | } | ||
| 4818 | | timeout_states COMMA timeout_state | ||
| 4819 | { | ||
| 4820 | 14 | list_add_tail(&$3->head, $1); | |
| 4821 | 14 | $$ = $1; | |
| 4822 | } | ||
| 4823 | ; | ||
| 4824 | |||
| 4825 | timeout_state : STRING COLON time_spec_or_num_s | ||
| 4826 | { | ||
| 4827 | struct timeout_state *ts; | ||
| 4828 | |||
| 4829 | 32 | ts = xzalloc(sizeof(*ts)); | |
| 4830 | 32 | ts->timeout_str = $1; | |
| 4831 | 32 | ts->timeout_value = $3; | |
| 4832 | 32 | ts->location = @1; | |
| 4833 | 32 | init_list_head(&ts->head); | |
| 4834 | 32 | $$ = ts; | |
| 4835 | } | ||
| 4836 | ; | ||
| 4837 | |||
| 4838 | ct_timeout_config : PROTOCOL ct_l4protoname stmt_separator | ||
| 4839 | { | ||
| 4840 | struct ct_timeout *ct; | ||
| 4841 | 18 | int l4proto = $2; | |
| 4842 | |||
| 4843 | 18 | ct = &$<obj>0->ct_timeout; | |
| 4844 | 18 | ct->l4proto = l4proto; | |
| 4845 | } | ||
| 4846 | | POLICY '=' '{' timeout_states '}' stmt_separator close_scope_policy | ||
| 4847 | { | ||
| 4848 | struct ct_timeout *ct; | ||
| 4849 | |||
| 4850 | 17 | ct = &$<obj>0->ct_timeout; | |
| 4851 | 17 | list_splice_tail($4, &ct->timeout_list); | |
| 4852 | 17 | free($4); | |
| 4853 | } | ||
| 4854 | | L3PROTOCOL family_spec_explicit stmt_separator | ||
| 4855 | { | ||
| 4856 | 12 | $<obj>0->ct_timeout.l3proto = $2; | |
| 4857 | } | ||
| 4858 | ; | ||
| 4859 | |||
| 4860 | ct_expect_config : PROTOCOL ct_l4protoname stmt_separator | ||
| 4861 | { | ||
| 4862 | 18 | $<obj>0->ct_expect.l4proto = $2; | |
| 4863 | } | ||
| 4864 | | DPORT NUM stmt_separator | ||
| 4865 | { | ||
| 4866 | 16 | $<obj>0->ct_expect.dport = $2; | |
| 4867 | } | ||
| 4868 | | TIMEOUT time_spec stmt_separator | ||
| 4869 | { | ||
| 4870 | 15 | $<obj>0->ct_expect.timeout = $2; | |
| 4871 | } | ||
| 4872 | | SIZE NUM stmt_separator | ||
| 4873 | { | ||
| 4874 | 15 | $<obj>0->ct_expect.size = $2; | |
| 4875 | } | ||
| 4876 | | L3PROTOCOL family_spec_explicit stmt_separator | ||
| 4877 | { | ||
| 4878 | 12 | $<obj>0->ct_expect.l3proto = $2; | |
| 4879 | } | ||
| 4880 | ; | ||
| 4881 | |||
| 4882 | ct_obj_alloc : /* empty */ | ||
| 4883 | { | ||
| 4884 | 34 | $$ = obj_alloc(&@$); | |
| 4885 | } | ||
| 4886 | ; | ||
| 4887 | |||
| 4888 | limit_config : RATE limit_mode limit_rate_pkts limit_burst_pkts close_scope_rate | ||
| 4889 | { | ||
| 4890 | struct limit *limit; | ||
| 4891 | |||
| 4892 | 13 | limit = &$<obj>0->limit; | |
| 4893 | 13 | limit->rate = $3.rate; | |
| 4894 | 13 | limit->unit = $3.unit; | |
| 4895 | 13 | limit->burst = $4; | |
| 4896 | 13 | limit->type = NFT_LIMIT_PKTS; | |
| 4897 | 13 | limit->flags = $2; | |
| 4898 | } | ||
| 4899 | | RATE limit_mode limit_rate_bytes limit_burst_bytes close_scope_rate | ||
| 4900 | { | ||
| 4901 | struct limit *limit; | ||
| 4902 | |||
| 4903 | 8 | limit = &$<obj>0->limit; | |
| 4904 | 8 | limit->rate = $3.rate; | |
| 4905 | 8 | limit->unit = $3.unit; | |
| 4906 | 8 | limit->burst = $4; | |
| 4907 | 8 | limit->type = NFT_LIMIT_PKT_BYTES; | |
| 4908 | 8 | limit->flags = $2; | |
| 4909 | } | ||
| 4910 | ; | ||
| 4911 | |||
| 4912 | limit_obj : /* empty */ | ||
| 4913 | { | ||
| 4914 | 8 | $$ = obj_alloc(&@$); | |
| 4915 | 8 | $$->type = NFT_OBJECT_LIMIT; | |
| 4916 | } | ||
| 4917 | ; | ||
| 4918 | |||
| 4919 | 4 | erspan_block : /* empty */ { $$ = $<obj>-1; } | |
| 4920 | | erspan_block common_block | ||
| 4921 | | erspan_block stmt_separator | ||
| 4922 | | erspan_block erspan_config stmt_separator | ||
| 4923 | { | ||
| 4924 | 10 | $$ = $1; | |
| 4925 | } | ||
| 4926 | ; | ||
| 4927 | |||
| 4928 | erspan_block_alloc : /* empty */ | ||
| 4929 | { | ||
| 4930 | 4 | $$ = $<obj>-1; | |
| 4931 | |||
| 4932 |
1/2✗ Branch 0 (1524→1525) not taken.
✓ Branch 1 (1524→1526) taken 4 times.
|
4 | if (!tunnel_set_type(&$$->location, $$, TUNNEL_ERSPAN, "erspan", state)) |
| 4933 | ✗ | YYERROR; | |
| 4934 | } | ||
| 4935 | ; | ||
| 4936 | |||
| 4937 | erspan_config : HDRVERSION NUM | ||
| 4938 | { | ||
| 4939 |
1/2✗ Branch 0 (1527→1528) not taken.
✓ Branch 1 (1527→1529) taken 4 times.
|
4 | assert($<obj>0->tunnel.type == TUNNEL_ERSPAN); |
| 4940 | 4 | $<obj>0->tunnel.erspan.version = $2; | |
| 4941 | } | ||
| 4942 | | INDEX NUM | ||
| 4943 | { | ||
| 4944 | 2 | $<obj>0->tunnel.erspan.v1.index = $2; | |
| 4945 | } | ||
| 4946 | | DIRECTION INGRESS | ||
| 4947 | { | ||
| 4948 | 2 | $<obj>0->tunnel.erspan.v2.direction = 0; | |
| 4949 | } | ||
| 4950 | | DIRECTION EGRESS | ||
| 4951 | { | ||
| 4952 | ✗ | $<obj>0->tunnel.erspan.v2.direction = 1; | |
| 4953 | } | ||
| 4954 | | ID NUM | ||
| 4955 | { | ||
| 4956 | 2 | $<obj>0->tunnel.erspan.v2.hwid = $2; | |
| 4957 | } | ||
| 4958 | ; | ||
| 4959 | |||
| 4960 | 3 | geneve_block : /* empty */ { $$ = $<obj>-1; } | |
| 4961 | | geneve_block common_block | ||
| 4962 | | geneve_block stmt_separator | ||
| 4963 | | geneve_block geneve_config stmt_separator | ||
| 4964 | { | ||
| 4965 | 9 | $$ = $1; | |
| 4966 | } | ||
| 4967 | ; | ||
| 4968 | |||
| 4969 | geneve_block_alloc : /* empty */ | ||
| 4970 | { | ||
| 4971 | 4 | $$ = $<obj>-1; | |
| 4972 |
2/2✓ Branch 0 (1537→1538) taken 1 times.
✓ Branch 1 (1537→1539) taken 3 times.
|
4 | if (!tunnel_set_type(&$$->location, $$, TUNNEL_GENEVE, "geneve", state)) |
| 4973 | 1 | YYERROR; | |
| 4974 | |||
| 4975 | 3 | init_list_head(&$$->tunnel.geneve_opts); | |
| 4976 | } | ||
| 4977 | ; | ||
| 4978 | |||
| 4979 | geneve_config : CLASS NUM OPTTYPE NUM DATA string | ||
| 4980 | { | ||
| 4981 | struct tunnel_geneve *geneve; | ||
| 4982 | |||
| 4983 |
1/2✗ Branch 0 (1541→1542) not taken.
✓ Branch 1 (1541→1543) taken 9 times.
|
9 | assert($<obj>0->tunnel.type == TUNNEL_GENEVE); |
| 4984 | |||
| 4985 | 9 | geneve = xmalloc(sizeof(struct tunnel_geneve)); | |
| 4986 | 9 | geneve->geneve_class = $2; | |
| 4987 | 9 | geneve->type = $4; | |
| 4988 |
1/2✗ Branch 0 (1545→1546) not taken.
✓ Branch 1 (1545→1549) taken 9 times.
|
9 | if (tunnel_geneve_data_str2array($6, geneve->data, &geneve->data_len)) { |
| 4989 | ✗ | erec_queue(error(&@6, "Invalid data array %s\n", $6), state->msgs); | |
| 4990 | ✗ | free_const($6); | |
| 4991 | ✗ | free(geneve); | |
| 4992 | ✗ | YYERROR; | |
| 4993 | } | ||
| 4994 | |||
| 4995 | 9 | list_add_tail(&geneve->list, &$<obj>0->tunnel.geneve_opts); | |
| 4996 | 9 | free_const($6); | |
| 4997 | } | ||
| 4998 | ; | ||
| 4999 | |||
| 5000 | 3 | vxlan_block : /* empty */ { $$ = $<obj>-1; } | |
| 5001 | | vxlan_block common_block | ||
| 5002 | | vxlan_block stmt_separator | ||
| 5003 | | vxlan_block vxlan_config stmt_separator | ||
| 5004 | { | ||
| 5005 | 3 | $$ = $1; | |
| 5006 | } | ||
| 5007 | ; | ||
| 5008 | |||
| 5009 | vxlan_block_alloc : /* empty */ | ||
| 5010 | { | ||
| 5011 | 3 | $$ = $<obj>-1; | |
| 5012 | |||
| 5013 |
1/2✗ Branch 0 (1554→1555) not taken.
✓ Branch 1 (1554→1556) taken 3 times.
|
3 | if (!tunnel_set_type(&$$->location, $$, TUNNEL_VXLAN, "vxlan", state)) |
| 5014 | ✗ | YYERROR; | |
| 5015 | } | ||
| 5016 | ; | ||
| 5017 | |||
| 5018 | vxlan_config : GBP NUM | ||
| 5019 | { | ||
| 5020 |
1/2✗ Branch 0 (1557→1558) not taken.
✓ Branch 1 (1557→1559) taken 3 times.
|
3 | assert($<obj>0->tunnel.type == TUNNEL_VXLAN); |
| 5021 | 3 | $<obj>0->tunnel.vxlan.gbp = $2; | |
| 5022 | } | ||
| 5023 | ; | ||
| 5024 | |||
| 5025 | tunnel_config : ID NUM | ||
| 5026 | { | ||
| 5027 | 9 | $<obj>0->tunnel.id = $2; | |
| 5028 | } | ||
| 5029 | | IP SADDR symbol_expr close_scope_ip | ||
| 5030 | { | ||
| 5031 |
2/2✓ Branch 0 (1562→1563) taken 1 times.
✓ Branch 1 (1562→1565) taken 10 times.
|
11 | if (already_set($<obj>0->tunnel.src, &@3, state)) { |
| 5032 | 1 | expr_free($3); | |
| 5033 | 1 | YYERROR; | |
| 5034 | } | ||
| 5035 | |||
| 5036 | 10 | $<obj>0->tunnel.src = $3; | |
| 5037 | 10 | datatype_set($3, &ipaddr_type); | |
| 5038 | } | ||
| 5039 | | IP DADDR symbol_expr close_scope_ip | ||
| 5040 | { | ||
| 5041 |
1/2✗ Branch 0 (1568→1569) not taken.
✓ Branch 1 (1568→1571) taken 9 times.
|
9 | if (already_set($<obj>0->tunnel.dst, &@3, state)) { |
| 5042 | ✗ | expr_free($3); | |
| 5043 | ✗ | YYERROR; | |
| 5044 | } | ||
| 5045 | 9 | $<obj>0->tunnel.dst = $3; | |
| 5046 | 9 | datatype_set($3, &ipaddr_type); | |
| 5047 | } | ||
| 5048 | | IP6 SADDR symbol_expr close_scope_ip6 | ||
| 5049 | { | ||
| 5050 | ✗ | if (already_set($<obj>0->tunnel.src, &@3, state)) { | |
| 5051 | ✗ | expr_free($3); | |
| 5052 | ✗ | YYERROR; | |
| 5053 | } | ||
| 5054 | ✗ | $<obj>0->tunnel.src = $3; | |
| 5055 | ✗ | datatype_set($3, &ip6addr_type); | |
| 5056 | } | ||
| 5057 | | IP6 DADDR symbol_expr close_scope_ip6 | ||
| 5058 | { | ||
| 5059 | ✗ | if (already_set($<obj>0->tunnel.dst, &@3, state)) { | |
| 5060 | ✗ | expr_free($3); | |
| 5061 | ✗ | YYERROR; | |
| 5062 | } | ||
| 5063 | ✗ | $<obj>0->tunnel.dst = $3; | |
| 5064 | ✗ | datatype_set($3, &ip6addr_type); | |
| 5065 | } | ||
| 5066 | | SPORT NUM | ||
| 5067 | { | ||
| 5068 | 9 | $<obj>0->tunnel.sport = $2; | |
| 5069 | } | ||
| 5070 | | DPORT NUM | ||
| 5071 | { | ||
| 5072 | 9 | $<obj>0->tunnel.dport = $2; | |
| 5073 | } | ||
| 5074 | | TTL NUM | ||
| 5075 | { | ||
| 5076 | 9 | $<obj>0->tunnel.ttl = $2; | |
| 5077 | } | ||
| 5078 | | TOS NUM | ||
| 5079 | { | ||
| 5080 | 8 | $<obj>0->tunnel.tos = $2; | |
| 5081 | } | ||
| 5082 | | ERSPAN erspan_block_alloc '{' erspan_block '}' | ||
| 5083 | { | ||
| 5084 | 4 | $2->location = @2; | |
| 5085 | } | ||
| 5086 | | VXLAN vxlan_block_alloc '{' vxlan_block '}' | ||
| 5087 | { | ||
| 5088 | 3 | $2->location = @2; | |
| 5089 | } | ||
| 5090 | | GENEVE geneve_block_alloc '{' geneve_block '}' | ||
| 5091 | { | ||
| 5092 | 3 | $2->location = @2; | |
| 5093 | } | ||
| 5094 | ; | ||
| 5095 | |||
| 5096 | 13 | tunnel_block : /* empty */ { $$ = $<obj>-1; } | |
| 5097 | | tunnel_block common_block | ||
| 5098 | | tunnel_block stmt_separator | ||
| 5099 | | tunnel_block tunnel_config stmt_separator | ||
| 5100 | { | ||
| 5101 | 73 | $$ = $1; | |
| 5102 | } | ||
| 5103 | | tunnel_block comment_spec | ||
| 5104 | { | ||
| 5105 | ✗ | if (already_set($<obj>1->comment, &@2, state)) { | |
| 5106 | ✗ | free_const($2); | |
| 5107 | ✗ | YYERROR; | |
| 5108 | } | ||
| 5109 | ✗ | $<obj>1->comment = $2; | |
| 5110 | } | ||
| 5111 | ; | ||
| 5112 | |||
| 5113 | tunnel_obj : /* empty */ | ||
| 5114 | { | ||
| 5115 | ✗ | $$ = obj_alloc(&@$); | |
| 5116 | ✗ | $$->type = NFT_OBJECT_TUNNEL; | |
| 5117 | } | ||
| 5118 | ; | ||
| 5119 | |||
| 5120 | relational_expr : expr /* implicit */ rhs_expr | ||
| 5121 | { | ||
| 5122 | 48889 | $$ = relational_expr_alloc(&@$, OP_IMPLICIT, $1, $2); | |
| 5123 | } | ||
| 5124 | | expr /* implicit */ list_rhs_expr | ||
| 5125 | { | ||
| 5126 | 71 | $$ = relational_expr_alloc(&@$, OP_IMPLICIT, $1, $2); | |
| 5127 | } | ||
| 5128 | | expr /* implicit */ basic_rhs_expr SLASH list_rhs_expr | ||
| 5129 | { | ||
| 5130 | ✗ | struct expr *mask = list_expr_to_binop($4); | |
| 5131 | ✗ | struct expr *binop = binop_expr_alloc(&@$, OP_AND, $1, mask); | |
| 5132 | |||
| 5133 | ✗ | $$ = relational_expr_alloc(&@$, OP_IMPLICIT, binop, $2); | |
| 5134 | } | ||
| 5135 | | expr /* implicit */ list_rhs_expr SLASH list_rhs_expr | ||
| 5136 | { | ||
| 5137 | 5 | struct expr *value = list_expr_to_binop($2); | |
| 5138 | 5 | struct expr *mask = list_expr_to_binop($4); | |
| 5139 | 5 | struct expr *binop = binop_expr_alloc(&@$, OP_AND, $1, mask); | |
| 5140 | |||
| 5141 | 5 | $$ = relational_expr_alloc(&@$, OP_IMPLICIT, binop, value); | |
| 5142 | } | ||
| 5143 | | expr relational_op basic_rhs_expr SLASH list_rhs_expr | ||
| 5144 | { | ||
| 5145 | 5 | struct expr *mask = list_expr_to_binop($5); | |
| 5146 | 5 | struct expr *binop = binop_expr_alloc(&@$, OP_AND, $1, mask); | |
| 5147 | |||
| 5148 | 5 | $$ = relational_expr_alloc(&@$, $2, binop, $3); | |
| 5149 | } | ||
| 5150 | | expr relational_op list_rhs_expr SLASH list_rhs_expr | ||
| 5151 | { | ||
| 5152 | ✗ | struct expr *value = list_expr_to_binop($3); | |
| 5153 | ✗ | struct expr *mask = list_expr_to_binop($5); | |
| 5154 | ✗ | struct expr *binop = binop_expr_alloc(&@$, OP_AND, $1, mask); | |
| 5155 | |||
| 5156 | ✗ | $$ = relational_expr_alloc(&@$, $2, binop, value); | |
| 5157 | } | ||
| 5158 | | expr relational_op rhs_expr | ||
| 5159 | { | ||
| 5160 | 2064 | $$ = relational_expr_alloc(&@2, $2, $1, $3); | |
| 5161 | } | ||
| 5162 | | expr relational_op list_rhs_expr | ||
| 5163 | { | ||
| 5164 | 11 | $$ = relational_expr_alloc(&@2, $2, $1, $3); | |
| 5165 | } | ||
| 5166 | ; | ||
| 5167 | |||
| 5168 | list_rhs_expr : basic_rhs_expr COMMA basic_rhs_expr | ||
| 5169 | { | ||
| 5170 | 98 | $$ = list_expr_alloc(&@$); | |
| 5171 | 98 | list_expr_add($$, $1); | |
| 5172 | 98 | list_expr_add($$, $3); | |
| 5173 | } | ||
| 5174 | | list_rhs_expr COMMA basic_rhs_expr | ||
| 5175 | { | ||
| 5176 | 29 | $1->location = @$; | |
| 5177 | 29 | list_expr_add($1, $3); | |
| 5178 | 29 | $$ = $1; | |
| 5179 | } | ||
| 5180 | ; | ||
| 5181 | |||
| 5182 | 67626 | rhs_expr : concat_rhs_expr { $$ = $1; } | |
| 5183 | 1906 | | set_expr { $$ = $1; } | |
| 5184 | 1545 | | set_ref_symbol_expr { $$ = $1; } | |
| 5185 | ; | ||
| 5186 | |||
| 5187 | shift_rhs_expr : primary_rhs_expr | ||
| 5188 | | shift_rhs_expr LSHIFT primary_rhs_expr | ||
| 5189 | { | ||
| 5190 | 1 | $$ = binop_expr_alloc(&@$, OP_LSHIFT, $1, $3); | |
| 5191 | } | ||
| 5192 | | shift_rhs_expr RSHIFT primary_rhs_expr | ||
| 5193 | { | ||
| 5194 | ✗ | $$ = binop_expr_alloc(&@$, OP_RSHIFT, $1, $3); | |
| 5195 | } | ||
| 5196 | ; | ||
| 5197 | |||
| 5198 | and_rhs_expr : shift_rhs_expr | ||
| 5199 | | and_rhs_expr AMPERSAND shift_rhs_expr | ||
| 5200 | { | ||
| 5201 | 3 | $$ = binop_expr_alloc(&@$, OP_AND, $1, $3); | |
| 5202 | } | ||
| 5203 | ; | ||
| 5204 | |||
| 5205 | exclusive_or_rhs_expr : and_rhs_expr | ||
| 5206 | | exclusive_or_rhs_expr CARET and_rhs_expr | ||
| 5207 | { | ||
| 5208 | ✗ | $$ = binop_expr_alloc(&@$, OP_XOR, $1, $3); | |
| 5209 | } | ||
| 5210 | ; | ||
| 5211 | |||
| 5212 | inclusive_or_rhs_expr : exclusive_or_rhs_expr | ||
| 5213 | | inclusive_or_rhs_expr '|' exclusive_or_rhs_expr | ||
| 5214 | { | ||
| 5215 | 564 | $$ = binop_expr_alloc(&@$, OP_OR, $1, $3); | |
| 5216 | } | ||
| 5217 | ; | ||
| 5218 | |||
| 5219 | basic_rhs_expr : inclusive_or_rhs_expr | ||
| 5220 | ; | ||
| 5221 | |||
| 5222 | concat_rhs_expr : basic_rhs_expr | ||
| 5223 | | multiton_rhs_expr | ||
| 5224 | | concat_rhs_expr DOT multiton_rhs_expr | ||
| 5225 | { | ||
| 5226 | 2637 | struct location rhs[] = { | |
| 5227 | [1] = @2, | ||
| 5228 | [2] = @3, | ||
| 5229 | }; | ||
| 5230 | |||
| 5231 | 2637 | $$ = handle_concat_expr(&@$, $$, $1, $3, rhs); | |
| 5232 | } | ||
| 5233 | | concat_rhs_expr DOT basic_rhs_expr | ||
| 5234 | { | ||
| 5235 | 83460 | struct location rhs[] = { | |
| 5236 | [1] = @2, | ||
| 5237 | [2] = @3, | ||
| 5238 | }; | ||
| 5239 | |||
| 5240 | 83460 | $$ = handle_concat_expr(&@$, $$, $1, $3, rhs); | |
| 5241 | } | ||
| 5242 | ; | ||
| 5243 | |||
| 5244 | 152 | boolean_keys : EXISTS { $$ = true; } | |
| 5245 | 28 | | MISSING { $$ = false; } | |
| 5246 | ; | ||
| 5247 | |||
| 5248 | boolean_expr : boolean_keys | ||
| 5249 | { | ||
| 5250 | 180 | $$ = constant_expr_alloc(&@$, &boolean_type, | |
| 5251 | BYTEORDER_HOST_ENDIAN, | ||
| 5252 | 180 | sizeof($1) * BITS_PER_BYTE, &$1); | |
| 5253 | } | ||
| 5254 | ; | ||
| 5255 | |||
| 5256 | 68 | keyword_expr : ETHER close_scope_eth { $$ = symbol_value(&@$, "ether"); } | |
| 5257 | 100 | | IP close_scope_ip { $$ = symbol_value(&@$, "ip"); } | |
| 5258 | 57 | | IP6 close_scope_ip6 { $$ = symbol_value(&@$, "ip6"); } | |
| 5259 | 40 | | VLAN close_scope_vlan { $$ = symbol_value(&@$, "vlan"); } | |
| 5260 | 28 | | ARP close_scope_arp { $$ = symbol_value(&@$, "arp"); } | |
| 5261 | 15 | | DNAT close_scope_nat { $$ = symbol_value(&@$, "dnat"); } | |
| 5262 | 10 | | SNAT close_scope_nat { $$ = symbol_value(&@$, "snat"); } | |
| 5263 | 25 | | ECN { $$ = symbol_value(&@$, "ecn"); } | |
| 5264 | 10 | | RESET close_scope_reset { $$ = symbol_value(&@$, "reset"); } | |
| 5265 | 15 | | DESTROY close_scope_destroy { $$ = symbol_value(&@$, "destroy"); } | |
| 5266 | 9 | | ORIGINAL { $$ = symbol_value(&@$, "original"); } | |
| 5267 | 3 | | REPLY { $$ = symbol_value(&@$, "reply"); } | |
| 5268 | 9 | | LABEL { $$ = symbol_value(&@$, "label"); } | |
| 5269 | ✗ | | LAST close_scope_last { $$ = symbol_value(&@$, "last"); } | |
| 5270 | ; | ||
| 5271 | |||
| 5272 | 845395 | primary_rhs_expr : symbol_expr { $$ = $1; } | |
| 5273 | 254239 | | integer_expr { $$ = $1; } | |
| 5274 | 180 | | boolean_expr { $$ = $1; } | |
| 5275 | 360 | | keyword_expr { $$ = $1; } | |
| 5276 | | TCP close_scope_tcp | ||
| 5277 | { | ||
| 5278 | 610 | uint8_t data = IPPROTO_TCP; | |
| 5279 | 610 | $$ = constant_expr_alloc(&@$, &inet_protocol_type, | |
| 5280 | BYTEORDER_HOST_ENDIAN, | ||
| 5281 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5282 | } | ||
| 5283 | | UDP close_scope_udp | ||
| 5284 | { | ||
| 5285 | 582 | uint8_t data = IPPROTO_UDP; | |
| 5286 | 582 | $$ = constant_expr_alloc(&@$, &inet_protocol_type, | |
| 5287 | BYTEORDER_HOST_ENDIAN, | ||
| 5288 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5289 | } | ||
| 5290 | | UDPLITE close_scope_udplite | ||
| 5291 | { | ||
| 5292 | 40 | uint8_t data = IPPROTO_UDPLITE; | |
| 5293 | 40 | $$ = constant_expr_alloc(&@$, &inet_protocol_type, | |
| 5294 | BYTEORDER_HOST_ENDIAN, | ||
| 5295 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5296 | } | ||
| 5297 | | ESP close_scope_esp | ||
| 5298 | { | ||
| 5299 | 51 | uint8_t data = IPPROTO_ESP; | |
| 5300 | 51 | $$ = constant_expr_alloc(&@$, &inet_protocol_type, | |
| 5301 | BYTEORDER_HOST_ENDIAN, | ||
| 5302 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5303 | } | ||
| 5304 | | AH close_scope_ah | ||
| 5305 | { | ||
| 5306 | 44 | uint8_t data = IPPROTO_AH; | |
| 5307 | 44 | $$ = constant_expr_alloc(&@$, &inet_protocol_type, | |
| 5308 | BYTEORDER_HOST_ENDIAN, | ||
| 5309 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5310 | } | ||
| 5311 | | ICMP close_scope_icmp | ||
| 5312 | { | ||
| 5313 | 501 | uint8_t data = IPPROTO_ICMP; | |
| 5314 | 501 | $$ = constant_expr_alloc(&@$, &inet_protocol_type, | |
| 5315 | BYTEORDER_HOST_ENDIAN, | ||
| 5316 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5317 | } | ||
| 5318 | | IGMP | ||
| 5319 | { | ||
| 5320 | 2 | uint8_t data = IPPROTO_IGMP; | |
| 5321 | 2 | $$ = constant_expr_alloc(&@$, &inet_protocol_type, | |
| 5322 | BYTEORDER_HOST_ENDIAN, | ||
| 5323 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5324 | } | ||
| 5325 | | ICMP6 close_scope_icmp | ||
| 5326 | { | ||
| 5327 | 22 | uint8_t data = IPPROTO_ICMPV6; | |
| 5328 | 22 | $$ = constant_expr_alloc(&@$, &inet_protocol_type, | |
| 5329 | BYTEORDER_HOST_ENDIAN, | ||
| 5330 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5331 | } | ||
| 5332 | | GRE close_scope_gre | ||
| 5333 | { | ||
| 5334 | ✗ | uint8_t data = IPPROTO_GRE; | |
| 5335 | ✗ | $$ = constant_expr_alloc(&@$, &inet_protocol_type, | |
| 5336 | BYTEORDER_HOST_ENDIAN, | ||
| 5337 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5338 | } | ||
| 5339 | | COMP close_scope_comp | ||
| 5340 | { | ||
| 5341 | 30 | uint8_t data = IPPROTO_COMP; | |
| 5342 | 30 | $$ = constant_expr_alloc(&@$, &inet_protocol_type, | |
| 5343 | BYTEORDER_HOST_ENDIAN, | ||
| 5344 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5345 | } | ||
| 5346 | | DCCP close_scope_dccp | ||
| 5347 | { | ||
| 5348 | 40 | uint8_t data = IPPROTO_DCCP; | |
| 5349 | 40 | $$ = constant_expr_alloc(&@$, &inet_protocol_type, | |
| 5350 | BYTEORDER_HOST_ENDIAN, | ||
| 5351 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5352 | } | ||
| 5353 | | SCTP close_scope_sctp | ||
| 5354 | { | ||
| 5355 | 368 | uint8_t data = IPPROTO_SCTP; | |
| 5356 | 368 | $$ = constant_expr_alloc(&@$, &inet_protocol_type, | |
| 5357 | BYTEORDER_HOST_ENDIAN, | ||
| 5358 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5359 | } | ||
| 5360 | | REDIRECT close_scope_nat | ||
| 5361 | { | ||
| 5362 | 3 | uint8_t data = ICMP_REDIRECT; | |
| 5363 | 3 | $$ = constant_expr_alloc(&@$, &icmp_type_type, | |
| 5364 | BYTEORDER_HOST_ENDIAN, | ||
| 5365 | sizeof(data) * BITS_PER_BYTE, &data); | ||
| 5366 | } | ||
| 5367 | 140 | | '(' basic_rhs_expr ')' { $$ = $2; } | |
| 5368 | ; | ||
| 5369 | |||
| 5370 | 218 | relational_op : EQ { $$ = OP_EQ; } | |
| 5371 | 1687 | | NEQ { $$ = OP_NEQ; } | |
| 5372 | 61 | | LT { $$ = OP_LT; } | |
| 5373 | 87 | | GT { $$ = OP_GT; } | |
| 5374 | 4 | | GTE { $$ = OP_GTE; } | |
| 5375 | ✗ | | LTE { $$ = OP_LTE; } | |
| 5376 | 23 | | NOT { $$ = OP_NEG; } | |
| 5377 | ; | ||
| 5378 | |||
| 5379 | verdict_expr : ACCEPT | ||
| 5380 | { | ||
| 5381 | 4874 | $$ = verdict_expr_alloc(&@$, NF_ACCEPT, NULL); | |
| 5382 | } | ||
| 5383 | | DROP | ||
| 5384 | { | ||
| 5385 | 2287 | $$ = verdict_expr_alloc(&@$, NF_DROP, NULL); | |
| 5386 | } | ||
| 5387 | | CONTINUE | ||
| 5388 | { | ||
| 5389 | 16 | $$ = verdict_expr_alloc(&@$, NFT_CONTINUE, NULL); | |
| 5390 | } | ||
| 5391 | | JUMP chain_expr | ||
| 5392 | { | ||
| 5393 | 135111 | $$ = verdict_expr_alloc(&@$, NFT_JUMP, $2); | |
| 5394 | } | ||
| 5395 | | GOTO chain_expr | ||
| 5396 | { | ||
| 5397 | 4969 | $$ = verdict_expr_alloc(&@$, NFT_GOTO, $2); | |
| 5398 | } | ||
| 5399 | | RETURN | ||
| 5400 | { | ||
| 5401 | 1417 | $$ = verdict_expr_alloc(&@$, NFT_RETURN, NULL); | |
| 5402 | } | ||
| 5403 | ; | ||
| 5404 | |||
| 5405 | chain_expr : variable_expr | ||
| 5406 | | identifier | ||
| 5407 | { | ||
| 5408 | 277632 | $$ = constant_expr_alloc(&@$, &string_type, | |
| 5409 | BYTEORDER_HOST_ENDIAN, | ||
| 5410 | 140077 | strlen($1) * BITS_PER_BYTE, | |
| 5411 | 140077 | $1); | |
| 5412 | 137555 | free_const($1); | |
| 5413 | } | ||
| 5414 | ; | ||
| 5415 | |||
| 5416 | meta_expr : META meta_key close_scope_meta | ||
| 5417 | { | ||
| 5418 | 1817 | $$ = meta_expr_alloc(&@$, $2); | |
| 5419 | } | ||
| 5420 | | meta_key_unqualified | ||
| 5421 | { | ||
| 5422 | 40992 | $$ = meta_expr_alloc(&@$, $1); | |
| 5423 | } | ||
| 5424 | | META STRING close_scope_meta | ||
| 5425 | { | ||
| 5426 | struct error_record *erec; | ||
| 5427 | unsigned int key; | ||
| 5428 | |||
| 5429 | 478 | erec = meta_key_parse(&@$, $2, &key); | |
| 5430 | 478 | free_const($2); | |
| 5431 |
1/2✗ Branch 0 (1752→1753) not taken.
✓ Branch 1 (1752→1755) taken 478 times.
|
478 | if (erec != NULL) { |
| 5432 | ✗ | erec_queue(erec, state->msgs); | |
| 5433 | ✗ | YYERROR; | |
| 5434 | } | ||
| 5435 | |||
| 5436 | 478 | $$ = meta_expr_alloc(&@$, key); | |
| 5437 | } | ||
| 5438 | ; | ||
| 5439 | |||
| 5440 | meta_key : meta_key_qualified | ||
| 5441 | | meta_key_unqualified | ||
| 5442 | ; | ||
| 5443 | |||
| 5444 | 85 | meta_key_qualified : LENGTH { $$ = NFT_META_LEN; } | |
| 5445 | 69 | | PROTOCOL { $$ = NFT_META_PROTOCOL; } | |
| 5446 | 122 | | PRIORITY { $$ = NFT_META_PRIORITY; } | |
| 5447 | 28 | | RANDOM { $$ = NFT_META_PRANDOM; } | |
| 5448 | 5 | | SECMARK close_scope_secmark { $$ = NFT_META_SECMARK; } | |
| 5449 | ; | ||
| 5450 | |||
| 5451 | 824 | meta_key_unqualified : MARK { $$ = NFT_META_MARK; } | |
| 5452 | 228 | | IIF { $$ = NFT_META_IIF; } | |
| 5453 | 40388 | | IIFNAME { $$ = NFT_META_IIFNAME; } | |
| 5454 | 54 | | IIFTYPE { $$ = NFT_META_IIFTYPE; } | |
| 5455 | 118 | | OIF { $$ = NFT_META_OIF; } | |
| 5456 | 185 | | OIFNAME { $$ = NFT_META_OIFNAME; } | |
| 5457 | 28 | | OIFTYPE { $$ = NFT_META_OIFTYPE; } | |
| 5458 | 133 | | SKUID { $$ = NFT_META_SKUID; } | |
| 5459 | 119 | | SKGID { $$ = NFT_META_SKGID; } | |
| 5460 | 4 | | NFTRACE { $$ = NFT_META_NFTRACE; } | |
| 5461 | 7 | | RTCLASSID { $$ = NFT_META_RTCLASSID; } | |
| 5462 | ✗ | | IBRIPORT { $$ = NFT_META_BRI_IIFNAME; } | |
| 5463 | ✗ | | OBRIPORT { $$ = NFT_META_BRI_OIFNAME; } | |
| 5464 | 3 | | IBRIDGENAME { $$ = NFT_META_BRI_IIFNAME; } | |
| 5465 | 3 | | OBRIDGENAME { $$ = NFT_META_BRI_OIFNAME; } | |
| 5466 | 76 | | PKTTYPE { $$ = NFT_META_PKTTYPE; } | |
| 5467 | 56 | | CPU { $$ = NFT_META_CPU; } | |
| 5468 | 150 | | IIFGROUP { $$ = NFT_META_IIFGROUP; } | |
| 5469 | 142 | | OIFGROUP { $$ = NFT_META_OIFGROUP; } | |
| 5470 | 42 | | CGROUP { $$ = NFT_META_CGROUP; } | |
| 5471 | 9 | | IPSEC close_scope_ipsec { $$ = NFT_META_SECPATH; } | |
| 5472 | 101 | | TIME { $$ = NFT_META_TIME_NS; } | |
| 5473 | 41 | | DAY { $$ = NFT_META_TIME_DAY; } | |
| 5474 | 157 | | HOUR { $$ = NFT_META_TIME_HOUR; } | |
| 5475 | ; | ||
| 5476 | |||
| 5477 | meta_stmt : META meta_key SET stmt_expr close_scope_meta | ||
| 5478 | { | ||
| 5479 |
2/2✓ Branch 0 (1787→1788) taken 3 times.
✓ Branch 1 (1787→1794) taken 341 times.
|
344 | switch ($2) { |
| 5480 | 3 | case NFT_META_SECMARK: | |
| 5481 |
2/2✓ Branch 0 (1788→1789) taken 2 times.
✓ Branch 1 (1788→1791) taken 1 times.
|
3 | switch ($4->etype) { |
| 5482 | 2 | case EXPR_CT: | |
| 5483 | 2 | $$ = meta_stmt_alloc(&@$, $2, $4); | |
| 5484 | 2 | break; | |
| 5485 | 1 | default: | |
| 5486 | 1 | $$ = objref_stmt_alloc(&@$); | |
| 5487 | 1 | $$->objref.type = NFT_OBJECT_SECMARK; | |
| 5488 | 1 | $$->objref.expr = $4; | |
| 5489 | 1 | break; | |
| 5490 | } | ||
| 5491 | 3 | break; | |
| 5492 | 341 | default: | |
| 5493 | 341 | $$ = meta_stmt_alloc(&@$, $2, $4); | |
| 5494 | 339 | break; | |
| 5495 | } | ||
| 5496 | } | ||
| 5497 | | meta_key_unqualified SET stmt_expr | ||
| 5498 | { | ||
| 5499 | 10 | $$ = meta_stmt_alloc(&@$, $1, $3); | |
| 5500 | } | ||
| 5501 | | META STRING SET stmt_expr close_scope_meta | ||
| 5502 | { | ||
| 5503 | struct error_record *erec; | ||
| 5504 | unsigned int key; | ||
| 5505 | |||
| 5506 | 4 | erec = meta_key_parse(&@$, $2, &key); | |
| 5507 | 4 | free_const($2); | |
| 5508 |
2/2✓ Branch 0 (1800→1801) taken 1 times.
✓ Branch 1 (1800→1804) taken 3 times.
|
4 | if (erec != NULL) { |
| 5509 | 1 | erec_queue(erec, state->msgs); | |
| 5510 | 1 | expr_free($4); | |
| 5511 | 1 | YYERROR; | |
| 5512 | } | ||
| 5513 | |||
| 5514 | 3 | $$ = meta_stmt_alloc(&@$, key, $4); | |
| 5515 | } | ||
| 5516 | | NOTRACK | ||
| 5517 | { | ||
| 5518 | 3 | $$ = notrack_stmt_alloc(&@$); | |
| 5519 | } | ||
| 5520 | | FLOW OFFLOAD AT string close_scope_at | ||
| 5521 | { | ||
| 5522 | ✗ | $$ = flow_offload_stmt_alloc(&@$, $4); | |
| 5523 | } | ||
| 5524 | | FLOW ADD AT string close_scope_at | ||
| 5525 | { | ||
| 5526 | 12 | $$ = flow_offload_stmt_alloc(&@$, $4); | |
| 5527 | } | ||
| 5528 | ; | ||
| 5529 | |||
| 5530 | socket_expr : SOCKET socket_key close_scope_socket | ||
| 5531 | { | ||
| 5532 | 21 | $$ = socket_expr_alloc(&@$, $2, 0); | |
| 5533 | } | ||
| 5534 | | SOCKET CGROUPV2 LEVEL NUM close_scope_socket | ||
| 5535 | { | ||
| 5536 | 1 | $$ = socket_expr_alloc(&@$, NFT_SOCKET_CGROUPV2, $4); | |
| 5537 | } | ||
| 5538 | ; | ||
| 5539 | |||
| 5540 | 9 | socket_key : TRANSPARENT { $$ = NFT_SOCKET_TRANSPARENT; } | |
| 5541 | 3 | | MARK { $$ = NFT_SOCKET_MARK; } | |
| 5542 | 9 | | WILDCARD { $$ = NFT_SOCKET_WILDCARD; } | |
| 5543 | ; | ||
| 5544 | |||
| 5545 | 2 | tunnel_key : PATH { $$ = NFT_TUNNEL_PATH; } | |
| 5546 | 1 | | ID { $$ = NFT_TUNNEL_ID; } | |
| 5547 | ; | ||
| 5548 | |||
| 5549 | tunnel_expr : TUNNEL tunnel_key | ||
| 5550 | { | ||
| 5551 | 3 | $$ = tunnel_expr_alloc(&@$, $2); | |
| 5552 | } | ||
| 5553 | ; | ||
| 5554 | |||
| 5555 | 68 | offset_opt : /* empty */ { $$ = 0; } | |
| 5556 | 10 | | OFFSET NUM { $$ = $2; } | |
| 5557 | ; | ||
| 5558 | |||
| 5559 | 46 | numgen_type : INC { $$ = NFT_NG_INCREMENTAL; } | |
| 5560 | ✗ | | RANDOM { $$ = NFT_NG_RANDOM; } | |
| 5561 | ; | ||
| 5562 | |||
| 5563 | numgen_expr : NUMGEN numgen_type MOD NUM offset_opt close_scope_numgen | ||
| 5564 | { | ||
| 5565 | 46 | $$ = numgen_expr_alloc(&@$, $2, $4, $5); | |
| 5566 | } | ||
| 5567 | ; | ||
| 5568 | |||
| 5569 | 12 | xfrm_spnum : SPNUM NUM { $$ = $2; } | |
| 5570 | 41 | | { $$ = 0; } | |
| 5571 | ; | ||
| 5572 | |||
| 5573 | 35 | xfrm_dir : IN { $$ = XFRM_POLICY_IN; } | |
| 5574 | 18 | | OUT { $$ = XFRM_POLICY_OUT; } | |
| 5575 | ; | ||
| 5576 | |||
| 5577 | 3 | xfrm_state_key : SPI { $$ = NFT_XFRM_KEY_SPI; } | |
| 5578 | 35 | | REQID { $$ = NFT_XFRM_KEY_REQID; } | |
| 5579 | ; | ||
| 5580 | |||
| 5581 | 6 | xfrm_state_proto_key : DADDR { $$ = NFT_XFRM_KEY_DADDR_IP4; } | |
| 5582 | 6 | | SADDR { $$ = NFT_XFRM_KEY_SADDR_IP4; } | |
| 5583 | ; | ||
| 5584 | |||
| 5585 | xfrm_expr : IPSEC xfrm_dir xfrm_spnum xfrm_state_key close_scope_ipsec | ||
| 5586 | { | ||
| 5587 |
2/2✓ Branch 0 (1838→1839) taken 3 times.
✓ Branch 1 (1838→1842) taken 35 times.
|
38 | if ($3 > 255) { |
| 5588 | 3 | erec_queue(error(&@3, "value too large"), state->msgs); | |
| 5589 | 3 | YYERROR; | |
| 5590 | } | ||
| 5591 | 35 | $$ = xfrm_expr_alloc(&@$, $2, $3, $4); | |
| 5592 | } | ||
| 5593 | | IPSEC xfrm_dir xfrm_spnum nf_key_proto xfrm_state_proto_key close_scope_ipsec | ||
| 5594 | { | ||
| 5595 | 12 | enum nft_xfrm_keys xfrmk = $5; | |
| 5596 | |||
| 5597 |
2/3✓ Branch 0 (1844→1845) taken 6 times.
✓ Branch 1 (1844→1846) taken 6 times.
✗ Branch 2 (1844→1851) not taken.
|
12 | switch ($4) { |
| 5598 | 6 | case NFPROTO_IPV4: | |
| 5599 | 6 | break; | |
| 5600 | 6 | case NFPROTO_IPV6: | |
| 5601 |
2/2✓ Branch 0 (1846→1847) taken 3 times.
✓ Branch 1 (1846→1848) taken 3 times.
|
6 | if ($5 == NFT_XFRM_KEY_SADDR_IP4) |
| 5602 | 3 | xfrmk = NFT_XFRM_KEY_SADDR_IP6; | |
| 5603 |
1/2✓ Branch 0 (1848→1849) taken 3 times.
✗ Branch 1 (1848→1850) not taken.
|
3 | else if ($5 == NFT_XFRM_KEY_DADDR_IP4) |
| 5604 | 3 | xfrmk = NFT_XFRM_KEY_DADDR_IP6; | |
| 5605 | 6 | break; | |
| 5606 | ✗ | default: | |
| 5607 | ✗ | YYERROR; | |
| 5608 | break; | ||
| 5609 | } | ||
| 5610 | |||
| 5611 |
1/2✗ Branch 0 (1852→1853) not taken.
✓ Branch 1 (1852→1856) taken 12 times.
|
12 | if ($3 > 255) { |
| 5612 | ✗ | erec_queue(error(&@3, "value too large"), state->msgs); | |
| 5613 | ✗ | YYERROR; | |
| 5614 | } | ||
| 5615 | |||
| 5616 | 12 | $$ = xfrm_expr_alloc(&@$, $2, $3, xfrmk); | |
| 5617 | } | ||
| 5618 | ; | ||
| 5619 | |||
| 5620 | hash_expr : JHASH expr MOD NUM SEED NUM offset_opt close_scope_hash | ||
| 5621 | { | ||
| 5622 | 4 | $$ = hash_expr_alloc(&@$, $4, true, $6, $7, NFT_HASH_JENKINS); | |
| 5623 | 4 | $$->hash.expr = $2; | |
| 5624 | } | ||
| 5625 | | JHASH expr MOD NUM offset_opt close_scope_hash | ||
| 5626 | { | ||
| 5627 | 8 | $$ = hash_expr_alloc(&@$, $4, false, 0, $5, NFT_HASH_JENKINS); | |
| 5628 | 8 | $$->hash.expr = $2; | |
| 5629 | } | ||
| 5630 | | SYMHASH MOD NUM offset_opt close_scope_hash | ||
| 5631 | { | ||
| 5632 | 20 | $$ = hash_expr_alloc(&@$, $3, false, 0, $4, NFT_HASH_SYM); | |
| 5633 | } | ||
| 5634 | ; | ||
| 5635 | |||
| 5636 | 99 | nf_key_proto : IP close_scope_ip { $$ = NFPROTO_IPV4; } | |
| 5637 | 50 | | IP6 close_scope_ip6 { $$ = NFPROTO_IPV6; } | |
| 5638 | ; | ||
| 5639 | |||
| 5640 | rt_expr : RT rt_key close_scope_rt | ||
| 5641 | { | ||
| 5642 | 23 | $$ = rt_expr_alloc(&@$, $2, true); | |
| 5643 | } | ||
| 5644 | | RT nf_key_proto rt_key close_scope_rt | ||
| 5645 | { | ||
| 5646 | 6 | enum nft_rt_keys rtk = $3; | |
| 5647 | |||
| 5648 |
2/3✓ Branch 0 (1868→1869) taken 3 times.
✓ Branch 1 (1868→1870) taken 3 times.
✗ Branch 2 (1868→1873) not taken.
|
6 | switch ($2) { |
| 5649 | 3 | case NFPROTO_IPV4: | |
| 5650 | 3 | break; | |
| 5651 | 3 | case NFPROTO_IPV6: | |
| 5652 |
1/2✓ Branch 0 (1870→1871) taken 3 times.
✗ Branch 1 (1870→1872) not taken.
|
3 | if ($3 == NFT_RT_NEXTHOP4) |
| 5653 | 3 | rtk = NFT_RT_NEXTHOP6; | |
| 5654 | 3 | break; | |
| 5655 | ✗ | default: | |
| 5656 | ✗ | YYERROR; | |
| 5657 | break; | ||
| 5658 | } | ||
| 5659 | |||
| 5660 | 6 | $$ = rt_expr_alloc(&@$, rtk, false); | |
| 5661 | } | ||
| 5662 | ; | ||
| 5663 | |||
| 5664 | 3 | rt_key : CLASSID { $$ = NFT_RT_CLASSID; } | |
| 5665 | 13 | | NEXTHOP { $$ = NFT_RT_NEXTHOP4; } | |
| 5666 | 5 | | MTU { $$ = NFT_RT_TCPMSS; } | |
| 5667 | 8 | | IPSEC close_scope_ipsec { $$ = NFT_RT_XFRM; } | |
| 5668 | ; | ||
| 5669 | |||
| 5670 | ct_expr : CT ct_key close_scope_ct | ||
| 5671 | { | ||
| 5672 | 590 | $$ = ct_expr_alloc(&@$, $2, -1); | |
| 5673 | } | ||
| 5674 | | CT ct_dir ct_key_dir close_scope_ct | ||
| 5675 | { | ||
| 5676 | 30 | $$ = ct_expr_alloc(&@$, $3, $2); | |
| 5677 | } | ||
| 5678 | | CT ct_dir ct_key_proto_field close_scope_ct | ||
| 5679 | { | ||
| 5680 | 19 | $$ = ct_expr_alloc(&@$, $3, $2); | |
| 5681 | } | ||
| 5682 | ; | ||
| 5683 | |||
| 5684 | 42 | ct_dir : ORIGINAL { $$ = IP_CT_DIR_ORIGINAL; } | |
| 5685 | 16 | | REPLY { $$ = IP_CT_DIR_REPLY; } | |
| 5686 | ; | ||
| 5687 | |||
| 5688 | 3 | ct_key : L3PROTOCOL { $$ = NFT_CT_L3PROTOCOL; } | |
| 5689 | 3 | | PROTOCOL { $$ = NFT_CT_PROTOCOL; } | |
| 5690 | 257 | | MARK { $$ = NFT_CT_MARK; } | |
| 5691 | 256 | | STATE { $$ = NFT_CT_STATE; } | |
| 5692 | 24 | | DIRECTION { $$ = NFT_CT_DIRECTION; } | |
| 5693 | 39 | | STATUS { $$ = NFT_CT_STATUS; } | |
| 5694 | 63 | | EXPIRATION { $$ = NFT_CT_EXPIRATION; } | |
| 5695 | 38 | | HELPER { $$ = NFT_CT_HELPER; } | |
| 5696 | 2 | | SADDR { $$ = NFT_CT_SRC; } | |
| 5697 | ✗ | | DADDR { $$ = NFT_CT_DST; } | |
| 5698 | ✗ | | PROTO_SRC { $$ = NFT_CT_PROTO_SRC; } | |
| 5699 | ✗ | | PROTO_DST { $$ = NFT_CT_PROTO_DST; } | |
| 5700 | 12 | | LABEL { $$ = NFT_CT_LABELS; } | |
| 5701 | 30 | | EVENT { $$ = NFT_CT_EVENTMASK; } | |
| 5702 | 5 | | SECMARK close_scope_secmark { $$ = NFT_CT_SECMARK; } | |
| 5703 | 3 | | ID { $$ = NFT_CT_ID; } | |
| 5704 | | ct_key_dir_optional | ||
| 5705 | ; | ||
| 5706 | |||
| 5707 | 4 | ct_key_dir : SADDR { $$ = NFT_CT_SRC; } | |
| 5708 | 1 | | DADDR { $$ = NFT_CT_DST; } | |
| 5709 | ✗ | | L3PROTOCOL { $$ = NFT_CT_L3PROTOCOL; } | |
| 5710 | 1 | | PROTOCOL { $$ = NFT_CT_PROTOCOL; } | |
| 5711 | 2 | | PROTO_SRC { $$ = NFT_CT_PROTO_SRC; } | |
| 5712 | 7 | | PROTO_DST { $$ = NFT_CT_PROTO_DST; } | |
| 5713 | | ct_key_dir_optional | ||
| 5714 | ; | ||
| 5715 | |||
| 5716 | 11 | ct_key_proto_field : IP SADDR close_scope_ip { $$ = NFT_CT_SRC_IP; } | |
| 5717 | 7 | | IP DADDR close_scope_ip { $$ = NFT_CT_DST_IP; } | |
| 5718 | 1 | | IP6 SADDR close_scope_ip6 { $$ = NFT_CT_SRC_IP6; } | |
| 5719 | ✗ | | IP6 DADDR close_scope_ip6 { $$ = NFT_CT_DST_IP6; } | |
| 5720 | ; | ||
| 5721 | |||
| 5722 | 17 | ct_key_dir_optional : BYTES { $$ = NFT_CT_BYTES; } | |
| 5723 | 3 | | PACKETS { $$ = NFT_CT_PKTS; } | |
| 5724 | 6 | | AVGPKT { $$ = NFT_CT_AVGPKT; } | |
| 5725 | 37 | | ZONE { $$ = NFT_CT_ZONE; } | |
| 5726 | ; | ||
| 5727 | |||
| 5728 | symbol_stmt_expr : symbol_expr | ||
| 5729 | | keyword_expr | ||
| 5730 | ; | ||
| 5731 | |||
| 5732 | list_stmt_expr : symbol_stmt_expr COMMA symbol_stmt_expr | ||
| 5733 | { | ||
| 5734 | 9 | $$ = list_expr_alloc(&@$); | |
| 5735 | 9 | list_expr_add($$, $1); | |
| 5736 | 9 | list_expr_add($$, $3); | |
| 5737 | } | ||
| 5738 | | list_stmt_expr COMMA symbol_stmt_expr | ||
| 5739 | { | ||
| 5740 | 12 | $1->location = @$; | |
| 5741 | 12 | list_expr_add($1, $3); | |
| 5742 | 12 | $$ = $1; | |
| 5743 | } | ||
| 5744 | ; | ||
| 5745 | |||
| 5746 | ct_stmt : CT ct_key SET stmt_expr close_scope_ct | ||
| 5747 | { | ||
| 5748 |
2/2✓ Branch 0 (1924→1925) taken 19 times.
✓ Branch 1 (1924→1927) taken 156 times.
|
175 | switch ($2) { |
| 5749 | 19 | case NFT_CT_HELPER: | |
| 5750 | 19 | $$ = objref_stmt_alloc(&@$); | |
| 5751 | 19 | $$->objref.type = NFT_OBJECT_CT_HELPER; | |
| 5752 | 19 | $$->objref.expr = $4; | |
| 5753 | 19 | break; | |
| 5754 | 156 | default: | |
| 5755 | 156 | $$ = ct_stmt_alloc(&@$, $2, -1, $4); | |
| 5756 | 156 | break; | |
| 5757 | } | ||
| 5758 | } | ||
| 5759 | | CT ct_dir ct_key_dir_optional SET stmt_expr close_scope_ct | ||
| 5760 | { | ||
| 5761 | 6 | $$ = ct_stmt_alloc(&@$, $3, $2, $5); | |
| 5762 | } | ||
| 5763 | ; | ||
| 5764 | |||
| 5765 | payload_stmt : payload_expr SET stmt_expr | ||
| 5766 | { | ||
| 5767 |
2/2✓ Branch 0 (1932→1933) taken 9 times.
✓ Branch 1 (1932→1935) taken 293 times.
|
302 | if ($1->etype == EXPR_EXTHDR) |
| 5768 | 9 | $$ = exthdr_stmt_alloc(&@$, $1, $3); | |
| 5769 | else | ||
| 5770 | 293 | $$ = payload_stmt_alloc(&@$, $1, $3); | |
| 5771 | } | ||
| 5772 | ; | ||
| 5773 | |||
| 5774 | payload_expr : payload_raw_expr | ||
| 5775 | | eth_hdr_expr | ||
| 5776 | | vlan_hdr_expr | ||
| 5777 | | arp_hdr_expr | ||
| 5778 | | ip_hdr_expr | ||
| 5779 | | icmp_hdr_expr | ||
| 5780 | | igmp_hdr_expr | ||
| 5781 | | ip6_hdr_expr | ||
| 5782 | | icmp6_hdr_expr | ||
| 5783 | | auth_hdr_expr | ||
| 5784 | | esp_hdr_expr | ||
| 5785 | | comp_hdr_expr | ||
| 5786 | | udp_hdr_expr | ||
| 5787 | | udplite_hdr_expr | ||
| 5788 | | tcp_hdr_expr close_scope_tcp | ||
| 5789 | | dccp_hdr_expr | ||
| 5790 | | sctp_hdr_expr | ||
| 5791 | | th_hdr_expr | ||
| 5792 | | vxlan_hdr_expr | ||
| 5793 | | geneve_hdr_expr | ||
| 5794 | | gre_hdr_expr | ||
| 5795 | | gretap_hdr_expr | ||
| 5796 | ; | ||
| 5797 | |||
| 5798 | payload_raw_len : NUM | ||
| 5799 | { | ||
| 5800 |
2/2✓ Branch 0 (1938→1939) taken 1 times.
✓ Branch 1 (1938→1942) taken 173 times.
|
174 | if ($1 > NFT_MAX_EXPR_LEN_BITS) { |
| 5801 | 1 | erec_queue(error(&@1, "raw payload length %lu exceeds upper limit of %lu", | |
| 5802 | $1, NFT_MAX_EXPR_LEN_BITS), | ||
| 5803 | state->msgs); | ||
| 5804 | 1 | YYERROR; | |
| 5805 | } | ||
| 5806 | |||
| 5807 |
2/2✓ Branch 0 (1942→1943) taken 7 times.
✓ Branch 1 (1942→1946) taken 166 times.
|
173 | if ($1 == 0) { |
| 5808 | 7 | erec_queue(error(&@1, "raw payload length cannot be 0"), state->msgs); | |
| 5809 | 7 | YYERROR; | |
| 5810 | } | ||
| 5811 | |||
| 5812 | 166 | $$ = $1; | |
| 5813 | } | ||
| 5814 | ; | ||
| 5815 | |||
| 5816 | payload_raw_expr : AT payload_base_spec COMMA NUM COMMA payload_raw_len close_scope_at | ||
| 5817 | { | ||
| 5818 | 159 | $$ = payload_expr_alloc(&@$, NULL, 0); | |
| 5819 | 159 | payload_init_raw($$, $2, $4, $6); | |
| 5820 | 159 | $$->byteorder = BYTEORDER_BIG_ENDIAN; | |
| 5821 | 159 | $$->payload.is_raw = true; | |
| 5822 | } | ||
| 5823 | ; | ||
| 5824 | |||
| 5825 | 21 | payload_base_spec : LL_HDR { $$ = PROTO_BASE_LL_HDR; } | |
| 5826 | 25 | | NETWORK_HDR { $$ = PROTO_BASE_NETWORK_HDR; } | |
| 5827 | 55 | | TRANSPORT_HDR close_scope_th { $$ = PROTO_BASE_TRANSPORT_HDR; } | |
| 5828 | | STRING | ||
| 5829 | { | ||
| 5830 |
1/2✓ Branch 0 (1953→1954) taken 66 times.
✗ Branch 1 (1953→1955) not taken.
|
66 | if (!strcmp($1, "ih")) { |
| 5831 | 66 | $$ = PROTO_BASE_INNER_HDR; | |
| 5832 | } else { | ||
| 5833 | ✗ | erec_queue(error(&@1, "unknown raw payload base"), state->msgs); | |
| 5834 | ✗ | free_const($1); | |
| 5835 | ✗ | YYERROR; | |
| 5836 | } | ||
| 5837 | 66 | free_const($1); | |
| 5838 | } | ||
| 5839 | ; | ||
| 5840 | |||
| 5841 | eth_hdr_expr : ETHER eth_hdr_field close_scope_eth | ||
| 5842 | { | ||
| 5843 | 3835 | $$ = payload_expr_alloc(&@$, &proto_eth, $2); | |
| 5844 | } | ||
| 5845 | ; | ||
| 5846 | |||
| 5847 | 3215 | eth_hdr_field : SADDR { $$ = ETHHDR_SADDR; } | |
| 5848 | 15 | | DADDR { $$ = ETHHDR_DADDR; } | |
| 5849 | 605 | | TYPE close_scope_type { $$ = ETHHDR_TYPE; } | |
| 5850 | ; | ||
| 5851 | |||
| 5852 | vlan_hdr_expr : VLAN vlan_hdr_field close_scope_vlan | ||
| 5853 | { | ||
| 5854 | 1824 | $$ = payload_expr_alloc(&@$, &proto_vlan, $2); | |
| 5855 | } | ||
| 5856 | ; | ||
| 5857 | |||
| 5858 | 1741 | vlan_hdr_field : ID { $$ = VLANHDR_VID; } | |
| 5859 | 3 | | CFI { $$ = VLANHDR_CFI; } | |
| 5860 | 39 | | DEI { $$ = VLANHDR_DEI; } | |
| 5861 | 16 | | PCP { $$ = VLANHDR_PCP; } | |
| 5862 | 25 | | TYPE close_scope_type { $$ = VLANHDR_TYPE; } | |
| 5863 | ; | ||
| 5864 | |||
| 5865 | arp_hdr_expr : ARP arp_hdr_field close_scope_arp | ||
| 5866 | { | ||
| 5867 | 177 | $$ = payload_expr_alloc(&@$, &proto_arp, $2); | |
| 5868 | } | ||
| 5869 | ; | ||
| 5870 | |||
| 5871 | 30 | arp_hdr_field : HTYPE { $$ = ARPHDR_HRD; } | |
| 5872 | 12 | | PTYPE { $$ = ARPHDR_PRO; } | |
| 5873 | 24 | | HLEN { $$ = ARPHDR_HLN; } | |
| 5874 | 24 | | PLEN { $$ = ARPHDR_PLN; } | |
| 5875 | 51 | | OPERATION { $$ = ARPHDR_OP; } | |
| 5876 | 3 | | SADDR ETHER close_scope_eth { $$ = ARPHDR_SADDR_ETHER; } | |
| 5877 | 15 | | DADDR ETHER close_scope_eth { $$ = ARPHDR_DADDR_ETHER; } | |
| 5878 | 12 | | SADDR IP close_scope_ip { $$ = ARPHDR_SADDR_IP; } | |
| 5879 | 6 | | DADDR IP close_scope_ip { $$ = ARPHDR_DADDR_IP; } | |
| 5880 | ; | ||
| 5881 | |||
| 5882 | ip_hdr_expr : IP ip_hdr_field close_scope_ip | ||
| 5883 | { | ||
| 5884 | 2550 | $$ = payload_expr_alloc(&@$, &proto_ip, $2); | |
| 5885 | } | ||
| 5886 | | IP OPTION ip_option_type ip_option_field close_scope_ip | ||
| 5887 | { | ||
| 5888 | 6 | $$ = ipopt_expr_alloc(&@$, $3, $4); | |
| 5889 |
2/2✓ Branch 0 (1985→1986) taken 1 times.
✓ Branch 1 (1985→1989) taken 5 times.
|
6 | if (!$$) { |
| 5890 | 1 | erec_queue(error(&@1, "unknown ip option type/field"), state->msgs); | |
| 5891 | 1 | YYERROR; | |
| 5892 | } | ||
| 5893 | |||
| 5894 |
1/2✗ Branch 0 (1989→1990) not taken.
✓ Branch 1 (1989→1991) taken 5 times.
|
5 | if ($4 == IPOPT_FIELD_TYPE) |
| 5895 | ✗ | $$->exthdr.flags = NFT_EXTHDR_F_PRESENT; | |
| 5896 | } | ||
| 5897 | | IP OPTION ip_option_type close_scope_ip | ||
| 5898 | { | ||
| 5899 | 1 | $$ = ipopt_expr_alloc(&@$, $3, IPOPT_FIELD_TYPE); | |
| 5900 | 1 | $$->exthdr.flags = NFT_EXTHDR_F_PRESENT; | |
| 5901 | } | ||
| 5902 | ; | ||
| 5903 | |||
| 5904 | 44 | ip_hdr_field : HDRVERSION { $$ = IPHDR_VERSION; } | |
| 5905 | 67 | | HDRLENGTH { $$ = IPHDR_HDRLENGTH; } | |
| 5906 | 157 | | DSCP { $$ = IPHDR_DSCP; } | |
| 5907 | 55 | | ECN { $$ = IPHDR_ECN; } | |
| 5908 | 30 | | LENGTH { $$ = IPHDR_LENGTH; } | |
| 5909 | 35 | | ID { $$ = IPHDR_ID; } | |
| 5910 | 45 | | FRAG_OFF { $$ = IPHDR_FRAG_OFF; } | |
| 5911 | 35 | | TTL { $$ = IPHDR_TTL; } | |
| 5912 | 328 | | PROTOCOL { $$ = IPHDR_PROTOCOL; } | |
| 5913 | 40 | | CHECKSUM { $$ = IPHDR_CHECKSUM; } | |
| 5914 | 1121 | | SADDR { $$ = IPHDR_SADDR; } | |
| 5915 | 593 | | DADDR { $$ = IPHDR_DADDR; } | |
| 5916 | ; | ||
| 5917 | |||
| 5918 | ✗ | ip_option_type : LSRR { $$ = IPOPT_LSRR; } | |
| 5919 | 1 | | RR { $$ = IPOPT_RR; } | |
| 5920 | ✗ | | SSRR { $$ = IPOPT_SSRR; } | |
| 5921 | 6 | | RA { $$ = IPOPT_RA; } | |
| 5922 | ; | ||
| 5923 | |||
| 5924 | ✗ | ip_option_field : TYPE close_scope_type { $$ = IPOPT_FIELD_TYPE; } | |
| 5925 | ✗ | | LENGTH { $$ = IPOPT_FIELD_LENGTH; } | |
| 5926 | 6 | | VALUE { $$ = IPOPT_FIELD_VALUE; } | |
| 5927 | ✗ | | PTR { $$ = IPOPT_FIELD_PTR; } | |
| 5928 | ✗ | | ADDR { $$ = IPOPT_FIELD_ADDR_0; } | |
| 5929 | ; | ||
| 5930 | |||
| 5931 | icmp_hdr_expr : ICMP icmp_hdr_field close_scope_icmp | ||
| 5932 | { | ||
| 5933 | 202 | $$ = payload_expr_alloc(&@$, &proto_icmp, $2); | |
| 5934 | } | ||
| 5935 | ; | ||
| 5936 | |||
| 5937 | 134 | icmp_hdr_field : TYPE close_scope_type { $$ = ICMPHDR_TYPE; } | |
| 5938 | 10 | | CODE { $$ = ICMPHDR_CODE; } | |
| 5939 | 6 | | CHECKSUM { $$ = ICMPHDR_CHECKSUM; } | |
| 5940 | 20 | | ID { $$ = ICMPHDR_ID; } | |
| 5941 | 15 | | SEQUENCE { $$ = ICMPHDR_SEQ; } | |
| 5942 | 8 | | GATEWAY { $$ = ICMPHDR_GATEWAY; } | |
| 5943 | 9 | | MTU { $$ = ICMPHDR_MTU; } | |
| 5944 | ; | ||
| 5945 | |||
| 5946 | igmp_hdr_expr : IGMP igmp_hdr_field close_scope_igmp | ||
| 5947 | { | ||
| 5948 | 15 | $$ = payload_expr_alloc(&@$, &proto_igmp, $2); | |
| 5949 | } | ||
| 5950 | ; | ||
| 5951 | |||
| 5952 | 7 | igmp_hdr_field : TYPE close_scope_type { $$ = IGMPHDR_TYPE; } | |
| 5953 | 6 | | CHECKSUM { $$ = IGMPHDR_CHECKSUM; } | |
| 5954 | 2 | | MRT { $$ = IGMPHDR_MRT; } | |
| 5955 | ✗ | | GROUP { $$ = IGMPHDR_GROUP; } | |
| 5956 | ; | ||
| 5957 | |||
| 5958 | ip6_hdr_expr : IP6 ip6_hdr_field close_scope_ip6 | ||
| 5959 | { | ||
| 5960 | 907 | $$ = payload_expr_alloc(&@$, &proto_ip6, $2); | |
| 5961 | } | ||
| 5962 | ; | ||
| 5963 | |||
| 5964 | ✗ | ip6_hdr_field : HDRVERSION { $$ = IP6HDR_VERSION; } | |
| 5965 | 55 | | DSCP { $$ = IP6HDR_DSCP; } | |
| 5966 | 6 | | ECN { $$ = IP6HDR_ECN; } | |
| 5967 | 20 | | FLOWLABEL { $$ = IP6HDR_FLOWLABEL; } | |
| 5968 | 12 | | LENGTH { $$ = IP6HDR_LENGTH; } | |
| 5969 | 83 | | NEXTHDR { $$ = IP6HDR_NEXTHDR; } | |
| 5970 | 28 | | HOPLIMIT { $$ = IP6HDR_HOPLIMIT; } | |
| 5971 | 482 | | SADDR { $$ = IP6HDR_SADDR; } | |
| 5972 | 221 | | DADDR { $$ = IP6HDR_DADDR; } | |
| 5973 | ; | ||
| 5974 | icmp6_hdr_expr : ICMP6 icmp6_hdr_field close_scope_icmp | ||
| 5975 | { | ||
| 5976 | 167 | $$ = payload_expr_alloc(&@$, &proto_icmp6, $2); | |
| 5977 | } | ||
| 5978 | ; | ||
| 5979 | |||
| 5980 | 109 | icmp6_hdr_field : TYPE close_scope_type { $$ = ICMP6HDR_TYPE; } | |
| 5981 | 6 | | CODE { $$ = ICMP6HDR_CODE; } | |
| 5982 | 6 | | CHECKSUM { $$ = ICMP6HDR_CHECKSUM; } | |
| 5983 | ✗ | | PPTR { $$ = ICMP6HDR_PPTR; } | |
| 5984 | 8 | | MTU { $$ = ICMP6HDR_MTU; } | |
| 5985 | 12 | | ID { $$ = ICMP6HDR_ID; } | |
| 5986 | 12 | | SEQUENCE { $$ = ICMP6HDR_SEQ; } | |
| 5987 | 4 | | MAXDELAY { $$ = ICMP6HDR_MAXDELAY; } | |
| 5988 | 7 | | TADDR { $$ = ICMP6HDR_TADDR; } | |
| 5989 | 3 | | DADDR { $$ = ICMP6HDR_DADDR; } | |
| 5990 | ; | ||
| 5991 | |||
| 5992 | auth_hdr_expr : AH auth_hdr_field close_scope_ah | ||
| 5993 | { | ||
| 5994 | 110 | $$ = payload_expr_alloc(&@$, &proto_ah, $2); | |
| 5995 | } | ||
| 5996 | ; | ||
| 5997 | |||
| 5998 | ✗ | auth_hdr_field : NEXTHDR { $$ = AHHDR_NEXTHDR; } | |
| 5999 | 20 | | HDRLENGTH { $$ = AHHDR_HDRLENGTH; } | |
| 6000 | 30 | | RESERVED { $$ = AHHDR_RESERVED; } | |
| 6001 | 30 | | SPI { $$ = AHHDR_SPI; } | |
| 6002 | 30 | | SEQUENCE { $$ = AHHDR_SEQUENCE; } | |
| 6003 | ; | ||
| 6004 | |||
| 6005 | esp_hdr_expr : ESP esp_hdr_field close_scope_esp | ||
| 6006 | { | ||
| 6007 | 55 | $$ = payload_expr_alloc(&@$, &proto_esp, $2); | |
| 6008 | } | ||
| 6009 | ; | ||
| 6010 | |||
| 6011 | 30 | esp_hdr_field : SPI { $$ = ESPHDR_SPI; } | |
| 6012 | 25 | | SEQUENCE { $$ = ESPHDR_SEQUENCE; } | |
| 6013 | ; | ||
| 6014 | |||
| 6015 | comp_hdr_expr : COMP comp_hdr_field close_scope_comp | ||
| 6016 | { | ||
| 6017 | 71 | $$ = payload_expr_alloc(&@$, &proto_comp, $2); | |
| 6018 | } | ||
| 6019 | ; | ||
| 6020 | |||
| 6021 | 11 | comp_hdr_field : NEXTHDR { $$ = COMPHDR_NEXTHDR; } | |
| 6022 | 30 | | FLAGS { $$ = COMPHDR_FLAGS; } | |
| 6023 | 30 | | CPI { $$ = COMPHDR_CPI; } | |
| 6024 | ; | ||
| 6025 | |||
| 6026 | udp_hdr_expr : UDP udp_hdr_field close_scope_udp | ||
| 6027 | { | ||
| 6028 | 794 | $$ = payload_expr_alloc(&@$, &proto_udp, $2); | |
| 6029 | } | ||
| 6030 | ; | ||
| 6031 | |||
| 6032 | 73 | udp_hdr_field : SPORT { $$ = UDPHDR_SPORT; } | |
| 6033 | 565 | | DPORT { $$ = UDPHDR_DPORT; } | |
| 6034 | 75 | | LENGTH { $$ = UDPHDR_LENGTH; } | |
| 6035 | 81 | | CHECKSUM { $$ = UDPHDR_CHECKSUM; } | |
| 6036 | ; | ||
| 6037 | |||
| 6038 | udplite_hdr_expr : UDPLITE udplite_hdr_field close_scope_udplite | ||
| 6039 | { | ||
| 6040 | 100 | $$ = payload_expr_alloc(&@$, &proto_udplite, $2); | |
| 6041 | } | ||
| 6042 | ; | ||
| 6043 | |||
| 6044 | 30 | udplite_hdr_field : SPORT { $$ = UDPHDR_SPORT; } | |
| 6045 | 30 | | DPORT { $$ = UDPHDR_DPORT; } | |
| 6046 | ✗ | | CSUMCOV { $$ = UDPHDR_LENGTH; } | |
| 6047 | 40 | | CHECKSUM { $$ = UDPHDR_CHECKSUM; } | |
| 6048 | ; | ||
| 6049 | |||
| 6050 | tcp_hdr_expr : TCP tcp_hdr_field | ||
| 6051 | { | ||
| 6052 | 1498 | $$ = payload_expr_alloc(&@$, &proto_tcp, $2); | |
| 6053 | } | ||
| 6054 | | TCP OPTION tcp_hdr_option_type | ||
| 6055 | { | ||
| 6056 | 47 | $$ = tcpopt_expr_alloc(&@$, $3, TCPOPT_COMMON_KIND); | |
| 6057 | 47 | $$->exthdr.flags = NFT_EXTHDR_F_PRESENT; | |
| 6058 | } | ||
| 6059 | | TCP OPTION tcp_hdr_option_kind_and_field | ||
| 6060 | { | ||
| 6061 | 106 | $$ = tcpopt_expr_alloc(&@$, $3.kind, $3.field); | |
| 6062 |
2/2✓ Branch 0 (2086→2087) taken 1 times.
✓ Branch 1 (2086→2090) taken 105 times.
|
106 | if ($$ == NULL) { |
| 6063 | 1 | erec_queue(error(&@1, "Could not find a tcp option template"), state->msgs); | |
| 6064 | 1 | YYERROR; | |
| 6065 | } | ||
| 6066 | } | ||
| 6067 | | TCP OPTION AT close_scope_at tcp_hdr_option_type COMMA NUM COMMA payload_raw_len | ||
| 6068 | { | ||
| 6069 | 7 | $$ = tcpopt_expr_alloc(&@$, $5, 0); | |
| 6070 | 7 | tcpopt_init_raw($$, $5, $7, $9, 0); | |
| 6071 | } | ||
| 6072 | ; | ||
| 6073 | |||
| 6074 | inner_inet_expr : ip_hdr_expr | ||
| 6075 | | icmp_hdr_expr | ||
| 6076 | | igmp_hdr_expr | ||
| 6077 | | ip6_hdr_expr | ||
| 6078 | | icmp6_hdr_expr | ||
| 6079 | | auth_hdr_expr | ||
| 6080 | | esp_hdr_expr | ||
| 6081 | | comp_hdr_expr | ||
| 6082 | | udp_hdr_expr | ||
| 6083 | | udplite_hdr_expr | ||
| 6084 | | tcp_hdr_expr close_scope_tcp | ||
| 6085 | | dccp_hdr_expr | ||
| 6086 | | sctp_hdr_expr | ||
| 6087 | | th_hdr_expr | ||
| 6088 | ; | ||
| 6089 | |||
| 6090 | inner_eth_expr : eth_hdr_expr | ||
| 6091 | | vlan_hdr_expr | ||
| 6092 | | arp_hdr_expr | ||
| 6093 | ; | ||
| 6094 | |||
| 6095 | inner_expr : inner_eth_expr | ||
| 6096 | | inner_inet_expr | ||
| 6097 | ; | ||
| 6098 | |||
| 6099 | vxlan_hdr_expr : VXLAN vxlan_hdr_field | ||
| 6100 | { | ||
| 6101 | struct expr *expr; | ||
| 6102 | |||
| 6103 | 10 | expr = payload_expr_alloc(&@$, &proto_vxlan, $2); | |
| 6104 | 10 | expr->payload.inner_desc = &proto_vxlan; | |
| 6105 | 10 | $$ = expr; | |
| 6106 | } | ||
| 6107 | | VXLAN inner_expr | ||
| 6108 | { | ||
| 6109 | 72 | $$ = $2; | |
| 6110 | 72 | $$->location = @$; | |
| 6111 | 72 | $$->payload.inner_desc = &proto_vxlan; | |
| 6112 | } | ||
| 6113 | ; | ||
| 6114 | |||
| 6115 | 10 | vxlan_hdr_field : VNI { $$ = VXLANHDR_VNI; } | |
| 6116 | ✗ | | FLAGS { $$ = VXLANHDR_FLAGS; } | |
| 6117 | ; | ||
| 6118 | |||
| 6119 | geneve_hdr_expr : GENEVE geneve_hdr_field | ||
| 6120 | { | ||
| 6121 | struct expr *expr; | ||
| 6122 | |||
| 6123 | 10 | expr = payload_expr_alloc(&@$, &proto_geneve, $2); | |
| 6124 | 10 | expr->payload.inner_desc = &proto_geneve; | |
| 6125 | 10 | $$ = expr; | |
| 6126 | } | ||
| 6127 | | GENEVE inner_expr | ||
| 6128 | { | ||
| 6129 | 55 | $$ = $2; | |
| 6130 | 55 | $$->location = @$; | |
| 6131 | 55 | $$->payload.inner_desc = &proto_geneve; | |
| 6132 | } | ||
| 6133 | ; | ||
| 6134 | |||
| 6135 | 10 | geneve_hdr_field : VNI { $$ = GNVHDR_VNI; } | |
| 6136 | ✗ | | TYPE { $$ = GNVHDR_TYPE; } | |
| 6137 | ; | ||
| 6138 | |||
| 6139 | gre_hdr_expr : GRE gre_hdr_field close_scope_gre | ||
| 6140 | { | ||
| 6141 | 5 | $$ = payload_expr_alloc(&@$, &proto_gre, $2); | |
| 6142 | } | ||
| 6143 | | GRE close_scope_gre inner_inet_expr | ||
| 6144 | { | ||
| 6145 | 45 | $$ = $3; | |
| 6146 | 45 | $$->payload.inner_desc = &proto_gre; | |
| 6147 | } | ||
| 6148 | ; | ||
| 6149 | |||
| 6150 | 5 | gre_hdr_field : HDRVERSION { $$ = GREHDR_VERSION; } | |
| 6151 | ✗ | | FLAGS { $$ = GREHDR_FLAGS; } | |
| 6152 | ✗ | | PROTOCOL { $$ = GREHDR_PROTOCOL; } | |
| 6153 | ; | ||
| 6154 | |||
| 6155 | gretap_hdr_expr : GRETAP close_scope_gre inner_expr | ||
| 6156 | { | ||
| 6157 | 55 | $$ = $3; | |
| 6158 | 55 | $$->payload.inner_desc = &proto_gretap; | |
| 6159 | } | ||
| 6160 | ; | ||
| 6161 | |||
| 6162 | optstrip_stmt : RESET TCP OPTION tcp_hdr_option_type close_scope_tcp | ||
| 6163 | { | ||
| 6164 | 15 | $$ = optstrip_stmt_alloc(&@$, tcpopt_expr_alloc(&@$, | |
| 6165 | 15 | $4, TCPOPT_COMMON_KIND)); | |
| 6166 | } | ||
| 6167 | ; | ||
| 6168 | |||
| 6169 | 117 | tcp_hdr_field : SPORT { $$ = TCPHDR_SPORT; } | |
| 6170 | 955 | | DPORT { $$ = TCPHDR_DPORT; } | |
| 6171 | 50 | | SEQUENCE { $$ = TCPHDR_SEQ; } | |
| 6172 | 35 | | ACKSEQ { $$ = TCPHDR_ACKSEQ; } | |
| 6173 | 5 | | DOFF { $$ = TCPHDR_DOFF; } | |
| 6174 | ✗ | | RESERVED { $$ = TCPHDR_RESERVED; } | |
| 6175 | 236 | | FLAGS { $$ = TCPHDR_FLAGS; } | |
| 6176 | 35 | | WINDOW { $$ = TCPHDR_WINDOW; } | |
| 6177 | 30 | | CHECKSUM { $$ = TCPHDR_CHECKSUM; } | |
| 6178 | 35 | | URGPTR { $$ = TCPHDR_URGPTR; } | |
| 6179 | ; | ||
| 6180 | |||
| 6181 | tcp_hdr_option_kind_and_field : MSS tcpopt_field_maxseg | ||
| 6182 | { | ||
| 6183 | 19 | struct tcp_kind_field kind_field = { .kind = TCPOPT_KIND_MAXSEG, .field = $2 }; | |
| 6184 | 19 | $$ = kind_field; | |
| 6185 | } | ||
| 6186 | | tcp_hdr_option_sack tcpopt_field_sack | ||
| 6187 | { | ||
| 6188 | 36 | struct tcp_kind_field kind_field = { .kind = $1, .field = $2 }; | |
| 6189 | 36 | $$ = kind_field; | |
| 6190 | } | ||
| 6191 | | WINDOW tcpopt_field_window | ||
| 6192 | { | ||
| 6193 | 3 | struct tcp_kind_field kind_field = { .kind = TCPOPT_KIND_WINDOW, .field = $2 }; | |
| 6194 | 3 | $$ = kind_field; | |
| 6195 | } | ||
| 6196 | | TIMESTAMP tcpopt_field_tsopt | ||
| 6197 | { | ||
| 6198 | 6 | struct tcp_kind_field kind_field = { .kind = TCPOPT_KIND_TIMESTAMP, .field = $2 }; | |
| 6199 | 6 | $$ = kind_field; | |
| 6200 | } | ||
| 6201 | | tcp_hdr_option_type LENGTH | ||
| 6202 | { | ||
| 6203 | 19 | struct tcp_kind_field kind_field = { .kind = $1, .field = TCPOPT_COMMON_LENGTH }; | |
| 6204 | 19 | $$ = kind_field; | |
| 6205 | } | ||
| 6206 | | MPTCP tcpopt_field_mptcp | ||
| 6207 | { | ||
| 6208 | 23 | struct tcp_kind_field kind_field = { .kind = TCPOPT_KIND_MPTCP, .field = $2 }; | |
| 6209 | 23 | $$ = kind_field; | |
| 6210 | } | ||
| 6211 | ; | ||
| 6212 | |||
| 6213 | 24 | tcp_hdr_option_sack : SACK { $$ = TCPOPT_KIND_SACK; } | |
| 6214 | 6 | | SACK0 { $$ = TCPOPT_KIND_SACK; } | |
| 6215 | 6 | | SACK1 { $$ = TCPOPT_KIND_SACK1; } | |
| 6216 | 6 | | SACK2 { $$ = TCPOPT_KIND_SACK2; } | |
| 6217 | 6 | | SACK3 { $$ = TCPOPT_KIND_SACK3; } | |
| 6218 | ; | ||
| 6219 | |||
| 6220 | ✗ | tcp_hdr_option_type : ECHO { $$ = TCPOPT_KIND_ECHO; } | |
| 6221 | 9 | | EOL { $$ = TCPOPT_KIND_EOL; } | |
| 6222 | 8 | | FASTOPEN { $$ = TCPOPT_KIND_FASTOPEN; } | |
| 6223 | 3 | | MD5SIG { $$ = TCPOPT_KIND_MD5SIG; } | |
| 6224 | 6 | | MPTCP { $$ = TCPOPT_KIND_MPTCP; } | |
| 6225 | 9 | | MSS { $$ = TCPOPT_KIND_MAXSEG; } | |
| 6226 | 8 | | NOP { $$ = TCPOPT_KIND_NOP; } | |
| 6227 | 10 | | SACK_PERM { $$ = TCPOPT_KIND_SACK_PERMITTED; } | |
| 6228 | 6 | | TIMESTAMP { $$ = TCPOPT_KIND_TIMESTAMP; } | |
| 6229 | 9 | | WINDOW { $$ = TCPOPT_KIND_WINDOW; } | |
| 6230 | 6 | | tcp_hdr_option_sack { $$ = $1; } | |
| 6231 | | NUM { | ||
| 6232 |
2/2✓ Branch 0 (2146→2147) taken 6 times.
✓ Branch 1 (2146→2150) taken 20 times.
|
26 | if ($1 > 255) { |
| 6233 | 6 | erec_queue(error(&@1, "value too large"), state->msgs); | |
| 6234 | 6 | YYERROR; | |
| 6235 | } | ||
| 6236 | 20 | $$ = $1; | |
| 6237 | } | ||
| 6238 | ; | ||
| 6239 | |||
| 6240 | 18 | tcpopt_field_sack : LEFT { $$ = TCPOPT_SACK_LEFT; } | |
| 6241 | 18 | | RIGHT { $$ = TCPOPT_SACK_RIGHT; } | |
| 6242 | ; | ||
| 6243 | |||
| 6244 | 3 | tcpopt_field_window : COUNT { $$ = TCPOPT_WINDOW_COUNT; } | |
| 6245 | ; | ||
| 6246 | |||
| 6247 | 3 | tcpopt_field_tsopt : TSVAL { $$ = TCPOPT_TS_TSVAL; } | |
| 6248 | 3 | | TSECR { $$ = TCPOPT_TS_TSECR; } | |
| 6249 | ; | ||
| 6250 | |||
| 6251 | 19 | tcpopt_field_maxseg : SIZE { $$ = TCPOPT_MAXSEG_SIZE; } | |
| 6252 | ; | ||
| 6253 | |||
| 6254 | 23 | tcpopt_field_mptcp : SUBTYPE { $$ = TCPOPT_MPTCP_SUBTYPE; } | |
| 6255 | ; | ||
| 6256 | |||
| 6257 | dccp_hdr_expr : DCCP dccp_hdr_field close_scope_dccp | ||
| 6258 | { | ||
| 6259 | 55 | $$ = payload_expr_alloc(&@$, &proto_dccp, $2); | |
| 6260 | } | ||
| 6261 | | DCCP OPTION NUM close_scope_dccp | ||
| 6262 | { | ||
| 6263 | ✗ | if ($3 > DCCPOPT_TYPE_MAX) { | |
| 6264 | ✗ | erec_queue(error(&@1, "value too large"), | |
| 6265 | state->msgs); | ||
| 6266 | ✗ | YYERROR; | |
| 6267 | } | ||
| 6268 | ✗ | $$ = dccpopt_expr_alloc(&@$, $3); | |
| 6269 | } | ||
| 6270 | ; | ||
| 6271 | |||
| 6272 | 25 | dccp_hdr_field : SPORT { $$ = DCCPHDR_SPORT; } | |
| 6273 | 10 | | DPORT { $$ = DCCPHDR_DPORT; } | |
| 6274 | 20 | | TYPE close_scope_type { $$ = DCCPHDR_TYPE; } | |
| 6275 | ; | ||
| 6276 | |||
| 6277 | 10 | sctp_chunk_type : DATA { $$ = SCTP_CHUNK_TYPE_DATA; } | |
| 6278 | 11 | | INIT { $$ = SCTP_CHUNK_TYPE_INIT; } | |
| 6279 | 10 | | INIT_ACK { $$ = SCTP_CHUNK_TYPE_INIT_ACK; } | |
| 6280 | 5 | | SACK { $$ = SCTP_CHUNK_TYPE_SACK; } | |
| 6281 | 5 | | HEARTBEAT { $$ = SCTP_CHUNK_TYPE_HEARTBEAT; } | |
| 6282 | 5 | | HEARTBEAT_ACK { $$ = SCTP_CHUNK_TYPE_HEARTBEAT_ACK; } | |
| 6283 | 5 | | ABORT { $$ = SCTP_CHUNK_TYPE_ABORT; } | |
| 6284 | 5 | | SHUTDOWN { $$ = SCTP_CHUNK_TYPE_SHUTDOWN; } | |
| 6285 | 5 | | SHUTDOWN_ACK { $$ = SCTP_CHUNK_TYPE_SHUTDOWN_ACK; } | |
| 6286 | 5 | | ERROR { $$ = SCTP_CHUNK_TYPE_ERROR; } | |
| 6287 | 5 | | COOKIE_ECHO { $$ = SCTP_CHUNK_TYPE_COOKIE_ECHO; } | |
| 6288 | 5 | | COOKIE_ACK { $$ = SCTP_CHUNK_TYPE_COOKIE_ACK; } | |
| 6289 | 5 | | ECNE { $$ = SCTP_CHUNK_TYPE_ECNE; } | |
| 6290 | 5 | | CWR { $$ = SCTP_CHUNK_TYPE_CWR; } | |
| 6291 | 5 | | SHUTDOWN_COMPLETE { $$ = SCTP_CHUNK_TYPE_SHUTDOWN_COMPLETE; } | |
| 6292 | 5 | | ASCONF_ACK { $$ = SCTP_CHUNK_TYPE_ASCONF_ACK; } | |
| 6293 | 5 | | FORWARD_TSN { $$ = SCTP_CHUNK_TYPE_FORWARD_TSN; } | |
| 6294 | 5 | | ASCONF { $$ = SCTP_CHUNK_TYPE_ASCONF; } | |
| 6295 | ; | ||
| 6296 | |||
| 6297 | 5 | sctp_chunk_common_field : TYPE close_scope_type { $$ = SCTP_CHUNK_COMMON_TYPE; } | |
| 6298 | 5 | | FLAGS { $$ = SCTP_CHUNK_COMMON_FLAGS; } | |
| 6299 | 5 | | LENGTH { $$ = SCTP_CHUNK_COMMON_LENGTH; } | |
| 6300 | ; | ||
| 6301 | |||
| 6302 | ✗ | sctp_chunk_data_field : TSN { $$ = SCTP_CHUNK_DATA_TSN; } | |
| 6303 | 5 | | STREAM { $$ = SCTP_CHUNK_DATA_STREAM; } | |
| 6304 | ✗ | | SSN { $$ = SCTP_CHUNK_DATA_SSN; } | |
| 6305 | ✗ | | PPID { $$ = SCTP_CHUNK_DATA_PPID; } | |
| 6306 | ; | ||
| 6307 | |||
| 6308 | ✗ | sctp_chunk_init_field : INIT_TAG { $$ = SCTP_CHUNK_INIT_TAG; } | |
| 6309 | ✗ | | A_RWND { $$ = SCTP_CHUNK_INIT_RWND; } | |
| 6310 | 5 | | NUM_OSTREAMS { $$ = SCTP_CHUNK_INIT_OSTREAMS; } | |
| 6311 | 4 | | NUM_ISTREAMS { $$ = SCTP_CHUNK_INIT_ISTREAMS; } | |
| 6312 | 5 | | INIT_TSN { $$ = SCTP_CHUNK_INIT_TSN; } | |
| 6313 | ; | ||
| 6314 | |||
| 6315 | ✗ | sctp_chunk_sack_field : CUM_TSN_ACK { $$ = SCTP_CHUNK_SACK_CTSN_ACK; } | |
| 6316 | 5 | | A_RWND { $$ = SCTP_CHUNK_SACK_RWND; } | |
| 6317 | ✗ | | NUM_GACK_BLOCKS { $$ = SCTP_CHUNK_SACK_GACK_BLOCKS; } | |
| 6318 | ✗ | | NUM_DUP_TSNS { $$ = SCTP_CHUNK_SACK_DUP_TSNS; } | |
| 6319 | ; | ||
| 6320 | |||
| 6321 | sctp_chunk_alloc : sctp_chunk_type | ||
| 6322 | { | ||
| 6323 | 91 | $$ = sctp_chunk_expr_alloc(&@$, $1, SCTP_CHUNK_COMMON_TYPE); | |
| 6324 | 91 | $$->exthdr.flags = NFT_EXTHDR_F_PRESENT; | |
| 6325 | } | ||
| 6326 | | sctp_chunk_type sctp_chunk_common_field | ||
| 6327 | { | ||
| 6328 | 15 | $$ = sctp_chunk_expr_alloc(&@$, $1, $2); | |
| 6329 | } | ||
| 6330 | | DATA sctp_chunk_data_field | ||
| 6331 | { | ||
| 6332 | 5 | $$ = sctp_chunk_expr_alloc(&@$, SCTP_CHUNK_TYPE_DATA, $2); | |
| 6333 | } | ||
| 6334 | | INIT sctp_chunk_init_field | ||
| 6335 | { | ||
| 6336 | 9 | $$ = sctp_chunk_expr_alloc(&@$, SCTP_CHUNK_TYPE_INIT, $2); | |
| 6337 | } | ||
| 6338 | | INIT_ACK sctp_chunk_init_field | ||
| 6339 | { | ||
| 6340 | 5 | $$ = sctp_chunk_expr_alloc(&@$, SCTP_CHUNK_TYPE_INIT_ACK, $2); | |
| 6341 | } | ||
| 6342 | | SACK sctp_chunk_sack_field | ||
| 6343 | { | ||
| 6344 | 5 | $$ = sctp_chunk_expr_alloc(&@$, SCTP_CHUNK_TYPE_SACK, $2); | |
| 6345 | } | ||
| 6346 | | SHUTDOWN CUM_TSN_ACK | ||
| 6347 | { | ||
| 6348 | 5 | $$ = sctp_chunk_expr_alloc(&@$, SCTP_CHUNK_TYPE_SHUTDOWN, | |
| 6349 | SCTP_CHUNK_SHUTDOWN_CTSN_ACK); | ||
| 6350 | } | ||
| 6351 | | ECNE LOWEST_TSN | ||
| 6352 | { | ||
| 6353 | 5 | $$ = sctp_chunk_expr_alloc(&@$, SCTP_CHUNK_TYPE_ECNE, | |
| 6354 | SCTP_CHUNK_ECNE_CWR_MIN_TSN); | ||
| 6355 | } | ||
| 6356 | | CWR LOWEST_TSN | ||
| 6357 | { | ||
| 6358 | 5 | $$ = sctp_chunk_expr_alloc(&@$, SCTP_CHUNK_TYPE_CWR, | |
| 6359 | SCTP_CHUNK_ECNE_CWR_MIN_TSN); | ||
| 6360 | } | ||
| 6361 | | ASCONF_ACK SEQNO | ||
| 6362 | { | ||
| 6363 | 5 | $$ = sctp_chunk_expr_alloc(&@$, SCTP_CHUNK_TYPE_ASCONF_ACK, | |
| 6364 | SCTP_CHUNK_ASCONF_SEQNO); | ||
| 6365 | } | ||
| 6366 | | FORWARD_TSN NEW_CUM_TSN | ||
| 6367 | { | ||
| 6368 | 5 | $$ = sctp_chunk_expr_alloc(&@$, SCTP_CHUNK_TYPE_FORWARD_TSN, | |
| 6369 | SCTP_CHUNK_FORWARD_TSN_NCTSN); | ||
| 6370 | } | ||
| 6371 | | ASCONF SEQNO | ||
| 6372 | { | ||
| 6373 | 5 | $$ = sctp_chunk_expr_alloc(&@$, SCTP_CHUNK_TYPE_ASCONF, | |
| 6374 | SCTP_CHUNK_ASCONF_SEQNO); | ||
| 6375 | } | ||
| 6376 | ; | ||
| 6377 | |||
| 6378 | sctp_hdr_expr : SCTP sctp_hdr_field close_scope_sctp | ||
| 6379 | { | ||
| 6380 | 120 | $$ = payload_expr_alloc(&@$, &proto_sctp, $2); | |
| 6381 | } | ||
| 6382 | | SCTP CHUNK sctp_chunk_alloc close_scope_sctp_chunk close_scope_sctp | ||
| 6383 | { | ||
| 6384 | 160 | $$ = $3; | |
| 6385 | } | ||
| 6386 | ; | ||
| 6387 | |||
| 6388 | 30 | sctp_hdr_field : SPORT { $$ = SCTPHDR_SPORT; } | |
| 6389 | 30 | | DPORT { $$ = SCTPHDR_DPORT; } | |
| 6390 | 30 | | VTAG { $$ = SCTPHDR_VTAG; } | |
| 6391 | 30 | | CHECKSUM { $$ = SCTPHDR_CHECKSUM; } | |
| 6392 | ; | ||
| 6393 | |||
| 6394 | th_hdr_expr : TRANSPORT_HDR th_hdr_field close_scope_th | ||
| 6395 | { | ||
| 6396 | 54 | $$ = payload_expr_alloc(&@$, &proto_th, $2); | |
| 6397 |
1/2✓ Branch 0 (2235→2236) taken 54 times.
✗ Branch 1 (2235→2237) not taken.
|
54 | if ($$) |
| 6398 | 54 | $$->payload.is_raw = true; | |
| 6399 | } | ||
| 6400 | ; | ||
| 6401 | |||
| 6402 | 2 | th_hdr_field : SPORT { $$ = THDR_SPORT; } | |
| 6403 | 52 | | DPORT { $$ = THDR_DPORT; } | |
| 6404 | ; | ||
| 6405 | |||
| 6406 | exthdr_expr : hbh_hdr_expr | ||
| 6407 | | rt_hdr_expr | ||
| 6408 | | rt0_hdr_expr | ||
| 6409 | | rt2_hdr_expr | ||
| 6410 | | rt4_hdr_expr | ||
| 6411 | | frag_hdr_expr | ||
| 6412 | | dst_hdr_expr | ||
| 6413 | | mh_hdr_expr | ||
| 6414 | ; | ||
| 6415 | |||
| 6416 | hbh_hdr_expr : HBH hbh_hdr_field close_scope_hbh | ||
| 6417 | { | ||
| 6418 | 40 | $$ = exthdr_expr_alloc(&@$, &exthdr_hbh, $2); | |
| 6419 | } | ||
| 6420 | ; | ||
| 6421 | |||
| 6422 | 28 | hbh_hdr_field : NEXTHDR { $$ = HBHHDR_NEXTHDR; } | |
| 6423 | 12 | | HDRLENGTH { $$ = HBHHDR_HDRLENGTH; } | |
| 6424 | ; | ||
| 6425 | |||
| 6426 | rt_hdr_expr : RT rt_hdr_field close_scope_rt | ||
| 6427 | { | ||
| 6428 | 70 | $$ = exthdr_expr_alloc(&@$, &exthdr_rt, $2); | |
| 6429 | } | ||
| 6430 | ; | ||
| 6431 | |||
| 6432 | 32 | rt_hdr_field : NEXTHDR { $$ = RTHDR_NEXTHDR; } | |
| 6433 | 12 | | HDRLENGTH { $$ = RTHDR_HDRLENGTH; } | |
| 6434 | 14 | | TYPE close_scope_type { $$ = RTHDR_TYPE; } | |
| 6435 | 12 | | SEG_LEFT { $$ = RTHDR_SEG_LEFT; } | |
| 6436 | ; | ||
| 6437 | |||
| 6438 | rt0_hdr_expr : RT0 rt0_hdr_field close_scope_rt | ||
| 6439 | { | ||
| 6440 | ✗ | $$ = exthdr_expr_alloc(&@$, &exthdr_rt0, $2); | |
| 6441 | } | ||
| 6442 | ; | ||
| 6443 | |||
| 6444 | rt0_hdr_field : ADDR '[' NUM ']' | ||
| 6445 | { | ||
| 6446 | ✗ | $$ = RT0HDR_ADDR_1 + $3 - 1; | |
| 6447 | } | ||
| 6448 | ; | ||
| 6449 | |||
| 6450 | rt2_hdr_expr : RT2 rt2_hdr_field close_scope_rt | ||
| 6451 | { | ||
| 6452 | ✗ | $$ = exthdr_expr_alloc(&@$, &exthdr_rt2, $2); | |
| 6453 | } | ||
| 6454 | ; | ||
| 6455 | |||
| 6456 | ✗ | rt2_hdr_field : ADDR { $$ = RT2HDR_ADDR; } | |
| 6457 | ; | ||
| 6458 | |||
| 6459 | rt4_hdr_expr : RT4 rt4_hdr_field close_scope_rt | ||
| 6460 | { | ||
| 6461 | 15 | $$ = exthdr_expr_alloc(&@$, &exthdr_rt4, $2); | |
| 6462 | } | ||
| 6463 | ; | ||
| 6464 | |||
| 6465 | 4 | rt4_hdr_field : LAST_ENT { $$ = RT4HDR_LASTENT; } | |
| 6466 | 4 | | FLAGS { $$ = RT4HDR_FLAGS; } | |
| 6467 | 5 | | TAG { $$ = RT4HDR_TAG; } | |
| 6468 | | SID '[' NUM ']' | ||
| 6469 | { | ||
| 6470 | 2 | $$ = RT4HDR_SID_1 + $3 - 1; | |
| 6471 | } | ||
| 6472 | ; | ||
| 6473 | |||
| 6474 | frag_hdr_expr : FRAG frag_hdr_field close_scope_frag | ||
| 6475 | { | ||
| 6476 | 140 | $$ = exthdr_expr_alloc(&@$, &exthdr_frag, $2); | |
| 6477 | } | ||
| 6478 | ; | ||
| 6479 | |||
| 6480 | 48 | frag_hdr_field : NEXTHDR { $$ = FRAGHDR_NEXTHDR; } | |
| 6481 | 24 | | RESERVED { $$ = FRAGHDR_RESERVED; } | |
| 6482 | 28 | | FRAG_OFF { $$ = FRAGHDR_FRAG_OFF; } | |
| 6483 | 4 | | RESERVED2 { $$ = FRAGHDR_RESERVED2; } | |
| 6484 | 8 | | MORE_FRAGMENTS { $$ = FRAGHDR_MFRAGS; } | |
| 6485 | 28 | | ID { $$ = FRAGHDR_ID; } | |
| 6486 | ; | ||
| 6487 | |||
| 6488 | dst_hdr_expr : DST dst_hdr_field close_scope_dst | ||
| 6489 | { | ||
| 6490 | 38 | $$ = exthdr_expr_alloc(&@$, &exthdr_dst, $2); | |
| 6491 | } | ||
| 6492 | ; | ||
| 6493 | |||
| 6494 | 28 | dst_hdr_field : NEXTHDR { $$ = DSTHDR_NEXTHDR; } | |
| 6495 | 10 | | HDRLENGTH { $$ = DSTHDR_HDRLENGTH; } | |
| 6496 | ; | ||
| 6497 | |||
| 6498 | mh_hdr_expr : MH mh_hdr_field close_scope_mh | ||
| 6499 | { | ||
| 6500 | 74 | $$ = exthdr_expr_alloc(&@$, &exthdr_mh, $2); | |
| 6501 | } | ||
| 6502 | ; | ||
| 6503 | |||
| 6504 | 32 | mh_hdr_field : NEXTHDR { $$ = MHHDR_NEXTHDR; } | |
| 6505 | 12 | | HDRLENGTH { $$ = MHHDR_HDRLENGTH; } | |
| 6506 | 6 | | TYPE close_scope_type { $$ = MHHDR_TYPE; } | |
| 6507 | 12 | | RESERVED { $$ = MHHDR_RESERVED; } | |
| 6508 | 12 | | CHECKSUM { $$ = MHHDR_CHECKSUM; } | |
| 6509 | ; | ||
| 6510 | |||
| 6511 | exthdr_exists_expr : EXTHDR exthdr_key | ||
| 6512 | { | ||
| 6513 | const struct exthdr_desc *desc; | ||
| 6514 | |||
| 6515 | 16 | desc = exthdr_find_proto($2); | |
| 6516 | |||
| 6517 | /* Assume that NEXTHDR template is always | ||
| 6518 | * the first one in list of templates. | ||
| 6519 | */ | ||
| 6520 | 16 | $$ = exthdr_expr_alloc(&@$, desc, 1); | |
| 6521 | 16 | $$->exthdr.flags = NFT_EXTHDR_F_PRESENT; | |
| 6522 | } | ||
| 6523 | ; | ||
| 6524 | |||
| 6525 | 12 | exthdr_key : HBH close_scope_hbh { $$ = IPPROTO_HOPOPTS; } | |
| 6526 | 1 | | RT close_scope_rt { $$ = IPPROTO_ROUTING; } | |
| 6527 | 1 | | FRAG close_scope_frag { $$ = IPPROTO_FRAGMENT; } | |
| 6528 | 1 | | DST close_scope_dst { $$ = IPPROTO_DSTOPTS; } | |
| 6529 | 1 | | MH close_scope_mh { $$ = IPPROTO_MH; } | |
| 6530 | ; | ||
| 6531 | |||
| 6532 | %% | ||
| 6533 | |||
| 6534 | static int | ||
| 6535 | 236 | yyreport_syntax_error(const yypcontext_t *yyctx, struct nft_ctx *nft, | |
| 6536 | void *scanner, struct parser_state *state) | ||
| 6537 | { | ||
| 6538 | 236 | const char *bad_token = yysymbol_name(yypcontext_token(yyctx)); | |
| 6539 | 236 | struct location *loc = yypcontext_location(yyctx); | |
| 6540 | yysymbol_kind_t *exp_tokens; | ||
| 6541 | int exp_tokens_cnt; | ||
| 6542 | size_t errbufsz; | ||
| 6543 | FILE *errfp; | ||
| 6544 | char *msg; | ||
| 6545 | |||
| 6546 | 236 | errfp = open_memstream(&msg, &errbufsz); | |
| 6547 |
1/2✗ Branch 0 (6→7) not taken.
✓ Branch 1 (6→8) taken 236 times.
|
236 | if (!errfp) |
| 6548 | ✗ | memory_allocation_error(); | |
| 6549 | |||
| 6550 | 236 | exp_tokens_cnt = yypcontext_expected_tokens(yyctx, NULL, 0); | |
| 6551 | 236 | exp_tokens = xmalloc_array(exp_tokens_cnt, sizeof(yysymbol_kind_t)); | |
| 6552 | 236 | yypcontext_expected_tokens(yyctx, exp_tokens, exp_tokens_cnt); | |
| 6553 | |||
| 6554 | 236 | fprintf(errfp, "syntax error, unexpected %s\nexpected any of: ", bad_token); | |
| 6555 | |||
| 6556 |
2/2✓ Branch 0 (25→13) taken 8545 times.
✓ Branch 1 (25→26) taken 236 times.
|
8781 | for (int i = 0; i < exp_tokens_cnt; i++) { |
| 6557 | 8545 | const char *token_name = yysymbol_name(exp_tokens[i]); | |
| 6558 | 8545 | bool is_keyword = true; | |
| 6559 | |||
| 6560 | /* tokens that name generic things shall be printed as <foo>; detect them */ | ||
| 6561 |
2/2✓ Branch 0 (14→15) taken 393 times.
✓ Branch 1 (14→16) taken 8152 times.
|
8545 | switch (exp_tokens[i]) { |
| 6562 | 393 | case YYSYMBOL_NUM: | |
| 6563 | case YYSYMBOL_STRING: | ||
| 6564 | case YYSYMBOL_QUOTED_STRING: | ||
| 6565 | case YYSYMBOL_ASTERISK_STRING: | ||
| 6566 | 393 | is_keyword = false; | |
| 6567 | 393 | break; | |
| 6568 | 8152 | default: | |
| 6569 | 8152 | break; | |
| 6570 | } | ||
| 6571 | |||
| 6572 |
2/2✓ Branch 0 (17→18) taken 8309 times.
✓ Branch 1 (17→19) taken 236 times.
|
8545 | if (i > 0) |
| 6573 | 8309 | fputs(", ", errfp); | |
| 6574 |
2/2✓ Branch 0 (19→20) taken 393 times.
✓ Branch 1 (19→21) taken 8152 times.
|
8545 | if (!is_keyword) |
| 6575 | 393 | fputc('<', errfp); | |
| 6576 | 8545 | fputs(token_name, errfp); | |
| 6577 |
2/2✓ Branch 0 (22→23) taken 393 times.
✓ Branch 1 (22→24) taken 8152 times.
|
8545 | if (!is_keyword) |
| 6578 | 393 | fputc('>', errfp); | |
| 6579 | } | ||
| 6580 | |||
| 6581 | 236 | free(exp_tokens); | |
| 6582 | 236 | fclose(errfp); | |
| 6583 | /* no newline on the end of the error message; this is intended */ | ||
| 6584 | 236 | yyerror(loc, nft, scanner, state, msg); | |
| 6585 | |||
| 6586 | 236 | free(msg); | |
| 6587 | 236 | return 0; | |
| 6588 | } | ||
| 6589 |