net: add helper support in tc act_ct for ovs offloading
Subsystems (5)
v3 cover net: add helper support in tc act_ct for ovs offloading
lya reported an issue that FTP traffic would be broken when the OVS flow with ct(commit,alg=ftp) installed in the OVS kernel module, and it was caused by that TC didn't support the ftp helper offloaded from OVS.
This patchset is to add the helper support in act_ct for OVS offloading in kernel net/sched.
The 1st and 2nd patches move some common code into nf_conntrack_helper from openvswitch so that they could be used by net/sched in the 4th patch (Note there are still some other common code used in both OVS and TC, and I will extract it in other patches). The 3rd patch extracts another function in net/sched to make the 4th patch easier to write. The 4th patch adds this feature in net/sched.
The user space part will be added in another patch, and with it these OVS flows (FTP over SNAT) can be used to test this feature:
table=0, in_port=veth1,tcp,tcp_dst=2121,ct_state=-trk \
actions=ct(table=1, nat), normal
table=0, in_port=veth2,tcp,ct_state=-trk actions=ct(table=1, nat)
table=0, in_port=veth1,tcp,ct_state=-trk actions=ct(table=0, nat)
table=0, in_port=veth1,tcp,ct_state=+trk+rel actions=ct(commit, nat),normal
table=0, in_port=veth1,tcp,ct_state=+trk+est actions=veth2"
table=1, in_port=veth1,tcp,tcp_dst=2121,ct_state=+trk+new \
actions=ct(commit, nat(src=7.7.16.1), alg=ftp),normal"
table=1, in_port=veth1,tcp,tcp_dst=2121,ct_state=+trk+est actions=veth2"
table=1, in_port=veth2,tcp,ct_state=+trk+est actions=veth1"v1->v2:
- go to drop instead of return -EINVAL when fails to add SEQADJ ext in tcf_ct_act() as Paolo noticed.
- add the 2nd patch to extract nf_ct_add_helper from openvswitch for tc act_ct use.
- add ct exts only when the ct is not confirmed as Pablo noticed.
v2->v3:
- fix a warning of unused variable 'err' when CONFIG_NF_NAT is disabled.
Xin Long (4):
net: move the ct helper function to nf_conntrack_helper for ovs and tc
net: move add ct helper function to nf_conntrack_helper for ovs and tc
net: sched: call tcf_ct_params_free to free params in tcf_ct_init
net: sched: add helper support in act_ct
include/net/netfilter/nf_conntrack_helper.h | 4 + include/net/tc_act/tc_ct.h | 1 + include/uapi/linux/tc_act/tc_ct.h | 3 + net/netfilter/nf_conntrack_helper.c | 102 +++++++++++++++++ net/openvswitch/conntrack.c | 105 +---------------- net/sched/act_ct.c | 118 ++++++++++++++++---- 6 files changed, 212 insertions(+), 121 deletions(-)
Signature · 1 line
2.31.1
PATCH v3 1/4 net: move the ct helper function to nf_conntrack_helper for ovs and tc
Move ovs_ct_helper from openvswitch to nf_conntrack_helper and rename as nf_ct_helper so that it can be used in TC act_ct in the next patch. Note that it also adds the checks for the family and proto, as in TC act_ct, the packets with correct family and proto are not guaranteed.
--- include/net/netfilter/nf_conntrack_helper.h | 2 + net/netfilter/nf_conntrack_helper.c | 71 +++++++++++++++++++++ net/openvswitch/conntrack.c | 61 +----------------- 3 files changed, 74 insertions(+), 60 deletions(-)
include/net/netfilter/nf_conntrack_helper.h +2 -0
@@ -115,6 +115,8 @@ struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp);int __nf_ct_try_assign_helper (struct nf_conn *ct,struct nf_conn *tmpl,gfp_t flags); +int nf_ct_helper (struct sk_buff *skb,u16 proto); +void nf_ct_helper_destroy (struct nf_conn *ct);static inline struct nf_conn_help *nfct_help (const struct nf_conn *ct)
net/netfilter/nf_conntrack_helper.c +71 -0
84 lines not on this page · raw message
net/openvswitch/conntrack.c +1 -60
73 lines not on this page · raw message
Signature · 1 line
2.31.1
Aaron Conole
maintainerRe: [PATCHv3 net-next 1/4] net: move the ct helper function to nf_conntrack_helper for ovs and tc
Quoted 7 lines · Xin Long
Move
ovs_ct_helperfrom openvswitch tonf_conntrack_helperand rename asnf_ct_helperso that it can be used in TCact_ctin the next patch. Note that it also adds the checks for the family and proto, as in TCact_ct, the packets with correct family and proto are not guaranteed.Signed-off-by Xin Long <[email protected]>---
Hi Xin,
Quoted 33 lines
include/net/netfilter/nf_conntrack_helper.h | 2 + net/netfilter/nf_conntrack_helper.c | 71 +++++++++++++++++++++ net/openvswitch/conntrack.c | 61 +----------------- 3 files changed, 74 insertions(+), 60 deletions(-)include/net/netfilter/nf_conntrack_helper.h +2
-0@@ -115,6 +115,8 @@ struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp);int __nf_ct_try_assign_helper (struct nf_conn *ct,struct nf_conn *tmpl,gfp_t flags); +int nf_ct_helper (struct sk_buff *skb,u16 proto); +void nf_ct_helper_destroy (struct nf_conn *ct);static inline struct nf_conn_help *nfct_help (const struct nf_conn *ct)net/netfilter/nf_conntrack_helper.c +2
-0@@ -26,7 +26,9 @@#include <net/netfilter/nf_conntrack_extend.h> #include <net/netfilter/nf_conntrack_helper.h> #include <net/netfilter/nf_conntrack_l4proto.h> +#include <net/netfilter/nf_conntrack_seqadj.h> #include <net/netfilter/nf_log.h> +#include <net/ip.h> static DEFINE_MUTEX (nf_ct_helper_mutex);struct hlist_head *nf_ct_helper_hash__read_mostly ;
net/netfilter/nf_conntrack_helper.c int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl, · line 246
Quoted 5 lines
net/netfilter/nf_conntrack_helper.c +2
-0@@ -240,6 +242,75 @@ int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl, }EXPORT_SYMBOL_GPL (__nf_ct_try_assign_helper); +/* 'skb' should already be pulled to nh_ofs. */ +int nf_ct_helper (struct sk_buff *skb,u16 proto)
AFAICT, in all the places we call this we will have the nf_conn and ip_conntrack_info already. Maybe it makes sense to pass them here rather than looking up again? Originally, that information wasn't available in the calling function - over time this has been added so we might as well reduce the amount of "extra lookups" performed.
Quoted 148 lines
net/netfilter/nf_conntrack_helper.c +67
-0+{ +const struct nf_conntrack_helper *helper; +const struct nf_conn_help *help; +enum ip_conntrack_info ctinfo; +unsigned int protoff; +struct nf_conn *ct; +int err; + + ct =nf_ct_get (skb, &ctinfo); +if (!ct || ctinfo ==IP_CT_RELATED_REPLY ) +return NF_ACCEPT ; + + help =nfct_help (ct); +if (!help) +return NF_ACCEPT ; + + helper =rcu_dereference (help->helper); +if (!helper) +return NF_ACCEPT ; + +if (helper->tuple.src.l3num !=NFPROTO_UNSPEC && + helper->tuple.src.l3num != proto) +return NF_ACCEPT ; + +switch (proto) { +case NFPROTO_IPV4 : + protoff =ip_hdrlen (skb); + proto =ip_hdr (skb)->protocol; +break ; +case NFPROTO_IPV6 : { +u8 nexthdr =ipv6_hdr (skb)->nexthdr; +__be16 frag_off; +int ofs; + + ofs =ipv6_skip_exthdr (skb,sizeof (struct ipv6hdr ), &nexthdr, + &frag_off); +if (ofs <0 || (frag_off &htons (~0x7 )) !=0 ) { +pr_debug ("proto header not found\n" ); +return NF_ACCEPT ; + } + protoff = ofs; + proto = nexthdr; +break ; + } +default : +WARN_ONCE (1 ,"helper invoked on non-IP family!" ); +return NF_DROP ; + } + +if (helper->tuple.dst.protonum != proto) +return NF_ACCEPT ; + + err = helper->help (skb, protoff, ct, ctinfo); +if (err !=NF_ACCEPT ) +return err; + +/* Adjust seqs after helper. This is needed due to some helpers (e.g., +* FTP with NAT) adusting the TCP payload size when mangling IP +* addresses and/or port numbers in the text-based control connection. +*/ +if (test_bit (IPS_SEQ_ADJUST_BIT , &ct->status) && + !nf_ct_seq_adjust (skb, ct, ctinfo, protoff)) +return NF_DROP ; +return NF_ACCEPT ; +} +EXPORT_SYMBOL_GPL (nf_ct_helper); +/* appropriate ct lock protecting must be taken by caller */ static int unhelp (struct nf_conn *ct,void *me) {net/openvswitch/conntrack.c +1
-60@@ -434,65 +434,6 @@ static int ovs_ct_set_labels(struct nf_conn *ct, struct sw_flow_key *key,return 0 ; } -/* 'skb' should already be pulled to nh_ofs. */ -static int ovs_ct_helper (struct sk_buff *skb,u16 proto) -{ -const struct nf_conntrack_helper *helper; -const struct nf_conn_help *help; -enum ip_conntrack_info ctinfo; -unsigned int protoff; -struct nf_conn *ct; -int err; - - ct =nf_ct_get (skb, &ctinfo); -if (!ct || ctinfo ==IP_CT_RELATED_REPLY ) -return NF_ACCEPT ; - - help =nfct_help (ct); -if (!help) -return NF_ACCEPT ; - - helper =rcu_dereference (help->helper); -if (!helper) -return NF_ACCEPT ; - -switch (proto) { -case NFPROTO_IPV4 : - protoff =ip_hdrlen (skb); -break ; -case NFPROTO_IPV6 : { -u8 nexthdr =ipv6_hdr (skb)->nexthdr; -__be16 frag_off; -int ofs; - - ofs =ipv6_skip_exthdr (skb,sizeof (struct ipv6hdr ), &nexthdr, - &frag_off); -if (ofs <0 || (frag_off &htons (~0x7 )) !=0 ) { -pr_debug ("proto header not found\n" ); -return NF_ACCEPT ; - } - protoff = ofs; -break ; - } -default : -WARN_ONCE (1 ,"helper invoked on non-IP family!" ); -return NF_DROP ; - } - - err = helper->help (skb, protoff, ct, ctinfo); -if (err !=NF_ACCEPT ) -return err; - -/* Adjust seqs after helper. This is needed due to some helpers (e.g., -* FTP with NAT) adusting the TCP payload size when mangling IP -* addresses and/or port numbers in the text-based control connection. -*/ -if (test_bit (IPS_SEQ_ADJUST_BIT , &ct->status) && - !nf_ct_seq_adjust (skb, ct, ctinfo, protoff)) -return NF_DROP ; -return NF_ACCEPT ; -} -/* Returns 0 on success, -EINPROGRESS if 'skb' is stolen, or other nonzero * value if 'skb' is freed. */ @@ -1038,7 +979,7 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,*/ if ((nf_ct_is_confirmed (ct) ? !cached || add_helper : info->commit) && -ovs_ct_helper (skb, info->family) !=NF_ACCEPT ) { +nf_ct_helper (skb, info->family) !=NF_ACCEPT ) {return -EINVAL ; }
Re: [PATCHv3 net-next 1/4] net: move the ct helper function to nf_conntrack_helper for ovs and tc
Quoted 49 lines · Aaron Conole
Quoted 7 lines · Xin Long
Move
ovs_ct_helperfrom openvswitch tonf_conntrack_helperand rename asnf_ct_helperso that it can be used in TCact_ctin the next patch. Note that it also adds the checks for the family and proto, as in TCact_ct, the packets with correct family and proto are not guaranteed.Signed-off-by Xin Long <[email protected]>---
Hi Xin,
Quoted 36 lines
include/net/netfilter/nf_conntrack_helper.h | 2 + net/netfilter/nf_conntrack_helper.c | 71 +++++++++++++++++++++ net/openvswitch/conntrack.c | 61 +----------------- 3 files changed, 74 insertions(+), 60 deletions(-)include/net/netfilter/nf_conntrack_helper.h +2
-0@@ -115,6 +115,8 @@ struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp);int __nf_ct_try_assign_helper (struct nf_conn *ct,struct nf_conn *tmpl,gfp_t flags); +int nf_ct_helper (struct sk_buff *skb,u16 proto); +void nf_ct_helper_destroy (struct nf_conn *ct);static inline struct nf_conn_help *nfct_help (const struct nf_conn *ct)net/netfilter/nf_conntrack_helper.c +2
-0@@ -26,7 +26,9 @@#include <net/netfilter/nf_conntrack_extend.h> #include <net/netfilter/nf_conntrack_helper.h> #include <net/netfilter/nf_conntrack_l4proto.h> +#include <net/netfilter/nf_conntrack_seqadj.h> #include <net/netfilter/nf_log.h> +#include <net/ip.h> static DEFINE_MUTEX (nf_ct_helper_mutex);struct hlist_head *nf_ct_helper_hash__read_mostly ;@@ -240,6 +242,75 @@ int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl, }EXPORT_SYMBOL_GPL (__nf_ct_try_assign_helper);
Quoted 8 lines
net/netfilter/nf_conntrack_helper.c int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl, · line 246
Quoted 2 lines
net/netfilter/nf_conntrack_helper.c +2
-0+/* 'skb' should already be pulled to nh_ofs. */ +int nf_ct_helper (struct sk_buff *skb,u16 proto)AFAICT, in all the places we call this we will have the
nf_connandip_conntrack_infoalready. Maybe it makes sense to pass them here rather than looking up again? Originally, that information wasn't available in the calling function - over time this has been added so we might as well reduce the amount of "extra lookups" performed.
I just tried to keep nf_ct_helper() as similar as possible to the original ovs_ct_helper().
But sure, we can also pass ct and ctinfo as the arguments, like some other functions where it passes all of skb, ct and ctinfo.
Thanks.
Quoted 150 lines
Quoted 149 lines
net/netfilter/nf_conntrack_helper.c +67
-0+{ +const struct nf_conntrack_helper *helper; +const struct nf_conn_help *help; +enum ip_conntrack_info ctinfo; +unsigned int protoff; +struct nf_conn *ct; +int err; + + ct =nf_ct_get (skb, &ctinfo); +if (!ct || ctinfo ==IP_CT_RELATED_REPLY ) +return NF_ACCEPT ; + + help =nfct_help (ct); +if (!help) +return NF_ACCEPT ; + + helper =rcu_dereference (help->helper); +if (!helper) +return NF_ACCEPT ; + +if (helper->tuple.src.l3num !=NFPROTO_UNSPEC && + helper->tuple.src.l3num != proto) +return NF_ACCEPT ; + +switch (proto) { +case NFPROTO_IPV4 : + protoff =ip_hdrlen (skb); + proto =ip_hdr (skb)->protocol; +break ; +case NFPROTO_IPV6 : { +u8 nexthdr =ipv6_hdr (skb)->nexthdr; +__be16 frag_off; +int ofs; + + ofs =ipv6_skip_exthdr (skb,sizeof (struct ipv6hdr ), &nexthdr, + &frag_off); +if (ofs <0 || (frag_off &htons (~0x7 )) !=0 ) { +pr_debug ("proto header not found\n" ); +return NF_ACCEPT ; + } + protoff = ofs; + proto = nexthdr; +break ; + } +default : +WARN_ONCE (1 ,"helper invoked on non-IP family!" ); +return NF_DROP ; + } + +if (helper->tuple.dst.protonum != proto) +return NF_ACCEPT ; + + err = helper->help (skb, protoff, ct, ctinfo); +if (err !=NF_ACCEPT ) +return err; + +/* Adjust seqs after helper. This is needed due to some helpers (e.g., +* FTP with NAT) adusting the TCP payload size when mangling IP +* addresses and/or port numbers in the text-based control connection. +*/ +if (test_bit (IPS_SEQ_ADJUST_BIT , &ct->status) && + !nf_ct_seq_adjust (skb, ct, ctinfo, protoff)) +return NF_DROP ; +return NF_ACCEPT ; +} +EXPORT_SYMBOL_GPL (nf_ct_helper); +/* appropriate ct lock protecting must be taken by caller */ static int unhelp (struct nf_conn *ct,void *me) {net/openvswitch/conntrack.c +1
-60@@ -434,65 +434,6 @@ static int ovs_ct_set_labels(struct nf_conn *ct, struct sw_flow_key *key,return 0 ; } -/* 'skb' should already be pulled to nh_ofs. */ -static int ovs_ct_helper (struct sk_buff *skb,u16 proto) -{ -const struct nf_conntrack_helper *helper; -const struct nf_conn_help *help; -enum ip_conntrack_info ctinfo; -unsigned int protoff; -struct nf_conn *ct; -int err; - - ct =nf_ct_get (skb, &ctinfo); -if (!ct || ctinfo ==IP_CT_RELATED_REPLY ) -return NF_ACCEPT ; - - help =nfct_help (ct); -if (!help) -return NF_ACCEPT ; - - helper =rcu_dereference (help->helper); -if (!helper) -return NF_ACCEPT ; - -switch (proto) { -case NFPROTO_IPV4 : - protoff =ip_hdrlen (skb); -break ; -case NFPROTO_IPV6 : { -u8 nexthdr =ipv6_hdr (skb)->nexthdr; -__be16 frag_off; -int ofs; - - ofs =ipv6_skip_exthdr (skb,sizeof (struct ipv6hdr ), &nexthdr, - &frag_off); -if (ofs <0 || (frag_off &htons (~0x7 )) !=0 ) { -pr_debug ("proto header not found\n" ); -return NF_ACCEPT ; - } - protoff = ofs; -break ; - } -default : -WARN_ONCE (1 ,"helper invoked on non-IP family!" ); -return NF_DROP ; - } - - err = helper->help (skb, protoff, ct, ctinfo); -if (err !=NF_ACCEPT ) -return err; - -/* Adjust seqs after helper. This is needed due to some helpers (e.g., -* FTP with NAT) adusting the TCP payload size when mangling IP -* addresses and/or port numbers in the text-based control connection. -*/ -if (test_bit (IPS_SEQ_ADJUST_BIT , &ct->status) && - !nf_ct_seq_adjust (skb, ct, ctinfo, protoff)) -return NF_DROP ; -return NF_ACCEPT ; -} -/* Returns 0 on success, -EINPROGRESS if 'skb' is stolen, or other nonzero * value if 'skb' is freed. */ @@ -1038,7 +979,7 @@ static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key,*/ if ((nf_ct_is_confirmed (ct) ? !cached || add_helper : info->commit) && -ovs_ct_helper (skb, info->family) !=NF_ACCEPT ) { +nf_ct_helper (skb, info->family) !=NF_ACCEPT ) {return -EINVAL ; }
PATCH v3 2/4 net: move add ct helper function to nf_conntrack_helper for ovs and tc
In reply to Xin LongMove ovs_ct_add_helper from openvswitch to nf_conntrack_helper and rename as nf_ct_add_helper, so that it can be used in TC act_ct in the next patch.
--- include/net/netfilter/nf_conntrack_helper.h | 2 + net/netfilter/nf_conntrack_helper.c | 31 +++++++++++++++ net/openvswitch/conntrack.c | 44 +++------------------ 3 files changed, 38 insertions(+), 39 deletions(-)
include/net/netfilter/nf_conntrack_helper.h +2 -0
@@ -116,6 +116,8 @@ int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl, gfp_t flags);int nf_ct_helper (struct sk_buff *skb,u16 proto); +int nf_ct_add_helper (struct nf_conn *ct,const char *name,u8 family, +u8 proto,bool nat,struct nf_conntrack_helper **hp);void nf_ct_helper_destroy (struct nf_conn *ct);
net/netfilter/nf_conntrack_helper.c +31 -0
@@ -311,6 +311,37 @@ int nf_ct_helper(struct sk_buff *skb, u16 proto) }EXPORT_SYMBOL_GPL (nf_ct_helper); +int nf_ct_add_helper (struct nf_conn *ct,const char *name,u8 family, +u8 proto,bool nat,struct nf_conntrack_helper **hp) +{ +struct nf_conntrack_helper *helper; +struct nf_conn_help *help; +int ret =0 ; + + helper =nf_conntrack_helper_try_module_get (name, family, proto); +if (!helper) +return -EINVAL ; + + help =nf_ct_helper_ext_add (ct,GFP_KERNEL ); +if (!help) { +nf_conntrack_helper_put (helper); +return -ENOMEM ; + } +#if IS_ENABLED (CONFIG_NF_NAT ) +if (nat) { + ret =nf_nat_helper_try_module_get (name, family, proto); +if (ret) { +nf_conntrack_helper_put (helper); +return ret; + } + } +#endif +rcu_assign_pointer (help->helper, helper); + *hp = helper; +return ret; +} +EXPORT_SYMBOL_GPL (nf_ct_add_helper); +/* appropriate ct lock protecting must be taken by caller */ static int unhelp (struct nf_conn *ct,void *me) {
net/openvswitch/conntrack.c +5 -39
57 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH v3 3/4 net: sched: call tcf_ct_params_free to free params in tcf_ct_init
In reply to Xin LongThis patch is to make the err path simple by calling tcf_ct_params_free(), so that it won't cause problems when more members are added into param and need freeing on the err path.
--- net/sched/act_ct.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
net/sched/act_ct.c +18 -17
@@ -345,11 +345,9 @@ static void tcf_ct_flow_table_cleanup_work(struct work_struct *work)module_put (THIS_MODULE ); } -static void tcf_ct_flow_table_put (struct tcf_ct_params *params) +static void tcf_ct_flow_table_put (struct tcf_ct_flow_table *ct_ft) { -struct tcf_ct_flow_table *ct_ft = params->ct_ft; - -if (refcount_dec_and_test (¶ms->ct_ft->ref)) { +if (refcount_dec_and_test (&ct_ft->ref)) {rhashtable_remove_fast (&zones_ht, &ct_ft->node, zones_params);INIT_RCU_WORK (&ct_ft->rwork, tcf_ct_flow_table_cleanup_work);queue_rcu_work (act_ct_wq, &ct_ft->rwork);
@@ -832,18 +830,23 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,return err; } -static void tcf_ct_params_free (struct rcu_head *head) +static void tcf_ct_params_free (struct tcf_ct_params *params) { -struct tcf_ct_params *params =container_of (head, - struct tcf_ct_params, rcu); - -tcf_ct_flow_table_put (params); - +if (params->ct_ft) +tcf_ct_flow_table_put (params->ct_ft);if (params->tmpl)nf_ct_put (params->tmpl);kfree (params); } +static void tcf_ct_params_free_rcu (struct rcu_head *head) +{ +struct tcf_ct_params *params; + + params = container_of(head, struct tcf_ct_params, rcu); +tcf_ct_params_free (params); +} +#if IS_ENABLED (CONFIG_NF_NAT )/* Modelled after nf_nat_ipv[46]_fn(). * range is only used for new, uninitialized NAT state.
@@ -1390,7 +1393,7 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, err =tcf_ct_flow_table_get (net, params);if (err) - goto cleanup_params; + goto cleanup;spin_lock_bh (&c->tcf_lock); goto_ch =tcf_action_set_ctrlact (*a, parm->action, goto_ch);
@@ -1401,17 +1404,15 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla,if (goto_ch)tcf_chain_put_by_act (goto_ch);if (params) -call_rcu (¶ms->rcu, tcf_ct_params_free); +call_rcu (¶ms->rcu, tcf_ct_params_free_rcu);return res; -cleanup_params: -if (params->tmpl) -nf_ct_put (params->tmpl); cleanup:if (goto_ch)tcf_chain_put_by_act (goto_ch); -kfree (params); +if (params) +tcf_ct_params_free (params);tcf_idr_release (*a, bind);return err; }
@@ -1423,7 +1424,7 @@ static void tcf_ct_cleanup(struct tc_action *a) params =rcu_dereference_protected (c->params,1 );if (params) -call_rcu (¶ms->rcu, tcf_ct_params_free); +call_rcu (¶ms->rcu, tcf_ct_params_free_rcu); } static int tcf_ct_dump_key_val(struct sk_buff *skb,
Signature · 1 line
2.31.1
PATCH v3 4/4 net: sched: add helper support in act_ct
In reply to Xin LongThis patch is to add helper support in act_ct for OVS actions=ct(alg=xxx) offloading, which is corresponding to Commit cae3a2627520 ("openvswitch:
Allow attaching helpers to ct action") in OVS kernel part.
The difference is when adding TC actions family and proto cannot be got from the filter/match, other than helper name in tb[TCA_CT_HELPER_NAME], we also need to send the family in tb[TCA_CT_HELPER_FAMILY] and the proto in tb[TCA_CT_HELPER_PROTO] to kernel.
--- include/net/tc_act/tc_ct.h | 1 + include/uapi/linux/tc_act/tc_ct.h | 3 ++ net/sched/act_ct.c | 83 +++++++++++++++++++++++++++++-- 3 files changed, 82 insertions(+), 5 deletions(-)
include/net/tc_act/tc_ct.h +1 -0
@@ -10,6 +10,7 @@#include <net/netfilter/nf_conntrack_labels.h> struct tcf_ct_params { +struct nf_conntrack_helper *helper;struct nf_conn *tmpl;u16 zone;
include/uapi/linux/tc_act/tc_ct.h +3 -0
@@ -22,6 +22,9 @@ enum {TCA_CT_NAT_PORT_MIN ,/* be16 */ TCA_CT_NAT_PORT_MAX ,/* be16 */ TCA_CT_PAD , +TCA_CT_HELPER_NAME ,/* string */ +TCA_CT_HELPER_FAMILY ,/* u8 */ +TCA_CT_HELPER_PROTO ,/* u8 */ __TCA_CT_MAX };
net/sched/act_ct.c +78 -5
160 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [ovs-dev] [PATCHv3 net-next 4/4] net: sched: add helper support in act_ct
On Mon, Oct 31, 2022 at 11:36:10AM -0400, Xin Long wrote:
...
Quoted 11 lines
net/sched/act_ct.c +1
-0@@ -33,6 +33,7 @@#include <net/netfilter/nf_conntrack_acct.h> #include <net/netfilter/ipv6/nf_defrag_ipv6.h> #include <net/netfilter/nf_conntrack_act_ct.h> +#include <net/netfilter/nf_conntrack_seqadj.h> #include <uapi/linux/netfilter/nf_nat.h> static struct workqueue_struct *act_ct_wq;
net/sched/act_ct.c struct tc_ct_action_net { · line 659
Quoted 5 lines
net/sched/act_ct.c +1
-1@@ -655,7 +656,7 @@ struct tc_ct_action_net {/* Determine whether skb->_nfct is equal to the result of conntrack lookup. */ static bool tcf_ct_skb_nfct_cached (struct net *net,struct sk_buff *skb, -u16 zone_id,bool force) +struct tcf_ct_params *p,bool force)
Nit, it could have fetched 'force' from p->ct_action too then, as it is only used in this function.
There's a typo in Ilya's name in the cover letter.
Other than this, LGTM.
Re: [ovs-dev] [PATCHv3 net-next 4/4] net: sched: add helper support in act_ct
Quoted 15 lines · Marcelo Ricardo Leitner
On Mon, Oct 31, 2022 at 11:36:10AM -0400, Xin Long wrote:
...Quoted 12 lines
net/sched/act_ct.c +1
-0@@ -33,6 +33,7 @@#include <net/netfilter/nf_conntrack_acct.h> #include <net/netfilter/ipv6/nf_defrag_ipv6.h> #include <net/netfilter/nf_conntrack_act_ct.h> +#include <net/netfilter/nf_conntrack_seqadj.h> #include <uapi/linux/netfilter/nf_nat.h> static struct workqueue_struct *act_ct_wq;@@ -655,7 +656,7 @@ struct tc_ct_action_net {
Quoted 7 lines
net/sched/act_ct.c struct tc_ct_action_net { · line 659
Quoted 4 lines
net/sched/act_ct.c +1
-1/* Determine whether skb->_nfct is equal to the result of conntrack lookup. */ static bool tcf_ct_skb_nfct_cached (struct net *net,struct sk_buff *skb, -u16 zone_id,bool force) +struct tcf_ct_params *p,bool force)Nit, it could have fetched 'force' from
p->ct_actiontoo then, as it is only used in this function.
right, we can save one variable here.
Quoted 2 lines
There's a typo in Ilya's name in the cover letter.
Ah sorry, it was a letter missed when copying from the last cover.
Quoted 3 lines
Other than this, LGTM.
Thanks!