Skip to contentSkip to conversation

netfilter: nftables: fix documentation for dup statement

PATCH In review Quentin Armitage 4 participants 7 messages Aug 27, 2020 – Sep 3, 2020 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: nftables: fix documentation for dup statement

The dup statement requires an address, and the device is optional, not the other way round.

---
 doc/statements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doc/statements.txt +0 -0
index 9155f286..835db087 100644
@@ -648,7 +648,7 @@ The dup statement is used to duplicate a packet and send the

copy to a different
destination.

[verse]
-*dup to* 'device'
+*dup to* 'address'
*dup to* 'address' *device* 'device'

.Dup statement values

Signature · 1 line
2.25.4
reviewer
#1 lore raw

Hi,

Quoted 17 lines · Quentin Armitage

The dup statement requires an address, and the device is optional, not the other way round.

---
 doc/statements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doc/statements.txt +0 -0
index 9155f286..835db087 100644
@@ -648,7 +648,7 @@ The dup statement is used to duplicate a packet and send the

copy to a different
destination.

[verse]

doc/statements.txt

Quoted 5 lines
doc/statements.txt +1 -1
-*dup to* 'device'
+*dup to* 'address'
 *dup to* 'address' *device* 'device'
 
 .Dup statement values

The examples are wrong, too. I wonder if this is really just a mistake and all three examples given (including the "advanced" usage using a map) are just wrong or if 'dup' actually was meant to support duplicating to a device in mirror port fashion.

Florian, you wrote the docs. What's your take here?

Thanks, Phil

maintainer
#2 lore raw
Quoted 24 lines · Phil Sutter

Hi,

Quoted 21 lines · Quentin Armitage

The dup statement requires an address, and the device is optional, not the other way round.

---
 doc/statements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doc/statements.txt +0 -0
index 9155f286..835db087 100644
@@ -648,7 +648,7 @@ The dup statement is used to duplicate a packet and send the

copy to a different
destination.

[verse]

doc/statements.txt +1 -1
-*dup to* 'device'
+*dup to* 'address'
 *dup to* 'address' *device* 'device'
Quoted 6 lines
Quoted 1 line

.Dup statement values

The examples are wrong, too. I wonder if this is really just a mistake and all three examples given (including the "advanced" usage using a map) are just wrong or if 'dup' actually was meant to support duplicating to a device in mirror port fashion.

Right, 'dup to eth0' can be used in the netdev ingress hook.

For dup from ipv4/ipv6 families the address is needed.

#3 lore raw
Quoted 35 lines · Florian Westphal
Quoted 27 lines · Phil Sutter

Hi,

Quoted 24 lines · Quentin Armitage

The dup statement requires an address, and the device is optional, not the other way round.

Signed-off-by: Quentin Armitage <
[email protected]

Quoted 1 line
---
 doc/statements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doc/statements.txt +0 -0
index 9155f286..835db087 100644
@@ -648,7 +648,7 @@ The dup statement is used to duplicate a packet and

send the
copy to a different
destination.

[verse]

doc/statements.txt +1 -1
-*dup to* 'device'
+*dup to* 'address'
 *dup to* 'address' *device* 'device'
Quoted 6 lines
Quoted 1 line

.Dup statement values

The examples are wrong, too. I wonder if this is really just a mistake and all three examples given (including the "advanced" usage using a map) are just wrong or if 'dup' actually was meant to support duplicating to a device in mirror port fashion.

Quoted 3 lines

Right, 'dup to eth0' can be used in the netdev ingress hook.

For dup from ipv4/ipv6 families the address is needed.

So it seems the valid options are:
*dup to* 'device' # netdev ingress hook only
*dup to* 'address' # ipv4/ipv6 only
*dup to* 'address' *device* 'device' # ipv4/ipv6 only

From a user perspective being able to specify "dup to 'device'" is something that is useful to be able to specify. I am now using:
dup to ip[6] daddr device 'device'
but it seems to me that having to specify "to ip[6] daddr" is unnecessary.

So far as I can see, it would be quite straightforward to allow "dup to 'device'" to be specified and for nft to handle it with an implied "to ip[6] addr". I am happy to produce a patch to do this if it would be helpful.

I am also happy to submit a revised patch for statements.txt if that would be useful.

Quentin Armitage

reviewer
#4 lore raw

Hi Quentin,

Quoted 45 lines · Quentin Armitage
Quoted 35 lines · Florian Westphal
Quoted 27 lines · Phil Sutter

Hi,

Quoted 24 lines · Quentin Armitage

The dup statement requires an address, and the device is optional, not the other way round.

Signed-off-by: Quentin Armitage <
[email protected]

Quoted 1 line
---
 doc/statements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doc/statements.txt +0 -0
index 9155f286..835db087 100644
@@ -648,7 +648,7 @@ The dup statement is used to duplicate a packet and

