From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 A8B1DC282CE for ; Tue, 12 Feb 2019 00:43:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 74F5420844 for ; Tue, 12 Feb 2019 00:43:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ExupMFuQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727996AbfBLAm5 (ORCPT ); Mon, 11 Feb 2019 19:42:57 -0500 Received: from mail-ua1-f74.google.com ([209.85.222.74]:37184 "EHLO mail-ua1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727926AbfBLAm4 (ORCPT ); Mon, 11 Feb 2019 19:42:56 -0500 Received: by mail-ua1-f74.google.com with SMTP id 49so133597ual.4 for ; Mon, 11 Feb 2019 16:42:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=bViixQnZsVcrhtlrd0rObMRyDiFobNREGiljG2WDnvU=; b=ExupMFuQOsVLKyzzjDTjNanhVAWt5diyjioaH6AuQjl0bh+H23eEIehfjhRmhOrLVb aBCxTvzt4Ni66Bt0f2dXtZ1NiBwPoJMLpoLXq96p41Wd4QQUzIp1+Pay3eGI24bXvZZV 2o9QgqMG7FZkjqdlVZ/A+DIncrZCKtLRWSCnjNdUdZzbLKkCu6+gAHVUUCNqu1225SBr Hnd6KTK3pFhWXFMvAhEnqNiCPFTadQKw+dTxPmqY3MRTnQQ1REBoiSdSwioeCYxtmaJh SdAHG/SoEcv5C4d/N7SPe7qVbBPiZXwmFFCoe5/vfKGIoNYUeQOIJKR6fBfpPY0gMlPn y+9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=bViixQnZsVcrhtlrd0rObMRyDiFobNREGiljG2WDnvU=; b=sBIv8aKPAYGgUyvvF393vVbn5Ryop7iMvcFu5hAqOxAV86IfPAiqYeOeZOq4+Y+fza DGNiYeZXbb1pzj4tu7JuhHoOkZU9z8zUEGimyIiRGdL0bErfK/sgHiHRE7cl4BHBNssh fbsJsrXAFqjbMlSLfWXmMkhxGqgkc6PiecSYBMxOJYMlRQFqOs5JHbTQJod1Z+jILJvh urGDAoHtsf9PCFZqLSflvNf2LPYLX5afycAcYmmL89n6uf2VNWF128jlPT8yn9Dfvnam 11IdrCz9LGkNWtn6rpE22j8AlmSxg9JepVTf5B4hcmaWMJo3eO6SUiCWkii2DAB+Opr2 HLuA== X-Gm-Message-State: AHQUAuYYSnVcrVkZTpfHvH7nJmrnR4v1MvqcFlQmxDnbq6VjHMr7zZAB TfHbrzi9Bv8cghIDEkXV4b1G64I4 X-Google-Smtp-Source: AHgI3IYtpq1LIIAXju2axDOvZ43pOCT4oFX1hNCFCGxQimP/KnZJo7AwflUaFK1RUg+ThtH8Yjo6DzZj X-Received: by 2002:a67:e452:: with SMTP id n18mr720299vsm.11.1549932175158; Mon, 11 Feb 2019 16:42:55 -0800 (PST) Date: Mon, 11 Feb 2019 16:42:42 -0800 Message-Id: <20190212004249.219268-1-posk@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.20.1.791.gb4d0f1c61a-goog Subject: [PATCH bpf-next v9 0/7] bpf: add BPF_LWT_ENCAP_IP option to bpf_lwt_push_encap From: Peter Oskolkov To: Alexei Starovoitov , Daniel Borkmann , netdev@vger.kernel.org Cc: Peter Oskolkov , David Ahern , Willem de Bruijn , Peter Oskolkov Content-Type: text/plain; charset="UTF-8" Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patchset implements BPF_LWT_ENCAP_IP mode in bpf_lwt_push_encap BPF helper. It enables BPF programs (specifically, BPF_PROG_TYPE_LWT_IN and BPF_PROG_TYPE_LWT_XMIT prog types) to add IP encapsulation headers to packets (e.g. IP/GRE, GUE, IPIP). This is useful when thousands of different short-lived flows should be encapped, each with different and dynamically determined destination. Although lwtunnels can be used in some of these scenarios, the ability to dynamically generate encap headers adds more flexibility, e.g. when routing depends on the state of the host (reflected in global bpf maps). V2 changes: added flowi-based route lookup, IPv6 encapping, and encapping on ingress. V3 changes: incorporated David Ahern's suggestions: - added l3mdev check/oif (patch 2) - sync bpf.h from include/uapi into tools/include/uapi - selftest tweaks V4 changes: moved route lookup/dst change from bpf_push_ip_encap to when BPF_LWT_REROUTE is handled, as suggested by David Ahern. V5 changes: added a check in lwt_xmit that skb->protocol stays the same if the skb is to be passed back to the stack (ret == BPF_OK). Again, suggested by David Ahern. V6 changes: abandoned. V7 changes: added handling of GSO packets (patch 3 in the patchset added), as suggested by BPF maintainers. V8 changes: - fixed build errors when LWT or IPV6 are not enabled; - whitelisted TCP GSO instead of blacklisting SCTP and UDP GSO, as suggested by Willem de Bruijn; - added validation that pushed length cover needed headers when GRE/UDP encap is detected, as suggested by Willem de Bruijn; - a couple of minor/stylistic tweaks/fixed typos. V9 changes: - fixed a kbuild test robot compiler warning; - added ipv6_route_input to ipv6_stub (patch 4 in the patchset added), and IPv6 routing functions are now invoked via ipv6_stub, as suggested by David Ahern. Peter Oskolkov (7): bpf: add plumbing for BPF_LWT_ENCAP_IP in bpf_lwt_push_encap bpf: implement BPF_LWT_ENCAP_IP mode in bpf_lwt_push_encap bpf: handle GSO in bpf_lwt_push_encap ipv6_stub: add ipv6_route_input stub/proxy. bpf: add handling of BPF_LWT_REROUTE to lwt_bpf.c bpf: sync /include/.../bpf.h with tools/include/.../bpf.h selftests: bpf: add test_lwt_ip_encap selftest include/net/addrconf.h | 1 + include/net/lwtunnel.h | 2 + include/uapi/linux/bpf.h | 26 +- net/core/filter.c | 49 ++- net/core/lwt_bpf.c | 261 +++++++++++++++ net/ipv6/addrconf_core.c | 6 + net/ipv6/af_inet6.c | 7 + tools/include/uapi/linux/bpf.h | 26 +- tools/testing/selftests/bpf/Makefile | 5 +- .../testing/selftests/bpf/test_lwt_ip_encap.c | 85 +++++ .../selftests/bpf/test_lwt_ip_encap.sh | 311 ++++++++++++++++++ 11 files changed, 768 insertions(+), 11 deletions(-) create mode 100644 tools/testing/selftests/bpf/test_lwt_ip_encap.c create mode 100755 tools/testing/selftests/bpf/test_lwt_ip_encap.sh -- 2.20.1.791.gb4d0f1c61a-goog