From: Xin Long <lucien.xin@gmail.com>
To: network dev <netdev@vger.kernel.org>, dev@openvswitch.org
Cc: davem@davemloft.net, kuba@kernel.org,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Pravin B Shelar <pshelar@ovn.org>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Jiri Pirko <jiri@resnulli.us>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Florian Westphal <fw@strlen.de>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
Ilya Maximets <i.maximets@ovn.org>,
Aaron Conole <aconole@redhat.com>
Subject: [PATCHv2 net-next 4/5] net: sched: move frag check and tc_skb_cb update out of handle_fragments
Date: Tue, 7 Feb 2023 17:52:09 -0500 [thread overview]
Message-ID: <a73fd95cb3873dd8f94da53487428b44cb2534a2.1675810210.git.lucien.xin@gmail.com> (raw)
In-Reply-To: <cover.1675810210.git.lucien.xin@gmail.com>
This patch has no functional changes and just moves frag check and
tc_skb_cb update out of handle_fragments, to make it easier to move
the duplicate code from handle_fragments() into nf_conntrack_ovs later.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/sched/act_ct.c | 71 +++++++++++++++++++++++++---------------------
1 file changed, 39 insertions(+), 32 deletions(-)
diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index 0a1ecc972a8b..9f133ed93815 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -778,29 +778,10 @@ static int tcf_ct_ipv6_is_fragment(struct sk_buff *skb, bool *frag)
return 0;
}
-static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
- u8 family, u16 zone, bool *defrag)
+static int handle_fragments(struct net *net, struct sk_buff *skb,
+ u16 zone, u8 family, u16 *mru)
{
- enum ip_conntrack_info ctinfo;
- struct nf_conn *ct;
- int err = 0;
- bool frag;
- u16 mru;
-
- /* Previously seen (loopback)? Ignore. */
- ct = nf_ct_get(skb, &ctinfo);
- if ((ct && !nf_ct_is_template(ct)) || ctinfo == IP_CT_UNTRACKED)
- return 0;
-
- if (family == NFPROTO_IPV4)
- err = tcf_ct_ipv4_is_fragment(skb, &frag);
- else
- err = tcf_ct_ipv6_is_fragment(skb, &frag);
- if (err || !frag)
- return err;
-
- skb_get(skb);
- mru = tc_skb_cb(skb)->mru;
+ int err;
if (family == NFPROTO_IPV4) {
enum ip_defrag_users user = IP_DEFRAG_CONNTRACK_IN + zone;
@@ -812,10 +793,8 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
if (err && err != -EINPROGRESS)
return err;
- if (!err) {
- *defrag = true;
- mru = IPCB(skb)->frag_max_size;
- }
+ 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;
@@ -825,18 +804,14 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
if (err && err != -EINPROGRESS)
goto out_free;
- if (!err) {
- *defrag = true;
- mru = IP6CB(skb)->frag_max_size;
- }
+ if (!err)
+ *mru = IP6CB(skb)->frag_max_size;
#else
err = -EOPNOTSUPP;
goto out_free;
#endif
}
- if (err != -EINPROGRESS)
- tc_skb_cb(skb)->mru = mru;
skb_clear_hash(skb);
skb->ignore_df = 1;
return err;
@@ -846,6 +821,38 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
return err;
}
+static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
+ u8 family, u16 zone, bool *defrag)
+{
+ enum ip_conntrack_info ctinfo;
+ struct nf_conn *ct;
+ int err = 0;
+ bool frag;
+ u16 mru;
+
+ /* Previously seen (loopback)? Ignore. */
+ ct = nf_ct_get(skb, &ctinfo);
+ if ((ct && !nf_ct_is_template(ct)) || ctinfo == IP_CT_UNTRACKED)
+ return 0;
+
+ if (family == NFPROTO_IPV4)
+ err = tcf_ct_ipv4_is_fragment(skb, &frag);
+ else
+ err = tcf_ct_ipv6_is_fragment(skb, &frag);
+ if (err || !frag)
+ return err;
+
+ skb_get(skb);
+ err = handle_fragments(net, skb, zone, family, &mru);
+ if (err)
+ return err;
+
+ *defrag = true;
+ tc_skb_cb(skb)->mru = mru;
+
+ return 0;
+}
+
static void tcf_ct_params_free(struct tcf_ct_params *params)
{
if (params->helper) {
--
2.31.1
next prev parent reply other threads:[~2023-02-07 22:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 22:52 [PATCHv2 net-next 0/5] net: move more duplicate code of ovs and tc conntrack into nf_conntrack_ovs Xin Long
2023-02-07 22:52 ` [PATCHv2 net-next 1/5] net: create nf_conntrack_ovs for ovs and tc use Xin Long
2023-02-08 10:15 ` Simon Horman
2023-02-09 14:59 ` Aaron Conole
2023-02-07 22:52 ` [PATCHv2 net-next 2/5] net: extract nf_ct_skb_network_trim function to nf_conntrack_ovs Xin Long
2023-02-08 10:15 ` Simon Horman
2023-02-09 15:00 ` Aaron Conole
2023-02-07 22:52 ` [PATCHv2 net-next 3/5] openvswitch: move key and ovs_cb update out of handle_fragments Xin Long
2023-02-08 10:16 ` Simon Horman
2023-02-09 15:01 ` Aaron Conole
2023-02-07 22:52 ` Xin Long [this message]
2023-02-08 10:16 ` [PATCHv2 net-next 4/5] net: sched: move frag check and tc_skb_cb " Simon Horman
2023-02-07 22:52 ` [PATCHv2 net-next 5/5] net: extract nf_ct_handle_fragments to nf_conntrack_ovs Xin Long
2023-02-08 10:17 ` Simon Horman
2023-02-09 15:08 ` Aaron Conole
2023-02-10 6:21 ` [PATCHv2 net-next 0/5] net: move more duplicate code of ovs and tc conntrack into nf_conntrack_ovs Jakub Kicinski
2023-02-10 10:35 ` Florian Westphal
2023-02-11 0:30 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a73fd95cb3873dd8f94da53487428b44cb2534a2.1675810210.git.lucien.xin@gmail.com \
--to=lucien.xin@gmail.com \
--cc=aconole@redhat.com \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=i.maximets@ovn.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=pshelar@ovn.org \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).