fff-network: Improve IPv6 WAN connectivity

Submitted by Fabian Blaese on June 14, 2020, 11:17 a.m.

Details

Message ID 20200614111705.481189-2-fabian@blaese.de
State Superseded
Headers show

Commit Message

Fabian Blaese June 14, 2020, 11:17 a.m.
Until now, IPv6 connectivity was only ensured by some custom sysctls.
OpenWrt has a proper way of enabling IPv6 client (SLAAC, as well as DHCPv6)
for an interface. Switching to OpenWrt's way of configuring client addresses
for an interface might also make configuration more reliable, as the appropriate
sysctls are now set by netifd. Especially OnePort and TwoPort devices will
benefit from this change, as IPv6 auto configuration does not have to be manually
enabled and disabled for a physical interface, but rather is set as an option for
our logical wan interface.

At the same time this change enables DHCPv6 client support for WAN.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
---
 src/packages/fff/fff-network/files/etc/config/network    | 5 +++++
 .../fff/fff-network/files/usr/sbin/configurenetwork      | 9 +--------
 2 files changed, 6 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-network/files/etc/config/network b/src/packages/fff/fff-network/files/etc/config/network
index d2ee443..1f56ce5 100644
--- a/src/packages/fff/fff-network/files/etc/config/network
+++ b/src/packages/fff/fff-network/files/etc/config/network
@@ -12,6 +12,11 @@  config interface 'wan'
         option proto 'dhcp'
         option ifname 'eth1'
 
+config interface 'wan6'
+        option proto 'dhcpv6'
+        option reqprefix 'no'
+        option ifname '@wan'
+
 config interface 'ethmesh'
         option proto 'batadv_hardif'
         option master 'bat0'
diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
index 0ae7ba8..4bbc4f1 100755
--- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
+++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
@@ -126,11 +126,7 @@  if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
         uci set network.${SWITCHDEV}_2.vlan=2
         uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
 
-        enableAutoConf "$WANDEV.2"
-    else
-        enableAutoConf "$WANDEV"
-    fi
-    
+
     uci set network.${SWITCHDEV}_3=switch_vlan
     uci set network.${SWITCHDEV}_3.device=$SWITCHHW
     uci set network.${SWITCHDEV}_3.vlan=3
