Cake - FQ_codel the next generation
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: David Miller <davem@davemloft.net>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	Cake List <cake@lists.bufferbloat.net>,
	Davide Caratti <dcaratti@redhat.com>,
	Jiri Pirko <jiri@resnulli.us>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Subject: Re: [Cake] [PATCH net v2] sched: consistently handle layer3 header accesses in the presence of VLANs
Date: Fri, 03 Jul 2020 22:09:34 +0200	[thread overview]
Message-ID: <87mu4gmkch.fsf@toke.dk> (raw)
In-Reply-To: <CAM_iQpVbm0DGGjsdtJD0esuyx9Xmjo=3VCg=C5feqDDbFM+6XQ@mail.gmail.com>

Cong Wang <xiyou.wangcong@gmail.com> writes:

> On Fri, Jul 3, 2020 at 8:22 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>> diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
>> index b05e855f1ddd..d0c1cb0d264d 100644
>> --- a/include/linux/if_vlan.h
>> +++ b/include/linux/if_vlan.h
>> @@ -308,6 +308,35 @@ static inline bool eth_type_vlan(__be16 ethertype)
>>         }
>>  }
>>
>> +/* A getter for the SKB protocol field which will handle VLAN tags consistently
>> + * whether VLAN acceleration is enabled or not.
>> + */
>> +static inline __be16 skb_protocol(const struct sk_buff *skb, bool skip_vlan)
>> +{
>> +       unsigned int offset = skb_mac_offset(skb) + sizeof(struct ethhdr);
>> +       __be16 proto = skb->protocol;
>> +       struct vlan_hdr vhdr, *vh;
>> +
>> +       if (!skip_vlan)
>> +               /* VLAN acceleration strips the VLAN header from the skb and
>> +                * moves it to skb->vlan_proto
>> +                */
>> +               return skb_vlan_tag_present(skb) ? skb->vlan_proto : proto;
>> +
>> +       while (eth_type_vlan(proto)) {
>> +               vh = skb_header_pointer(skb, offset, sizeof(vhdr), &vhdr);
>> +               if (!vh)
>> +                       break;
>> +
>> +               proto = vh->h_vlan_encapsulated_proto;
>> +               offset += sizeof(vhdr);
>> +       }
>> +
>> +       return proto;
>> +}
>> +
>> +
>> +
>
> Just nit: too many newlines here. Please run checkpatch.pl.

Hmm, I did run checkpatch, but seems it only complains about multiple
newlines when run with --strict. Will fix, thanks! :)

>>  static inline bool vlan_hw_offload_capable(netdev_features_t features,
>>                                            __be16 proto)
>>  {
>> diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
>> index 0f0d1efe06dd..82763ba597f2 100644
>> --- a/include/net/inet_ecn.h
>> +++ b/include/net/inet_ecn.h
>> @@ -4,6 +4,7 @@
>>
>>  #include <linux/ip.h>
>>  #include <linux/skbuff.h>
>> +#include <linux/if_vlan.h>
>>
>>  #include <net/inet_sock.h>
>>  #include <net/dsfield.h>
>> @@ -172,7 +173,7 @@ static inline void ipv6_copy_dscp(unsigned int dscp, struct ipv6hdr *inner)
>>
>>  static inline int INET_ECN_set_ce(struct sk_buff *skb)
>>  {
>> -       switch (skb->protocol) {
>> +       switch (skb_protocol(skb, true)) {
>>         case cpu_to_be16(ETH_P_IP):
>>                 if (skb_network_header(skb) + sizeof(struct iphdr) <=
>>                     skb_tail_pointer(skb))
>> @@ -191,7 +192,7 @@ static inline int INET_ECN_set_ce(struct sk_buff *skb)
>>
>>  static inline int INET_ECN_set_ect1(struct sk_buff *skb)
>>  {
>> -       switch (skb->protocol) {
>> +       switch (skb_protocol(skb, true)) {
>>         case cpu_to_be16(ETH_P_IP):
>>                 if (skb_network_header(skb) + sizeof(struct iphdr) <=
>>                     skb_tail_pointer(skb))
>
> These two helpers are called by non-net_sched too, are you sure
> your change is correct for them too?
>
> For example, IP6_ECN_decapsulate() uses skb->protocol then calls
> INET_ECN_decapsulate() which calls the above, after your change
> they use skb_protocol(). This looks inconsistent to me.

Good point. I'll change IP{,6}_ECN_decapsulate() to also use
skb_protocol().

-Toke


  reply	other threads:[~2020-07-03 20:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03 15:22 Toke Høiland-Jørgensen
2020-07-03 19:19 ` Cong Wang
2020-07-03 20:09   ` Toke Høiland-Jørgensen [this message]
2020-07-03 20:16 ` Roman Mashak
2020-07-03 20:22   ` Toke Høiland-Jørgensen

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

  List information: https://lists.bufferbloat.net/postorius/lists/cake.lists.bufferbloat.net/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mu4gmkch.fsf@toke.dk \
    --to=toke@redhat.com \
    --cc=cake@lists.bufferbloat.net \
    --cc=davem@davemloft.net \
    --cc=dcaratti@redhat.com \
    --cc=i.ponetaev@ndmsystems.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.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