From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH net-next v6] Add Common Applications Kept Enhanced (cake) qdisc Date: Tue, 1 May 2018 12:41:29 -0700 Message-ID: References: <20180429213439.7389-1-toke@toke.dk> <878t932ont.fsf@toke.dk> <4ec8da81-8671-f434-bada-27088b09ce7b@gmail.com> <871sev2mvx.fsf@toke.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: Linux Kernel Network Developers , Cake List To: =?UTF-8?Q?Toke_H=c3=b8iland-J=c3=b8rgensen?= , Eric Dumazet , Dave Taht , Cong Wang Return-path: Received: from mail-pg0-f65.google.com ([74.125.83.65]:43592 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750766AbeEATlb (ORCPT ); Tue, 1 May 2018 15:41:31 -0400 Received: by mail-pg0-f65.google.com with SMTP id k11-v6so7810105pgo.10 for ; Tue, 01 May 2018 12:41:31 -0700 (PDT) In-Reply-To: <871sev2mvx.fsf@toke.dk> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 05/01/2018 12:31 PM, Toke Høiland-Jørgensen wrote: > Could you comment on specifically what you believe is broken in this, > please, so I can fix it in the same iteration? > Apart from the various pskb_may_pull() this helper should not change skb layout. Ideally, the skb should be const and you would use skb_header_pointer() to make clear you do not ever write this skb. This would make the reviewer job pretty easy, as no side effect can possibly happen. > +static inline struct tcphdr *cake_get_tcphdr(struct sk_buff *skb) > +{ > + struct ipv6hdr *ipv6h; > + struct iphdr *iph; > + > + /* check IPv6 header size immediately, since for IPv4 we need the space > + * for the TCP header anyway > + */ > + if (!pskb_may_pull(skb, skb_network_offset(skb) + > + sizeof(struct ipv6hdr))) > + return NULL; > + > + iph = ip_hdr(skb); > + > + if (iph->version == 4) { > + /* special-case 6in4 tunnelling, as that is a common way to get > + * v6 connectivity in the home > + */ > + if (iph->protocol == IPPROTO_IPV6) { > + if (!pskb_may_pull(skb, (skb_network_offset(skb) + > + ip_hdrlen(skb) + > + sizeof(struct ipv6hdr)))) > + return NULL; > + > + ipv6h = (struct ipv6hdr *)(skb_network_header(skb) + > + ip_hdrlen(skb)); > + > + if (ipv6h->nexthdr != IPPROTO_TCP) > + return NULL; > + > + skb_set_inner_network_header(skb, > + skb_network_offset(skb) + > + ip_hdrlen(skb)); > + skb_set_inner_transport_header(skb, > + skb_inner_network_offset(skb) + > + sizeof(struct ipv6hdr)); This is not allowed for a dissector.