From patchwork Tue Apr 24 17:44:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mathieu Xhonneux X-Patchwork-Id: 903627 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=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Bo8QgWVJ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Vnhr4Bpvz9ryr for ; Wed, 25 Apr 2018 01:45:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751487AbeDXPog (ORCPT ); Tue, 24 Apr 2018 11:44:36 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:55690 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750916AbeDXPod (ORCPT ); Tue, 24 Apr 2018 11:44:33 -0400 Received: by mail-wm0-f41.google.com with SMTP id a8so1941367wmg.5 for ; Tue, 24 Apr 2018 08:44:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tY0Vll/BNt78bGkBiLK50j1ia16CQTgaVyisTvZ1TKk=; b=Bo8QgWVJ9s57krMCPr0RJC7M2zI7TsXL+CD3rCVAH45eCE8iFlZKTztSr97eZUQBHH f4eSk4v54S7JiuttAWykptvJn3PmIKWNTfY3zSJITeap6oV6Kfc1QWYk7FDwtUgsPH/P XhwRr+wOgmbzyLCnZr9hPMdxf49dtur3M2PVgPswDpWaB4FZohMFKtKKTIfWO9ekzwKI 6csqME2eKsTYFsr/31Mq8IQ+ByO6DDZHF8EFk74evi2H8kPu6DTys304pkP/nKaQ1GzQ udiX5WPL5s30YTri+2rLX0WNZ3ELF962qXHztl8lOiJwC8jSN9eOHgGqAtBCvPyyMXpb lQhQ== 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:mime-version :content-transfer-encoding; bh=tY0Vll/BNt78bGkBiLK50j1ia16CQTgaVyisTvZ1TKk=; b=H1Eb4GbAmQDSM0FXlE9d7z/uVvnQ5tRhvStCOjBHZW6yOLw1pV8toEhNyyThtnDjAs YoRSJo1XGerPlY8DEjDqvTPpACh1tACMzyJmytVyRc7+2RfjtEzddDY55u58JQ45YcVM FA1OrpJcGCF74+A1LoOGfY5s7DD07FjSrstmWy8m9n6FqoI0TzQPkJXywbYz2znr+TD9 CB1Pt+oHCIeFXdh6B00vW9lDqlckpPhjvNjdaZ6XqEdJ9ESOP9ME9TaEQE4WZms5hwsi dR9cjeiHvFXbHWsigDNCm5IPz5brU7EjX/OdKjHyzbUA7Qd7gCmree4M0efVrtBPpIGp PURw== X-Gm-Message-State: ALQs6tDIAME7uzrkaEOsNmtcZInKaoI+yQKpOAIGnLxeMWhSOzOlO4gO nCnJb8YyTCrBgrbhMFOlN3y6Xg== X-Google-Smtp-Source: AIpwx497hiu/E0EMZcjq4mdpAhpvNbTlB61jsdZOr4E4esmz/8YZgDRYxISeaW2KMXRBExMaIrIPNg== X-Received: by 10.80.153.83 with SMTP id l19mr34502483edb.179.1524584671957; Tue, 24 Apr 2018 08:44:31 -0700 (PDT) Received: from trondheim.voo.be ([2a02:2788:7d4:17f1::2]) by smtp.googlemail.com with ESMTPSA id g59sm8775214ede.60.2018.04.24.08.44.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 08:44:30 -0700 (PDT) From: Mathieu Xhonneux To: netdev@vger.kernel.org Cc: dlebrun@google.com, alexei.starovoitov@gmail.com Subject: [PATCH net-next v2 0/5] ipv6: sr: introduce seg6local End.BPF action Date: Tue, 24 Apr 2018 18:44:11 +0100 Message-Id: X-Mailer: git-send-email 2.16.1 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org As of Linux 4.14, it is possible to define advanced local processing for IPv6 packets with a Segment Routing Header through the seg6local LWT infrastructure. This LWT implements the network programming principles defined in the IETF “SRv6 Network Programming” draft. The implemented operations are generic, and it would be very interesting to be able to implement user-specific seg6local actions, without having to modify the kernel directly. To do so, this patchset adds an End.BPF action to seg6local, powered by some specific Segment Routing-related helpers, which provide SR functionalities that can be applied on the packet. This BPF hook would then allow to implement specific actions at native kernel speed such as OAM features, advanced SR SDN policies, SRv6 actions like Segment Routing Header (SRH) encapsulation depending on the content of the packet, etc ... This patchset is divided in 5 patches, whose main features are : - A new seg6local action End.BPF with the corresponding new BPF program type BPF_PROG_TYPE_LWT_SEG6LOCAL. Such attached BPF program can be passed to the LWT seg6local through netlink, the same way as the LWT BPF hook operates. - 3 new BPF helpers for the seg6local BPF hook, allowing to edit/grow/ shrink a SRH and apply on a packet some of the generic SRv6 actions. - 1 new BPF helper for the LWT BPF IN hook, allowing to add a SRH through encapsulation (via IPv6 encapsulation or inlining if the packet contains already an IPv6 header). As this patchset adds a new LWT BPF hook, I took into account the result of the discussions when the LWT BPF infrastructure got merged. Hence, the seg6local BPF hook doesn’t allow write access to skb->data directly, only the SRH can be modified through specific helpers, which ensures that the integrity of the packet is maintained. More details are available in the related patches messages. The performances of this BPF hook have been assessed with the BPF JIT enabled on a Intel Xeon X3440 processors with 4 cores and 8 threads clocked at 2.53 GHz. No throughput losses are noted with the seg6local BPF hook when the BPF program does nothing (440kpps). Adding a 8-bytes TLV (1 call each to bpf_lwt_seg6_adjust_srh and bpf_lwt_seg6_store_bytes) drops the throughput to 410kpps, and inlining a SRH via bpf_lwt_seg6_action drops the throughput to 420kpps. All throughputs are stable. ------- v2: move the SRH integrity state from skb->cb to a per-cpu buffer Thanks. Mathieu Xhonneux (5): ipv6: sr: export function lookup_nexthop bpf: Add IPv6 Segment Routing helpers bpf: Split lwt inout verifier structures ipv6: sr: Add seg6local action End.BPF selftests/bpf: test for seg6local End.BPF action include/linux/bpf_types.h | 4 +- include/net/seg6.h | 3 +- include/net/seg6_local.h | 32 ++ include/uapi/linux/bpf.h | 58 ++- include/uapi/linux/seg6_local.h | 3 + kernel/bpf/verifier.c | 1 + net/core/filter.c | 375 +++++++++++++++--- net/ipv6/seg6_local.c | 176 ++++++++- tools/include/uapi/linux/bpf.h | 59 ++- tools/testing/selftests/bpf/Makefile | 6 +- tools/testing/selftests/bpf/bpf_helpers.h | 13 +- tools/testing/selftests/bpf/test_lwt_seg6local.c | 438 ++++++++++++++++++++++ tools/testing/selftests/bpf/test_lwt_seg6local.sh | 140 +++++++ 13 files changed, 1234 insertions(+), 74 deletions(-) create mode 100644 include/net/seg6_local.h create mode 100644 tools/testing/selftests/bpf/test_lwt_seg6local.c create mode 100755 tools/testing/selftests/bpf/test_lwt_seg6local.sh