All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiao Liang <shaw.leon@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft] fib: Change data type of fib oifname to "ifname"
Date: Tue, 25 Feb 2025 18:02:17 +0800	[thread overview]
Message-ID: <20250225100220.18931-1-shaw.leon@gmail.com> (raw)

Change data type of fib oifname from "string" to "ifname", so that it
can be matched against a set of ifnames:

    set x {
            type ifname
    }
    chain y {
            fib saddr oifname @x drop
    }

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
---
 doc/primary-expression.txt                                    | 4 ++--
 src/fib.c                                                     | 2 +-
 tests/shell/testcases/sets/0029named_ifname_dtype_0           | 1 +
 tests/shell/testcases/sets/dumps/0029named_ifname_dtype_0.nft | 1 +
 4 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/doc/primary-expression.txt b/doc/primary-expression.txt
index c6a33bbe..40aca3d3 100644
--- a/doc/primary-expression.txt
+++ b/doc/primary-expression.txt
@@ -354,10 +354,10 @@ address types can be shown with *nft* *describe* *fib_addrtype*.
 |Keyword| Description| Result Type
 |oif|
 Output interface index|
-integer (32 bit)
+iface_index
 |oifname|
 Output interface name|
-string
+ifname
 |type|
 Address type |
 fib_addrtype (see *nft* *describe* *fib_addrtype* for a list)
diff --git a/src/fib.c b/src/fib.c
index e95271c9..5a7c1170 100644
--- a/src/fib.c
+++ b/src/fib.c
@@ -179,7 +179,7 @@ struct expr *fib_expr_alloc(const struct location *loc,
 		type = &ifindex_type;
 		break;
 	case NFT_FIB_RESULT_OIFNAME:
-		type = &string_type;
+		type = &ifname_type;
 		len = IFNAMSIZ * BITS_PER_BYTE;
 		break;
 	case NFT_FIB_RESULT_ADDRTYPE:
diff --git a/tests/shell/testcases/sets/0029named_ifname_dtype_0 b/tests/shell/testcases/sets/0029named_ifname_dtype_0
index 2dbcd22b..ea581406 100755
--- a/tests/shell/testcases/sets/0029named_ifname_dtype_0
+++ b/tests/shell/testcases/sets/0029named_ifname_dtype_0
@@ -40,6 +40,7 @@ EXPECTED="table inet t {
 	chain c {
 		iifname @s accept
 		oifname @s accept
+		fib saddr oifname @s accept
 		tcp dport . meta iifname @sc accept
 		meta iifname . meta mark @nv accept
 	}
diff --git a/tests/shell/testcases/sets/dumps/0029named_ifname_dtype_0.nft b/tests/shell/testcases/sets/dumps/0029named_ifname_dtype_0.nft
index 55cd4f26..6f9832a9 100644
--- a/tests/shell/testcases/sets/dumps/0029named_ifname_dtype_0.nft
+++ b/tests/shell/testcases/sets/dumps/0029named_ifname_dtype_0.nft
@@ -51,6 +51,7 @@ table inet t {
 	chain c {
 		iifname @s accept
 		oifname @s accept
+		fib saddr oifname @s accept
 		tcp dport . iifname @sc accept
 		iifname . meta mark @nv accept
 	}
-- 
2.48.1


             reply	other threads:[~2025-02-25 10:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25 10:02 Xiao Liang [this message]
2025-02-25 18:45 ` [PATCH nft] fib: Change data type of fib oifname to "ifname" Florian Westphal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250225100220.18931-1-shaw.leon@gmail.com \
    --to=shaw.leon@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.