From patchwork Thu Jun 25 11:55:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 217142 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC421C433DF for ; Thu, 25 Jun 2020 11:55:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A99A206C0 for ; Thu, 25 Jun 2020 11:55:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jH+e2480" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404659AbgFYLzU (ORCPT ); Thu, 25 Jun 2020 07:55:20 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:50544 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728063AbgFYLzL (ORCPT ); Thu, 25 Jun 2020 07:55:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593086109; 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=+GyCVjS8LavJYzTtjsaGAZKXMsx/0KStkzJq3dfYbt4=; b=jH+e2480V7wuyhJC/bZoAHb++MviINYUzkq/R47cu+6gSNK+/8hfLs0PKqySEeNV4M8H33 y43gOCjyNwtKktyeSGdpI2VNn0gImOohEUoGE2qiENnWg13Yguh2vrRW7sJzZfoOc1AphE NevEVpDNM3WVXnoyDpX3SCDClwkpBr8= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-161-KZNwTZXvPpaQ8abadHxXcg-1; Thu, 25 Jun 2020 07:55:07 -0400 X-MC-Unique: KZNwTZXvPpaQ8abadHxXcg-1 Received: by mail-wm1-f71.google.com with SMTP id l2so6648561wmi.2 for ; Thu, 25 Jun 2020 04:55:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=+GyCVjS8LavJYzTtjsaGAZKXMsx/0KStkzJq3dfYbt4=; b=Slf8G9OFmVU/Ty8H/E1xyl32+bw9u1A5CTMM9tyxzhu2x1it9Tq7/tv2okm//j5TEk SrkLtOHytzy7yE9gP62Gkd8J91A6pJ2yH+RiWeLHRQrczvmLD0me3e3abx4lXHrv7Sh8 6YEJJEWrcn6u3Bz+x5WSZlkuXDYW/f691xACDS0uGExFNQCL9hQZqW09aBDZF9bk7C0Z gIT5mRFOe8CnQdADyPBsFfH5ub98qpVytzOpOs8gPzYXU4/GH6YgLuV1ggzRK2GFnEGp oJ5UgKd0Y8cL2QljmHOTqEhLmvBe6NnQifq4QQj6ZI864RZGXvFclFDMF7ZWnyrw5kCa vokw== X-Gm-Message-State: AOAM533ChfeBRtcge7H4SqtPl/ieExNYxUHzIwY4hKpYOoehVoYWaIUw GMpm9f32OYE/n4RkUk9jzihgRcFJY9tnvhrzBWR2F0WH6Qm5cGVga65C1Vkjnx1G3j4B3+Gsysf crgKtPINKti/RjAQs X-Received: by 2002:adf:de12:: with SMTP id b18mr29199207wrm.390.1593086106426; Thu, 25 Jun 2020 04:55:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzixQVDcysECuSK19xqNfgAFGxuWDWVR/lLk1obBH5HLClAUOnlT7+gODGTqff+OoDNWxACMw== X-Received: by 2002:adf:de12:: with SMTP id b18mr29199182wrm.390.1593086106142; Thu, 25 Jun 2020 04:55:06 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id d24sm11573252wmb.45.2020.06.25.04.55.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 04:55:05 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id F201B1814FA; Thu, 25 Jun 2020 13:55:03 +0200 (CEST) Subject: [PATCH net-next 1/5] sch_cake: fix IP protocol handling in the presence of VLAN tags From: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= To: David Miller Cc: netdev@vger.kernel.org, cake@lists.bufferbloat.net Date: Thu, 25 Jun 2020 13:55:03 +0200 Message-ID: <159308610390.190211.17831843954243284203.stgit@toke.dk> In-Reply-To: <159308610282.190211.9431406149182757758.stgit@toke.dk> References: <159308610282.190211.9431406149182757758.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ilya Ponetayev CAKE was using the return value of tc_skb_protocol() and expecting it to be the IP protocol type. This can fail in the presence of QinQ VLAN tags, making CAKE unable to handle ECN marking and diffserv parsing in this case. Fix this by implementing our own version of tc_skb_protocol(), which will use skb->protocol directly, but also parse and skip over any VLAN tags and return the inner protocol number instead. Also fix CE marking by implementing a version of INET_ECN_set_ce() that uses the same parsing routine. Fixes: ea82511518f4 ("sch_cake: Add NAT awareness to packet classifier") Fixes: b2100cc56fca ("sch_cake: Use tc_skb_protocol() helper for getting packet protocol") Fixes: 046f6fd5daef ("sched: Add Common Applications Kept Enhanced (cake) qdisc") Signed-off-by: Ilya Ponetayev [ squash original two patches, rewrite commit message ] Signed-off-by: Toke Høiland-Jørgensen --- net/sched/sch_cake.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c index 60f8ae578819..0f594d88a957 100644 --- a/net/sched/sch_cake.c +++ b/net/sched/sch_cake.c @@ -497,6 +497,52 @@ static bool cobalt_queue_empty(struct cobalt_vars *vars, return down; } +static __be16 cake_skb_proto(const struct sk_buff *skb) +{ + unsigned int offset = skb_mac_offset(skb) + sizeof(struct ethhdr); + __be16 proto = skb->protocol; + struct vlan_hdr vhdr, *vh; + + while (proto == htons(ETH_P_8021Q) || proto == htons(ETH_P_8021AD)) { + vh = skb_header_pointer(skb, offset, sizeof(vhdr), &vhdr); + if (!vh) + break; + + proto = vh->h_vlan_encapsulated_proto; + offset += sizeof(vhdr); + } + + return proto; +} + +static int cake_set_ce(struct sk_buff *skb) +{ + int wlen = skb_network_offset(skb); + + switch (cake_skb_proto(skb)) { + case htons(ETH_P_IP): + wlen += sizeof(struct iphdr); + if (!pskb_may_pull(skb, wlen) || + skb_try_make_writable(skb, wlen)) + return 0; + + return IP_ECN_set_ce(ip_hdr(skb)); + + case htons(ETH_P_IPV6): + wlen += sizeof(struct ipv6hdr); + if (!pskb_may_pull(skb, wlen) || + skb_try_make_writable(skb, wlen)) + return 0; + + return IP6_ECN_set_ce(skb, ipv6_hdr(skb)); + + default: + return 0; + } + + return 0; +} + /* Call this with a freshly dequeued packet for possible congestion marking. * Returns true as an instruction to drop the packet, false for delivery. */ @@ -549,7 +595,7 @@ static bool cobalt_should_drop(struct cobalt_vars *vars, if (next_due && vars->dropping) { /* Use ECN mark if possible, otherwise drop */ - drop = !(vars->ecn_marked = INET_ECN_set_ce(skb)); + drop = !(vars->ecn_marked = cake_set_ce(skb)); vars->count++; if (!vars->count) @@ -592,7 +638,7 @@ static bool cake_update_flowkeys(struct flow_keys *keys, bool rev = !skb->_nfct, upd = false; __be32 ip; - if (tc_skb_protocol(skb) != htons(ETH_P_IP)) + if (cake_skb_proto(skb) != htons(ETH_P_IP)) return false; if (!nf_ct_get_tuple_skb(&tuple, skb)) @@ -1556,7 +1602,7 @@ static u8 cake_handle_diffserv(struct sk_buff *skb, u16 wash) int wlen = skb_network_offset(skb); u8 dscp; - switch (tc_skb_protocol(skb)) { + switch (cake_skb_proto(skb)) { case htons(ETH_P_IP): wlen += sizeof(struct iphdr); if (!pskb_may_pull(skb, wlen) || From patchwork Thu Jun 25 11:55:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= X-Patchwork-Id: 217141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BA11C433E0 for ; Thu, 25 Jun 2020 11:55:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E86B520781 for ; Thu, 25 Jun 2020 11:55:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hoNqiT66" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404676AbgFYLzZ (ORCPT ); Thu, 25 Jun 2020 07:55:25 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:58555 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2404652AbgFYLzR (ORCPT ); Thu, 25 Jun 2020 07:55:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593086116; 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=wGT3qBYmtlNm7VbabgpoFKFwexBpZntpyA+fDg/nDwk=; b=hoNqiT66OK2wafxBqkMHVDdqC76LN6sK8GeX27ChJSjnfoezCZr6AG6H4r5rl7GvgntedF SKsQ1S0HzPQO9hRSN/CjLMrWedm2v+2uYPBsxZQi9rMfEfDa3zZFD4W4tkDXwA9+vlwkU3 3tpu0WhAYK9fPzC3YJk+v8roiV2g/vM= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-166-V82uLNafMo2dli1gsW-Eeg-1; Thu, 25 Jun 2020 07:55:10 -0400 X-MC-Unique: V82uLNafMo2dli1gsW-Eeg-1 Received: by mail-wm1-f72.google.com with SMTP id t18so6849295wmj.5 for ; Thu, 25 Jun 2020 04:55:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=wGT3qBYmtlNm7VbabgpoFKFwexBpZntpyA+fDg/nDwk=; b=WcUNS/tnPDXAqBq+G68zul/Dt5JzAi3F7mbR6NNw9j1uImi4Ji0yUynCxHl5WyrkVG maYtLbU3QZ1rX96kStca3QWmb2aqcM8fPaLGnEMExMOOXGkrnG2REWWnum+pQ0Er9sao n4S550ntmX1dHB79ilFwL8p1hUGU8sRuhJ6u9cctTMQgEGQ5F5MhTI/cGo3eTC7xWzY5 Au76XlHkHGIFez7Yh2GDMroy6luD8IxgXWxhDXM+K6z46o7XHgzoPnx9dM1XjpaYA+qU 8tlo7cBWiq44ESz51hlkrtYrIkPqo/QMM897NlX+IwB/oUmOu1EXpV8FCPppiqHd3s36 AUFQ== X-Gm-Message-State: AOAM531PWGSvYNNJmGHwLF1CsMWl5o9sV8Gl6mimC2jYzcUzW6lNO5ci R70RGX0QXlb4Qm1wWvtemCJaj5mBOV6/todwRBAA1lIfBoqysBet4VWv57ikw0JCeVcO5dKu0S3 fDIf2E3flwjhkfzQN X-Received: by 2002:adf:a507:: with SMTP id i7mr39279920wrb.0.1593086109443; Thu, 25 Jun 2020 04:55:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGfAxqBQdT54TXBka/hC/Yk1+w80El0LGJCtPMPSOE33IV6f7u7la2SMPi+3u5TRNoTzTQSw== X-Received: by 2002:adf:a507:: with SMTP id i7mr39279899wrb.0.1593086109201; Thu, 25 Jun 2020 04:55:09 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk ([2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id g16sm27455995wrh.91.2020.06.25.04.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2020 04:55:08 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 409631814FA; Thu, 25 Jun 2020 13:55:07 +0200 (CEST) Subject: [PATCH net-next 4/5] sch_cake: add RFC 8622 LE PHB support to CAKE diffserv handling From: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= To: David Miller Cc: netdev@vger.kernel.org, cake@lists.bufferbloat.net Date: Thu, 25 Jun 2020 13:55:07 +0200 Message-ID: <159308610718.190211.15767931665695188384.stgit@toke.dk> In-Reply-To: <159308610282.190211.9431406149182757758.stgit@toke.dk> References: <159308610282.190211.9431406149182757758.stgit@toke.dk> User-Agent: StGit/0.23 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Kevin Darbyshire-Bryant Change tin mapping on diffserv3, 4 & 8 for LE PHB support, in essence making LE a member of the Bulk tin. Bulk has the least priority and minimum of 1/16th total bandwidth in the face of higher priority traffic. NB: Diffserv 3 & 4 swap tin 0 & 1 priorities from the default order as found in diffserv8, in case anyone is wondering why it looks a bit odd. Signed-off-by: Kevin Darbyshire-Bryant [ reword commit message slightly ] Signed-off-by: Toke Høiland-Jørgensen --- net/sched/sch_cake.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c index 958523c777be..78a702a4e1d4 100644 --- a/net/sched/sch_cake.c +++ b/net/sched/sch_cake.c @@ -312,8 +312,8 @@ static const u8 precedence[] = { }; static const u8 diffserv8[] = { - 2, 5, 1, 2, 4, 2, 2, 2, - 0, 2, 1, 2, 1, 2, 1, 2, + 2, 0, 1, 2, 4, 2, 2, 2, + 1, 2, 1, 2, 1, 2, 1, 2, 5, 2, 4, 2, 4, 2, 4, 2, 3, 2, 3, 2, 3, 2, 3, 2, 6, 2, 3, 2, 3, 2, 3, 2, @@ -323,7 +323,7 @@ static const u8 diffserv8[] = { }; static const u8 diffserv4[] = { - 0, 2, 0, 0, 2, 0, 0, 0, + 0, 1, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, @@ -334,7 +334,7 @@ static const u8 diffserv4[] = { }; static const u8 diffserv3[] = { - 0, 0, 0, 0, 2, 0, 0, 0, + 0, 1, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,