From patchwork Thu Jun 13 19:27:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115584 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Pv0N53KPz9s5c; Fri, 14 Jun 2019 05:28:04 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hbVOC-0002nv-LN; Thu, 13 Jun 2019 19:28:00 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hbVOB-0002mJ-88 for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:27:59 +0000 Received: from mail-wr1-f69.google.com ([209.85.221.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hbVOA-0005GW-Uh for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:27:58 +0000 Received: by mail-wr1-f69.google.com with SMTP id g2so20686wrq.19 for ; Thu, 13 Jun 2019 12:27:58 -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:subject:date:message-id:in-reply-to :references; bh=5lUmZwT9HKdUAGxVxGhM9/sNZYh5qQ2OWFKR8spRO2k=; b=IAeg040W7EnmEks2y35cDBlk7jMdA+N5NcoKJSnFpDd6x1IuB0Q93+C7/6IFao0ZA0 gpdq+baiHV2Qc3YToGOIfgHs7tuCd/wYJ5d4gxRY7hw/5MLQdhUz0lFGBeSRVTHfESX5 Id7Uty5iTzTywWdW0a5/KhRcK5cb0UVkk6Hx0R/oaDzfhkVF9ri4AjWO7rQF0F0kqVYu BPvqbsMk7tmMc5iJn+QwuJOx3qj7lngmQKRC6qlmEsG5mqQQrm70xUY1HJQIgj3dnE94 YNwqhCC6V/r2ADEbvjngXVKW/lUKQGdZziMxTBic2xOEUhmelGlJZmBzSLTeFsPAfkcb RIYg== X-Gm-Message-State: APjAAAWUjVal23+97/1M0ellIk2mf8APDmmhxXUgRm/GPbyjFbMZ80LZ u+rQMTscpT+i7hFgCxLcok4UqpPPPQb+stdwET3lNDTyZfyyMAL/GC50hduYShfapgQZfS9Iyi8 /TGHjl0IZCfLdTGH1ggUOwdSGHY17KRcLv9nRGqEy5w== X-Received: by 2002:a05:600c:389:: with SMTP id w9mr4691110wmd.139.1560454078544; Thu, 13 Jun 2019 12:27:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxnS+Y9nGp49apy7hX7sNdBojz1B3LCKClidNhTVJC9W1SbGd/1mxd+PUlkWFsdhQ0G1bFemw== X-Received: by 2002:a05:600c:389:: with SMTP id w9mr4691103wmd.139.1560454078402; Thu, 13 Jun 2019 12:27:58 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id y38sm1082235wrd.41.2019.06.13.12.27.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 12:27:58 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 1/3] azure XDP generic fixes - option 2 Date: Thu, 13 Jun 2019 20:27:53 +0100 Message-Id: <20190613192755.31428-2-ioanna-maria.alifieraki@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190613192755.31428-1-ioanna-maria.alifieraki@canonical.com> References: <20190613192755.31428-1-ioanna-maria.alifieraki@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Stephen Hemminger BugLink: https://bugs.launchpad.net/bugs/1831254 The netvsc VF skb handler should make sure that skb is not shared. Similar logic already exists in bonding and team device drivers. This is not an issue in practice because the VF devicex does not send up shared skb's. But the netvsc driver should do the right thing if it did. Fixes: 0c195567a8f6 ("netvsc: transparent VF management") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller (cherry picked from commit 996ed04741467f6d1552440c92988b132a9487ec) Signed-off-by: Ioanna Alifieraki --- drivers/net/hyperv/netvsc_drv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index c0fc30a1f600..c86c79949097 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -1836,6 +1836,12 @@ static rx_handler_result_t netvsc_vf_handle_frame(struct sk_buff **pskb) struct netvsc_vf_pcpu_stats *pcpu_stats = this_cpu_ptr(ndev_ctx->vf_stats); + skb = skb_share_check(skb, GFP_ATOMIC); + if (unlikely(!skb)) + return RX_HANDLER_CONSUMED; + + *pskb = skb; + skb->dev = ndev; u64_stats_update_begin(&pcpu_stats->syncp); From patchwork Thu Jun 13 19:27:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115586 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Pv0R3wLdz9sND; Fri, 14 Jun 2019 05:28:07 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hbVOF-0002pX-08; Thu, 13 Jun 2019 19:28:03 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hbVOC-0002nw-UB for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:28:00 +0000 Received: from mail-wr1-f70.google.com ([209.85.221.70]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hbVOC-0005Gf-G0 for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:28:00 +0000 Received: by mail-wr1-f70.google.com with SMTP id q16so31934wrx.5 for ; Thu, 13 Jun 2019 12:28:00 -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:subject:date:message-id:in-reply-to :references; bh=suJcyJxsFfU0K0yPoDRvAP7Uf9sQa8ce16pTjgi8Bac=; b=qgZpVdL7lfTFSl7QzNWcAoK9NdTjOxpS8abZ5GBqEZXQkjob1ZBp6EpKeC5RRAgN8u 3t3keDFH5RKu9KeuR+Ktq/8NhUo+DA1plgifMHj5xdS7oPSDm3lgLSo12hbgviRIxgsw OyDxX3UROmKRrl+E7QlMLNpT4Qdpnd3LgHCHnQ2HhSgNRWGD21HjI0nHkj2ZQOpeNeJM ORUyaxgozbRm9QsrUiTgOJvBZBQN8ulkAmDaN9X7ISZYV8q3jMIwYsKZx5SIFL/q6eGy jze/A3pwVTecM2V/IkFFif3ydbGV2QD1BB1i3lqUHxGa7rKYecDUt+3N55kudNLMHkLj 9qwg== X-Gm-Message-State: APjAAAUnNhNNX1T4FaMFWXPeoQpTxyDu5RrX+1PN8d+x1OYmLmk06cvT 6C2fkZawmsD9kJ6lt8IEiIvYDGMJ4M/9rL9hs+9DxWgCe2TWHn6r+FVgPVY2ZzhB3BGru5sdAy+ mpytxN7ekLHwl/N5t+/23Mydv56Tu1/BrqETGJk1VzQ== X-Received: by 2002:adf:8044:: with SMTP id 62mr13485451wrk.20.1560454080057; Thu, 13 Jun 2019 12:28:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYUBcIemau926MJ2VBEF1UOa+FYf8gg4t2kI9XMrW9DONSAUlK4vgaw3elA7HfNsI1Bj3Vew== X-Received: by 2002:adf:8044:: with SMTP id 62mr13485440wrk.20.1560454079868; Thu, 13 Jun 2019 12:27:59 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id o6sm1020438wmc.15.2019.06.13.12.27.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 12:27:59 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 2/3] azure XDP generic fixes - option 2 Date: Thu, 13 Jun 2019 20:27:54 +0100 Message-Id: <20190613192755.31428-3-ioanna-maria.alifieraki@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190613192755.31428-1-ioanna-maria.alifieraki@canonical.com> References: <20190613192755.31428-1-ioanna-maria.alifieraki@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Eric Dumazet BugLink: https://bugs.launchpad.net/bugs/1831254 We prefer static_branch_unlikely() over static_key_false() these days. Signed-off-by: Eric Dumazet Acked-by: Soheil Hassas Yeganeh Acked-by: Willem de Bruijn Signed-off-by: David S. Miller (backported from commit dc05360fee660a9dbe59824b3f7896534210432b) [hunk 7 in original commit modifies netif_receive_skb_list_internal function which is not present. So remove this hunk.] Signed-off-by: Ioanna Alifieraki --- drivers/net/tun.c | 2 +- include/linux/netdevice.h | 4 ++-- include/net/sock.h | 2 +- net/core/dev.c | 8 ++++---- net/core/net-sysfs.c | 4 ++-- net/core/sysctl_net_core.c | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 694a27da7278..1151f7511c1c 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1039,7 +1039,7 @@ static int tun_net_close(struct net_device *dev) static void tun_automq_xmit(struct tun_struct *tun, struct sk_buff *skb) { #ifdef CONFIG_RPS - if (tun->numqueues == 1 && static_key_false(&rps_needed)) { + if (tun->numqueues == 1 && static_branch_unlikely(&rps_needed)) { /* Select queue was not called for the skbuff, so we extract the * RPS hash and save it into the flow_table here. */ diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3045a5cee0d8..1e652e4f08e6 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -194,8 +194,8 @@ struct net_device_stats { #ifdef CONFIG_RPS #include -extern struct static_key rps_needed; -extern struct static_key rfs_needed; +extern struct static_key_false rps_needed; +extern struct static_key_false rfs_needed; #endif struct neighbour; diff --git a/include/net/sock.h b/include/net/sock.h index 762069bb0d8c..6f550817e5d5 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -937,7 +937,7 @@ static inline void sock_rps_record_flow_hash(__u32 hash) static inline void sock_rps_record_flow(const struct sock *sk) { #ifdef CONFIG_RPS - if (static_key_false(&rfs_needed)) { + if (static_branch_unlikely(&rfs_needed)) { /* Reading sk->sk_rxhash might incur an expensive cache line * miss. * diff --git a/net/core/dev.c b/net/core/dev.c index bf669e77f9f3..99f62b724d6e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3702,9 +3702,9 @@ EXPORT_SYMBOL(rps_sock_flow_table); u32 rps_cpu_mask __read_mostly; EXPORT_SYMBOL(rps_cpu_mask); -struct static_key rps_needed __read_mostly; +struct static_key_false rps_needed __read_mostly; EXPORT_SYMBOL(rps_needed); -struct static_key rfs_needed __read_mostly; +struct static_key_false rfs_needed __read_mostly; EXPORT_SYMBOL(rfs_needed); static struct rps_dev_flow * @@ -4216,7 +4216,7 @@ static int netif_rx_internal(struct sk_buff *skb) } #ifdef CONFIG_RPS - if (static_key_false(&rps_needed)) { + if (static_branch_unlikely(&rps_needed)) { struct rps_dev_flow voidflow, *rflow = &voidflow; int cpu; @@ -4775,7 +4775,7 @@ static int netif_receive_skb_internal(struct sk_buff *skb) rcu_read_lock(); #ifdef CONFIG_RPS - if (static_key_false(&rps_needed)) { + if (static_branch_unlikely(&rps_needed)) { struct rps_dev_flow voidflow, *rflow = &voidflow; int cpu = get_rps_cpu(skb->dev, skb, &rflow); diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 151e6cd47972..51a2169605f1 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -759,9 +759,9 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue, rcu_assign_pointer(queue->rps_map, map); if (map) - static_key_slow_inc(&rps_needed); + static_branch_inc(&rps_needed); if (old_map) - static_key_slow_dec(&rps_needed); + static_branch_dec(&rps_needed); mutex_unlock(&rps_map_mutex); diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index b1a2c5e38530..4f9a939c51e5 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -84,12 +84,12 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write, if (sock_table != orig_sock_table) { rcu_assign_pointer(rps_sock_flow_table, sock_table); if (sock_table) { - static_key_slow_inc(&rps_needed); - static_key_slow_inc(&rfs_needed); + static_branch_inc(&rps_needed); + static_branch_inc(&rfs_needed); } if (orig_sock_table) { - static_key_slow_dec(&rps_needed); - static_key_slow_dec(&rfs_needed); + static_branch_dec(&rps_needed); + static_branch_dec(&rfs_needed); synchronize_rcu(); vfree(orig_sock_table); } From patchwork Thu Jun 13 19:27:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115585 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Pv0R1X3Xz9sDB; Fri, 14 Jun 2019 05:28:07 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hbVOF-0002pz-MV; Thu, 13 Jun 2019 19:28:03 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hbVOE-0002p7-Cc for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:28:02 +0000 Received: from mail-wm1-f72.google.com ([209.85.128.72]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hbVOD-0005HC-NP for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:28:01 +0000 Received: by mail-wm1-f72.google.com with SMTP id v125so59394wme.5 for ; Thu, 13 Jun 2019 12:28:01 -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:subject:date:message-id:in-reply-to :references; bh=PQRSAcC8sb4xpAgcI3W8e3j7FUC6yjunykbyAcSuhTM=; b=rvgYzuXI/s1HVsl+OoTgN+LyB+fbGwWkpKqt7LxDUEh66OzHX9zjbVJ5p4c1RU72wl hvmQ1mrczgJgz192pUu3lMk/iTh4KgeMsMNJOQ4cjB1wtXPT4aPBAJq30bP6EaWLSc/F 0DjEz5xAHsTNK9b+SeLm5PtKosRtR1BmTtrjPwoUKkx8TCKgh5QEJu7g0q4GwZF5PKGT blcKtiM5asEbs9BI3pfCfoNn1VbJxCNCgzlsmXsfa5nhPCQiW6ueEvtCvKQBQ+jdOfs+ crYh7OZnI9R99j9EYNLgqrOgci/RXZ/SzOBfhk5AU1B+ZuWtmIzm7HXzPssg8NszWgyo OIRQ== X-Gm-Message-State: APjAAAVrsZUJjfBgMOv+GkA+fpDdSc7nHhf9BpL8An5QIGVmlCwCOt/o 1jpgTdOYTWbTYmYhw9CGkuJ6lNF8oopgoI4Wq45DmV+fV/M/y6wdfWGKkgCpOE4nkwEf8hJlJHr PPQ//MkEHRYdZs7kiuJV0Z4V1chwN4xBNAay/HYfncw== X-Received: by 2002:a5d:5007:: with SMTP id e7mr34317097wrt.231.1560454081305; Thu, 13 Jun 2019 12:28:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsj6yE4G8MUgtyjJD48lXV3O38ETdyI1pcc0zWtEBd4k0HTQTVD/03TM50eQpanXs4Lhwmsw== X-Received: by 2002:a5d:5007:: with SMTP id e7mr34317085wrt.231.1560454081137; Thu, 13 Jun 2019 12:28:01 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id y17sm1275205wrg.18.2019.06.13.12.28.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 12:28:00 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 3/3] azure XDP generic fixes - option 2 Date: Thu, 13 Jun 2019 20:27:55 +0100 Message-Id: <20190613192755.31428-4-ioanna-maria.alifieraki@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190613192755.31428-1-ioanna-maria.alifieraki@canonical.com> References: <20190613192755.31428-1-ioanna-maria.alifieraki@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Stephen Hemminger BugLink: https://bugs.launchpad.net/bugs/1831254 When a device is stacked like (team, bonding, failsafe or netvsc) the XDP generic program for the parent device was not called. Move the call to XDP generic inside __netif_receive_skb_core where it can be done multiple times for stacked case. Fixes: d445516966dc ("net: xdp: support xdp generic on virtual devices") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller (backported from commit 458bf2f224f04a513b0be972f8708e78ee2c986e) [Hunks 4 and 5 in oringinal commit modify netif_receive_skb_list_internal function which is not present, so do not remove them.] Signed-off-by: Ioanna Alifieraki --- net/core/dev.c | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 99f62b724d6e..901b558cce5c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4198,23 +4198,6 @@ static int netif_rx_internal(struct sk_buff *skb) trace_netif_rx(skb); - if (static_branch_unlikely(&generic_xdp_needed_key)) { - int ret; - - preempt_disable(); - rcu_read_lock(); - ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb); - rcu_read_unlock(); - preempt_enable(); - - /* Consider XDP consuming the packet a success from - * the netdev point of view we do not want to count - * this as an error. - */ - if (ret != XDP_PASS) - return NET_RX_SUCCESS; - } - #ifdef CONFIG_RPS if (static_branch_unlikely(&rps_needed)) { struct rps_dev_flow voidflow, *rflow = &voidflow; @@ -4543,6 +4526,18 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc) __this_cpu_inc(softnet_data.processed); + if (static_branch_unlikely(&generic_xdp_needed_key)) { + int ret2; + + preempt_disable(); + ret2 = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb); + preempt_enable(); + + if (ret2 != XDP_PASS) + return NET_RX_DROP; + skb_reset_mac_len(skb); + } + if (skb->protocol == cpu_to_be16(ETH_P_8021Q) || skb->protocol == cpu_to_be16(ETH_P_8021AD)) { skb = skb_vlan_untag(skb); @@ -4760,19 +4755,6 @@ static int netif_receive_skb_internal(struct sk_buff *skb) if (skb_defer_rx_timestamp(skb)) return NET_RX_SUCCESS; - if (static_branch_unlikely(&generic_xdp_needed_key)) { - int ret; - - preempt_disable(); - rcu_read_lock(); - ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb); - rcu_read_unlock(); - preempt_enable(); - - if (ret != XDP_PASS) - return NET_RX_DROP; - } - rcu_read_lock(); #ifdef CONFIG_RPS if (static_branch_unlikely(&rps_needed)) {