From patchwork Fri Apr 13 12:36:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Westphal X-Patchwork-Id: 897932 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@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=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=strlen.de Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40My6x5ng3z9s27 for ; Fri, 13 Apr 2018 22:40:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754608AbeDMMkj (ORCPT ); Fri, 13 Apr 2018 08:40:39 -0400 Received: from Chamillionaire.breakpoint.cc ([146.0.238.67]:36878 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754037AbeDMMki (ORCPT ); Fri, 13 Apr 2018 08:40:38 -0400 Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.89) (envelope-from ) id 1f6y0K-0006Gz-WA; Fri, 13 Apr 2018 14:40:37 +0200 From: Florian Westphal To: Cc: Florian Westphal Subject: [PATCH nft] src: rename ibrportname, obrportname Date: Fri, 13 Apr 2018 14:36:32 +0200 Message-Id: <20180413123632.18547-1-fw@strlen.de> X-Mailer: git-send-email 2.16.1 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org For bridge, iifname is the port name, whereas 'ibrport' is the logical name of the bridge ("br0") the port ("iifname") is enslaved to. So, 'ibrport' is a misnomer. libnftl calls these 'bri_iifname' and 'bri_oifname', which is good but using 'briiifname' in nft is rather ugly, so use 'ibridgename' and 'obridgename' instead. Old names are still recognized, listing shows the new names. Signed-off-by: Florian Westphal --- doc/nft.xml | 8 ++++---- src/meta.c | 15 +++++++++++++-- src/parser_bison.y | 2 ++ src/scanner.l | 2 ++ tests/py/bridge/meta.t | 6 ++++++ tests/py/bridge/meta.t.payload | 10 ++++++++++ tests/py/inet/meta.t | 2 ++ tests/py/ip/meta.t | 3 +++ 8 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 tests/py/bridge/meta.t create mode 100644 tests/py/bridge/meta.t.payload diff --git a/doc/nft.xml b/doc/nft.xml index 88d39415820c..47e106900d35 100644 --- a/doc/nft.xml +++ b/doc/nft.xml @@ -2738,8 +2738,8 @@ filter output icmpv6 type { echo-request, echo-reply } skgid nftrace rtclassid - ibriport - obriport + ibridgename + obridgename pkttype cpu iifgroup @@ -2853,12 +2853,12 @@ filter output icmpv6 type { echo-request, echo-reply } realm - ibriport + ibridgename Input bridge interface name ifname - obriport + obridgename Output bridge interface name ifname diff --git a/src/meta.c b/src/meta.c index 11de2dab8b9b..f80109641757 100644 --- a/src/meta.c +++ b/src/meta.c @@ -413,10 +413,10 @@ static const struct meta_template meta_templates[] = { 1 , BYTEORDER_HOST_ENDIAN), [NFT_META_RTCLASSID] = META_TEMPLATE("rtclassid", &realm_type, 4 * 8, BYTEORDER_HOST_ENDIAN), - [NFT_META_BRI_IIFNAME] = META_TEMPLATE("ibriport", &ifname_type, + [NFT_META_BRI_IIFNAME] = META_TEMPLATE("ibridgename", &ifname_type, IFNAMSIZ * BITS_PER_BYTE, BYTEORDER_HOST_ENDIAN), - [NFT_META_BRI_OIFNAME] = META_TEMPLATE("obriport", &ifname_type, + [NFT_META_BRI_OIFNAME] = META_TEMPLATE("obridgename", &ifname_type, IFNAMSIZ * BITS_PER_BYTE, BYTEORDER_HOST_ENDIAN), [NFT_META_PKTTYPE] = META_TEMPLATE("pkttype", &pkttype_type, @@ -451,6 +451,8 @@ static bool meta_key_is_qualified(enum nft_meta_keys key) case NFT_META_PRIORITY: case NFT_META_PRANDOM: case NFT_META_SECPATH: + case NFT_META_BRI_IIFNAME: + case NFT_META_BRI_OIFNAME: return true; default: return false; @@ -652,6 +654,15 @@ struct error_record *meta_key_parse(const struct location *loc, return NULL; } + /* Backwards compat hack */ + if (strcmp(str, "ibriport") == 0) { + *value = NFT_META_BRI_IIFNAME; + return NULL; + } else if (strcmp(str, "obriport") == 0) { + *value = NFT_META_BRI_OIFNAME; + return NULL; + } + len = (int)sizeof(buf); size = sizeof(buf); diff --git a/src/parser_bison.y b/src/parser_bison.y index f1617eeaf149..ab758cbe86ab 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -395,6 +395,8 @@ int nft_lex(void *, void *, void *); %token RTCLASSID "rtclassid" %token IBRIPORT "ibriport" %token OBRIPORT "obriport" +%token IBRIDGENAME "ibridgename" +%token OBRIDGENAME "obridgename" %token PKTTYPE "pkttype" %token CPU "cpu" %token IIFGROUP "iifgroup" diff --git a/src/scanner.l b/src/scanner.l index d908a8fefc4f..bb77f3d08d2b 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -486,7 +486,9 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) "nftrace" { return NFTRACE; } "rtclassid" { return RTCLASSID; } "ibriport" { return IBRIPORT; } +"ibridgename" { return IBRIDGENAME; } "obriport" { return OBRIPORT; } +"obridgename" { return OBRIDGENAME; } "pkttype" { return PKTTYPE; } "cpu" { return CPU; } "iifgroup" { return IIFGROUP; } diff --git a/tests/py/bridge/meta.t b/tests/py/bridge/meta.t new file mode 100644 index 000000000000..ed373677a442 --- /dev/null +++ b/tests/py/bridge/meta.t @@ -0,0 +1,6 @@ +:input;type filter hook input priority 0 + +*bridge;test-bridge;input + +meta obridgename "br0";ok;meta obridgename "br0" +meta ibridgename "br0";ok;meta ibridgename "br0" diff --git a/tests/py/bridge/meta.t.payload b/tests/py/bridge/meta.t.payload new file mode 100644 index 000000000000..2728c0a5026d --- /dev/null +++ b/tests/py/bridge/meta.t.payload @@ -0,0 +1,10 @@ +# meta obridgename "br0" +bridge test-bridge input + [ meta load bri_oifname => reg 1 ] + [ cmp eq reg 1 0x00307262 0x00000000 0x00000000 0x00000000 ] + +# meta ibridgename "br0" +bridge test-bridge input + [ meta load bri_iifname => reg 1 ] + [ cmp eq reg 1 0x00307262 0x00000000 0x00000000 0x00000000 ] + diff --git a/tests/py/inet/meta.t b/tests/py/inet/meta.t index d68896dc0b9e..cfde9f32babe 100644 --- a/tests/py/inet/meta.t +++ b/tests/py/inet/meta.t @@ -14,3 +14,5 @@ meta nfproto ipv6 meta l4proto tcp;ok;meta nfproto ipv6 meta l4proto 6 meta nfproto ipv4 counter ip saddr 1.2.3.4;ok meta secpath exists;ok meta secpath missing;ok +meta ibridgename "br0";fail +meta obridgename "br0";fail diff --git a/tests/py/ip/meta.t b/tests/py/ip/meta.t index d0682adf1366..c3afae79314c 100644 --- a/tests/py/ip/meta.t +++ b/tests/py/ip/meta.t @@ -7,3 +7,6 @@ meta l4proto icmp icmp type echo-request;ok;icmp type echo-request meta l4proto ipv6-icmp icmpv6 type nd-router-advert;ok;icmpv6 type nd-router-advert meta l4proto 58 icmpv6 type nd-router-advert;ok;icmpv6 type nd-router-advert icmpv6 type nd-router-advert;ok + +meta ibridgename "br0";fail +meta obridgename "br0";fail