From: Davide Caratti <dcaratti@redhat.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Jiri Pirko <jiri@resnulli.us>,
Jamal Hadi Salim <jhs@mojatatu.com>,
"David S . Miller" <davem@davemloft.net>,
netdev@vger.kernel.org
Cc: shuali@redhat.com, Eli Britstein <elibr@mellanox.com>,
Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH net v3 3/3] net/sched: act_skbedit: fix 'inheritdsfield' in case of QinQ packet
Date: Fri, 31 May 2019 19:26:09 +0200 [thread overview]
Message-ID: <7b081d3ece27a867a213d2d61dcfcac5e9bb59ad.1559322531.git.dcaratti@redhat.com> (raw)
In-Reply-To: <cover.1559322531.git.dcaratti@redhat.com>
like it was previously done on TC 'csum' (see commit 2ecba2d1e45b ("net:
sched: act_csum: Fix csum calc for tagged packets")), TC 'skbedit' might
need to adjust the network offset, if the packet has unstripped/multiple
tags: otherwise 'inheritdsfield' will just be skipped for QinQ packets.
Fixes: e7e3728bd776 ("net:sched: add action inheritdsfield to skbedit")
CC: Li Shuang <shuali@redhat.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
net/sched/act_skbedit.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c
index 7ec159b95364..34a0c661c8c5 100644
--- a/net/sched/act_skbedit.c
+++ b/net/sched/act_skbedit.c
@@ -39,6 +39,7 @@ static int tcf_skbedit_act(struct sk_buff *skb, const struct tc_action *a,
{
struct tcf_skbedit *d = to_skbedit(a);
struct tcf_skbedit_params *params;
+ unsigned int vlan_hdr_count = 0;
int action;
tcf_lastuse_update(&d->tcf_tm);
@@ -50,9 +51,17 @@ static int tcf_skbedit_act(struct sk_buff *skb, const struct tc_action *a,
if (params->flags & SKBEDIT_F_PRIORITY)
skb->priority = params->priority;
if (params->flags & SKBEDIT_F_INHERITDSFIELD) {
- int wlen = skb_network_offset(skb);
-
- switch (tc_skb_protocol(skb)) {
+ __be16 proto = tc_skb_protocol(skb);
+ int wlen;
+
+again:
+ wlen = skb_network_offset(skb);
+ switch (proto) {
+ case htons(ETH_P_8021AD): /* Fall Through */
+ case htons(ETH_P_8021Q):
+ if (tc_skb_pull_vlans(skb, &vlan_hdr_count, &proto))
+ goto err;
+ goto again;
case htons(ETH_P_IP):
wlen += sizeof(struct iphdr);
if (!pskb_may_pull(skb, wlen))
@@ -77,11 +86,18 @@ static int tcf_skbedit_act(struct sk_buff *skb, const struct tc_action *a,
}
if (params->flags & SKBEDIT_F_PTYPE)
skb->pkt_type = params->ptype;
+
+out:
+ while (vlan_hdr_count--) {
+ skb_push(skb, VLAN_HLEN);
+ skb_reset_network_header(skb);
+ }
return action;
err:
qstats_drop_inc(this_cpu_ptr(d->common.cpu_qstats));
- return TC_ACT_SHOT;
+ action = TC_ACT_SHOT;
+ goto out;
}
static const struct nla_policy skbedit_policy[TCA_SKBEDIT_MAX + 1] = {
--
2.20.1
next prev parent reply other threads:[~2019-05-31 17:26 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-31 17:26 [PATCH net v3 0/3] net/sched: fix actions reading the network header in case of QinQ packets Davide Caratti
2019-05-31 17:26 ` [PATCH net v3 1/3] net/sched: act_csum: pull all VLAN headers before checksumming Davide Caratti
2019-05-31 18:38 ` Cong Wang
2019-05-31 22:01 ` Davide Caratti
2019-05-31 22:50 ` Cong Wang
2019-06-02 4:22 ` Eli Britstein
2019-06-04 17:41 ` Cong Wang
2019-05-31 17:26 ` [PATCH net v3 2/3] net/sched: act_pedit: fix 'ex munge' on network header in case of QinQ packet Davide Caratti
2019-05-31 17:26 ` Davide Caratti [this message]
2019-05-31 18:42 ` [PATCH net v3 0/3] net/sched: fix actions reading the network header in case of QinQ packets Cong Wang
2019-05-31 22:01 ` Davide Caratti
2019-05-31 22:29 ` Cong Wang
2019-06-02 4:22 ` Eli Britstein
2019-06-04 17:55 ` Cong Wang
2019-06-04 18:19 ` Eli Britstein
2019-06-06 1:42 ` Cong Wang
2019-06-06 5:37 ` Eli Britstein
2019-06-11 0:52 ` Cong Wang
2019-06-11 4:43 ` Eli Britstein
2019-06-07 18:20 ` Davide Caratti
2019-06-08 11:19 ` Eli Britstein
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=7b081d3ece27a867a213d2d61dcfcac5e9bb59ad.1559322531.git.dcaratti@redhat.com \
--to=dcaratti@redhat.com \
--cc=davem@davemloft.net \
--cc=elibr@mellanox.com \
--cc=eric.dumazet@gmail.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=shuali@redhat.com \
--cc=stephen@networkplumber.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).