summaryrefslogtreecommitdiffstats
path: root/net/sched/act_ct.c
diff options
context:
space:
mode:
authorXin Long <lucien.xin@gmail.com>2023-02-07 23:52:10 +0100
committerJakub Kicinski <kuba@kernel.org>2023-02-11 01:23:03 +0100
commit0785407e78d4bce56e04d92a6c961900b3d513dd (patch)
tree9efb911dc87a0d6db5c1634a3f57d3c4d9e0b895 /net/sched/act_ct.c
parentnet: sched: move frag check and tc_skb_cb update out of handle_fragments (diff)
downloadlinux-0785407e78d4bce56e04d92a6c961900b3d513dd.tar.xz
linux-0785407e78d4bce56e04d92a6c961900b3d513dd.zip
net: extract nf_ct_handle_fragments to nf_conntrack_ovs
Now handle_fragments() in OVS and TC have the similar code, and this patch removes the duplicate code by moving the function to nf_conntrack_ovs. Note that skb_clear_hash(skb) or skb->ignore_df = 1 should be done only when defrag returns 0, as it does in other places in kernel. Signed-off-by: Xin Long <lucien.xin@gmail.com> Reviewed-by: Simon Horman <simon.horman@corigine.com> Reviewed-by: Aaron Conole <aconole@redhat.com> Acked-by: Florian Westphal <fw@strlen.de> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/sched/act_ct.c')
-rw-r--r--net/sched/act_ct.c46
1 files changed, 2 insertions, 44 deletions
diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index 9f133ed93815..9cc0bc7c71ed 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -778,49 +778,6 @@ static int tcf_ct_ipv6_is_fragment(struct sk_buff *skb, bool *frag)
return 0;
}
-static int handle_fragments(struct net *net, struct sk_buff *skb,
- u16 zone, u8 family, u16 *mru)
-{
- int err;
-
- if (family == NFPROTO_IPV4) {
- enum ip_defrag_users user = IP_DEFRAG_CONNTRACK_IN + zone;
-
- memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
- local_bh_disable();
- err = ip_defrag(net, skb, user);
- local_bh_enable();
- if (err && err != -EINPROGRESS)
- return err;
-
- if (!err)
- *mru = IPCB(skb)->frag_max_size;
- } else { /* NFPROTO_IPV6 */
-#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
- enum ip6_defrag_users user = IP6_DEFRAG_CONNTRACK_IN + zone;
-
- memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
- err = nf_ct_frag6_gather(net, skb, user);
- if (err && err != -EINPROGRESS)
- goto out_free;
-
- if (!err)
- *mru = IP6CB(skb)->frag_max_size;
-#else
- err = -EOPNOTSUPP;
- goto out_free;
-#endif
- }
-
- skb_clear_hash(skb);
- skb->ignore_df = 1;
- return err;
-
-out_free:
- kfree_skb(skb);
- return err;
-}
-
static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
u8 family, u16 zone, bool *defrag)
{
@@ -828,6 +785,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
struct nf_conn *ct;
int err = 0;
bool frag;
+ u8 proto;
u16 mru;
/* Previously seen (loopback)? Ignore. */
@@ -843,7 +801,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
return err;
skb_get(skb);
- err = handle_fragments(net, skb, zone, family, &mru);
+ err = nf_ct_handle_fragments(net, skb, zone, family, &proto, &mru);
if (err)
return err;