Skip to contentSkip to conversation

doc: nft.8: Mention wildcard interface matching

PATCH In review Phil Sutter 2 participants 4 messages Feb 10, 2020 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH v2 1/2 doc: nft.8: Mention wildcard interface matching

Special meaning of asterisk in interface names wasn't described anywhere.

---
Changes since v1:
- Generalize sentence about escaping for literal asterisk character.

---
 doc/primary-expression.txt | 7 +++++++
 1 file changed, 7 insertions(+)
doc/primary-expression.txt +7 -0
index 94eccc20241a2..b5488790360dc 100644
@@ -36,6 +36,13 @@ add such a rule, it will stop matching if the interface gets renamed and it
 will match again in case interface gets deleted and later a new interface
 with the same name is created.
 
+Like with iptables, wildcard matching on interface name prefixes is available for
+*iifname* and *oifname* matches by appending an asterisk (*) character. Note
+however that unlike iptables, nftables does not accept interface names
+consisting of the wildcard character only - users are supposed to just skip
+those always matching expressions. In order to match on literal asterisk
+character, one may escape it using backslash (\).
+
 .Meta expression types
 [options="header"]
 |==================
Signature · 1 line
2.24.1
author reviewer
#1 lore raw

PATCH v2 2/2 scanner: Extend asteriskstring definition

Accept escaped asterisks also mid-string and as only character. Especially the latter will help when translating from iptables where asterisk has no special meaning.

---
Changes since v1:
- Still reject unescaped asterisks mid-string.

---
 src/scanner.l | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/scanner.l +1 -1
index 99ee83559d2eb..20a59de51d1ff 100644
@@ -120,7 +120,7 @@ numberstring	({decstring}|{hexstring})
 letter		[a-zA-Z]
 string		({letter}|[_.])({letter}|{digit}|[/\-_\.])*
 quotedstring	\"[^"]*\"
-asteriskstring	({string}\*|{string}\\\*)
+asteriskstring	({string}\*|{string}\\\*|\\\*|{string}\\\*{string})
 comment		#.*$
 slash		\/
 
Signature · 1 line
2.24.1
#2 lore raw

Re: [nft PATCH v2 2/2] scanner: Extend asteriskstring definition

Quoted 3 lines · Phil Sutter

Accept escaped asterisks also mid-string and as only character. Especially the latter will help when translating from iptables where asterisk has no special meaning.

Fine with me, thanks.