From: Cong Wang <xiyou.wangcong@gmail.com>
To: Davide Caratti <dcaratti@redhat.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
Jiri Pirko <jiri@resnulli.us>,
Jamal Hadi Salim <jhs@mojatatu.com>,
"David S . Miller" <davem@davemloft.net>,
Linux Kernel Network Developers <netdev@vger.kernel.org>,
Shuang Li <shuali@redhat.com>, Eli Britstein <elibr@mellanox.com>,
Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [PATCH net v3 1/3] net/sched: act_csum: pull all VLAN headers before checksumming
Date: Fri, 31 May 2019 11:38:41 -0700 [thread overview]
Message-ID: <CAM_iQpW68XR3Y6gyb0zyd3qooCwPHBM1Fm+THcS=migSNsHMzA@mail.gmail.com> (raw)
In-Reply-To: <a773fd1d70707d03861be674f7692a0148f6bb40.1559322531.git.dcaratti@redhat.com>
On Fri, May 31, 2019 at 10:26 AM Davide Caratti <dcaratti@redhat.com> wrote:
> diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c
> index 14bb525e355e..e8308ddcae9d 100644
> --- a/net/sched/act_csum.c
> +++ b/net/sched/act_csum.c
> @@ -574,7 +574,6 @@ static int tcf_csum_act(struct sk_buff *skb, const struct tc_action *a,
> struct tcf_result *res)
> {
> struct tcf_csum *p = to_tcf_csum(a);
> - bool orig_vlan_tag_present = false;
> unsigned int vlan_hdr_count = 0;
> struct tcf_csum_params *params;
> u32 update_flags;
> @@ -604,17 +603,8 @@ static int tcf_csum_act(struct sk_buff *skb, const struct tc_action *a,
> break;
> case cpu_to_be16(ETH_P_8021AD): /* fall through */
> case cpu_to_be16(ETH_P_8021Q):
> - if (skb_vlan_tag_present(skb) && !orig_vlan_tag_present) {
> - protocol = skb->protocol;
> - orig_vlan_tag_present = true;
> - } else {
> - struct vlan_hdr *vlan = (struct vlan_hdr *)skb->data;
> -
> - protocol = vlan->h_vlan_encapsulated_proto;
> - skb_pull(skb, VLAN_HLEN);
> - skb_reset_network_header(skb);
> - vlan_hdr_count++;
> - }
> + if (tc_skb_pull_vlans(skb, &vlan_hdr_count, &protocol))
> + goto drop;
> goto again;
Why do you still need to loop here? tc_skb_pull_vlans() already
contains a loop to pop all vlan tags?
> }
>
> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
> index d4699156974a..382ee69fb1a5 100644
> --- a/net/sched/cls_api.c
> +++ b/net/sched/cls_api.c
> @@ -3300,6 +3300,28 @@ unsigned int tcf_exts_num_actions(struct tcf_exts *exts)
> }
> EXPORT_SYMBOL(tcf_exts_num_actions);
>
> +int tc_skb_pull_vlans(struct sk_buff *skb, unsigned int *hdr_count,
> + __be16 *proto)
It looks like this function fits better in net/core/skbuff.c, because
I don't see anything TC specific.
> +{
> + if (skb_vlan_tag_present(skb))
> + *proto = skb->protocol;
> +
> + while (eth_type_vlan(*proto)) {
> + struct vlan_hdr *vlan;
> +
> + if (unlikely(!pskb_may_pull(skb, VLAN_HLEN)))
> + return -ENOMEM;
> +
> + vlan = (struct vlan_hdr *)skb->data;
> + *proto = vlan->h_vlan_encapsulated_proto;
> + skb_pull(skb, VLAN_HLEN);
> + skb_reset_network_header(skb);
Any reason not to call __skb_vlan_pop() directly?
> + (*hdr_count)++;
> + }
> + return 0;
> +}
Thanks.
next prev parent reply other threads:[~2019-05-31 18:38 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 [this message]
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 ` [PATCH net v3 3/3] net/sched: act_skbedit: fix 'inheritdsfield' " Davide Caratti
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='CAM_iQpW68XR3Y6gyb0zyd3qooCwPHBM1Fm+THcS=migSNsHMzA@mail.gmail.com' \
--to=xiyou.wangcong@gmail.com \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--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 \
/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).