-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
Maintainer: @feckert
Environment: openwrt 21.02.3 mwan3 2.10.13-1
Description:
I am using mwan3 between a 6in4 tunnel (HE) with a static prefix and my ISPs dynamic ipv6 delegation. My hosts use addresses from the 6in4 tunnel prefix, but when it's available they go out the cable modem interface after being translated to the dynamic delegation via NETMAP. This allows me to accept incoming connections via static ipv6 addresses, but still use my ISPs native dynamic delegation for outgoing connections. This is actually working great, but I have noticed an odd problem.
Incoming connections from the 6in4 tunnel are not triggering the mwan3_iface_in rules:
Chain mwan3_iface_in_hurricane (1 references)
pkts bytes target prot opt in out source destination
0 0 MARK all 6in4-hurricane * ::/0 ::/0 match-set mwan3_connected src mark match 0x0/0x3f00 /* default */ MARK or 0x3f00
0 0 MARK all 6in4-hurricane * ::/0 ::/0 mark match 0x0/0x3f00 /* hurricane */ MARK xset 0x400/0x3f00
I added some logging at the top of the mwan3_hook chain to take a look at the incoming packets from the 6in4 tunnel and noticed that the packets had already been marked with 0x3f00 which was causing them to bypass most of the mwan3 rules.
kern.debug kernel: [30491.841853] MWAN3(debug)IN=6in4-hurricane OUT= MAC= SRC=2600:xxxx:xxxx:xxxx:0000:0000:0000:0001 DST=2001:xxxx:xxxx:0000:0000:0000:0000:3156 LEN=104 TC=0 HOPLIMIT=55 FLOWLBL=130007 PROTO=ICMPv6 TYPE=128 CODE=0 ID=11559 SEQ=0 MARK=0x3f00
Where was this mark coming from? The logging was happening before any rules in the ipv6 mangle table marked packets. The only place I could think of was the ipv4 mangle table. Was it somehow carrying the mark over from when it came in the ipv4 interface. To test this I inserted a rule to the ipv4 mwan3_hook table excluding anything incoming from the 6in4 tunnel endpoint.
iptables -t mangle -I mwan3_hook -i bond0.5 -s 184.105.250.46 -j RETURN
Immediately incoming ipv6 connections start hitting the mwan3_iface_in rule:
Chain mwan3_iface_in_hurricane (1 references)
pkts bytes target prot opt in out source destination
0 0 MARK all 6in4-hurricane * ::/0 ::/0 match-set mwan3_connected src mark match 0x0/0x3f00 /* default */ MARK or 0x3f00
9 936 MARK all 6in4-hurricane * ::/0 ::/0 mark match 0x0/0x3f00 /* hurricane */ MARK xset 0x400/0x3f00
and the mark is gone:
kern.debug kernel: [31785.307303] MWAN3(debug)IN=6in4-hurricane OUT= MAC= SRC=2600:xxxx:xxxx:xxxx:0000:0000:0000:0001 DST=2001:xxxx:xxxx:0000:0000:0000:0000:3156 LEN=104 TC=0 HOPLIMIT=55 FLOWLBL=130007 PROTO=ICMPv6 TYPE=128 CODE=0 ID=57133 SEQ=7
Is this expected behavior for netfilter? A mark made to a 6in4 packet in the ipv4 mangle table would automatically translate to the ipv6 mangle table? I'm pretty sure that's what I'm seeing. If it is expected behavior what can be done to deal with this in mwan3?
My setup is still working because the packets just go to the main table and get routed out properly from that. I could see this behavior causing problems though.