Skip to content

Conversation

@filippocarletti
Copy link

Maintainer: @feckert
Compile tested: x86-64, snapshot
Run tested: x86-64, 23.05.4

Description:
Router-initiated traffic can select the uplink to use via the mwan3 use command or the socket wrapper.
This PR adds ip rules to enable route selection using the uplink's source IP address.

Additional information:
Given that eth0.1 is the backup wan, the ping -c 1 -I eth0.1 www.google.com command used by the documentation now only works before mwan3 is configured. With this patch, it will work even after mwan3 has been configured.
See this forum thread for discussion.

@feckert
Copy link
Member

feckert commented Oct 11, 2024

Please bump the PKG_RELEASE.
Change is OK 👍

Add ip rules to enable route selection for traffic from the router
itself using the source IP address of the uplinks.

Signed-off-by: Filippo Carletti <[email protected]>
@filippocarletti
Copy link
Author

PKG_RELEASE bumped.

Cosmetic: silence warning messages when stopping mwan3:
```
~# /etc/init.d/mwan3 restart
{}{}{}grep: warning: stray \ before :
grep: warning: stray \ before :
```

Signed-off-by: Filippo Carletti <[email protected]>
@filippocarletti
Copy link
Author

@feckert do you think it's ready for merging?

@BKPepe BKPepe requested a review from feckert December 9, 2024 09:29
@feckert
Copy link
Member

feckert commented Dec 9, 2024

Sorry, I don't have time to investigate and verify this right now :-(


mwan3_delete_iface_rules "$1"

network_get_ipaddr wan_addr "${1}"
Copy link
Member

@feckert feckert Dec 19, 2024

Choose a reason for hiding this comment

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

Sorry for the late review!
I have some comments about this change that we should think about

  • We have to call different functions for IPv4 and IPv6.
  • Can we always be sure that we will get an IP form the function network_get_ipaddr or network_get_ipaddr6 ?

Copy link
Author

Choose a reason for hiding this comment

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

What about the following?

--- mwan3.sh	2024-09-23 12:34:46.000000000 +0000
+++ /lib/mwan3/mwan3.sh	2024-12-23 18:09:25.564820431 +0000
@@ -519,15 +519,16 @@
 
 	if [ "$family" = "ipv4" ]; then
 		IP="$IP4"
+		network_get_ipaddr wan_addr "${1}"
 	elif [ "$family" = "ipv6" ] && [ $NO_IPV6 -eq 0 ]; then
 		IP="$IP6"
+		network_get_subnet6 wan_addr "${1}"
 	else
 		return
 	fi
 
 	mwan3_delete_iface_rules "$1"
 
-	network_get_ipaddr wan_addr "${1}"
 
 	$IP rule add pref $((id+1000)) iif "$2" lookup "$id"
 	$IP rule add pref $((id+1500)) from ${wan_addr} lookup "$id"

Copy link
Author

Choose a reason for hiding this comment

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

network_get_subnet6 may fail, we could skip the rule if it returns 1.

Copy link
Member

Choose a reason for hiding this comment

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

Why do you want to use the network_get_subnet6 function and not the function network_get_ipaddr6 ?

Copy link
Author

Choose a reason for hiding this comment

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

I'm not experienced in IPv6, I think that you always get a subnet from the ISP (opposed to a single IPv4 address).

@feckert
Copy link
Member

feckert commented Jan 8, 2025

The mwan3 is written in shell and is therefore very fragile! Can we make the functionality configurable so that we don't break other setups?

@filippocarletti
Copy link
Author

This PR is missing the deletion of IP rules when a WAN uplink goes down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants