diff options
author | Phil Sutter <phil@nwl.cc> | 2022-09-27 23:19:34 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2022-09-28 18:25:10 +0200 |
commit | aa0b8b03f7c7e741ccd96360bd64d90ea8c3c3aa (patch) | |
tree | 9e32cb4a2f606a99f17edf73d832d4e7b6d8ce76 /extensions | |
parent | 8dc22798bf813ce92aaac58a6fe8749fe3fc18dc (diff) |
ebtables: Support '-p Length'
To match on Ethernet frames using the etherproto field as length value,
ebtables accepts the special protocol name "LENGTH". Implement this in
ebtables-nft using a native match for 'ether type < 0x0600'.
Since extension 802_3 matches are valid only with such Ethernet frames,
add a local add_match() wrapper which complains if the extension is used
without '-p Length' parameter. Legacy ebtables does this within the
extension's final_check callback, but it's not possible here due for lack of
fw->bitmask field access.
While being at it, add xlate support, adjust tests and make ebtables-nft
print the case-insensitive argument with capital 'L' like legacy
ebtables does.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/generic.txlate | 6 | ||||
-rw-r--r-- | extensions/libebt_802_3.t | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/extensions/generic.txlate b/extensions/generic.txlate index 9ae9a5b5..6779d6f8 100644 --- a/extensions/generic.txlate +++ b/extensions/generic.txlate @@ -67,6 +67,12 @@ nft add rule bridge filter FORWARD iifname != "iname" meta ibrname "ilogname" oi ebtables-translate -I INPUT -p ip -d 1:2:3:4:5:6/ff:ff:ff:ff:00:00 nft insert rule bridge filter INPUT ether type 0x800 ether daddr 01:02:03:04:00:00 and ff:ff:ff:ff:00:00 == 01:02:03:04:00:00 counter +ebtables-translate -I INPUT -p Length +nft insert rule bridge filter INPUT ether type < 0x0600 counter + +ebtables-translate -I INPUT -p ! Length +nft insert rule bridge filter INPUT ether type >= 0x0600 counter + # asterisk is not special in iptables and it is even a valid interface name iptables-translate -A FORWARD -i '*' -o 'eth*foo' nft add rule ip filter FORWARD iifname "\*" oifname "eth\*foo" counter diff --git a/extensions/libebt_802_3.t b/extensions/libebt_802_3.t index ddfb2f0a..a138f35d 100644 --- a/extensions/libebt_802_3.t +++ b/extensions/libebt_802_3.t @@ -1,3 +1,5 @@ :INPUT,FORWARD,OUTPUT ---802_3-sap ! 0x0a -j CONTINUE;=;OK ---802_3-type 0x000a -j RETURN;=;OK +--802_3-sap ! 0x0a -j CONTINUE;=;FAIL +--802_3-type 0x000a -j RETURN;=;FAIL +-p Length --802_3-sap ! 0x0a -j CONTINUE;=;OK +-p Length --802_3-type 0x000a -j RETURN;=;OK |