1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _NET_NF_TABLES_H 3 #define _NET_NF_TABLES_H 4 5 #include <asm/unaligned.h> 6 #include <linux/list.h> 7 #include <linux/netfilter.h> 8 #include <linux/netfilter/nfnetlink.h> 9 #include <linux/netfilter/x_tables.h> 10 #include <linux/netfilter/nf_tables.h> 11 #include <linux/u64_stats_sync.h> 12 #include <linux/rhashtable.h> 13 #include <net/netfilter/nf_flow_table.h> 14 #include <net/netlink.h> 15 #include <net/flow_offload.h> 16 17 struct module; 18 19 #define NFT_JUMP_STACK_SIZE 16 20 21 struct nft_pktinfo { 22 struct sk_buff *skb; 23 bool tprot_set; 24 u8 tprot; 25 /* for x_tables compatibility */ 26 struct xt_action_param xt; 27 }; 28 29 static inline struct net *nft_net(const struct nft_pktinfo *pkt) 30 { 31 return pkt->xt.state->net; 32 } 33 34 static inline unsigned int nft_hook(const struct nft_pktinfo *pkt) 35 { 36 return pkt->xt.state->hook; 37 } 38 39 static inline u8 nft_pf(const struct nft_pktinfo *pkt) 40 { 41 return pkt->xt.state->pf; 42 } 43 44 static inline const struct net_device *nft_in(const struct nft_pktinfo *pkt) 45 { 46 return pkt->xt.state->in; 47 } 48 49 static inline const struct net_device *nft_out(const struct nft_pktinfo *pkt) 50 { 51 return pkt->xt.state->out; 52 } 53 54 static inline void nft_set_pktinfo(struct nft_pktinfo *pkt, 55 struct sk_buff *skb, 56 const struct nf_hook_state *state) 57 { 58 pkt->skb = skb; 59 pkt->xt.state = state; 60 } 61 62 static inline void nft_set_pktinfo_unspec(struct nft_pktinfo *pkt, 63 struct sk_buff *skb) 64 { 65 pkt->tprot_set = false; 66 pkt->tprot = 0; 67 pkt->xt.thoff = 0; 68 pkt->xt.fragoff = 0; 69 } 70 71 /** 72 * struct nft_verdict - nf_tables verdict 73 * 74 * @code: nf_tables/netfilter verdict code 75 * @chain: destination chain for NFT_JUMP/NFT_GOTO 76 */ 77 struct nft_verdict { 78 u32 code; 79 struct nft_chain *chain; 80 }; 81 82 struct nft_data { 83 union { 84 u32 data[4]; 85 struct nft_verdict verdict; 86 }; 87 } __attribute__((aligned(__alignof__(u64)))); 88 89 /** 90 * struct nft_regs - nf_tables register set 91 * 92 * @data: data registers 93 * @verdict: verdict register 94 * 95 * The first four data registers alias to the verdict register. 96 */ 97 struct nft_regs { 98 union { 99 u32 data[20]; 100 struct nft_verdict verdict; 101 }; 102 }; 103 104 /* Store/load an u8, u16 or u64 integer to/from the u32 data register. 105 * 106 * Note, when using concatenations, register allocation happens at 32-bit 107 * level. So for store instruction, pad the rest part with zero to avoid 108 * garbage values. 109 */ 110 111 static inline void nft_reg_store8(u32 *dreg, u8 val) 112 { 113 *dreg = 0; 114 *(u8 *)dreg = val; 115 } 116 117 static inline u8 nft_reg_load8(u32 *sreg) 118 { 119 return *(u8 *)sreg; 120 } 121 122 static inline void nft_reg_store16(u32 *dreg, u16 val) 123 { 124 *dreg = 0; 125 *(u16 *)dreg = val; 126 } 127 128 static inline u16 nft_reg_load16(u32 *sreg) 129 { 130 return *(u16 *)sreg; 131 } 132 133 static inline void nft_reg_store64(u32 *dreg, u64 val) 134 { 135 put_unaligned(val, (u64 *)dreg); 136 } 137 138 static inline u64 nft_reg_load64(u32 *sreg) 139 { 140 return get_unaligned((u64 *)sreg); 141 } 142 143 static inline void nft_data_copy(u32 *dst, const struct nft_data *src, 144 unsigned int len) 145 { 146 memcpy(dst, src, len); 147 } 148 149 static inline void nft_data_debug(const struct nft_data *data) 150 { 151 pr_debug("data[0]=%x data[1]=%x data[2]=%x data[3]=%x\n", 152 data->data[0], data->data[1], 153 data->data[2], data->data[3]); 154 } 155 156 /** 157 * struct nft_ctx - nf_tables rule/set context 158 * 159 * @net: net namespace 160 * @table: the table the chain is contained in 161 * @chain: the chain the rule is contained in 162 * @nla: netlink attributes 163 * @portid: netlink portID of the original message 164 * @seq: netlink sequence number 165 * @family: protocol family 166 * @level: depth of the chains 167 * @report: notify via unicast netlink message 168 */ 169 struct nft_ctx { 170 struct net *net; 171 struct nft_table *table; 172 struct nft_chain *chain; 173 const struct nlattr * const *nla; 174 u32 portid; 175 u32 seq; 176 u16 flags; 177 u8 family; 178 u8 level; 179 bool report; 180 }; 181 182 struct nft_data_desc { 183 enum nft_data_types type; 184 unsigned int len; 185 }; 186 187 int nft_data_init(const struct nft_ctx *ctx, 188 struct nft_data *data, unsigned int size, 189 struct nft_data_desc *desc, const struct nlattr *nla); 190 void nft_data_hold(const struct nft_data *data, enum nft_data_types type); 191 void nft_data_release(const struct nft_data *data, enum nft_data_types type); 192 int nft_data_dump(struct sk_buff *skb, int attr, const struct nft_data *data, 193 enum nft_data_types type, unsigned int len); 194 195 static inline enum nft_data_types nft_dreg_to_type(enum nft_registers reg) 196 { 197 return reg == NFT_REG_VERDICT ? NFT_DATA_VERDICT : NFT_DATA_VALUE; 198 } 199 200 static inline enum nft_registers nft_type_to_reg(enum nft_data_types type) 201 { 202 return type == NFT_DATA_VERDICT ? NFT_REG_VERDICT : NFT_REG_1 * NFT_REG_SIZE / NFT_REG32_SIZE; 203 } 204 205 int nft_parse_u32_check(const struct nlattr *attr, int max, u32 *dest); 206 unsigned int nft_parse_register(const struct nlattr *attr); 207 int nft_dump_register(struct sk_buff *skb, unsigned int attr, unsigned int reg); 208 209 int nft_validate_register_load(enum nft_registers reg, unsigned int len); 210 int nft_validate_register_store(const struct nft_ctx *ctx, 211 enum nft_registers reg, 212 const struct nft_data *data, 213 enum nft_data_types type, unsigned int len); 214 215 /** 216 * struct nft_userdata - user defined data associated with an object 217 * 218 * @len: length of the data 219 * @data: content 220 * 221 * The presence of user data is indicated in an object specific fashion, 222 * so a length of zero can't occur and the value "len" indicates data 223 * of length len + 1. 224 */ 225 struct nft_userdata { 226 u8 len; 227 unsigned char data[0]; 228 }; 229 230 /** 231 * struct nft_set_elem - generic representation of set elements 232 * 233 * @key: element key 234 * @priv: element private data and extensions 235 */ 236 struct nft_set_elem { 237 union { 238 u32 buf[NFT_DATA_VALUE_MAXLEN / sizeof(u32)]; 239 struct nft_data val; 240 } key; 241 void *priv; 242 }; 243 244 struct nft_set; 245 struct nft_set_iter { 246 u8 genmask; 247 unsigned int count; 248 unsigned int skip; 249 int err; 250 int (*fn)(const struct nft_ctx *ctx, 251 struct nft_set *set, 252 const struct nft_set_iter *iter, 253 struct nft_set_elem *elem); 254 }; 255 256 /** 257 * struct nft_set_desc - description of set elements 258 * 259 * @klen: key length 260 * @dlen: data length 261 * @size: number of set elements 262 */ 263 struct nft_set_desc { 264 unsigned int klen; 265 unsigned int dlen; 266 unsigned int size; 267 }; 268 269 /** 270 * enum nft_set_class - performance class 271 * 272 * @NFT_LOOKUP_O_1: constant, O(1) 273 * @NFT_LOOKUP_O_LOG_N: logarithmic, O(log N) 274 * @NFT_LOOKUP_O_N: linear, O(N) 275 */ 276 enum nft_set_class { 277 NFT_SET_CLASS_O_1, 278 NFT_SET_CLASS_O_LOG_N, 279 NFT_SET_CLASS_O_N, 280 }; 281 282 /** 283 * struct nft_set_estimate - estimation of memory and performance 284 * characteristics 285 * 286 * @size: required memory 287 * @lookup: lookup performance class 288 * @space: memory class 289 */ 290 struct nft_set_estimate { 291 u64 size; 292 enum nft_set_class lookup; 293 enum nft_set_class space; 294 }; 295 296 struct nft_set_ext; 297 struct nft_expr; 298 299 /** 300 * struct nft_set_ops - nf_tables set operations 301 * 302 * @lookup: look up an element within the set 303 * @update: update an element if exists, add it if doesn't exist 304 * @delete: delete an element 305 * @insert: insert new element into set 306 * @activate: activate new element in the next generation 307 * @deactivate: lookup for element and deactivate it in the next generation 308 * @flush: deactivate element in the next generation 309 * @remove: remove element from set 310 * @walk: iterate over all set elements 311 * @get: get set elements 312 * @privsize: function to return size of set private data 313 * @init: initialize private data of new set instance 314 * @destroy: destroy private data of set instance 315 * @elemsize: element private size 316 * 317 * Operations lookup, update and delete have simpler interfaces, are faster 318 * and currently only used in the packet path. All the rest are slower, 319 * control plane functions. 320 */ 321 struct nft_set_ops { 322 bool (*lookup)(const struct net *net, 323 const struct nft_set *set, 324 const u32 *key, 325 const struct nft_set_ext **ext); 326 bool (*update)(struct nft_set *set, 327 const u32 *key, 328 void *(*new)(struct nft_set *, 329 const struct nft_expr *, 330 struct nft_regs *), 331 const struct nft_expr *expr, 332 struct nft_regs *regs, 333 const struct nft_set_ext **ext); 334 bool (*delete)(const struct nft_set *set, 335 const u32 *key); 336 337 int (*insert)(const struct net *net, 338 const struct nft_set *set, 339 const struct nft_set_elem *elem, 340 struct nft_set_ext **ext); 341 void (*activate)(const struct net *net, 342 const struct nft_set *set, 343 const struct nft_set_elem *elem); 344 void * (*deactivate)(const struct net *net, 345 const struct nft_set *set, 346 const struct nft_set_elem *elem); 347 bool (*flush)(const struct net *net, 348 const struct nft_set *set, 349 void *priv); 350 void (*remove)(const struct net *net, 351 const struct nft_set *set, 352 const struct nft_set_elem *elem); 353 void (*walk)(const struct nft_ctx *ctx, 354 struct nft_set *set, 355 struct nft_set_iter *iter); 356 void * (*get)(const struct net *net, 357 const struct nft_set *set, 358 const struct nft_set_elem *elem, 359 unsigned int flags); 360 361 u64 (*privsize)(const struct nlattr * const nla[], 362 const struct nft_set_desc *desc); 363 bool (*estimate)(const struct nft_set_desc *desc, 364 u32 features, 365 struct nft_set_estimate *est); 366 int (*init)(const struct nft_set *set, 367 const struct nft_set_desc *desc, 368 const struct nlattr * const nla[]); 369 void (*destroy)(const struct nft_set *set); 370 void (*gc_init)(const struct nft_set *set); 371 372 unsigned int elemsize; 373 }; 374 375 /** 376 * struct nft_set_type - nf_tables set type 377 * 378 * @ops: set ops for this type 379 * @list: used internally 380 * @owner: module reference 381 * @features: features supported by the implementation 382 */ 383 struct nft_set_type { 384 const struct nft_set_ops ops; 385 struct list_head list; 386 struct module *owner; 387 u32 features; 388 }; 389 #define to_set_type(o) container_of(o, struct nft_set_type, ops) 390 391 int nft_register_set(struct nft_set_type *type); 392 void nft_unregister_set(struct nft_set_type *type); 393 394 /** 395 * struct nft_set - nf_tables set instance 396 * 397 * @list: table set list node 398 * @bindings: list of set bindings 399 * @table: table this set belongs to 400 * @net: netnamespace this set belongs to 401 * @name: name of the set 402 * @handle: unique handle of the set 403 * @ktype: key type (numeric type defined by userspace, not used in the kernel) 404 * @dtype: data type (verdict or numeric type defined by userspace) 405 * @objtype: object type (see NFT_OBJECT_* definitions) 406 * @size: maximum set size 407 * @use: number of rules references to this set 408 * @nelems: number of elements 409 * @ndeact: number of deactivated elements queued for removal 410 * @timeout: default timeout value in jiffies 411 * @gc_int: garbage collection interval in msecs 412 * @policy: set parameterization (see enum nft_set_policies) 413 * @udlen: user data length 414 * @udata: user data 415 * @ops: set ops 416 * @flags: set flags 417 * @genmask: generation mask 418 * @klen: key length 419 * @dlen: data length 420 * @data: private set data 421 */ 422 struct nft_set { 423 struct list_head list; 424 struct list_head bindings; 425 struct nft_table *table; 426 possible_net_t net; 427 char *name; 428 u64 handle; 429 u32 ktype; 430 u32 dtype; 431 u32 objtype; 432 u32 size; 433 u32 use; 434 atomic_t nelems; 435 u32 ndeact; 436 u64 timeout; 437 u32 gc_int; 438 u16 policy; 439 u16 udlen; 440 unsigned char *udata; 441 /* runtime data below here */ 442 const struct nft_set_ops *ops ____cacheline_aligned; 443 u16 flags:14, 444 genmask:2; 445 u8 klen; 446 u8 dlen; 447 unsigned char data[] 448 __attribute__((aligned(__alignof__(u64)))); 449 }; 450 451 static inline bool nft_set_is_anonymous(const struct nft_set *set) 452 { 453 return set->flags & NFT_SET_ANONYMOUS; 454 } 455 456 static inline void *nft_set_priv(const struct nft_set *set) 457 { 458 return (void *)set->data; 459 } 460 461 static inline struct nft_set *nft_set_container_of(const void *priv) 462 { 463 return (void *)priv - offsetof(struct nft_set, data); 464 } 465 466 struct nft_set *nft_set_lookup_global(const struct net *net, 467 const struct nft_table *table, 468 const struct nlattr *nla_set_name, 469 const struct nlattr *nla_set_id, 470 u8 genmask); 471 472 static inline unsigned long nft_set_gc_interval(const struct nft_set *set) 473 { 474 return set->gc_int ? msecs_to_jiffies(set->gc_int) : HZ; 475 } 476 477 /** 478 * struct nft_set_binding - nf_tables set binding 479 * 480 * @list: set bindings list node 481 * @chain: chain containing the rule bound to the set 482 * @flags: set action flags 483 * 484 * A set binding contains all information necessary for validation 485 * of new elements added to a bound set. 486 */ 487 struct nft_set_binding { 488 struct list_head list; 489 const struct nft_chain *chain; 490 u32 flags; 491 }; 492 493 enum nft_trans_phase; 494 void nf_tables_deactivate_set(const struct nft_ctx *ctx, struct nft_set *set, 495 struct nft_set_binding *binding, 496 enum nft_trans_phase phase); 497 int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set, 498 struct nft_set_binding *binding); 499 void nf_tables_destroy_set(const struct nft_ctx *ctx, struct nft_set *set); 500 501 /** 502 * enum nft_set_extensions - set extension type IDs 503 * 504 * @NFT_SET_EXT_KEY: element key 505 * @NFT_SET_EXT_DATA: mapping data 506 * @NFT_SET_EXT_FLAGS: element flags 507 * @NFT_SET_EXT_TIMEOUT: element timeout 508 * @NFT_SET_EXT_EXPIRATION: element expiration time 509 * @NFT_SET_EXT_USERDATA: user data associated with the element 510 * @NFT_SET_EXT_EXPR: expression assiociated with the element 511 * @NFT_SET_EXT_OBJREF: stateful object reference associated with element 512 * @NFT_SET_EXT_NUM: number of extension types 513 */ 514 enum nft_set_extensions { 515 NFT_SET_EXT_KEY, 516 NFT_SET_EXT_DATA, 517 NFT_SET_EXT_FLAGS, 518 NFT_SET_EXT_TIMEOUT, 519 NFT_SET_EXT_EXPIRATION, 520 NFT_SET_EXT_USERDATA, 521 NFT_SET_EXT_EXPR, 522 NFT_SET_EXT_OBJREF, 523 NFT_SET_EXT_NUM 524 }; 525 526 /** 527 * struct nft_set_ext_type - set extension type 528 * 529 * @len: fixed part length of the extension 530 * @align: alignment requirements of the extension 531 */ 532 struct nft_set_ext_type { 533 u8 len; 534 u8 align; 535 }; 536 537 extern const struct nft_set_ext_type nft_set_ext_types[]; 538 539 /** 540 * struct nft_set_ext_tmpl - set extension template 541 * 542 * @len: length of extension area 543 * @offset: offsets of individual extension types 544 */ 545 struct nft_set_ext_tmpl { 546 u16 len; 547 u8 offset[NFT_SET_EXT_NUM]; 548 }; 549 550 /** 551 * struct nft_set_ext - set extensions 552 * 553 * @genmask: generation mask 554 * @offset: offsets of individual extension types 555 * @data: beginning of extension data 556 */ 557 struct nft_set_ext { 558 u8 genmask; 559 u8 offset[NFT_SET_EXT_NUM]; 560 char data[0]; 561 }; 562 563 static inline void nft_set_ext_prepare(struct nft_set_ext_tmpl *tmpl) 564 { 565 memset(tmpl, 0, sizeof(*tmpl)); 566 tmpl->len = sizeof(struct nft_set_ext); 567 } 568 569 static inline void nft_set_ext_add_length(struct nft_set_ext_tmpl *tmpl, u8 id, 570 unsigned int len) 571 { 572 tmpl->len = ALIGN(tmpl->len, nft_set_ext_types[id].align); 573 BUG_ON(tmpl->len > U8_MAX); 574 tmpl->offset[id] = tmpl->len; 575 tmpl->len += nft_set_ext_types[id].len + len; 576 } 577 578 static inline void nft_set_ext_add(struct nft_set_ext_tmpl *tmpl, u8 id) 579 { 580 nft_set_ext_add_length(tmpl, id, 0); 581 } 582 583 static inline void nft_set_ext_init(struct nft_set_ext *ext, 584 const struct nft_set_ext_tmpl *tmpl) 585 { 586 memcpy(ext->offset, tmpl->offset, sizeof(ext->offset)); 587 } 588 589 static inline bool __nft_set_ext_exists(const struct nft_set_ext *ext, u8 id) 590 { 591 return !!ext->offset[id]; 592 } 593 594 static inline bool nft_set_ext_exists(const struct nft_set_ext *ext, u8 id) 595 { 596 return ext && __nft_set_ext_exists(ext, id); 597 } 598 599 static inline void *nft_set_ext(const struct nft_set_ext *ext, u8 id) 600 { 601 return (void *)ext + ext->offset[id]; 602 } 603 604 static inline struct nft_data *nft_set_ext_key(const struct nft_set_ext *ext) 605 { 606 return nft_set_ext(ext, NFT_SET_EXT_KEY); 607 } 608 609 static inline struct nft_data *nft_set_ext_data(const struct nft_set_ext *ext) 610 { 611 return nft_set_ext(ext, NFT_SET_EXT_DATA); 612 } 613 614 static inline u8 *nft_set_ext_flags(const struct nft_set_ext *ext) 615 { 616 return nft_set_ext(ext, NFT_SET_EXT_FLAGS); 617 } 618 619 static inline u64 *nft_set_ext_timeout(const struct nft_set_ext *ext) 620 { 621 return nft_set_ext(ext, NFT_SET_EXT_TIMEOUT); 622 } 623 624 static inline u64 *nft_set_ext_expiration(const struct nft_set_ext *ext) 625 { 626 return nft_set_ext(ext, NFT_SET_EXT_EXPIRATION); 627 } 628 629 static inline struct nft_userdata *nft_set_ext_userdata(const struct nft_set_ext *ext) 630 { 631 return nft_set_ext(ext, NFT_SET_EXT_USERDATA); 632 } 633 634 static inline struct nft_expr *nft_set_ext_expr(const struct nft_set_ext *ext) 635 { 636 return nft_set_ext(ext, NFT_SET_EXT_EXPR); 637 } 638 639 static inline bool nft_set_elem_expired(const struct nft_set_ext *ext) 640 { 641 return nft_set_ext_exists(ext, NFT_SET_EXT_EXPIRATION) && 642 time_is_before_eq_jiffies64(*nft_set_ext_expiration(ext)); 643 } 644 645 static inline struct nft_set_ext *nft_set_elem_ext(const struct nft_set *set, 646 void *elem) 647 { 648 return elem + set->ops->elemsize; 649 } 650 651 static inline struct nft_object **nft_set_ext_obj(const struct nft_set_ext *ext) 652 { 653 return nft_set_ext(ext, NFT_SET_EXT_OBJREF); 654 } 655 656 void *nft_set_elem_init(const struct nft_set *set, 657 const struct nft_set_ext_tmpl *tmpl, 658 const u32 *key, const u32 *data, 659 u64 timeout, u64 expiration, gfp_t gfp); 660 void nft_set_elem_destroy(const struct nft_set *set, void *elem, 661 bool destroy_expr); 662 663 /** 664 * struct nft_set_gc_batch_head - nf_tables set garbage collection batch 665 * 666 * @rcu: rcu head 667 * @set: set the elements belong to 668 * @cnt: count of elements 669 */ 670 struct nft_set_gc_batch_head { 671 struct rcu_head rcu; 672 const struct nft_set *set; 673 unsigned int cnt; 674 }; 675 676 #define NFT_SET_GC_BATCH_SIZE ((PAGE_SIZE - \ 677 sizeof(struct nft_set_gc_batch_head)) / \ 678 sizeof(void *)) 679 680 /** 681 * struct nft_set_gc_batch - nf_tables set garbage collection batch 682 * 683 * @head: GC batch head 684 * @elems: garbage collection elements 685 */ 686 struct nft_set_gc_batch { 687 struct nft_set_gc_batch_head head; 688 void *elems[NFT_SET_GC_BATCH_SIZE]; 689 }; 690 691 struct nft_set_gc_batch *nft_set_gc_batch_alloc(const struct nft_set *set, 692 gfp_t gfp); 693 void nft_set_gc_batch_release(struct rcu_head *rcu); 694 695 static inline void nft_set_gc_batch_complete(struct nft_set_gc_batch *gcb) 696 { 697 if (gcb != NULL) 698 call_rcu(&gcb->head.rcu, nft_set_gc_batch_release); 699 } 700 701 static inline struct nft_set_gc_batch * 702 nft_set_gc_batch_check(const struct nft_set *set, struct nft_set_gc_batch *gcb, 703 gfp_t gfp) 704 { 705 if (gcb != NULL) { 706 if (gcb->head.cnt + 1 < ARRAY_SIZE(gcb->elems)) 707 return gcb; 708 nft_set_gc_batch_complete(gcb); 709 } 710 return nft_set_gc_batch_alloc(set, gfp); 711 } 712 713 static inline void nft_set_gc_batch_add(struct nft_set_gc_batch *gcb, 714 void *elem) 715 { 716 gcb->elems[gcb->head.cnt++] = elem; 717 } 718 719 struct nft_expr_ops; 720 /** 721 * struct nft_expr_type - nf_tables expression type 722 * 723 * @select_ops: function to select nft_expr_ops 724 * @release_ops: release nft_expr_ops 725 * @ops: default ops, used when no select_ops functions is present 726 * @list: used internally 727 * @name: Identifier 728 * @owner: module reference 729 * @policy: netlink attribute policy 730 * @maxattr: highest netlink attribute number 731 * @family: address family for AF-specific types 732 * @flags: expression type flags 733 */ 734 struct nft_expr_type { 735 const struct nft_expr_ops *(*select_ops)(const struct nft_ctx *, 736 const struct nlattr * const tb[]); 737 void (*release_ops)(const struct nft_expr_ops *ops); 738 const struct nft_expr_ops *ops; 739 struct list_head list; 740 const char *name; 741 struct module *owner; 742 const struct nla_policy *policy; 743 unsigned int maxattr; 744 u8 family; 745 u8 flags; 746 }; 747 748 #define NFT_EXPR_STATEFUL 0x1 749 #define NFT_EXPR_GC 0x2 750 751 enum nft_trans_phase { 752 NFT_TRANS_PREPARE, 753 NFT_TRANS_ABORT, 754 NFT_TRANS_COMMIT, 755 NFT_TRANS_RELEASE 756 }; 757 758 struct nft_flow_rule; 759 struct nft_offload_ctx; 760 761 /** 762 * struct nft_expr_ops - nf_tables expression operations 763 * 764 * @eval: Expression evaluation function 765 * @size: full expression size, including private data size 766 * @init: initialization function 767 * @activate: activate expression in the next generation 768 * @deactivate: deactivate expression in next generation 769 * @destroy: destruction function, called after synchronize_rcu 770 * @dump: function to dump parameters 771 * @type: expression type 772 * @validate: validate expression, called during loop detection 773 * @data: extra data to attach to this expression operation 774 */ 775 struct nft_expr; 776 struct nft_expr_ops { 777 void (*eval)(const struct nft_expr *expr, 778 struct nft_regs *regs, 779 const struct nft_pktinfo *pkt); 780 int (*clone)(struct nft_expr *dst, 781 const struct nft_expr *src); 782 unsigned int size; 783 784 int (*init)(const struct nft_ctx *ctx, 785 const struct nft_expr *expr, 786 const struct nlattr * const tb[]); 787 void (*activate)(const struct nft_ctx *ctx, 788 const struct nft_expr *expr); 789 void (*deactivate)(const struct nft_ctx *ctx, 790 const struct nft_expr *expr, 791 enum nft_trans_phase phase); 792 void (*destroy)(const struct nft_ctx *ctx, 793 const struct nft_expr *expr); 794 void (*destroy_clone)(const struct nft_ctx *ctx, 795 const struct nft_expr *expr); 796 int (*dump)(struct sk_buff *skb, 797 const struct nft_expr *expr); 798 int (*validate)(const struct nft_ctx *ctx, 799 const struct nft_expr *expr, 800 const struct nft_data **data); 801 bool (*gc)(struct net *net, 802 const struct nft_expr *expr); 803 int (*offload)(struct nft_offload_ctx *ctx, 804 struct nft_flow_rule *flow, 805 const struct nft_expr *expr); 806 u32 offload_flags; 807 const struct nft_expr_type *type; 808 void *data; 809 }; 810 811 #define NFT_EXPR_MAXATTR 16 812 #define NFT_EXPR_SIZE(size) (sizeof(struct nft_expr) + \ 813 ALIGN(size, __alignof__(struct nft_expr))) 814 815 /** 816 * struct nft_expr - nf_tables expression 817 * 818 * @ops: expression ops 819 * @data: expression private data 820 */ 821 struct nft_expr { 822 const struct nft_expr_ops *ops; 823 unsigned char data[]; 824 }; 825 826 static inline void *nft_expr_priv(const struct nft_expr *expr) 827 { 828 return (void *)expr->data; 829 } 830 831 struct nft_expr *nft_expr_init(const struct nft_ctx *ctx, 832 const struct nlattr *nla); 833 void nft_expr_destroy(const struct nft_ctx *ctx, struct nft_expr *expr); 834 int nft_expr_dump(struct sk_buff *skb, unsigned int attr, 835 const struct nft_expr *expr); 836 837 /** 838 * struct nft_rule - nf_tables rule 839 * 840 * @list: used internally 841 * @handle: rule handle 842 * @genmask: generation mask 843 * @dlen: length of expression data 844 * @udata: user data is appended to the rule 845 * @data: expression data 846 */ 847 struct nft_rule { 848 struct list_head list; 849 u64 handle:42, 850 genmask:2, 851 dlen:12, 852 udata:1; 853 unsigned char data[] 854 __attribute__((aligned(__alignof__(struct nft_expr)))); 855 }; 856 857 static inline struct nft_expr *nft_expr_first(const struct nft_rule *rule) 858 { 859 return (struct nft_expr *)&rule->data[0]; 860 } 861 862 static inline struct nft_expr *nft_expr_next(const struct nft_expr *expr) 863 { 864 return ((void *)expr) + expr->ops->size; 865 } 866 867 static inline struct nft_expr *nft_expr_last(const struct nft_rule *rule) 868 { 869 return (struct nft_expr *)&rule->data[rule->dlen]; 870 } 871 872 static inline struct nft_userdata *nft_userdata(const struct nft_rule *rule) 873 { 874 return (void *)&rule->data[rule->dlen]; 875 } 876 877 /* 878 * The last pointer isn't really necessary, but the compiler isn't able to 879 * determine that the result of nft_expr_last() is always the same since it 880 * can't assume that the dlen value wasn't changed within calls in the loop. 881 */ 882 #define nft_rule_for_each_expr(expr, last, rule) \ 883 for ((expr) = nft_expr_first(rule), (last) = nft_expr_last(rule); \ 884 (expr) != (last); \ 885 (expr) = nft_expr_next(expr)) 886 887 enum nft_chain_flags { 888 NFT_BASE_CHAIN = 0x1, 889 NFT_CHAIN_HW_OFFLOAD = 0x2, 890 }; 891 892 #define NFT_CHAIN_POLICY_UNSET U8_MAX 893 894 /** 895 * struct nft_chain - nf_tables chain 896 * 897 * @rules: list of rules in the chain 898 * @list: used internally 899 * @rhlhead: used internally 900 * @table: table that this chain belongs to 901 * @handle: chain handle 902 * @use: number of jump references to this chain 903 * @flags: bitmask of enum nft_chain_flags 904 * @name: name of the chain 905 */ 906 struct nft_chain { 907 struct nft_rule *__rcu *rules_gen_0; 908 struct nft_rule *__rcu *rules_gen_1; 909 struct list_head rules; 910 struct list_head list; 911 struct rhlist_head rhlhead; 912 struct nft_table *table; 913 u64 handle; 914 u32 use; 915 u8 flags:6, 916 genmask:2; 917 char *name; 918 919 /* Only used during control plane commit phase: */ 920 struct nft_rule **rules_next; 921 }; 922 923 int nft_chain_validate(const struct nft_ctx *ctx, const struct nft_chain *chain); 924 925 enum nft_chain_types { 926 NFT_CHAIN_T_DEFAULT = 0, 927 NFT_CHAIN_T_ROUTE, 928 NFT_CHAIN_T_NAT, 929 NFT_CHAIN_T_MAX 930 }; 931 932 /** 933 * struct nft_chain_type - nf_tables chain type info 934 * 935 * @name: name of the type 936 * @type: numeric identifier 937 * @family: address family 938 * @owner: module owner 939 * @hook_mask: mask of valid hooks 940 * @hooks: array of hook functions 941 * @ops_register: base chain register function 942 * @ops_unregister: base chain unregister function 943 */ 944 struct nft_chain_type { 945 const char *name; 946 enum nft_chain_types type; 947 int family; 948 struct module *owner; 949 unsigned int hook_mask; 950 nf_hookfn *hooks[NF_MAX_HOOKS]; 951 int (*ops_register)(struct net *net, const struct nf_hook_ops *ops); 952 void (*ops_unregister)(struct net *net, const struct nf_hook_ops *ops); 953 }; 954 955 int nft_chain_validate_dependency(const struct nft_chain *chain, 956 enum nft_chain_types type); 957 int nft_chain_validate_hooks(const struct nft_chain *chain, 958 unsigned int hook_flags); 959 960 struct nft_stats { 961 u64 bytes; 962 u64 pkts; 963 struct u64_stats_sync syncp; 964 }; 965 966 /** 967 * struct nft_base_chain - nf_tables base chain 968 * 969 * @ops: netfilter hook ops 970 * @type: chain type 971 * @policy: default policy 972 * @stats: per-cpu chain stats 973 * @chain: the chain 974 * @dev_name: device name that this base chain is attached to (if any) 975 * @flow_block: flow block (for hardware offload) 976 */ 977 struct nft_base_chain { 978 struct nf_hook_ops ops; 979 const struct nft_chain_type *type; 980 u8 policy; 981 u8 flags; 982 struct nft_stats __percpu *stats; 983 struct nft_chain chain; 984 char dev_name[IFNAMSIZ]; 985 struct flow_block flow_block; 986 }; 987 988 static inline struct nft_base_chain *nft_base_chain(const struct nft_chain *chain) 989 { 990 return container_of(chain, struct nft_base_chain, chain); 991 } 992 993 static inline bool nft_is_base_chain(const struct nft_chain *chain) 994 { 995 return chain->flags & NFT_BASE_CHAIN; 996 } 997 998 int __nft_release_basechain(struct nft_ctx *ctx); 999 1000 unsigned int nft_do_chain(struct nft_pktinfo *pkt, void *priv); 1001 1002 /** 1003 * struct nft_table - nf_tables table 1004 * 1005 * @list: used internally 1006 * @chains_ht: chains in the table 1007 * @chains: same, for stable walks 1008 * @sets: sets in the table 1009 * @objects: stateful objects in the table 1010 * @flowtables: flow tables in the table 1011 * @hgenerator: handle generator state 1012 * @handle: table handle 1013 * @use: number of chain references to this table 1014 * @flags: table flag (see enum nft_table_flags) 1015 * @genmask: generation mask 1016 * @afinfo: address family info 1017 * @name: name of the table 1018 */ 1019 struct nft_table { 1020 struct list_head list; 1021 struct rhltable chains_ht; 1022 struct list_head chains; 1023 struct list_head sets; 1024 struct list_head objects; 1025 struct list_head flowtables; 1026 u64 hgenerator; 1027 u64 handle; 1028 u32 use; 1029 u16 family:6, 1030 flags:8, 1031 genmask:2; 1032 char *name; 1033 }; 1034 1035 void nft_register_chain_type(const struct nft_chain_type *); 1036 void nft_unregister_chain_type(const struct nft_chain_type *); 1037 1038 int nft_register_expr(struct nft_expr_type *); 1039 void nft_unregister_expr(struct nft_expr_type *); 1040 1041 int nft_verdict_dump(struct sk_buff *skb, int type, 1042 const struct nft_verdict *v); 1043 1044 /** 1045 * struct nft_object_hash_key - key to lookup nft_object 1046 * 1047 * @name: name of the stateful object to look up 1048 * @table: table the object belongs to 1049 */ 1050 struct nft_object_hash_key { 1051 const char *name; 1052 const struct nft_table *table; 1053 }; 1054 1055 /** 1056 * struct nft_object - nf_tables stateful object 1057 * 1058 * @list: table stateful object list node 1059 * @key: keys that identify this object 1060 * @rhlhead: nft_objname_ht node 1061 * @genmask: generation mask 1062 * @use: number of references to this stateful object 1063 * @handle: unique object handle 1064 * @ops: object operations 1065 * @data: object data, layout depends on type 1066 */ 1067 struct nft_object { 1068 struct list_head list; 1069 struct rhlist_head rhlhead; 1070 struct nft_object_hash_key key; 1071 u32 genmask:2, 1072 use:30; 1073 u64 handle; 1074 /* runtime data below here */ 1075 const struct nft_object_ops *ops ____cacheline_aligned; 1076 unsigned char data[] 1077 __attribute__((aligned(__alignof__(u64)))); 1078 }; 1079 1080 static inline void *nft_obj_data(const struct nft_object *obj) 1081 { 1082 return (void *)obj->data; 1083 } 1084 1085 #define nft_expr_obj(expr) *((struct nft_object **)nft_expr_priv(expr)) 1086 1087 struct nft_object *nft_obj_lookup(const struct net *net, 1088 const struct nft_table *table, 1089 const struct nlattr *nla, u32 objtype, 1090 u8 genmask); 1091 1092 void nft_obj_notify(struct net *net, const struct nft_table *table, 1093 struct nft_object *obj, u32 portid, u32 seq, 1094 int event, int family, int report, gfp_t gfp); 1095 1096 /** 1097 * struct nft_object_type - stateful object type 1098 * 1099 * @select_ops: function to select nft_object_ops 1100 * @ops: default ops, used when no select_ops functions is present 1101 * @list: list node in list of object types 1102 * @type: stateful object numeric type 1103 * @owner: module owner 1104 * @maxattr: maximum netlink attribute 1105 * @policy: netlink attribute policy 1106 */ 1107 struct nft_object_type { 1108 const struct nft_object_ops *(*select_ops)(const struct nft_ctx *, 1109 const struct nlattr * const tb[]); 1110 const struct nft_object_ops *ops; 1111 struct list_head list; 1112 u32 type; 1113 unsigned int maxattr; 1114 struct module *owner; 1115 const struct nla_policy *policy; 1116 }; 1117 1118 /** 1119 * struct nft_object_ops - stateful object operations 1120 * 1121 * @eval: stateful object evaluation function 1122 * @size: stateful object size 1123 * @init: initialize object from netlink attributes 1124 * @destroy: release existing stateful object 1125 * @dump: netlink dump stateful object 1126 * @update: update stateful object 1127 */ 1128 struct nft_object_ops { 1129 void (*eval)(struct nft_object *obj, 1130 struct nft_regs *regs, 1131 const struct nft_pktinfo *pkt); 1132 unsigned int size; 1133 int (*init)(const struct nft_ctx *ctx, 1134 const struct nlattr *const tb[], 1135 struct nft_object *obj); 1136 void (*destroy)(const struct nft_ctx *ctx, 1137 struct nft_object *obj); 1138 int (*dump)(struct sk_buff *skb, 1139 struct nft_object *obj, 1140 bool reset); 1141 void (*update)(struct nft_object *obj, 1142 struct nft_object *newobj); 1143 const struct nft_object_type *type; 1144 }; 1145 1146 int nft_register_obj(struct nft_object_type *obj_type); 1147 void nft_unregister_obj(struct nft_object_type *obj_type); 1148 1149 #define NFT_FLOWTABLE_DEVICE_MAX 8 1150 1151 /** 1152 * struct nft_flowtable - nf_tables flow table 1153 * 1154 * @list: flow table list node in table list 1155 * @table: the table the flow table is contained in 1156 * @name: name of this flow table 1157 * @hooknum: hook number 1158 * @priority: hook priority 1159 * @ops_len: number of hooks in array 1160 * @genmask: generation mask 1161 * @use: number of references to this flow table 1162 * @handle: unique object handle 1163 * @dev_name: array of device names 1164 * @data: rhashtable and garbage collector 1165 * @ops: array of hooks 1166 */ 1167 struct nft_flowtable { 1168 struct list_head list; 1169 struct nft_table *table; 1170 char *name; 1171 int hooknum; 1172 int priority; 1173 int ops_len; 1174 u32 genmask:2, 1175 use:30; 1176 u64 handle; 1177 /* runtime data below here */ 1178 struct nf_hook_ops *ops ____cacheline_aligned; 1179 struct nf_flowtable data; 1180 }; 1181 1182 struct nft_flowtable *nft_flowtable_lookup(const struct nft_table *table, 1183 const struct nlattr *nla, 1184 u8 genmask); 1185 1186 void nf_tables_deactivate_flowtable(const struct nft_ctx *ctx, 1187 struct nft_flowtable *flowtable, 1188 enum nft_trans_phase phase); 1189 1190 void nft_register_flowtable_type(struct nf_flowtable_type *type); 1191 void nft_unregister_flowtable_type(struct nf_flowtable_type *type); 1192 1193 /** 1194 * struct nft_traceinfo - nft tracing information and state 1195 * 1196 * @pkt: pktinfo currently processed 1197 * @basechain: base chain currently processed 1198 * @chain: chain currently processed 1199 * @rule: rule that was evaluated 1200 * @verdict: verdict given by rule 1201 * @type: event type (enum nft_trace_types) 1202 * @packet_dumped: packet headers sent in a previous traceinfo message 1203 * @trace: other struct members are initialised 1204 */ 1205 struct nft_traceinfo { 1206 const struct nft_pktinfo *pkt; 1207 const struct nft_base_chain *basechain; 1208 const struct nft_chain *chain; 1209 const struct nft_rule *rule; 1210 const struct nft_verdict *verdict; 1211 enum nft_trace_types type; 1212 bool packet_dumped; 1213 bool trace; 1214 }; 1215 1216 void nft_trace_init(struct nft_traceinfo *info, const struct nft_pktinfo *pkt, 1217 const struct nft_verdict *verdict, 1218 const struct nft_chain *basechain); 1219 1220 void nft_trace_notify(struct nft_traceinfo *info); 1221 1222 #define MODULE_ALIAS_NFT_CHAIN(family, name) \ 1223 MODULE_ALIAS("nft-chain-" __stringify(family) "-" name) 1224 1225 #define MODULE_ALIAS_NFT_AF_EXPR(family, name) \ 1226 MODULE_ALIAS("nft-expr-" __stringify(family) "-" name) 1227 1228 #define MODULE_ALIAS_NFT_EXPR(name) \ 1229 MODULE_ALIAS("nft-expr-" name) 1230 1231 #define MODULE_ALIAS_NFT_SET() \ 1232 MODULE_ALIAS("nft-set") 1233 1234 #define MODULE_ALIAS_NFT_OBJ(type) \ 1235 MODULE_ALIAS("nft-obj-" __stringify(type)) 1236 1237 #if IS_ENABLED(CONFIG_NF_TABLES) 1238 1239 /* 1240 * The gencursor defines two generations, the currently active and the 1241 * next one. Objects contain a bitmask of 2 bits specifying the generations 1242 * they're active in. A set bit means they're inactive in the generation 1243 * represented by that bit. 1244 * 1245 * New objects start out as inactive in the current and active in the 1246 * next generation. When committing the ruleset the bitmask is cleared, 1247 * meaning they're active in all generations. When removing an object, 1248 * it is set inactive in the next generation. After committing the ruleset, 1249 * the objects are removed. 1250 */ 1251 static inline unsigned int nft_gencursor_next(const struct net *net) 1252 { 1253 return net->nft.gencursor + 1 == 1 ? 1 : 0; 1254 } 1255 1256 static inline u8 nft_genmask_next(const struct net *net) 1257 { 1258 return 1 << nft_gencursor_next(net); 1259 } 1260 1261 static inline u8 nft_genmask_cur(const struct net *net) 1262 { 1263 /* Use READ_ONCE() to prevent refetching the value for atomicity */ 1264 return 1 << READ_ONCE(net->nft.gencursor); 1265 } 1266 1267 #define NFT_GENMASK_ANY ((1 << 0) | (1 << 1)) 1268 1269 /* 1270 * Generic transaction helpers 1271 */ 1272 1273 /* Check if this object is currently active. */ 1274 #define nft_is_active(__net, __obj) \ 1275 (((__obj)->genmask & nft_genmask_cur(__net)) == 0) 1276 1277 /* Check if this object is active in the next generation. */ 1278 #define nft_is_active_next(__net, __obj) \ 1279 (((__obj)->genmask & nft_genmask_next(__net)) == 0) 1280 1281 /* This object becomes active in the next generation. */ 1282 #define nft_activate_next(__net, __obj) \ 1283 (__obj)->genmask = nft_genmask_cur(__net) 1284 1285 /* This object becomes inactive in the next generation. */ 1286 #define nft_deactivate_next(__net, __obj) \ 1287 (__obj)->genmask = nft_genmask_next(__net) 1288 1289 /* After committing the ruleset, clear the stale generation bit. */ 1290 #define nft_clear(__net, __obj) \ 1291 (__obj)->genmask &= ~nft_genmask_next(__net) 1292 #define nft_active_genmask(__obj, __genmask) \ 1293 !((__obj)->genmask & __genmask) 1294 1295 /* 1296 * Set element transaction helpers 1297 */ 1298 1299 static inline bool nft_set_elem_active(const struct nft_set_ext *ext, 1300 u8 genmask) 1301 { 1302 return !(ext->genmask & genmask); 1303 } 1304 1305 static inline void nft_set_elem_change_active(const struct net *net, 1306 const struct nft_set *set, 1307 struct nft_set_ext *ext) 1308 { 1309 ext->genmask ^= nft_genmask_next(net); 1310 } 1311 1312 #endif /* IS_ENABLED(CONFIG_NF_TABLES) */ 1313 1314 /* 1315 * We use a free bit in the genmask field to indicate the element 1316 * is busy, meaning it is currently being processed either by 1317 * the netlink API or GC. 1318 * 1319 * Even though the genmask is only a single byte wide, this works 1320 * because the extension structure if fully constant once initialized, 1321 * so there are no non-atomic write accesses unless it is already 1322 * marked busy. 1323 */ 1324 #define NFT_SET_ELEM_BUSY_MASK (1 << 2) 1325 1326 #if defined(__LITTLE_ENDIAN_BITFIELD) 1327 #define NFT_SET_ELEM_BUSY_BIT 2 1328 #elif defined(__BIG_ENDIAN_BITFIELD) 1329 #define NFT_SET_ELEM_BUSY_BIT (BITS_PER_LONG - BITS_PER_BYTE + 2) 1330 #else 1331 #error 1332 #endif 1333 1334 static inline int nft_set_elem_mark_busy(struct nft_set_ext *ext) 1335 { 1336 unsigned long *word = (unsigned long *)ext; 1337 1338 BUILD_BUG_ON(offsetof(struct nft_set_ext, genmask) != 0); 1339 return test_and_set_bit(NFT_SET_ELEM_BUSY_BIT, word); 1340 } 1341 1342 static inline void nft_set_elem_clear_busy(struct nft_set_ext *ext) 1343 { 1344 unsigned long *word = (unsigned long *)ext; 1345 1346 clear_bit(NFT_SET_ELEM_BUSY_BIT, word); 1347 } 1348 1349 /** 1350 * struct nft_trans - nf_tables object update in transaction 1351 * 1352 * @list: used internally 1353 * @msg_type: message type 1354 * @put_net: ctx->net needs to be put 1355 * @ctx: transaction context 1356 * @data: internal information related to the transaction 1357 */ 1358 struct nft_trans { 1359 struct list_head list; 1360 int msg_type; 1361 bool put_net; 1362 struct nft_ctx ctx; 1363 char data[0]; 1364 }; 1365 1366 struct nft_trans_rule { 1367 struct nft_rule *rule; 1368 struct nft_flow_rule *flow; 1369 u32 rule_id; 1370 }; 1371 1372 #define nft_trans_rule(trans) \ 1373 (((struct nft_trans_rule *)trans->data)->rule) 1374 #define nft_trans_flow_rule(trans) \ 1375 (((struct nft_trans_rule *)trans->data)->flow) 1376 #define nft_trans_rule_id(trans) \ 1377 (((struct nft_trans_rule *)trans->data)->rule_id) 1378 1379 struct nft_trans_set { 1380 struct nft_set *set; 1381 u32 set_id; 1382 bool bound; 1383 }; 1384 1385 #define nft_trans_set(trans) \ 1386 (((struct nft_trans_set *)trans->data)->set) 1387 #define nft_trans_set_id(trans) \ 1388 (((struct nft_trans_set *)trans->data)->set_id) 1389 #define nft_trans_set_bound(trans) \ 1390 (((struct nft_trans_set *)trans->data)->bound) 1391 1392 struct nft_trans_chain { 1393 bool update; 1394 char *name; 1395 struct nft_stats __percpu *stats; 1396 u8 policy; 1397 }; 1398 1399 #define nft_trans_chain_update(trans) \ 1400 (((struct nft_trans_chain *)trans->data)->update) 1401 #define nft_trans_chain_name(trans) \ 1402 (((struct nft_trans_chain *)trans->data)->name) 1403 #define nft_trans_chain_stats(trans) \ 1404 (((struct nft_trans_chain *)trans->data)->stats) 1405 #define nft_trans_chain_policy(trans) \ 1406 (((struct nft_trans_chain *)trans->data)->policy) 1407 1408 struct nft_trans_table { 1409 bool update; 1410 bool enable; 1411 }; 1412 1413 #define nft_trans_table_update(trans) \ 1414 (((struct nft_trans_table *)trans->data)->update) 1415 #define nft_trans_table_enable(trans) \ 1416 (((struct nft_trans_table *)trans->data)->enable) 1417 1418 struct nft_trans_elem { 1419 struct nft_set *set; 1420 struct nft_set_elem elem; 1421 bool bound; 1422 }; 1423 1424 #define nft_trans_elem_set(trans) \ 1425 (((struct nft_trans_elem *)trans->data)->set) 1426 #define nft_trans_elem(trans) \ 1427 (((struct nft_trans_elem *)trans->data)->elem) 1428 #define nft_trans_elem_set_bound(trans) \ 1429 (((struct nft_trans_elem *)trans->data)->bound) 1430 1431 struct nft_trans_obj { 1432 struct nft_object *obj; 1433 struct nft_object *newobj; 1434 bool update; 1435 }; 1436 1437 #define nft_trans_obj(trans) \ 1438 (((struct nft_trans_obj *)trans->data)->obj) 1439 #define nft_trans_obj_newobj(trans) \ 1440 (((struct nft_trans_obj *)trans->data)->newobj) 1441 #define nft_trans_obj_update(trans) \ 1442 (((struct nft_trans_obj *)trans->data)->update) 1443 1444 struct nft_trans_flowtable { 1445 struct nft_flowtable *flowtable; 1446 }; 1447 1448 #define nft_trans_flowtable(trans) \ 1449 (((struct nft_trans_flowtable *)trans->data)->flowtable) 1450 1451 int __init nft_chain_filter_init(void); 1452 void nft_chain_filter_fini(void); 1453 1454 void __init nft_chain_route_init(void); 1455 void nft_chain_route_fini(void); 1456 #endif /* _NET_NF_TABLES_H */ 1457