From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.bufferbloat.net (Postfix) with ESMTPS id 2F9103B2A4 for ; Fri, 3 Jul 2020 16:09:45 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593806984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y+FWZ5yqiN8FH+sU2SZS0bUemdJq4rNskNBcQ33ENDc=; b=diXMLIli6MSwGKNL1+hPF+YF0ZGYmXzku9Mi6L7cRbh3tTP6fljermZ9dabMiYWmXQoZev onLoyDBahMDHGtEOgQ0cyDCcHY2CObG0f3cWTQPGTRl7lY972JTacxziZtGcMzQYUPD25Q ePDcRiF2XczCo2b41qXP74xez01ZkYE= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-220-ZmFGmuzFOWSdeVglkrNM_Q-1; Fri, 03 Jul 2020 16:09:41 -0400 X-MC-Unique: ZmFGmuzFOWSdeVglkrNM_Q-1 Received: by mail-pf1-f198.google.com with SMTP id d10so15952995pfn.21 for ; Fri, 03 Jul 2020 13:09:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=Y+FWZ5yqiN8FH+sU2SZS0bUemdJq4rNskNBcQ33ENDc=; b=TZgJWPqvAD+byL41PDSx7crIy9YS8NxHRbJ8wSUyTOtBFiZKppQxbIhUbV4OW1LtRp /ijbT72hqb/fZEeeukBHgSlHFalWG8VOpRMtnuD3D376MHnoKuEpEwWAia1g/vSUJbYC zCArlIUYp/31xsZ8dY4CQMqIEoVGS5lCEgybQ/V91mI+3RR0vsF0cnPqxA9u8G852Pxs g7Ojcmp+KWxo5P/l3/aAViZf277LbKOMLRcuxCZ0Zs/+8fh2OaN7XdOO/jzTnnQh+zLN c6HLvhrL8Cn7E7AketSs/hzdI0t98v9DxhNY1U4nYqHIJMRW8ZlzLKlm/ek8yCqec6lp EM5Q== X-Gm-Message-State: AOAM533p9+rV585Ptm91Q6u1vSMxknXGwPz0iFvcxEiGg2FBNY/T98cT 7Q4X1c3Zx9R6GqTkubxbemCokblc1MludUtmp3sYn80luRijk7C2xRvJP0zoYvs8GObMx8uXdkj spVNin9nSCwvzmo/f/lfQEQ== X-Received: by 2002:a63:745:: with SMTP id 66mr31446398pgh.316.1593806980397; Fri, 03 Jul 2020 13:09:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwLUegMoL/eIhQyxeQ10175pnIsYKZNbM3JXpTa5KqRRhhW5svTW3ecR8gzmcHFdkSZba8Yw== X-Received: by 2002:a63:745:: with SMTP id 66mr31446372pgh.316.1593806980016; Fri, 03 Jul 2020 13:09:40 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id p10sm6765948pgn.6.2020.07.03.13.09.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2020 13:09:39 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 47BA21804A8; Fri, 3 Jul 2020 22:09:34 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Cong Wang Cc: David Miller , Linux Kernel Network Developers , Cake List , Davide Caratti , Jiri Pirko , Jamal Hadi Salim , Ilya Ponetayev In-Reply-To: References: <20200703152239.471624-1-toke@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett Date: Fri, 03 Jul 2020 22:09:34 +0200 Message-ID: <87mu4gmkch.fsf@toke.dk> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=toke@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Cake] [PATCH net v2] sched: consistently handle layer3 header accesses in the presence of VLANs X-BeenThere: cake@lists.bufferbloat.net X-Mailman-Version: 2.1.20 Precedence: list List-Id: Cake - FQ_codel the next generation List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Jul 2020 20:09:45 -0000 Cong Wang writes: > On Fri, Jul 3, 2020 at 8:22 AM Toke H=C3=B8iland-J=C3=B8rgensen 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 cons= istently >> + * whether VLAN acceleration is enabled or not. >> + */ >> +static inline __be16 skb_protocol(const struct sk_buff *skb, bool skip_= vlan) >> +{ >> + unsigned int offset =3D skb_mac_offset(skb) + sizeof(struct ethh= dr); >> + __be16 proto =3D 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 : pro= to; >> + >> + while (eth_type_vlan(proto)) { >> + vh =3D skb_header_pointer(skb, offset, sizeof(vhdr), &vh= dr); >> + if (!vh) >> + break; >> + >> + proto =3D vh->h_vlan_encapsulated_proto; >> + offset +=3D 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 >> #include >> +#include >> >> #include >> #include >> @@ -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) <=3D >> skb_tail_pointer(skb)) >> @@ -191,7 +192,7 @@ static inline int INET_ECN_set_ce(struct sk_buff *sk= b) >> >> 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) <=3D >> 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