doc: nft.8: Mention wildcard interface matching
Phil Sutter
reviewerPATCH 1/2 doc: nft.8: Mention wildcard interface matching
Special meaning of asterisk in interface names wasn't described anywhere.
--- doc/primary-expression.txt | 7 +++++++ 1 file changed, 7 insertions(+)
doc/primary-expression.txt +7 -0
@@ -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 at end of interface name, one may escape it using backslash (\). + .Meta expression types [options="header"] |==================
Signature · 1 line
2.24.1
Phil Sutter
reviewerPATCH 2/2 scanner: Extend asteriskstring definition
Accept sole escaped asterisks as well as unescaped asterisks if surrounded by strings. The latter is merely cosmetic, but literal asterisk will help when translating from iptables where asterisk has no special meaning.
--- src/scanner.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/scanner.l +1 -1
@@ -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
Pablo Neira Ayuso
maintainerRe: [nft PATCH 2/2] scanner: Extend asteriskstring definition
Quoted 15 lines · Phil Sutter
Accept sole escaped asterisks as well as unescaped asterisks if surrounded by strings. The latter is merely cosmetic, but literal asterisk will help when translating from iptables where asterisk has no special meaning.
Signed-off-by Phil Sutter <[email protected]>--- src/scanner.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/scanner.l +0
-0
src/scanner.l numberstring ({decstring}|{hexstring}) · line 123
Quoted 5 lines
src/scanner.l +1
-1@@ -120,7 +120,7 @@ numberstring ({decstring}|{hexstring}) letter [a-zA-Z] string ({letter}|[_.])({letter}|{digit}|[/\-_\.])* quotedstring \"[^"]*\" -asteriskstring ({string}\*|{string}\\\*) +asteriskstring ({string}\*|{string}\\\*|\\\*|{string}\*{string})
Probably this:
{string}\\\*{string})instead of:
{string}\*{string})?
The escaping makes it probably clear that there is no support for infix wildcard matching?
This asteriskstring rule is falling under the string rule in bison. This is allowing to use \\\* for log messages too, and elsewhere.
Phil Sutter
reviewerRe: [nft PATCH 2/2] scanner: Extend asteriskstring definition
Hi Pablo,
Quoted 26 lines · Pablo Neira Ayuso
Quoted 15 lines · Phil Sutter
Accept sole escaped asterisks as well as unescaped asterisks if surrounded by strings. The latter is merely cosmetic, but literal asterisk will help when translating from iptables where asterisk has no special meaning.
Signed-off-by Phil Sutter <[email protected]>--- src/scanner.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/scanner.l +0
-0src/scanner.l numberstring ({decstring}|{hexstring}) · line 123
Quoted 5 lines
src/scanner.l +1
-1@@ -120,7 +120,7 @@ numberstring ({decstring}|{hexstring}) letter [a-zA-Z] string ({letter}|[_.])({letter}|{digit}|[/\-_\.])* quotedstring \"[^"]*\" -asteriskstring ({string}\*|{string}\\\*) +asteriskstring ({string}\*|{string}\\\*|\\\*|{string}\*{string})Probably this:
{string}\\\*{string})
Quoted 8 lines
instead of:
{string}\*{string})?
The escaping makes it probably clear that there is no support for infix wildcard matching?
Ah, you're right. I assumed it wasn't necessary to escape the asterisk mid-string, but if we ever added support for infix wildcards (no matter how unlikely) we were in real trouble.
BTW: Given how confusing bison-generated error messages are, maybe I should introduce "infixasteriskstring" in scanner.l to catch unescaped infix asterisks and generate a readable error message from there?
Quoted 2 lines
This asteriskstring rule is falling under the string rule in bison. This is allowing to use \\\* for log messages too, and elsewhere.
Ah, that's right. Good, bad, ugly? Just a "neutral remark" from you? :)
Thanks, Phil
Pablo Neira Ayuso
maintainerRe: [nft PATCH 2/2] scanner: Extend asteriskstring definition
Quoted 33 lines · Phil Sutter
Hi Pablo,
Quoted 30 lines · Pablo Neira Ayuso
Quoted 15 lines · Phil Sutter
Accept sole escaped asterisks as well as unescaped asterisks if surrounded by strings. The latter is merely cosmetic, but literal asterisk will help when translating from iptables where asterisk has no special meaning.
Signed-off-by Phil Sutter <[email protected]>--- src/scanner.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/scanner.l +0
-0src/scanner.l numberstring ({decstring}|{hexstring}) · line 123
Quoted 5 lines
src/scanner.l +1
-1@@ -120,7 +120,7 @@ numberstring ({decstring}|{hexstring}) letter [a-zA-Z] string ({letter}|[_.])({letter}|{digit}|[/\-_\.])* quotedstring \"[^"]*\" -asteriskstring ({string}\*|{string}\\\*) +asteriskstring ({string}\*|{string}\\\*|\\\*|{string}\*{string})Probably this:
{string}\\\*{string})instead of:
{string}\*{string})
Quoted 8 lines
Quoted 4 lines
?
The escaping makes it probably clear that there is no support for infix wildcard matching?
Ah, you're right. I assumed it wasn't necessary to escape the asterisk mid-string, but if we ever added support for infix wildcards (no matter how unlikely) we were in real trouble.
Yes, I don't expect mid-string matching in the future, but you never know, so better reserve this just in case :-)
Quoted 3 lines
BTW: Given how confusing bison-generated error messages are, maybe I should introduce "infixasteriskstring" in scanner.l to catch unescaped infix asterisks and generate a readable error message from there?
bison syntax error reporting is not great, yes. If you think that makes it easier for error reporting as a short term way to address the issue, that's fine with me.
Quoted 4 lines
Quoted 2 lines
This asteriskstring rule is falling under the string rule in bison. This is allowing to use \\\* for log messages too, and elsewhere.
Ah, that's right. Good, bad, ugly? Just a "neutral remark" from you? :)
Just a remark, no issue.
Phil Sutter
reviewerRe: [nft PATCH 2/2] scanner: Extend asteriskstring definition
Hi Pablo,
On Sun, Feb 09, 2020 at 11:21:43PM +0100, Pablo Neira Ayuso wrote:
[...]
Quoted 2 lines
Yes, I don't expect mid-string matching in the future, but you never know, so better reserve this just in case :-)
DONE, please see v2 I just sent.
Quoted 7 lines
Quoted 3 lines
BTW: Given how confusing bison-generated error messages are, maybe I should introduce "infixasteriskstring" in scanner.l to catch unescaped infix asterisks and generate a readable error message from there?
bison syntax error reporting is not great, yes. If you think that makes it easier for error reporting as a short term way to address the issue, that's fine with me.
Tried, but didn't go well - proper error reporting is best put into parser_bison, but there one can't complain about mid-string asterisk "anywhere" but only in defined places. So in others the then known token will make error messages even more confusing.
Cheers, Phil