1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
3 * net/sched/act_ct.c Connection Tracking action
5 * Authors: Paul Blakey <paulb@mellanox.com>
6 * Yossi Kuperman <yossiku@mellanox.com>
7 * Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
10 #include <linux/module.h>
11 #include <linux/init.h>
12 #include <linux/kernel.h>
13 #include <linux/skbuff.h>
14 #include <linux/rtnetlink.h>
15 #include <linux/pkt_cls.h>
17 #include <linux/ipv6.h>
18 #include <linux/rhashtable.h>
19 #include <net/netlink.h>
20 #include <net/pkt_sched.h>
21 #include <net/pkt_cls.h>
22 #include <net/act_api.h>
24 #include <net/ipv6_frag.h>
25 #include <uapi/linux/tc_act/tc_ct.h>
26 #include <net/tc_act/tc_ct.h>
28 #include <net/netfilter/nf_flow_table.h>
29 #include <net/netfilter/nf_conntrack.h>
30 #include <net/netfilter/nf_conntrack_core.h>
31 #include <net/netfilter/nf_conntrack_zones.h>
32 #include <net/netfilter/nf_conntrack_helper.h>
33 #include <net/netfilter/nf_conntrack_acct.h>
34 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
35 #include <net/netfilter/nf_conntrack_act_ct.h>
36 #include <uapi/linux/netfilter/nf_nat.h>
38 static struct workqueue_struct *act_ct_wq;
39 static struct rhashtable zones_ht;
40 static DEFINE_MUTEX(zones_mutex);
42 struct tcf_ct_flow_table {
43 struct rhash_head node; /* In zones tables */
45 struct rcu_work rwork;
46 struct nf_flowtable nf_ft;
53 static const struct rhashtable_params zones_params = {
54 .head_offset = offsetof(struct tcf_ct_flow_table, node),
55 .key_offset = offsetof(struct tcf_ct_flow_table, zone),
56 .key_len = sizeof_field(struct tcf_ct_flow_table, zone),
57 .automatic_shrinking = true,
60 static struct nf_ct_ext_type act_ct_extend __read_mostly = {
61 .len = sizeof(struct nf_conn_act_ct_ext),
62 .align = __alignof__(struct nf_conn_act_ct_ext),
63 .id = NF_CT_EXT_ACT_CT,
66 static struct flow_action_entry *
67 tcf_ct_flow_table_flow_action_get_next(struct flow_action *flow_action)
69 int i = flow_action->num_entries++;
71 return &flow_action->entries[i];
74 static void tcf_ct_add_mangle_action(struct flow_action *action,
75 enum flow_action_mangle_base htype,
80 struct flow_action_entry *entry;
82 entry = tcf_ct_flow_table_flow_action_get_next(action);
83 entry->id = FLOW_ACTION_MANGLE;
84 entry->mangle.htype = htype;
85 entry->mangle.mask = ~mask;
86 entry->mangle.offset = offset;
87 entry->mangle.val = val;
90 /* The following nat helper functions check if the inverted reverse tuple
91 * (target) is different then the current dir tuple - meaning nat for ports
92 * and/or ip is needed, and add the relevant mangle actions.
95 tcf_ct_flow_table_add_action_nat_ipv4(const struct nf_conntrack_tuple *tuple,
96 struct nf_conntrack_tuple target,
97 struct flow_action *action)
99 if (memcmp(&target.src.u3, &tuple->src.u3, sizeof(target.src.u3)))
100 tcf_ct_add_mangle_action(action, FLOW_ACT_MANGLE_HDR_TYPE_IP4,
101 offsetof(struct iphdr, saddr),
103 be32_to_cpu(target.src.u3.ip));
104 if (memcmp(&target.dst.u3, &tuple->dst.u3, sizeof(target.dst.u3)))
105 tcf_ct_add_mangle_action(action, FLOW_ACT_MANGLE_HDR_TYPE_IP4,
106 offsetof(struct iphdr, daddr),
108 be32_to_cpu(target.dst.u3.ip));
112 tcf_ct_add_ipv6_addr_mangle_action(struct flow_action *action,
113 union nf_inet_addr *addr,
118 for (i = 0; i < sizeof(struct in6_addr) / sizeof(u32); i++)
119 tcf_ct_add_mangle_action(action, FLOW_ACT_MANGLE_HDR_TYPE_IP6,
120 i * sizeof(u32) + offset,
121 0xFFFFFFFF, be32_to_cpu(addr->ip6[i]));
125 tcf_ct_flow_table_add_action_nat_ipv6(const struct nf_conntrack_tuple *tuple,
126 struct nf_conntrack_tuple target,
127 struct flow_action *action)
129 if (memcmp(&target.src.u3, &tuple->src.u3, sizeof(target.src.u3)))
130 tcf_ct_add_ipv6_addr_mangle_action(action, &target.src.u3,
131 offsetof(struct ipv6hdr,
133 if (memcmp(&target.dst.u3, &tuple->dst.u3, sizeof(target.dst.u3)))
134 tcf_ct_add_ipv6_addr_mangle_action(action, &target.dst.u3,
135 offsetof(struct ipv6hdr,
140 tcf_ct_flow_table_add_action_nat_tcp(const struct nf_conntrack_tuple *tuple,
141 struct nf_conntrack_tuple target,
142 struct flow_action *action)
144 __be16 target_src = target.src.u.tcp.port;
145 __be16 target_dst = target.dst.u.tcp.port;
147 if (target_src != tuple->src.u.tcp.port)
148 tcf_ct_add_mangle_action(action, FLOW_ACT_MANGLE_HDR_TYPE_TCP,
149 offsetof(struct tcphdr, source),
150 0xFFFF, be16_to_cpu(target_src));
151 if (target_dst != tuple->dst.u.tcp.port)
152 tcf_ct_add_mangle_action(action, FLOW_ACT_MANGLE_HDR_TYPE_TCP,
153 offsetof(struct tcphdr, dest),
154 0xFFFF, be16_to_cpu(target_dst));
158 tcf_ct_flow_table_add_action_nat_udp(const struct nf_conntrack_tuple *tuple,
159 struct nf_conntrack_tuple target,
160 struct flow_action *action)
162 __be16 target_src = target.src.u.udp.port;
163 __be16 target_dst = target.dst.u.udp.port;
165 if (target_src != tuple->src.u.udp.port)
166 tcf_ct_add_mangle_action(action, FLOW_ACT_MANGLE_HDR_TYPE_UDP,
167 offsetof(struct udphdr, source),
168 0xFFFF, be16_to_cpu(target_src));
169 if (target_dst != tuple->dst.u.udp.port)
170 tcf_ct_add_mangle_action(action, FLOW_ACT_MANGLE_HDR_TYPE_UDP,
171 offsetof(struct udphdr, dest),
172 0xFFFF, be16_to_cpu(target_dst));
175 static void tcf_ct_flow_table_add_action_meta(struct nf_conn *ct,
176 enum ip_conntrack_dir dir,
177 struct flow_action *action)
179 struct nf_conn_labels *ct_labels;
180 struct flow_action_entry *entry;
181 enum ip_conntrack_info ctinfo;
184 entry = tcf_ct_flow_table_flow_action_get_next(action);
185 entry->id = FLOW_ACTION_CT_METADATA;
186 #if IS_ENABLED(CONFIG_NF_CONNTRACK_MARK)
187 entry->ct_metadata.mark = ct->mark;
189 ctinfo = dir == IP_CT_DIR_ORIGINAL ? IP_CT_ESTABLISHED :
190 IP_CT_ESTABLISHED_REPLY;
191 /* aligns with the CT reference on the SKB nf_ct_set */
192 entry->ct_metadata.cookie = (unsigned long)ct | ctinfo;
193 entry->ct_metadata.orig_dir = dir == IP_CT_DIR_ORIGINAL;
195 act_ct_labels = entry->ct_metadata.labels;
196 ct_labels = nf_ct_labels_find(ct);
198 memcpy(act_ct_labels, ct_labels->bits, NF_CT_LABELS_MAX_SIZE);
200 memset(act_ct_labels, 0, NF_CT_LABELS_MAX_SIZE);
203 static int tcf_ct_flow_table_add_action_nat(struct net *net,
205 enum ip_conntrack_dir dir,
206 struct flow_action *action)
208 const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple;
209 struct nf_conntrack_tuple target;
211 if (!(ct->status & IPS_NAT_MASK))
214 nf_ct_invert_tuple(&target, &ct->tuplehash[!dir].tuple);
216 switch (tuple->src.l3num) {
218 tcf_ct_flow_table_add_action_nat_ipv4(tuple, target,
222 tcf_ct_flow_table_add_action_nat_ipv6(tuple, target,
229 switch (nf_ct_protonum(ct)) {
231 tcf_ct_flow_table_add_action_nat_tcp(tuple, target, action);
234 tcf_ct_flow_table_add_action_nat_udp(tuple, target, action);
243 static int tcf_ct_flow_table_fill_actions(struct net *net,
244 const struct flow_offload *flow,
245 enum flow_offload_tuple_dir tdir,
246 struct nf_flow_rule *flow_rule)
248 struct flow_action *action = &flow_rule->rule->action;
249 int num_entries = action->num_entries;
250 struct nf_conn *ct = flow->ct;
251 enum ip_conntrack_dir dir;
255 case FLOW_OFFLOAD_DIR_ORIGINAL:
256 dir = IP_CT_DIR_ORIGINAL;
258 case FLOW_OFFLOAD_DIR_REPLY:
259 dir = IP_CT_DIR_REPLY;
265 err = tcf_ct_flow_table_add_action_nat(net, ct, dir, action);
269 tcf_ct_flow_table_add_action_meta(ct, dir, action);
273 /* Clear filled actions */
274 for (i = num_entries; i < action->num_entries; i++)
275 memset(&action->entries[i], 0, sizeof(action->entries[i]));
276 action->num_entries = num_entries;
281 static struct nf_flowtable_type flowtable_ct = {
282 .action = tcf_ct_flow_table_fill_actions,
283 .owner = THIS_MODULE,
286 static int tcf_ct_flow_table_get(struct tcf_ct_params *params)
288 struct tcf_ct_flow_table *ct_ft;
291 mutex_lock(&zones_mutex);
292 ct_ft = rhashtable_lookup_fast(&zones_ht, ¶ms->zone, zones_params);
293 if (ct_ft && refcount_inc_not_zero(&ct_ft->ref))
296 ct_ft = kzalloc(sizeof(*ct_ft), GFP_KERNEL);
299 refcount_set(&ct_ft->ref, 1);
301 ct_ft->zone = params->zone;
302 err = rhashtable_insert_fast(&zones_ht, &ct_ft->node, zones_params);
306 ct_ft->nf_ft.type = &flowtable_ct;
307 ct_ft->nf_ft.flags |= NF_FLOWTABLE_HW_OFFLOAD |
308 NF_FLOWTABLE_COUNTER;
309 err = nf_flow_table_init(&ct_ft->nf_ft);
313 __module_get(THIS_MODULE);
315 params->ct_ft = ct_ft;
316 params->nf_ft = &ct_ft->nf_ft;
317 mutex_unlock(&zones_mutex);
322 rhashtable_remove_fast(&zones_ht, &ct_ft->node, zones_params);
326 mutex_unlock(&zones_mutex);
330 static void tcf_ct_flow_table_cleanup_work(struct work_struct *work)
332 struct flow_block_cb *block_cb, *tmp_cb;
333 struct tcf_ct_flow_table *ct_ft;
334 struct flow_block *block;
336 ct_ft = container_of(to_rcu_work(work), struct tcf_ct_flow_table,
338 nf_flow_table_free(&ct_ft->nf_ft);
340 /* Remove any remaining callbacks before cleanup */
341 block = &ct_ft->nf_ft.flow_block;
342 down_write(&ct_ft->nf_ft.flow_block_lock);
343 list_for_each_entry_safe(block_cb, tmp_cb, &block->cb_list, list) {
344 list_del(&block_cb->list);
345 flow_block_cb_free(block_cb);
347 up_write(&ct_ft->nf_ft.flow_block_lock);
350 module_put(THIS_MODULE);
353 static void tcf_ct_flow_table_put(struct tcf_ct_params *params)
355 struct tcf_ct_flow_table *ct_ft = params->ct_ft;
357 if (refcount_dec_and_test(¶ms->ct_ft->ref)) {
358 rhashtable_remove_fast(&zones_ht, &ct_ft->node, zones_params);
359 INIT_RCU_WORK(&ct_ft->rwork, tcf_ct_flow_table_cleanup_work);
360 queue_rcu_work(act_ct_wq, &ct_ft->rwork);
364 static void tcf_ct_flow_table_add(struct tcf_ct_flow_table *ct_ft,
368 struct nf_conn_act_ct_ext *act_ct_ext;
369 struct flow_offload *entry;
372 if (test_and_set_bit(IPS_OFFLOAD_BIT, &ct->status))
375 entry = flow_offload_alloc(ct);
382 ct->proto.tcp.seen[0].flags |= IP_CT_TCP_FLAG_BE_LIBERAL;
383 ct->proto.tcp.seen[1].flags |= IP_CT_TCP_FLAG_BE_LIBERAL;
386 act_ct_ext = nf_conn_act_ct_ext_find(ct);
388 entry->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple.iifidx =
389 act_ct_ext->ifindex[IP_CT_DIR_ORIGINAL];
390 entry->tuplehash[FLOW_OFFLOAD_DIR_REPLY].tuple.iifidx =
391 act_ct_ext->ifindex[IP_CT_DIR_REPLY];
394 err = flow_offload_add(&ct_ft->nf_ft, entry);
401 flow_offload_free(entry);
403 clear_bit(IPS_OFFLOAD_BIT, &ct->status);
406 static void tcf_ct_flow_table_process_conn(struct tcf_ct_flow_table *ct_ft,
408 enum ip_conntrack_info ctinfo)
412 if ((ctinfo != IP_CT_ESTABLISHED && ctinfo != IP_CT_ESTABLISHED_REPLY) ||
413 !test_bit(IPS_ASSURED_BIT, &ct->status))
416 switch (nf_ct_protonum(ct)) {
419 if (ct->proto.tcp.state != TCP_CONNTRACK_ESTABLISHED)
428 if (nf_ct_ext_exist(ct, NF_CT_EXT_HELPER) ||
429 ct->status & IPS_SEQ_ADJUST)
432 tcf_ct_flow_table_add(ct_ft, ct, tcp);
436 tcf_ct_flow_table_fill_tuple_ipv4(struct sk_buff *skb,
437 struct flow_offload_tuple *tuple,
438 struct tcphdr **tcph)
440 struct flow_ports *ports;
444 if (!pskb_network_may_pull(skb, sizeof(*iph)))
448 thoff = iph->ihl * 4;
450 if (ip_is_fragment(iph) ||
451 unlikely(thoff != sizeof(struct iphdr)))
454 if (iph->protocol != IPPROTO_TCP &&
455 iph->protocol != IPPROTO_UDP)
461 if (!pskb_network_may_pull(skb, iph->protocol == IPPROTO_TCP ?
462 thoff + sizeof(struct tcphdr) :
463 thoff + sizeof(*ports)))
467 if (iph->protocol == IPPROTO_TCP)
468 *tcph = (void *)(skb_network_header(skb) + thoff);
470 ports = (struct flow_ports *)(skb_network_header(skb) + thoff);
471 tuple->src_v4.s_addr = iph->saddr;
472 tuple->dst_v4.s_addr = iph->daddr;
473 tuple->src_port = ports->source;
474 tuple->dst_port = ports->dest;
475 tuple->l3proto = AF_INET;
476 tuple->l4proto = iph->protocol;
482 tcf_ct_flow_table_fill_tuple_ipv6(struct sk_buff *skb,
483 struct flow_offload_tuple *tuple,
484 struct tcphdr **tcph)
486 struct flow_ports *ports;
487 struct ipv6hdr *ip6h;
490 if (!pskb_network_may_pull(skb, sizeof(*ip6h)))
493 ip6h = ipv6_hdr(skb);
495 if (ip6h->nexthdr != IPPROTO_TCP &&
496 ip6h->nexthdr != IPPROTO_UDP)
499 if (ip6h->hop_limit <= 1)
502 thoff = sizeof(*ip6h);
503 if (!pskb_network_may_pull(skb, ip6h->nexthdr == IPPROTO_TCP ?
504 thoff + sizeof(struct tcphdr) :
505 thoff + sizeof(*ports)))
508 ip6h = ipv6_hdr(skb);
509 if (ip6h->nexthdr == IPPROTO_TCP)
510 *tcph = (void *)(skb_network_header(skb) + thoff);
512 ports = (struct flow_ports *)(skb_network_header(skb) + thoff);
513 tuple->src_v6 = ip6h->saddr;
514 tuple->dst_v6 = ip6h->daddr;
515 tuple->src_port = ports->source;
516 tuple->dst_port = ports->dest;
517 tuple->l3proto = AF_INET6;
518 tuple->l4proto = ip6h->nexthdr;
523 static bool tcf_ct_flow_table_lookup(struct tcf_ct_params *p,
527 struct nf_flowtable *nf_ft = &p->ct_ft->nf_ft;
528 struct flow_offload_tuple_rhash *tuplehash;
529 struct flow_offload_tuple tuple = {};
530 enum ip_conntrack_info ctinfo;
531 struct tcphdr *tcph = NULL;
532 struct flow_offload *flow;
538 if (!tcf_ct_flow_table_fill_tuple_ipv4(skb, &tuple, &tcph))
542 if (!tcf_ct_flow_table_fill_tuple_ipv6(skb, &tuple, &tcph))
549 tuplehash = flow_offload_lookup(nf_ft, &tuple);
553 dir = tuplehash->tuple.dir;
554 flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]);
557 if (tcph && (unlikely(tcph->fin || tcph->rst))) {
558 flow_offload_teardown(flow);
562 ctinfo = dir == FLOW_OFFLOAD_DIR_ORIGINAL ? IP_CT_ESTABLISHED :
563 IP_CT_ESTABLISHED_REPLY;
565 flow_offload_refresh(nf_ft, flow);
566 nf_conntrack_get(&ct->ct_general);
567 nf_ct_set(skb, ct, ctinfo);
568 if (nf_ft->flags & NF_FLOWTABLE_COUNTER)
569 nf_ct_acct_update(ct, dir, skb->len);
574 static int tcf_ct_flow_tables_init(void)
576 return rhashtable_init(&zones_ht, &zones_params);
579 static void tcf_ct_flow_tables_uninit(void)
581 rhashtable_destroy(&zones_ht);
584 static struct tc_action_ops act_ct_ops;
585 static unsigned int ct_net_id;
587 struct tc_ct_action_net {
588 struct tc_action_net tn; /* Must be first */
592 /* Determine whether skb->_nfct is equal to the result of conntrack lookup. */
593 static bool tcf_ct_skb_nfct_cached(struct net *net, struct sk_buff *skb,
594 u16 zone_id, bool force)
596 enum ip_conntrack_info ctinfo;
599 ct = nf_ct_get(skb, &ctinfo);
602 if (!net_eq(net, read_pnet(&ct->ct_net)))
604 if (nf_ct_zone(ct)->id != zone_id)
607 /* Force conntrack entry direction. */
608 if (force && CTINFO2DIR(ctinfo) != IP_CT_DIR_ORIGINAL) {
609 if (nf_ct_is_confirmed(ct))
613 nf_ct_set(skb, NULL, IP_CT_UNTRACKED);
621 /* Trim the skb to the length specified by the IP/IPv6 header,
622 * removing any trailing lower-layer padding. This prepares the skb
623 * for higher-layer processing that assumes skb->len excludes padding
624 * (such as nf_ip_checksum). The caller needs to pull the skb to the
625 * network header, and ensure ip_hdr/ipv6_hdr points to valid data.
627 static int tcf_ct_skb_network_trim(struct sk_buff *skb, int family)
634 len = ntohs(ip_hdr(skb)->tot_len);
637 len = sizeof(struct ipv6hdr)
638 + ntohs(ipv6_hdr(skb)->payload_len);
644 err = pskb_trim_rcsum(skb, len);
649 static u8 tcf_ct_skb_nf_family(struct sk_buff *skb)
651 u8 family = NFPROTO_UNSPEC;
653 switch (skb_protocol(skb, true)) {
654 case htons(ETH_P_IP):
655 family = NFPROTO_IPV4;
657 case htons(ETH_P_IPV6):
658 family = NFPROTO_IPV6;
667 static int tcf_ct_ipv4_is_fragment(struct sk_buff *skb, bool *frag)
671 len = skb_network_offset(skb) + sizeof(struct iphdr);
672 if (unlikely(skb->len < len))
674 if (unlikely(!pskb_may_pull(skb, len)))
677 *frag = ip_is_fragment(ip_hdr(skb));
681 static int tcf_ct_ipv6_is_fragment(struct sk_buff *skb, bool *frag)
683 unsigned int flags = 0, len, payload_ofs = 0;
684 unsigned short frag_off;
687 len = skb_network_offset(skb) + sizeof(struct ipv6hdr);
688 if (unlikely(skb->len < len))
690 if (unlikely(!pskb_may_pull(skb, len)))
693 nexthdr = ipv6_find_hdr(skb, &payload_ofs, -1, &frag_off, &flags);
694 if (unlikely(nexthdr < 0))
697 *frag = flags & IP6_FH_F_FRAG;
701 static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
702 u8 family, u16 zone, bool *defrag)
704 enum ip_conntrack_info ctinfo;
710 /* Previously seen (loopback)? Ignore. */
711 ct = nf_ct_get(skb, &ctinfo);
712 if ((ct && !nf_ct_is_template(ct)) || ctinfo == IP_CT_UNTRACKED)
715 if (family == NFPROTO_IPV4)
716 err = tcf_ct_ipv4_is_fragment(skb, &frag);
718 err = tcf_ct_ipv6_is_fragment(skb, &frag);
723 mru = tc_skb_cb(skb)->mru;
725 if (family == NFPROTO_IPV4) {
726 enum ip_defrag_users user = IP_DEFRAG_CONNTRACK_IN + zone;
728 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
730 err = ip_defrag(net, skb, user);
732 if (err && err != -EINPROGRESS)
737 mru = IPCB(skb)->frag_max_size;
739 } else { /* NFPROTO_IPV6 */
740 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
741 enum ip6_defrag_users user = IP6_DEFRAG_CONNTRACK_IN + zone;
743 memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
744 err = nf_ct_frag6_gather(net, skb, user);
745 if (err && err != -EINPROGRESS)
750 mru = IP6CB(skb)->frag_max_size;
758 if (err != -EINPROGRESS)
759 tc_skb_cb(skb)->mru = mru;
769 static void tcf_ct_params_free(struct rcu_head *head)
771 struct tcf_ct_params *params = container_of(head,
772 struct tcf_ct_params, rcu);
774 tcf_ct_flow_table_put(params);
777 nf_ct_put(params->tmpl);
781 #if IS_ENABLED(CONFIG_NF_NAT)
782 /* Modelled after nf_nat_ipv[46]_fn().
783 * range is only used for new, uninitialized NAT state.
784 * Returns either NF_ACCEPT or NF_DROP.
786 static int ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
787 enum ip_conntrack_info ctinfo,
788 const struct nf_nat_range2 *range,
789 enum nf_nat_manip_type maniptype)
791 __be16 proto = skb_protocol(skb, true);
792 int hooknum, err = NF_ACCEPT;
794 /* See HOOK2MANIP(). */
795 if (maniptype == NF_NAT_MANIP_SRC)
796 hooknum = NF_INET_LOCAL_IN; /* Source NAT */
798 hooknum = NF_INET_LOCAL_OUT; /* Destination NAT */
802 case IP_CT_RELATED_REPLY:
803 if (proto == htons(ETH_P_IP) &&
804 ip_hdr(skb)->protocol == IPPROTO_ICMP) {
805 if (!nf_nat_icmp_reply_translation(skb, ct, ctinfo,
809 } else if (IS_ENABLED(CONFIG_IPV6) && proto == htons(ETH_P_IPV6)) {
811 u8 nexthdr = ipv6_hdr(skb)->nexthdr;
812 int hdrlen = ipv6_skip_exthdr(skb,
813 sizeof(struct ipv6hdr),
814 &nexthdr, &frag_off);
816 if (hdrlen >= 0 && nexthdr == IPPROTO_ICMPV6) {
817 if (!nf_nat_icmpv6_reply_translation(skb, ct,
825 /* Non-ICMP, fall thru to initialize if needed. */
828 /* Seen it before? This can happen for loopback, retrans,
831 if (!nf_nat_initialized(ct, maniptype)) {
832 /* Initialize according to the NAT action. */
833 err = (range && range->flags & NF_NAT_RANGE_MAP_IPS)
834 /* Action is set up to establish a new
837 ? nf_nat_setup_info(ct, range, maniptype)
838 : nf_nat_alloc_null_binding(ct, hooknum);
839 if (err != NF_ACCEPT)
844 case IP_CT_ESTABLISHED:
845 case IP_CT_ESTABLISHED_REPLY:
853 err = nf_nat_packet(ct, ctinfo, hooknum, skb);
854 if (err == NF_ACCEPT) {
855 if (maniptype == NF_NAT_MANIP_SRC)
856 tc_skb_cb(skb)->post_ct_snat = 1;
857 if (maniptype == NF_NAT_MANIP_DST)
858 tc_skb_cb(skb)->post_ct_dnat = 1;
863 #endif /* CONFIG_NF_NAT */
865 static void tcf_ct_act_set_mark(struct nf_conn *ct, u32 mark, u32 mask)
867 #if IS_ENABLED(CONFIG_NF_CONNTRACK_MARK)
873 new_mark = mark | (ct->mark & ~(mask));
874 if (ct->mark != new_mark) {
876 if (nf_ct_is_confirmed(ct))
877 nf_conntrack_event_cache(IPCT_MARK, ct);
882 static void tcf_ct_act_set_labels(struct nf_conn *ct,
886 #if IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS)
887 size_t labels_sz = sizeof_field(struct tcf_ct_params, labels);
889 if (!memchr_inv(labels_m, 0, labels_sz))
892 nf_connlabels_replace(ct, labels, labels_m, 4);
896 static int tcf_ct_act_nat(struct sk_buff *skb,
898 enum ip_conntrack_info ctinfo,
900 struct nf_nat_range2 *range,
903 #if IS_ENABLED(CONFIG_NF_NAT)
905 enum nf_nat_manip_type maniptype;
907 if (!(ct_action & TCA_CT_ACT_NAT))
910 /* Add NAT extension if not confirmed yet. */
911 if (!nf_ct_is_confirmed(ct) && !nf_ct_nat_ext_add(ct))
912 return NF_DROP; /* Can't NAT. */
914 if (ctinfo != IP_CT_NEW && (ct->status & IPS_NAT_MASK) &&
915 (ctinfo != IP_CT_RELATED || commit)) {
916 /* NAT an established or related connection like before. */
917 if (CTINFO2DIR(ctinfo) == IP_CT_DIR_REPLY)
918 /* This is the REPLY direction for a connection
919 * for which NAT was applied in the forward
920 * direction. Do the reverse NAT.
922 maniptype = ct->status & IPS_SRC_NAT
923 ? NF_NAT_MANIP_DST : NF_NAT_MANIP_SRC;
925 maniptype = ct->status & IPS_SRC_NAT
926 ? NF_NAT_MANIP_SRC : NF_NAT_MANIP_DST;
927 } else if (ct_action & TCA_CT_ACT_NAT_SRC) {
928 maniptype = NF_NAT_MANIP_SRC;
929 } else if (ct_action & TCA_CT_ACT_NAT_DST) {
930 maniptype = NF_NAT_MANIP_DST;
935 err = ct_nat_execute(skb, ct, ctinfo, range, maniptype);
936 if (err == NF_ACCEPT && ct->status & IPS_DST_NAT) {
937 if (ct->status & IPS_SRC_NAT) {
938 if (maniptype == NF_NAT_MANIP_SRC)
939 maniptype = NF_NAT_MANIP_DST;
941 maniptype = NF_NAT_MANIP_SRC;
943 err = ct_nat_execute(skb, ct, ctinfo, range,
945 } else if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL) {
946 err = ct_nat_execute(skb, ct, ctinfo, NULL,
956 static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,
957 struct tcf_result *res)
959 struct net *net = dev_net(skb->dev);
960 bool cached, commit, clear, force;
961 enum ip_conntrack_info ctinfo;
962 struct tcf_ct *c = to_ct(a);
963 struct nf_conn *tmpl = NULL;
964 struct nf_hook_state state;
965 int nh_ofs, err, retval;
966 struct tcf_ct_params *p;
967 bool skip_add = false;
972 p = rcu_dereference_bh(c->params);
974 retval = READ_ONCE(c->tcf_action);
975 commit = p->ct_action & TCA_CT_ACT_COMMIT;
976 clear = p->ct_action & TCA_CT_ACT_CLEAR;
977 force = p->ct_action & TCA_CT_ACT_FORCE;
980 tcf_lastuse_update(&c->tcf_tm);
981 tcf_action_update_bstats(&c->common, skb);
984 tc_skb_cb(skb)->post_ct = false;
985 ct = nf_ct_get(skb, &ctinfo);
988 nf_ct_set(skb, NULL, IP_CT_UNTRACKED);
994 family = tcf_ct_skb_nf_family(skb);
995 if (family == NFPROTO_UNSPEC)
998 /* The conntrack module expects to be working at L3.
999 * We also try to pull the IPv4/6 header to linear area
1001 nh_ofs = skb_network_offset(skb);
1002 skb_pull_rcsum(skb, nh_ofs);
1003 err = tcf_ct_handle_fragments(net, skb, family, p->zone, &defrag);
1004 if (err == -EINPROGRESS) {
1005 retval = TC_ACT_STOLEN;
1011 err = tcf_ct_skb_network_trim(skb, family);
1015 /* If we are recirculating packets to match on ct fields and
1016 * committing with a separate ct action, then we don't need to
1017 * actually run the packet through conntrack twice unless it's for a
1020 cached = tcf_ct_skb_nfct_cached(net, skb, p->zone, force);
1022 if (tcf_ct_flow_table_lookup(p, skb, family)) {
1027 /* Associate skb with specified zone. */
1029 nf_conntrack_put(skb_nfct(skb));
1030 nf_conntrack_get(&tmpl->ct_general);
1031 nf_ct_set(skb, tmpl, IP_CT_NEW);
1034 state.hook = NF_INET_PRE_ROUTING;
1037 err = nf_conntrack_in(skb, &state);
1038 if (err != NF_ACCEPT)
1043 ct = nf_ct_get(skb, &ctinfo);
1046 nf_ct_deliver_cached_events(ct);
1047 nf_conn_act_ct_ext_fill(skb, ct, ctinfo);
1049 err = tcf_ct_act_nat(skb, ct, ctinfo, p->ct_action, &p->range, commit);
1050 if (err != NF_ACCEPT)
1054 tcf_ct_act_set_mark(ct, p->mark, p->mark_mask);
1055 tcf_ct_act_set_labels(ct, p->labels, p->labels_mask);
1057 if (!nf_ct_is_confirmed(ct))
1058 nf_conn_act_ct_ext_add(ct);
1060 /* This will take care of sending queued events
1061 * even if the connection is already confirmed.
1063 if (nf_conntrack_confirm(skb) != NF_ACCEPT)
1068 tcf_ct_flow_table_process_conn(p->ct_ft, ct, ctinfo);
1071 skb_push_rcsum(skb, nh_ofs);
1073 tc_skb_cb(skb)->post_ct = true;
1074 tc_skb_cb(skb)->zone = p->zone;
1077 qdisc_skb_cb(skb)->pkt_len = skb->len;
1081 tcf_action_inc_drop_qstats(&c->common);
1085 static const struct nla_policy ct_policy[TCA_CT_MAX + 1] = {
1086 [TCA_CT_ACTION] = { .type = NLA_U16 },
1087 [TCA_CT_PARMS] = NLA_POLICY_EXACT_LEN(sizeof(struct tc_ct)),
1088 [TCA_CT_ZONE] = { .type = NLA_U16 },
1089 [TCA_CT_MARK] = { .type = NLA_U32 },
1090 [TCA_CT_MARK_MASK] = { .type = NLA_U32 },
1091 [TCA_CT_LABELS] = { .type = NLA_BINARY,
1092 .len = 128 / BITS_PER_BYTE },
1093 [TCA_CT_LABELS_MASK] = { .type = NLA_BINARY,
1094 .len = 128 / BITS_PER_BYTE },
1095 [TCA_CT_NAT_IPV4_MIN] = { .type = NLA_U32 },
1096 [TCA_CT_NAT_IPV4_MAX] = { .type = NLA_U32 },
1097 [TCA_CT_NAT_IPV6_MIN] = NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)),
1098 [TCA_CT_NAT_IPV6_MAX] = NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)),
1099 [TCA_CT_NAT_PORT_MIN] = { .type = NLA_U16 },
1100 [TCA_CT_NAT_PORT_MAX] = { .type = NLA_U16 },
1103 static int tcf_ct_fill_params_nat(struct tcf_ct_params *p,
1106 struct netlink_ext_ack *extack)
1108 struct nf_nat_range2 *range;
1110 if (!(p->ct_action & TCA_CT_ACT_NAT))
1113 if (!IS_ENABLED(CONFIG_NF_NAT)) {
1114 NL_SET_ERR_MSG_MOD(extack, "Netfilter nat isn't enabled in kernel");
1118 if (!(p->ct_action & (TCA_CT_ACT_NAT_SRC | TCA_CT_ACT_NAT_DST)))
1121 if ((p->ct_action & TCA_CT_ACT_NAT_SRC) &&
1122 (p->ct_action & TCA_CT_ACT_NAT_DST)) {
1123 NL_SET_ERR_MSG_MOD(extack, "dnat and snat can't be enabled at the same time");
1128 if (tb[TCA_CT_NAT_IPV4_MIN]) {
1129 struct nlattr *max_attr = tb[TCA_CT_NAT_IPV4_MAX];
1131 p->ipv4_range = true;
1132 range->flags |= NF_NAT_RANGE_MAP_IPS;
1133 range->min_addr.ip =
1134 nla_get_in_addr(tb[TCA_CT_NAT_IPV4_MIN]);
1136 range->max_addr.ip = max_attr ?
1137 nla_get_in_addr(max_attr) :
1139 } else if (tb[TCA_CT_NAT_IPV6_MIN]) {
1140 struct nlattr *max_attr = tb[TCA_CT_NAT_IPV6_MAX];
1142 p->ipv4_range = false;
1143 range->flags |= NF_NAT_RANGE_MAP_IPS;
1144 range->min_addr.in6 =
1145 nla_get_in6_addr(tb[TCA_CT_NAT_IPV6_MIN]);
1147 range->max_addr.in6 = max_attr ?
1148 nla_get_in6_addr(max_attr) :
1149 range->min_addr.in6;
1152 if (tb[TCA_CT_NAT_PORT_MIN]) {
1153 range->flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
1154 range->min_proto.all = nla_get_be16(tb[TCA_CT_NAT_PORT_MIN]);
1156 range->max_proto.all = tb[TCA_CT_NAT_PORT_MAX] ?
1157 nla_get_be16(tb[TCA_CT_NAT_PORT_MAX]) :
1158 range->min_proto.all;
1164 static void tcf_ct_set_key_val(struct nlattr **tb,
1165 void *val, int val_type,
1166 void *mask, int mask_type,
1171 nla_memcpy(val, tb[val_type], len);
1176 if (mask_type == TCA_CT_UNSPEC || !tb[mask_type])
1177 memset(mask, 0xff, len);
1179 nla_memcpy(mask, tb[mask_type], len);
1182 static int tcf_ct_fill_params(struct net *net,
1183 struct tcf_ct_params *p,
1186 struct netlink_ext_ack *extack)
1188 struct tc_ct_action_net *tn = net_generic(net, ct_net_id);
1189 struct nf_conntrack_zone zone;
1190 struct nf_conn *tmpl;
1193 p->zone = NF_CT_DEFAULT_ZONE_ID;
1195 tcf_ct_set_key_val(tb,
1196 &p->ct_action, TCA_CT_ACTION,
1197 NULL, TCA_CT_UNSPEC,
1198 sizeof(p->ct_action));
1200 if (p->ct_action & TCA_CT_ACT_CLEAR)
1203 err = tcf_ct_fill_params_nat(p, parm, tb, extack);
1207 if (tb[TCA_CT_MARK]) {
1208 if (!IS_ENABLED(CONFIG_NF_CONNTRACK_MARK)) {
1209 NL_SET_ERR_MSG_MOD(extack, "Conntrack mark isn't enabled.");
1212 tcf_ct_set_key_val(tb,
1213 &p->mark, TCA_CT_MARK,
1214 &p->mark_mask, TCA_CT_MARK_MASK,
1218 if (tb[TCA_CT_LABELS]) {
1219 if (!IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS)) {
1220 NL_SET_ERR_MSG_MOD(extack, "Conntrack labels isn't enabled.");
1225 NL_SET_ERR_MSG_MOD(extack, "Failed to set connlabel length");
1228 tcf_ct_set_key_val(tb,
1229 p->labels, TCA_CT_LABELS,
1230 p->labels_mask, TCA_CT_LABELS_MASK,
1234 if (tb[TCA_CT_ZONE]) {
1235 if (!IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES)) {
1236 NL_SET_ERR_MSG_MOD(extack, "Conntrack zones isn't enabled.");
1240 tcf_ct_set_key_val(tb,
1241 &p->zone, TCA_CT_ZONE,
1242 NULL, TCA_CT_UNSPEC,
1246 nf_ct_zone_init(&zone, p->zone, NF_CT_DEFAULT_ZONE_DIR, 0);
1247 tmpl = nf_ct_tmpl_alloc(net, &zone, GFP_KERNEL);
1249 NL_SET_ERR_MSG_MOD(extack, "Failed to allocate conntrack template");
1252 __set_bit(IPS_CONFIRMED_BIT, &tmpl->status);
1258 static int tcf_ct_init(struct net *net, struct nlattr *nla,
1259 struct nlattr *est, struct tc_action **a,
1260 struct tcf_proto *tp, u32 flags,
1261 struct netlink_ext_ack *extack)
1263 struct tc_action_net *tn = net_generic(net, ct_net_id);
1264 bool bind = flags & TCA_ACT_FLAGS_BIND;
1265 struct tcf_ct_params *params = NULL;
1266 struct nlattr *tb[TCA_CT_MAX + 1];
1267 struct tcf_chain *goto_ch = NULL;
1274 NL_SET_ERR_MSG_MOD(extack, "Ct requires attributes to be passed");
1278 err = nla_parse_nested(tb, TCA_CT_MAX, nla, ct_policy, extack);
1282 if (!tb[TCA_CT_PARMS]) {
1283 NL_SET_ERR_MSG_MOD(extack, "Missing required ct parameters");
1286 parm = nla_data(tb[TCA_CT_PARMS]);
1287 index = parm->index;
1288 err = tcf_idr_check_alloc(tn, &index, a, bind);
1293 err = tcf_idr_create_from_flags(tn, index, est, a,
1294 &act_ct_ops, bind, flags);
1296 tcf_idr_cleanup(tn, index);
1299 res = ACT_P_CREATED;
1304 if (!(flags & TCA_ACT_FLAGS_REPLACE)) {
1305 tcf_idr_release(*a, bind);
1309 err = tcf_action_check_ctrlact(parm->action, tp, &goto_ch, extack);
1315 params = kzalloc(sizeof(*params), GFP_KERNEL);
1316 if (unlikely(!params)) {
1321 err = tcf_ct_fill_params(net, params, parm, tb, extack);
1325 err = tcf_ct_flow_table_get(params);
1329 spin_lock_bh(&c->tcf_lock);
1330 goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch);
1331 params = rcu_replace_pointer(c->params, params,
1332 lockdep_is_held(&c->tcf_lock));
1333 spin_unlock_bh(&c->tcf_lock);
1336 tcf_chain_put_by_act(goto_ch);
1338 call_rcu(¶ms->rcu, tcf_ct_params_free);
1344 tcf_chain_put_by_act(goto_ch);
1346 tcf_idr_release(*a, bind);
1350 static void tcf_ct_cleanup(struct tc_action *a)
1352 struct tcf_ct_params *params;
1353 struct tcf_ct *c = to_ct(a);
1355 params = rcu_dereference_protected(c->params, 1);
1357 call_rcu(¶ms->rcu, tcf_ct_params_free);
1360 static int tcf_ct_dump_key_val(struct sk_buff *skb,
1361 void *val, int val_type,
1362 void *mask, int mask_type,
1367 if (mask && !memchr_inv(mask, 0, len))
1370 err = nla_put(skb, val_type, len, val);
1374 if (mask_type != TCA_CT_UNSPEC) {
1375 err = nla_put(skb, mask_type, len, mask);
1383 static int tcf_ct_dump_nat(struct sk_buff *skb, struct tcf_ct_params *p)
1385 struct nf_nat_range2 *range = &p->range;
1387 if (!(p->ct_action & TCA_CT_ACT_NAT))
1390 if (!(p->ct_action & (TCA_CT_ACT_NAT_SRC | TCA_CT_ACT_NAT_DST)))
1393 if (range->flags & NF_NAT_RANGE_MAP_IPS) {
1394 if (p->ipv4_range) {
1395 if (nla_put_in_addr(skb, TCA_CT_NAT_IPV4_MIN,
1396 range->min_addr.ip))
1398 if (nla_put_in_addr(skb, TCA_CT_NAT_IPV4_MAX,
1399 range->max_addr.ip))
1402 if (nla_put_in6_addr(skb, TCA_CT_NAT_IPV6_MIN,
1403 &range->min_addr.in6))
1405 if (nla_put_in6_addr(skb, TCA_CT_NAT_IPV6_MAX,
1406 &range->max_addr.in6))
1411 if (range->flags & NF_NAT_RANGE_PROTO_SPECIFIED) {
1412 if (nla_put_be16(skb, TCA_CT_NAT_PORT_MIN,
1413 range->min_proto.all))
1415 if (nla_put_be16(skb, TCA_CT_NAT_PORT_MAX,
1416 range->max_proto.all))
1423 static inline int tcf_ct_dump(struct sk_buff *skb, struct tc_action *a,
1426 unsigned char *b = skb_tail_pointer(skb);
1427 struct tcf_ct *c = to_ct(a);
1428 struct tcf_ct_params *p;
1430 struct tc_ct opt = {
1431 .index = c->tcf_index,
1432 .refcnt = refcount_read(&c->tcf_refcnt) - ref,
1433 .bindcnt = atomic_read(&c->tcf_bindcnt) - bind,
1437 spin_lock_bh(&c->tcf_lock);
1438 p = rcu_dereference_protected(c->params,
1439 lockdep_is_held(&c->tcf_lock));
1440 opt.action = c->tcf_action;
1442 if (tcf_ct_dump_key_val(skb,
1443 &p->ct_action, TCA_CT_ACTION,
1444 NULL, TCA_CT_UNSPEC,
1445 sizeof(p->ct_action)))
1446 goto nla_put_failure;
1448 if (p->ct_action & TCA_CT_ACT_CLEAR)
1451 if (IS_ENABLED(CONFIG_NF_CONNTRACK_MARK) &&
1452 tcf_ct_dump_key_val(skb,
1453 &p->mark, TCA_CT_MARK,
1454 &p->mark_mask, TCA_CT_MARK_MASK,
1456 goto nla_put_failure;
1458 if (IS_ENABLED(CONFIG_NF_CONNTRACK_LABELS) &&
1459 tcf_ct_dump_key_val(skb,
1460 p->labels, TCA_CT_LABELS,
1461 p->labels_mask, TCA_CT_LABELS_MASK,
1463 goto nla_put_failure;
1465 if (IS_ENABLED(CONFIG_NF_CONNTRACK_ZONES) &&
1466 tcf_ct_dump_key_val(skb,
1467 &p->zone, TCA_CT_ZONE,
1468 NULL, TCA_CT_UNSPEC,
1470 goto nla_put_failure;
1472 if (tcf_ct_dump_nat(skb, p))
1473 goto nla_put_failure;
1476 if (nla_put(skb, TCA_CT_PARMS, sizeof(opt), &opt))
1477 goto nla_put_failure;
1479 tcf_tm_dump(&t, &c->tcf_tm);
1480 if (nla_put_64bit(skb, TCA_CT_TM, sizeof(t), &t, TCA_CT_PAD))
1481 goto nla_put_failure;
1482 spin_unlock_bh(&c->tcf_lock);
1486 spin_unlock_bh(&c->tcf_lock);
1491 static int tcf_ct_walker(struct net *net, struct sk_buff *skb,
1492 struct netlink_callback *cb, int type,
1493 const struct tc_action_ops *ops,
1494 struct netlink_ext_ack *extack)
1496 struct tc_action_net *tn = net_generic(net, ct_net_id);
1498 return tcf_generic_walker(tn, skb, cb, type, ops, extack);
1501 static int tcf_ct_search(struct net *net, struct tc_action **a, u32 index)
1503 struct tc_action_net *tn = net_generic(net, ct_net_id);
1505 return tcf_idr_search(tn, a, index);
1508 static void tcf_stats_update(struct tc_action *a, u64 bytes, u64 packets,
1509 u64 drops, u64 lastuse, bool hw)
1511 struct tcf_ct *c = to_ct(a);
1513 tcf_action_update_stats(a, bytes, packets, drops, hw);
1514 c->tcf_tm.lastuse = max_t(u64, c->tcf_tm.lastuse, lastuse);
1517 static int tcf_ct_offload_act_setup(struct tc_action *act, void *entry_data,
1518 u32 *index_inc, bool bind)
1521 struct flow_action_entry *entry = entry_data;
1523 entry->id = FLOW_ACTION_CT;
1524 entry->ct.action = tcf_ct_action(act);
1525 entry->ct.zone = tcf_ct_zone(act);
1526 entry->ct.flow_table = tcf_ct_ft(act);
1529 struct flow_offload_action *fl_action = entry_data;
1531 fl_action->id = FLOW_ACTION_CT;
1537 static struct tc_action_ops act_ct_ops = {
1540 .owner = THIS_MODULE,
1542 .dump = tcf_ct_dump,
1543 .init = tcf_ct_init,
1544 .cleanup = tcf_ct_cleanup,
1545 .walk = tcf_ct_walker,
1546 .lookup = tcf_ct_search,
1547 .stats_update = tcf_stats_update,
1548 .offload_act_setup = tcf_ct_offload_act_setup,
1549 .size = sizeof(struct tcf_ct),
1552 static __net_init int ct_init_net(struct net *net)
1554 unsigned int n_bits = sizeof_field(struct tcf_ct_params, labels) * 8;
1555 struct tc_ct_action_net *tn = net_generic(net, ct_net_id);
1557 if (nf_connlabels_get(net, n_bits - 1)) {
1559 pr_err("act_ct: Failed to set connlabels length");
1564 return tc_action_net_init(net, &tn->tn, &act_ct_ops);
1567 static void __net_exit ct_exit_net(struct list_head *net_list)
1572 list_for_each_entry(net, net_list, exit_list) {
1573 struct tc_ct_action_net *tn = net_generic(net, ct_net_id);
1576 nf_connlabels_put(net);
1580 tc_action_net_exit(net_list, ct_net_id);
1583 static struct pernet_operations ct_net_ops = {
1584 .init = ct_init_net,
1585 .exit_batch = ct_exit_net,
1587 .size = sizeof(struct tc_ct_action_net),
1590 static int __init ct_init_module(void)
1594 act_ct_wq = alloc_ordered_workqueue("act_ct_workqueue", 0);
1598 err = tcf_ct_flow_tables_init();
1602 err = tcf_register_action(&act_ct_ops, &ct_net_ops);
1606 err = nf_ct_extend_register(&act_ct_extend);
1608 goto err_register_extend;
1610 static_branch_inc(&tcf_frag_xmit_count);
1614 err_register_extend:
1615 tcf_unregister_action(&act_ct_ops, &ct_net_ops);
1617 tcf_ct_flow_tables_uninit();
1619 destroy_workqueue(act_ct_wq);
1623 static void __exit ct_cleanup_module(void)
1625 static_branch_dec(&tcf_frag_xmit_count);
1626 nf_ct_extend_unregister(&act_ct_extend);
1627 tcf_unregister_action(&act_ct_ops, &ct_net_ops);
1628 tcf_ct_flow_tables_uninit();
1629 destroy_workqueue(act_ct_wq);
1632 module_init(ct_init_module);
1633 module_exit(ct_cleanup_module);
1634 MODULE_AUTHOR("Paul Blakey <paulb@mellanox.com>");
1635 MODULE_AUTHOR("Yossi Kuperman <yossiku@mellanox.com>");
1636 MODULE_AUTHOR("Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>");
1637 MODULE_DESCRIPTION("Connection tracking action");
1638 MODULE_LICENSE("GPL v2");