From patchwork Thu Jun 13 19:26:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioanna Alifieraki X-Patchwork-Id: 1115582 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 45Ptz31Y0cz9sNT; Fri, 14 Jun 2019 05:26:55 +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 1hbVN4-0002TA-JK; Thu, 13 Jun 2019 19:26:50 +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 1hbVMz-0002O5-8w for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:45 +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 1hbVMy-00056R-1V for kernel-team@lists.ubuntu.com; Thu, 13 Jun 2019 19:26:44 +0000 Received: by mail-wm1-f72.google.com with SMTP id n25so69853wmc.7 for ; Thu, 13 Jun 2019 12:26:44 -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=LRqmxQbu2/M64LQbsGCu0OQYTxQch8Tsy91srFMBnk8=; b=c8PoMDIGk5Z2sZE6uOVxuH8QhiJTlzkY5yenD0mWnvAoN34ehn4CWE2s/FMXSsfIVs IyuONObHpJ8GWiSNyElm4BnOCl4BVg/6zZOjL+GN0r4KoMkccGPO0CPqt5NfUE8n9atX wEfOk47D5kvphYaf/F+WAhCL73cEBi5eqLc/1n+zQfwuMnCOpwPZhvCotcIYFFBW+5Uf ick0r7wNSHT7GKUFlK0vdoIPcSl4VcisQV27Fbua7q/8v9iA8e09X366nPuO1hRqQPlM 6rOkKHOEn3CCa75PgrljP+HwbiDa1SHdBt73/Y4IrRzHeq7EZHOrtt5+jy/XkK902+JJ 4ZIg== X-Gm-Message-State: APjAAAVwi1INB4k6K/vrz5ZdLrPn47NwSo8+Ga2xUUVbXGTcDAYHshSt XktRTsS0dI41W74MX5Y/kTkaYRhLaB2w90YqjGHqwow3HIscx0urLVcmayJKRmdgGJEQzImxEa+ 7gUQhF5SmOiTND3CbRKp542PKFFapM+P8JMb/u5N96w== X-Received: by 2002:a1c:1c4:: with SMTP id 187mr4451097wmb.87.1560454003606; Thu, 13 Jun 2019 12:26:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJqITrsH+IxvtybAnsEWeI92VsLhMe+tFjrJov9ulqB/00UcyLTRtPp1JVCFwouBww3g5QUw== X-Received: by 2002:a1c:1c4:: with SMTP id 187mr4451089wmb.87.1560454003376; Thu, 13 Jun 2019 12:26:43 -0700 (PDT) Received: from localhost ([2a02:c7d:31d6:7200:ecdd:10ea:9dc8:5da7]) by smtp.gmail.com with ESMTPSA id d3sm435547wrf.87.2019.06.13.12.26.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jun 2019 12:26:43 -0700 (PDT) From: Ioanna Alifieraki To: kernel-team@lists.ubuntu.com Subject: [RFC][b/azure][PATCH 8/8] azure XDP generic fixes - option 1 Date: Thu, 13 Jun 2019 20:26:30 +0100 Message-Id: <20190613192630.31244-9-ioanna-maria.alifieraki@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190613192630.31244-1-ioanna-maria.alifieraki@canonical.com> References: <20190613192630.31244-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 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) [hunk 5 does not apply cleanly beacuse of the different skb_list_del_init(skb) vs list_del(&skb->list) lines that is removed] Signed-off-by: Ioanna Alifieraki --- net/core/dev.c | 58 +++++++++++--------------------------------------- 1 file changed, 12 insertions(+), 46 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index ccb01cd5cc77..c0d8eeb30b97 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); @@ -4768,19 +4763,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)) { @@ -4801,7 +4783,6 @@ static int netif_receive_skb_internal(struct sk_buff *skb) static void netif_receive_skb_list_internal(struct list_head *head) { - struct bpf_prog *xdp_prog = NULL; struct sk_buff *skb, *next; struct list_head sublist; @@ -4814,21 +4795,6 @@ static void netif_receive_skb_list_internal(struct list_head *head) } list_splice_init(&sublist, head); - if (static_branch_unlikely(&generic_xdp_needed_key)) { - preempt_disable(); - rcu_read_lock(); - list_for_each_entry_safe(skb, next, head, list) { - xdp_prog = rcu_dereference(skb->dev->xdp_prog); - list_del(&skb->list); - if (do_xdp_generic(xdp_prog, skb) == XDP_PASS) - list_add_tail(&skb->list, &sublist); - } - rcu_read_unlock(); - preempt_enable(); - /* Put passed packets back on main list */ - list_splice_init(&sublist, head); - } - rcu_read_lock(); #ifdef CONFIG_RPS if (static_branch_unlikely(&rps_needed)) {