Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7FBFC54EE9 for ; Fri, 16 Sep 2022 11:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229750AbiIPLsG (ORCPT ); Fri, 16 Sep 2022 07:48:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbiIPLsF (ORCPT ); Fri, 16 Sep 2022 07:48:05 -0400 Received: from mail.netfilter.org (mail.netfilter.org [217.70.188.207]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7C59BAE9CC for ; Fri, 16 Sep 2022 04:48:02 -0700 (PDT) From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Subject: [PATCH nf-next,RFC 0/1] nf_tables inner match support Date: Fri, 16 Sep 2022 13:47:53 +0200 Message-Id: <20220916114754.31913-1-pablo@netfilter.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Hi, This is an early RFC to show progress on the inner match support, which allows to match on inner header fields that are usually encapsulated by tunnel protocols. The inner expression provides a parser for the tunneled packet which uses a userspace description of the expected inner headers, then the inner expression (only payload supported at this stage) is used to match on the inner header protocol fields, using the new link, network and transport offsets. Only VxLAN is supported in this patchset, I have work-in-progress with other type of tunnel protocols, such as IPIP and GRE. Currently nft generated bytecode to match on ethernet link layer and IPv4/IPv6 header fields. More work in userspace is required to generalize protocol tracking and implicit dependencies by reusing the existing codebase. Matching on VxLAN containing a VLAN frame is also broken, for the same reason. Maybe VxLAN containing VLAN is not top priority to support at this stage, but the goal is to allow for such flexibility by allowing users to fetch this new feature via userspace tool update. As an example, the bytecode that nft generates using this new expression looks like this: # nft --debug=netlink add rule x y udp dport 7777 vxlan ip saddr 1.2.3.4 ip x y [ meta load l4proto => reg 1 ] [ cmp eq reg 1 0x00000011 ] [ payload load 2b @ transport header + 2 => reg 1 ] [ cmp eq reg 1 0x0000611e ] [ inner hdrsize 8 flags f type 1 nfproto 2 [ payload load 4b @ network header + 12 => reg 1 ] ] [ cmp eq reg 1 0x04030201 ] Comments welcome. Pablo Neira Ayuso (1): netfilter: nft_inner: support for inner header matching include/net/netfilter/nf_tables.h | 5 + include/net/netfilter/nf_tables_core.h | 22 ++ include/uapi/linux/netfilter/nf_tables.h | 27 ++ net/netfilter/Makefile | 2 +- net/netfilter/nf_tables_api.c | 37 +++ net/netfilter/nf_tables_core.c | 1 + net/netfilter/nft_inner.c | 303 +++++++++++++++++++++++ net/netfilter/nft_payload.c | 113 ++++++++- 8 files changed, 508 insertions(+), 2 deletions(-) create mode 100644 net/netfilter/nft_inner.c -- 2.30.2