Skip to content

mwan3: fix some tunnels assigned the wrong mark#20923

Open
anyuta1166 wants to merge 3 commits intoopenwrt:masterfrom
anyuta1166:mwan3-mark-fix
Open

mwan3: fix some tunnels assigned the wrong mark#20923
anyuta1166 wants to merge 3 commits intoopenwrt:masterfrom
anyuta1166:mwan3-mark-fix

Conversation

@anyuta1166
Copy link
Contributor

The mark of underlying tunnel connection is assigned to all incoming packets inside tunnel. This breaks mwan3 routing. Attempt to fix this by clearing the mark in incoming packets. Do not touch outgoing packets to make sure that tracking and "mwan3 use" command works as expected.

Maintainer: @feckert
Compile tested: x86-64, OpenWrt master
Run tested: x86-64, OpenWrt master

Description:

There is an issue with some tunnels. The mark of underlying tunnel connection is assigned to all incoming packets inside tunnel. This breaks the routing, as replies to these packets may be sent to the wrong interface.
This applies, for example, to ipv6 tunnels (#14332 #18481), ipsec tunnels (#19607) and so on.
Fix this by resetting the mark in incoming packets.
This patch does not touch outgoing packets and doesn't break mwan3 wrapper library.

Fixes #14332 #18481 #19607

@feckert feckert self-assigned this May 3, 2023
Copy link
Contributor

@gentoo-root gentoo-root left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me (I don't have a setup with two tunnels to test it, though).

mwan3_pre and mwan3_post can be merged, both chains are identical.

bitthief added a commit to bitthief/packages that referenced this pull request May 8, 2023
bitthief added a commit to bitthief/packages that referenced this pull request May 8, 2023
bitthief added a commit to bitthief/packages that referenced this pull request May 19, 2023
bitthief added a commit to bitthief/packages that referenced this pull request May 20, 2023
bitthief added a commit to bitthief/packages that referenced this pull request May 24, 2023
bitthief added a commit to bitthief/packages that referenced this pull request May 24, 2023
openwrtdiy added a commit to openwrtdiy/packages that referenced this pull request Jul 28, 2023
bitthief added a commit to bitthief/packages that referenced this pull request Jul 28, 2023
bitthief added a commit to bitthief/packages that referenced this pull request Jul 28, 2023
Reference: 
https: //github.com/openwrt/pull/20923
Signed-off-by: bitthief <bitthief@protonmail.ch>
bitthief added a commit to bitthief/packages that referenced this pull request Aug 6, 2023
Reference: 
https: //github.com/openwrt/pull/20923
Signed-off-by: bitthief <bitthief@protonmail.ch>
bitthief added a commit to bitthief/packages that referenced this pull request Aug 11, 2023
Reference: 
https: //github.com/openwrt/pull/20923
Signed-off-by: bitthief <bitthief@protonmail.ch>
bitthief added a commit to bitthief/packages that referenced this pull request Aug 17, 2023
Reference: 
https: //github.com/openwrt/pull/20923
Signed-off-by: bitthief <bitthief@protonmail.ch>
@anyuta1166
Copy link
Contributor Author

anyuta1166 commented Aug 18, 2023

After pressing the above repair, there are a lot of errors in the system log on my side!

Your issue is not related to this PR. This PR just adds a couple of iptables rules, it doesn't touch a routing table in any way.

bitthief added a commit to bitthief/packages that referenced this pull request Sep 20, 2023
Reference: 
https: //github.com/openwrt/pull/20923
Signed-off-by: bitthief <bitthief@protonmail.ch>
@jamesmacwhite
Copy link
Contributor

@feckert Hi. Will this get merged? Seems like it solves a long standing issue?

bitthief added a commit to bitthief/packages that referenced this pull request Nov 9, 2023
Reference: 
https: //github.com/openwrt/pull/20923
Signed-off-by: bitthief <bitthief@protonmail.ch>
openwrtdiy added a commit to openwrtdiy/packages that referenced this pull request Nov 11, 2023
bitthief added a commit to bitthief/packages that referenced this pull request Nov 29, 2023
Reference: 
https: //github.com/openwrt/pull/20923
Signed-off-by: bitthief <bitthief@protonmail.ch>
@sumpfralle
Copy link
Contributor

Just for adding another anecdote: for me the problem appears for traffic reaching the router via a VXLAN interface, which is running over a wireguard tunnel (which is connected via one of the WAN interfaces).

I see the same problem: the traffic leaving the VXLAN interface is marked with 0x3f00. The traffic is erroneously routed via the WAN interface.

I applied the patch from this pull request and now the routing of traffic looks good.

Without that patch, I would be forced to separate the mwan3 setup from the tunnel setup (wireguard + VXLAN) by using two distinct OpenWrt routers for both tasks.

Thanks to @anyuta1166 for proposing the fix for this problem!

Copy link

@Lu5ck Lu5ck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it on 24.10.1. Applied the patch by manually editing the mentioned files. Confirm working for my FOU tunnel, fixed ping: sendto: Operation not permitted bug

@GeorgeSapkin
Copy link
Member

@anyuta1166 @feckert still relevant? If so this needs a PKG_RELEASE bump and all commits needs a message.

@feckert
Copy link
Member

feckert commented Dec 16, 2025

I don't have this problem in my setup. I would leave it open in case someone else has a problem. Due to lack of time, I haven't reviewed it yet.

The mark of underlying tunnel connection is assigned to all incoming packets inside tunnel. This breaks mwan3 routing. Attempt to fix this by clearing the mark in incoming packets. Do not touch outgoing packets to make sure that tracking and "mwan3 use" command works as expected.

Signed-off-by: Anna Tikhomirova <vamp@vampik.ru>
Signed-off-by: Anna Tikhomirova <vamp@vampik.ru>
The mark of outgoing connections propagates to the tunnel connection itself, which may break routing. Fix this by resetting the mark of outgoing packets after routing decision is made.

Suggested-by: Maxim Mikityanskiy <maxtram95@gmail.com>
Signed-off-by: Anna Tikhomirova <vamp@vampik.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mwan3: 2.10.x branch 50% ping loss with L2TP IPv6

8 participants