send the
copy to a different
destination.

[verse]

doc/statements.txt +1 -1
-*dup to* 'device'
+*dup to* 'address'
 *dup to* 'address' *device* 'device'
Quoted 6 lines
Quoted 1 line

.Dup statement values

The examples are wrong, too. I wonder if this is really just a mistake and all three examples given (including the "advanced" usage using a map) are just wrong or if 'dup' actually was meant to support duplicating to a device in mirror port fashion.

Quoted 3 lines

Right, 'dup to eth0' can be used in the netdev ingress hook.

For dup from ipv4/ipv6 families the address is needed.

So it seems the valid options are:
*dup to* 'device' # netdev ingress hook only
*dup to* 'address' # ipv4/ipv6 only
*dup to* 'address' *device* 'device' # ipv4/ipv6 only

Quoted 4 lines

From a user perspective being able to specify "dup to 'device'" is something that is useful to be able to specify. I am now using:
dup to ip[6] daddr device 'device'
but it seems to me that having to specify "to ip[6] daddr" is unnecessary.

Oh, and that works? From reading nf_dup_ipv4.c, the kernel seems to perform a route lookup for the packet's daddr on given iface. Did you add an onlink route or something to make sure that succeeds?

Cheers, Phil

#5 lore raw

Hi Phil,

Quoted 57 lines · Phil Sutter

Hi Quentin,

Quoted 49 lines · Quentin Armitage
Quoted 39 lines · Florian Westphal

Phil Sutter <
[email protected]

Quoted 30 lines

wrote:
Hi,

Quoted 26 lines · Quentin Armitage

The dup statement requires an address, and the device is optional, not the other way round.

Signed-off-by: Quentin Armitage <
[email protected]

---
 doc/statements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doc/statements.txt +0 -0
index 9155f286..835db087 100644
@@ -648,7 +648,7 @@ The dup statement is used to duplicate a packet

and
send the
copy to a different
destination.

[verse]

doc/statements.txt +1 -1
-*dup to* 'device'
+*dup to* 'address'
 *dup to* 'address' *device* 'device'
Quoted 6 lines
Quoted 1 line

.Dup statement values

The examples are wrong, too. I wonder if this is really just a mistake and all three examples given (including the "advanced" usage using a map) are just wrong or if 'dup' actually was meant to support duplicating to a device in mirror port fashion.

Quoted 3 lines

Right, 'dup to eth0' can be used in the netdev ingress hook.

For dup from ipv4/ipv6 families the address is needed.

So it seems the valid options are:
*dup to* 'device' # netdev ingress hook only
*dup to* 'address' # ipv4/ipv6 only
*dup to* 'address' *device* 'device' # ipv4/ipv6 only

Quoted 4 lines

From a user perspective being able to specify "dup to 'device'" is something that is useful to be able to specify. I am now using:
dup to ip[6] daddr device 'device'
but it seems to me that having to specify "to ip[6] daddr" is unnecessary.

Quoted 5 lines

Oh, and that works? From reading nf_dup_ipv4.c, the kernel seems to perform a route lookup for the packet's daddr on given iface. Did you add an onlink route or something to make sure that succeeds?

Cheers, Phil

It is working for me, both with IPv4 and IPv6, and I suspect the reason is that
I am using this for multicast packets. In particular, I have a macvlan and I want to join multicast groups on the macvlan interface but I want the IGMP/MLD join group messages to be sent with the MAC address of the "parent" interface of the macvlan, and not the mac address of the macvlan itself.

The rules I am using are:

 map vmac_map {
	type iface_index : iface_index
	elements = { "macvlan0" : "eth0" }

}

ip protocol igmp dup to ip daddr device oif map @vmac_map drop
and
icmpv6 type mld2-listener-report dup to ip6 daddr device oif map @vmac_map drop

With many thanks for your help,

Quentin

#6 lore raw
In reply to Quentin Armitage

Hi Quentin,

Thanks for your patch:

Quoted 3 lines · Quentin Armitage

The dup statement requires an address, and the device is optional, not the other way round.

table netdev x {
        chain y {
                type filter hook ingress device "eth0" priority filter; policy accept;
                ip protocol udp dup to "eth1"
        }
}

I think probably it should be good to clarify that:

- dup to 'device'
- fwd to 'device'

only work from the netdev family.

Thanks.

Quoted 23 lines
---
 doc/statements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
doc/statements.txt +0 -0
index 9155f286..835db087 100644
@@ -648,7 +648,7 @@ The dup statement is used to duplicate a packet and send the

copy to a different
destination.

[verse]

doc/statements.txt +1 -1
-*dup to* 'device'
+*dup to* 'address'
 *dup to* 'address' *device* 'device'
 
 .Dup statement values
Signature · 1 line
2.25.4