@@ -153,19 +149,16 @@  if [ "$ONE_PORT" = "YES" ] && ( ! uci -q get network.$SWITCHDEV.ifname || [ "$FO
     uci set network.$SWITCHDEV=interface
     uci set network.$SWITCHDEV.ifname=$SWITCHDEV
     if [ "$ETHMODE" = "WAN" ]; then
-        enableAutoConf "$WANDEV"
         uci set network.mesh.ifname="bat0"
         uci set network.wan.ifname="$WANDEV"
         uci del uci set network.ethmesh.ifname
         uci del network.eth0.macaddr
     elif [ "$ETHMODE" = "CLIENT" ] ; then
-        disableAutoConf "$WANDEV"
         uci set network.mesh.ifname="bat0 $SWITCHDEV"
         uci set network.wan.ifname="eth1" #eth1 because it is default in config file
         uci del network.ethmesh.ifname
         uci del network.eth0.macaddr
     elif [ "$ETHMODE" = "BATMAN" ] ; then
-        disableAutoConf "$WANDEV"
         uci set network.mesh.ifname="bat0"
         uci set network.wan.ifname="eth1" #eth1 because it is default in config file
         uci set network.ethmesh.ifname="$SWITCHDEV"

Comments

Robert Langhammer June 17, 2020, 7:04 a.m.
Hi,

das ist wirklich schöner als die versteckten sysctls.

Reviewed-by: Robert Langhammer <rlanghammer@web.de>

Am 14.06.20 um 13:17 schrieb Fabian Bläse:
> Until now, IPv6 connectivity was only ensured by some custom sysctls.
> OpenWrt has a proper way of enabling IPv6 client (SLAAC, as well as DHCPv6)
> for an interface. Switching to OpenWrt's way of configuring client addresses
> for an interface might also make configuration more reliable, as the appropriate
> sysctls are now set by netifd. Especially OnePort and TwoPort devices will
> benefit from this change, as IPv6 auto configuration does not have to be manually
> enabled and disabled for a physical interface, but rather is set as an option for
> our logical wan interface.
>
> At the same time this change enables DHCPv6 client support for WAN.
>
> Signed-off-by: Fabian Bläse <fabian@blaese.de>
> ---
>  src/packages/fff/fff-network/files/etc/config/network    | 5 +++++
>  .../fff/fff-network/files/usr/sbin/configurenetwork      | 9 +--------
>  2 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/src/packages/fff/fff-network/files/etc/config/network b/src/packages/fff/fff-network/files/etc/config/network
> index d2ee443..1f56ce5 100644
> --- a/src/packages/fff/fff-network/files/etc/config/network
> +++ b/src/packages/fff/fff-network/files/etc/config/network
> @@ -12,6 +12,11 @@ config interface 'wan'
>          option proto 'dhcp'
>          option ifname 'eth1'
>
> +config interface 'wan6'
> +        option proto 'dhcpv6'
> +        option reqprefix 'no'
> +        option ifname '@wan'
> +
>  config interface 'ethmesh'
>          option proto 'batadv_hardif'
>          option master 'bat0'
> diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> index 0ae7ba8..4bbc4f1 100755
> --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> @@ -126,11 +126,7 @@ if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
>          uci set network.${SWITCHDEV}_2.vlan=2
>          uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
>
> -        enableAutoConf "$WANDEV.2"
> -    else
> -        enableAutoConf "$WANDEV"
> -    fi
> -
> +
>      uci set network.${SWITCHDEV}_3=switch_vlan
>      uci set network.${SWITCHDEV}_3.device=$SWITCHHW
>      uci set network.${SWITCHDEV}_3.vlan=3
> @@ -153,19 +149,16 @@ if [ "$ONE_PORT" = "YES" ] && ( ! uci -q get network.$SWITCHDEV.ifname || [ "$FO
>      uci set network.$SWITCHDEV=interface
>      uci set network.$SWITCHDEV.ifname=$SWITCHDEV
>      if [ "$ETHMODE" = "WAN" ]; then
> -        enableAutoConf "$WANDEV"
>          uci set network.mesh.ifname="bat0"
>          uci set network.wan.ifname="$WANDEV"
>          uci del uci set network.ethmesh.ifname
>          uci del network.eth0.macaddr
>      elif [ "$ETHMODE" = "CLIENT" ] ; then
> -        disableAutoConf "$WANDEV"
>          uci set network.mesh.ifname="bat0 $SWITCHDEV"
>          uci set network.wan.ifname="eth1" #eth1 because it is default in config file
>          uci del network.ethmesh.ifname
>          uci del network.eth0.macaddr
>      elif [ "$ETHMODE" = "BATMAN" ] ; then
> -        disableAutoConf "$WANDEV"
>          uci set network.mesh.ifname="bat0"
>          uci set network.wan.ifname="eth1" #eth1 because it is default in config file
>          uci set network.ethmesh.ifname="$SWITCHDEV"
Robert Langhammer July 8, 2020, 3:23 p.m.
Hi,

es funktioniert nicht bei mir. Der netifd macht source specific routen:

# ip -6 r
default from 2003:d2:571d:9442::/64 via fe80::1 dev br-wan proto static
metric 512 pref medium
default from fd52:28be:4c6f:1::/64 via fe80::1 dev br-wan proto static
metric 512 pref medium

Wenn ich an br-mesh eine v6 binde: inet6 2a0b:f4c0:84:c::1/64 scope global

Kann ich mein Wireguardpeer nicht mehr erreichen:

prohibit 2a01:4f8:1c0c:70c4::2 from :: dev lo proto kernel src
2a0b:f4c0:84:c::1

Falsche src :-(

Ohne source specific geht es.

Viele Grüße
Robert

Am 17.06.20 um 09:04 schrieb Robert Langhammer:
> Hi,
>
> das ist wirklich schöner als die versteckten sysctls.
>
> Reviewed-by: Robert Langhammer <rlanghammer@web.de>
>
> Am 14.06.20 um 13:17 schrieb Fabian Bläse:
>> Until now, IPv6 connectivity was only ensured by some custom sysctls.
>> OpenWrt has a proper way of enabling IPv6 client (SLAAC, as well as DHCPv6)
>> for an interface. Switching to OpenWrt's way of configuring client addresses
>> for an interface might also make configuration more reliable, as the appropriate
>> sysctls are now set by netifd. Especially OnePort and TwoPort devices will
>> benefit from this change, as IPv6 auto configuration does not have to be manually
>> enabled and disabled for a physical interface, but rather is set as an option for
>> our logical wan interface.
>>
>> At the same time this change enables DHCPv6 client support for WAN.
>>
>> Signed-off-by: Fabian Bläse <fabian@blaese.de>
>> ---
>>  src/packages/fff/fff-network/files/etc/config/network    | 5 +++++
>>  .../fff/fff-network/files/usr/sbin/configurenetwork      | 9 +--------
>>  2 files changed, 6 insertions(+), 8 deletions(-)
>>
>> diff --git a/src/packages/fff/fff-network/files/etc/config/network b/src/packages/fff/fff-network/files/etc/config/network
>> index d2ee443..1f56ce5 100644
>> --- a/src/packages/fff/fff-network/files/etc/config/network
>> +++ b/src/packages/fff/fff-network/files/etc/config/network
>> @@ -12,6 +12,11 @@ config interface 'wan'
>>          option proto 'dhcp'
>>          option ifname 'eth1'
>>
>> +config interface 'wan6'
>> +        option proto 'dhcpv6'
>> +        option reqprefix 'no'
>> +        option ifname '@wan'
>> +
>>  config interface 'ethmesh'
>>          option proto 'batadv_hardif'
>>          option master 'bat0'
>> diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
>> index 0ae7ba8..4bbc4f1 100755
>> --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
>> +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
>> @@ -126,11 +126,7 @@ if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
>>          uci set network.${SWITCHDEV}_2.vlan=2
>>          uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
>>
>> -        enableAutoConf "$WANDEV.2"
>> -    else
>> -        enableAutoConf "$WANDEV"
>> -    fi
>> -
>> +
>>      uci set network.${SWITCHDEV}_3=switch_vlan
>>      uci set network.${SWITCHDEV}_3.device=$SWITCHHW
>>      uci set network.${SWITCHDEV}_3.vlan=3
>> @@ -153,19 +149,16 @@ if [ "$ONE_PORT" = "YES" ] && ( ! uci -q get network.$SWITCHDEV.ifname || [ "$FO
>>      uci set network.$SWITCHDEV=interface
>>      uci set network.$SWITCHDEV.ifname=$SWITCHDEV
>>      if [ "$ETHMODE" = "WAN" ]; then
>> -        enableAutoConf "$WANDEV"
>>          uci set network.mesh.ifname="bat0"
>>          uci set network.wan.ifname="$WANDEV"
>>          uci del uci set network.ethmesh.ifname
>>          uci del network.eth0.macaddr
>>      elif [ "$ETHMODE" = "CLIENT" ] ; then
>> -        disableAutoConf "$WANDEV"
>>          uci set network.mesh.ifname="bat0 $SWITCHDEV"
>>          uci set network.wan.ifname="eth1" #eth1 because it is default in config file
>>          uci del network.ethmesh.ifname
>>          uci del network.eth0.macaddr
>>      elif [ "$ETHMODE" = "BATMAN" ] ; then
>> -        disableAutoConf "$WANDEV"
>>          uci set network.mesh.ifname="bat0"
>>          uci set network.wan.ifname="eth1" #eth1 because it is default in config file
>>          uci set network.ethmesh.ifname="$SWITCHDEV"
Fabian Blaese July 21, 2020, 6:05 p.m.
Hallo Robert,

jetzt sehe ich das Problem an der Geschichte: die nicht-source-specific default aus der fff table gewinnt über die source-specific default aus der main table, obwohl die rule für fff später kommt.

Man kann das ganze aber abschalten:
config interface 'wan'
	option proto 'dhcpv6'
	option reqprefix 'no'
	option sourcefilter '0'
	option ifname 'eth0.90'

Die Option 'sourcefilter' ist im OpenWrt Wiki falsch benannt, dort heißt sie 'sourcerouting'.
Ich fix das bei Gelegenheit mal im OpenWrt Wiki und sende eine v2.

Danke für den guten Fund. :-)

Gruß
Fabian
Adrian Schmutzler July 22, 2020, 5:45 p.m.
Hallo,

> -----Original Message-----
> From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf
> Of Fabian Bläse
> Sent: Sonntag, 14. Juni 2020 13:17
> To: franken-dev@freifunk.net
> Subject: [PATCH] fff-network: Improve IPv6 WAN connectivity
> 
> Until now, IPv6 connectivity was only ensured by some custom sysctls.
> OpenWrt has a proper way of enabling IPv6 client (SLAAC, as well as DHCPv6)
> for an interface. Switching to OpenWrt's way of configuring client addresses
> for an interface might also make configuration more reliable, as the
> appropriate sysctls are now set by netifd. Especially OnePort and TwoPort

inwiefern berührt das denn unsere "default" sysctl settings in
https://github.com/FreifunkFranken/firmware/blob/master/src/packages/fff/fff-network/files/etc/sysctl.d/50-fff-network.conf

Passiert der netifd "danach" und sind die settings daher irrelevant, oder gibt es hier einen anderen Mechanismus?
Brauchen wir all die Settings in der sysctl überhaupt, oder macht OpenWrt nicht u.U. einen der IPv6 config dort auch "automatisch"?

> devices will benefit from this change, as IPv6 auto configuration does not
> have to be manually enabled and disabled for a physical interface, but rather
> is set as an option for our logical wan interface.
> 
> At the same time this change enables DHCPv6 client support for WAN.
> 
> Signed-off-by: Fabian Bläse <fabian@blaese.de>
> ---
>  src/packages/fff/fff-network/files/etc/config/network    | 5 +++++
>  .../fff/fff-network/files/usr/sbin/configurenetwork      | 9 +--------
>  2 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/src/packages/fff/fff-network/files/etc/config/network
> b/src/packages/fff/fff-network/files/etc/config/network
> index d2ee443..1f56ce5 100644
> --- a/src/packages/fff/fff-network/files/etc/config/network
> +++ b/src/packages/fff/fff-network/files/etc/config/network
> @@ -12,6 +12,11 @@ config interface 'wan'
>          option proto 'dhcp'
>          option ifname 'eth1'
> 
> +config interface 'wan6'
> +        option proto 'dhcpv6'
> +        option reqprefix 'no'
> +        option ifname '@wan'
> +
>  config interface 'ethmesh'
>          option proto 'batadv_hardif'
>          option master 'bat0'
> diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> index 0ae7ba8..4bbc4f1 100755
> --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> @@ -126,11 +126,7 @@ if ! uci -q get network.$SWITCHDEV > /dev/null || [
> "$FORCEPARSE" = '1' ] ; then
>          uci set network.${SWITCHDEV}_2.vlan=2
>          uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
> 
> -        enableAutoConf "$WANDEV.2"

Bitte auch gleich die Funktionen selbst mit töten, die stehen in der gleichen Datei ganz oben (auch setAutoConf kann weg).

Grüße

Adrian

> -    else
> -        enableAutoConf "$WANDEV"
> -    fi
> -
> +
>      uci set network.${SWITCHDEV}_3=switch_vlan
>      uci set network.${SWITCHDEV}_3.device=$SWITCHHW
>      uci set network.${SWITCHDEV}_3.vlan=3 @@ -153,19 +149,16 @@ if [
> "$ONE_PORT" = "YES" ] && ( ! uci -q get network.$SWITCHDEV.ifname || [
> "$FO
>      uci set network.$SWITCHDEV=interface
>      uci set network.$SWITCHDEV.ifname=$SWITCHDEV
>      if [ "$ETHMODE" = "WAN" ]; then
> -        enableAutoConf "$WANDEV"
>          uci set network.mesh.ifname="bat0"
>          uci set network.wan.ifname="$WANDEV"
>          uci del uci set network.ethmesh.ifname
>          uci del network.eth0.macaddr
>      elif [ "$ETHMODE" = "CLIENT" ] ; then
> -        disableAutoConf "$WANDEV"
>          uci set network.mesh.ifname="bat0 $SWITCHDEV"
>          uci set network.wan.ifname="eth1" #eth1 because it is default in config
> file
>          uci del network.ethmesh.ifname
>          uci del network.eth0.macaddr
>      elif [ "$ETHMODE" = "BATMAN" ] ; then
> -        disableAutoConf "$WANDEV"
>          uci set network.mesh.ifname="bat0"
>          uci set network.wan.ifname="eth1" #eth1 because it is default in config
> file
>          uci set network.ethmesh.ifname="$SWITCHDEV"
> --
> 2.27.0
Fabian Blaese July 31, 2020, 8:53 p.m.
On 22.07.20 19:45, mail@adrianschmutzler.de wrote:
> Hallo,
> 
>> -----Original Message-----
>> From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf
>> Of Fabian Bläse
>> Sent: Sonntag, 14. Juni 2020 13:17
>> To: franken-dev@freifunk.net
>> Subject: [PATCH] fff-network: Improve IPv6 WAN connectivity
>>
>> Until now, IPv6 connectivity was only ensured by some custom sysctls.
>> OpenWrt has a proper way of enabling IPv6 client (SLAAC, as well as DHCPv6)
>> for an interface. Switching to OpenWrt's way of configuring client addresses
>> for an interface might also make configuration more reliable, as the
>> appropriate sysctls are now set by netifd. Especially OnePort and TwoPort
> 
> inwiefern berührt das denn unsere "default" sysctl settings in
> https://github.com/FreifunkFranken/firmware/blob/master/src/packages/fff/fff-network/files/etc/sysctl.d/50-fff-network.conf
Eigentlich gar nicht. Oder was meinst du?
netifd setzt sich die wichtigen sysctls für ein Interface selbst passend.

> Passiert der netifd "danach" und sind die settings daher irrelevant, oder gibt es hier einen anderen Mechanismus?
> Brauchen wir all die Settings in der sysctl überhaupt, oder macht OpenWrt nicht u.U. einen der IPv6 config dort auch "automatisch"?
Ich bin mir hier selbst nicht sicher. Es gibt aber erstmal nicht einfach so einen Mechanismus sysctls zu laden. Entweder der netifd macht das, oder der netifd ist fertig, bevor sysctls applied werden (womit es für dynamische interfaces, wie z.B. vlans spätestens bei ifdown/ifup auch kaputt ist), oder es ist ganz kaputt.
Potentiell ist es möglich, dass unsere sysctls gar nicht, oder nur in bestimmten Fällen funktionieren.

Gruß
Fabian