From patchwork Sun May 19 03:10:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 1101620 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming-bpf@patchwork.ozlabs.org Delivered-To: patchwork-incoming-bpf@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=bpf-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=networkplumber.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="ozrAcyT0"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 456VjB2tb8z9s3q for ; Mon, 20 May 2019 04:21:34 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726610AbfESSVc (ORCPT ); Sun, 19 May 2019 14:21:32 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40349 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726040AbfESSVc (ORCPT ); Sun, 19 May 2019 14:21:32 -0400 Received: by mail-pg1-f196.google.com with SMTP id d30so5655283pgm.7 for ; Sun, 19 May 2019 11:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jW23EVTaONU8fGl2rO/gh8exrFRja4BdXSBKXyg60v0=; b=ozrAcyT0DpFtEMYykTdhJbaq66KrzCAXKUFjhOLB6dzNeGwggFwc56RbIt/G7DA7IW M/rItzMyRXrr1YWAA9gEUgIjPS2/IZYOtgquWDTPcOGMCesGJhlfAtsdM3AmJMoStidX UG8cOB3AP0ZIfOj1JoJ7+BLkc9leWofJbqyqzm1nb4jY0/EO8DfnuLFbOR7m7M545TBr 6SXhfosIzl5Jz6BNc5h1qqlxlgTk7KpE5cAxf0VUYWAxAn9TtNp6OgRudSg/2dJgXzQe 3wNqZg4XVFOSobHHfP5Yyge9R6Rn7EhRdQtKSXcfqhL7Hdz+MiCKzPE/n4yt9E3zIbUi J6pA== 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jW23EVTaONU8fGl2rO/gh8exrFRja4BdXSBKXyg60v0=; b=Cq8wXpWmMmEElEHzuhqXUdLqlLYOuojgvGWGgNtMDwHHMrRR7Mn3LWOfDWaiDnykbo +zCx5Cg/xtok3Il0PlSBU112NlNgwfuPDKgS8lGaBpp+glP0WAVj3K6Do98ZCFi8jfYw U6ymPeFVabs2MTFMmrh9tUqsQUfgp3g7//zOTZlBJCb2oHP+Sl8YxvBC7zVaF+zIdBKr N654c/DS2krLrAV/OKNoL9ffAr/exRQsSww8gW4S60/L/LUG+cCX25FW4e0KxG1Q8siv lvRTKwoP0zjFlr8xRB5HskA2hKGse7WnljOW99yyP4nA5gZm0gYNRXRpeP9NpP0uNTu5 hzLQ== X-Gm-Message-State: APjAAAVnYdF3SebcB2LLhxiEZXuYxLvKjTKWl9OY7hIXvvtH2kfDWpIE rPsZaxj3fB+aMji0uoQpDj9r2VJHCKE= X-Google-Smtp-Source: APXvYqxRzJW84pUeaYRcQIKBpl3JDeUa6cqWfgZ5OSUgwQndPN6hm0wQ7j5J8ZS2QG7aTVmpTFX33A== X-Received: by 2002:a62:fc56:: with SMTP id e83mr19902876pfh.27.1558235451125; Sat, 18 May 2019 20:10:51 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id s80sm39049604pfs.117.2019.05.18.20.10.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 May 2019 20:10:49 -0700 (PDT) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: netdev@vger.kernel.org, davem@davemloft.net Cc: xdp-newbies@vger.kernel.org, bpf@vger.kernel.org, Stephen Hemminger Subject: [PATCH v2 net 1/2] netvsc: unshare skb in VF rx handler Date: Sat, 18 May 2019 20:10:45 -0700 Message-Id: <20190519031046.4049-2-sthemmin@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190519031046.4049-1-sthemmin@microsoft.com> References: <20190519031046.4049-1-sthemmin@microsoft.com> MIME-Version: 1.0 Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org 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 --- 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 06393b215102..9873b8679f81 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -2000,6 +2000,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 Sun May 19 03:10:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 1101612 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming-bpf@patchwork.ozlabs.org Delivered-To: patchwork-incoming-bpf@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=bpf-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=networkplumber.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="rzk0sxgc"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 456VC71pzrz9s3q for ; Mon, 20 May 2019 03:58:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727618AbfESR66 (ORCPT ); Sun, 19 May 2019 13:58:58 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45966 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727456AbfESR66 (ORCPT ); Sun, 19 May 2019 13:58:58 -0400 Received: by mail-pg1-f193.google.com with SMTP id i21so5629807pgi.12 for ; Sun, 19 May 2019 10:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xYRthToGOVGrtWs/K77iVnKy2UFNhHHnBACsWKb9qN8=; b=rzk0sxgcSFBT6HdPWh1ToOScWy2gA+Joyd1bYf2PwVqr6+8v18UmTILLtYTApoNpbg IPAsqCIjjLU5ssIf3svAtIU06evlPSveke77CbH2AkcvAPT+UbpLz3lPbhw4wBIhBsnO OfAnoEOhgs7PSZowphBJ5G28+qoDJbNH8o3k3FDERquVaAxyGbKTK9kbKXRgsRvF/TSt fou0eWoMywhwwHaUv3uZz8Pgs3QMGXBBMzEvP9uBZhEwcA8Sg2wP4032WN2+gWmwfPPq bVSZ0hcaHJ7FIX52epyFd4fCksNBztXbrvFkhlAA8Fp8odkzpdIlmGI+k21U+/bWpv7B oujg== 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xYRthToGOVGrtWs/K77iVnKy2UFNhHHnBACsWKb9qN8=; b=iR1bU+pjQl4LUcCTUMT5gQWS0cmNdfDUU6RXKTznIVvQn+BXNw2IhjB2u8lKS6Mxk3 7ivwQe/IuK2bCR0cnUZNgCMFe9mwNBbC5+i/5tGPxGpDq50QzYhYcx6+Y3WkqRzb/RiB ZeDQYYcZ4foKCRPMY6+C+2jsB3APbgEu9fKFIg+dvAfAX+glJPa4fCceebhjo153qDKL PUo4AYdMAZ3/ZqwrGttc2sZKW7rEophL2ZNjmfmqzphfXZcKOusa00K2uYNU+w9zhBH5 WU9qP7pwgB7uUsjSgc1mhSvmyDGfWWP9tzm+VLR64VlTazKcwi4SpYobXZ/efYW2wy23 ozkQ== X-Gm-Message-State: APjAAAXJkSGu6WdjFPYrAhRax0raq6+0KYyjyf8RhaNwIneWx2LeAG+u 1fwNlz3f/JImjtq+28M5aFuJkcg4UqY= X-Google-Smtp-Source: APXvYqyoucFoYOSTtZKSe61X7xiKiWmULV+TFSbvE/bVuh25r1W26JPYc8xUwg6QaUUDS9CDWjDvrw== X-Received: by 2002:a62:5653:: with SMTP id k80mr71034976pfb.144.1558235452284; Sat, 18 May 2019 20:10:52 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id s80sm39049604pfs.117.2019.05.18.20.10.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 May 2019 20:10:51 -0700 (PDT) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: netdev@vger.kernel.org, davem@davemloft.net Cc: xdp-newbies@vger.kernel.org, bpf@vger.kernel.org, Stephen Hemminger , Jason Wang Subject: [PATCH v2 net 2/2] net: core: generic XDP support for stacked device Date: Sat, 18 May 2019 20:10:46 -0700 Message-Id: <20190519031046.4049-3-sthemmin@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190519031046.4049-1-sthemmin@microsoft.com> References: <20190519031046.4049-1-sthemmin@microsoft.com> MIME-Version: 1.0 Sender: bpf-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org When a device is stacked like (team, bonding, failsafe or netvsc) the XDP generic program for the parent device is not called. In these cases, the rx handler changes skb->dev to its own in the receive handler, and returns RX_HANDLER_ANOTHER. Fix this by calling do_xdp_generic if necessary before starting another round. Review of all the places RX_HANDLER_ANOTHER is returned show that the current devices do correctly change skb->dev. There was an older patch that got abandoned that did the same thing, this is just a rewrite. Suggested-by: Jason Wang Fixes: d445516966dc ("net: xdp: support xdp generic on virtual devices") Signed-off-by: Stephen Hemminger Acked-by: Jason Wang --- net/core/dev.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/core/dev.c b/net/core/dev.c index b6b8505cfb3e..240d0b2de1a8 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4921,6 +4921,16 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc, ret = NET_RX_SUCCESS; goto out; case RX_HANDLER_ANOTHER: + if (static_branch_unlikely(&generic_xdp_needed_key)) { + struct bpf_prog *xdp_prog; + + xdp_prog = rcu_dereference(skb->dev->xdp_prog); + ret = do_xdp_generic(xdp_prog, skb); + if (ret != XDP_PASS) { + ret = NET_RX_SUCCESS; + goto out; + } + } goto another_round; case RX_HANDLER_EXACT: deliver_exact = true;