From patchwork Wed Apr 18 04:42:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nikita V. Shirokov" X-Patchwork-Id: 900109 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@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=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tehnerd.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=tehnerd-com.20150623.gappssmtp.com header.i=@tehnerd-com.20150623.gappssmtp.com header.b="tFRYB2d5"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40R2pT2Y64z9s3X for ; Wed, 18 Apr 2018 23:22:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753918AbeDRNWG (ORCPT ); Wed, 18 Apr 2018 09:22:06 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:34315 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753883AbeDRNWF (ORCPT ); Wed, 18 Apr 2018 09:22:05 -0400 Received: by mail-pl0-f65.google.com with SMTP id z12-v6so1126499plo.1 for ; Wed, 18 Apr 2018 06:22:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tehnerd-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=6l/5cUcBMcgxxAwK2SETFKI9Sr2m+tIC1PCDQMhCIt4=; b=tFRYB2d5uZRb9W0tYbXlTDYY8tVn+zbgWP+vRonlyjEsy4Bvl5k/ZBTZPbrer14tfu w03mMNre0wE1D8huxem1/oM2dwQzmvPeNcHwob/1xxjCxoL0L5/oLSLBBpDZQYu57vWf XbUvBpZZbHENkcwnEF/YLoscavYHUDXRQhZLlgFNB2om3syalY9K170lcqVnvZz1WDec 70+nun5I2ggF+1EOGfcRCr69xoUWMksmiwa7YEqFKVtj31AyKQcCIeEYr6qz2G+Kqveu BtW3/5RyNMSE0wWFqLhaKg6DAhL759gHzdoF6a6L1w/W30CkowKeKtD8pl2z/uFy88At u9IA== 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; bh=6l/5cUcBMcgxxAwK2SETFKI9Sr2m+tIC1PCDQMhCIt4=; b=KIhQ8lNHV/y3AoKjUh3F36dCxwEnFiD2SXxMSvPi7LKg3TwPgbPTtFxf2EiSoEGJyy 6OnDZyyz4RgAVXE7NyuEtJL7VChqEycG+gz+HHL932tm9X1zE+UbcTULq3jzoZP/EJZn GSF0M6txorXofAiH0mzBMYSekCpF4X5sCLgLhinDLrIAzrwKgP30jWDM55BdRdXLrDv9 MI0z9W1EA5pgqMm7HeNzVaWSw14l+7g/JVqKCCdTb+i8ZfysHs6NURufRh8gPnS8H49p zJBODbDCp8jBSXy6Bp7NcDKD+dmtwdWKKlLQqe6sutVH7Jw9dHSsgCPlwLIBhZ8vUceJ ypng== X-Gm-Message-State: ALQs6tBfIUEasjm1pzT7RQu89FU2TJVAGdT9gobk7o+md0rgSovLzboj OYwJlPoUuKiAgHZahM+2W6vzEVldGwOpaw== X-Google-Smtp-Source: AIpwx48NphC4W80kpQPq5yVNcJlker+xXtq+O4Tj32dwlpTD7e9bdQzuM3yZ0qiFSRY/+9eoJIx/Ow== X-Received: by 2002:a17:902:8e8c:: with SMTP id bg12-v6mr2071333plb.295.1524057724616; Wed, 18 Apr 2018 06:22:04 -0700 (PDT) Received: from maindev.thefacebook.com ([199.201.64.2]) by smtp.gmail.com with ESMTPSA id u7sm3836378pfa.96.2018.04.18.06.22.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Apr 2018 06:22:03 -0700 (PDT) From: "Nikita V. Shirokov" To: Alexei Starovoitov , Daniel Borkmann Cc: netdev@vger.kernel.org, "Nikita V. Shirokov" Subject: [PATCH bpf-next v3 00/11] introduction of bpf_xdp_adjust_tail Date: Tue, 17 Apr 2018 21:42:12 -0700 Message-Id: <20180418044223.17685-1-tehnerd@tehnerd.com> X-Mailer: git-send-email 2.15.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In this patch series i'm add new bpf helper which allow to manupulate xdp's data_end pointer. right now only "shrinking" (reduce packet's size by moving pointer) is supported (and i see no use case for "growing"). Main use case for such helper is to be able to generate controll (ICMP) messages from XDP context. such messages usually contains first N bytes from original packets as a payload, and this is exactly what this helper would allow us to do (see patch 3 for sample program, where we generate ICMP "packet too big" message). This helper could be usefull for load balancing applications where after additional encapsulation, resulting packet could be bigger then interface MTU. Aside from new helper this patch series contains minor changes in device drivers (for ones which requires), so they would recal packet's length not only when head pointer was adjusted, but if tail's one as well. v2->v3: * adding missed "signed off by" in v2 v1->v2: * fixed kbuild warning * made offset eq 0 invalid for xdp_bpf_adjust_tail * splitted bpf_prog_test_run fix and selftests in sep commits * added SPDX licence where applicable * some reshuffling in patches order (tests now in the end) Nikita V. Shirokov (11): bpf: making bpf_prog_test run aware of possible data_end ptr change bpf: adding tests for bpf_xdp_adjust_tail bpf: adding bpf_xdp_adjust_tail helper bpf: make generic xdp compatible w/ bpf_xdp_adjust_tail bpf: make mlx4 compatible w/ bpf_xdp_adjust_tail bpf: make bnxt compatible w/ bpf_xdp_adjust_tail bpf: make cavium thunder compatible w/ bpf_xdp_adjust_tail bpf: make netronome nfp compatible w/ bpf_xdp_adjust_tail bpf: make tun compatible w/ bpf_xdp_adjust_tail bpf: make virtio compatible w/ bpf_xdp_adjust_tail bpf: add bpf_xdp_adjust_tail sample prog drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 2 +- drivers/net/ethernet/cavium/thunder/nicvf_main.c | 2 +- drivers/net/ethernet/mellanox/mlx4/en_rx.c | 2 +- .../net/ethernet/netronome/nfp/nfp_net_common.c | 2 +- drivers/net/tun.c | 3 +- drivers/net/virtio_net.c | 7 +- include/uapi/linux/bpf.h | 10 +- net/bpf/test_run.c | 3 +- net/core/dev.c | 10 +- net/core/filter.c | 29 +++- samples/bpf/Makefile | 4 + samples/bpf/xdp_adjust_tail_kern.c | 152 +++++++++++++++++++++ samples/bpf/xdp_adjust_tail_user.c | 142 +++++++++++++++++++ tools/include/uapi/linux/bpf.h | 10 +- tools/testing/selftests/bpf/Makefile | 2 +- tools/testing/selftests/bpf/bpf_helpers.h | 5 + tools/testing/selftests/bpf/test_adjust_tail.c | 30 ++++ tools/testing/selftests/bpf/test_progs.c | 32 +++++ 18 files changed, 435 insertions(+), 12 deletions(-) create mode 100644 samples/bpf/xdp_adjust_tail_kern.c create mode 100644 samples/bpf/xdp_adjust_tail_user.c create mode 100644 tools/testing/selftests/bpf/test_adjust_tail.c