Message ID | 20180303203234.12546-2-tim@tn-x.org |
---|---|
State | Accepted |
Headers | show |
diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork index f318d8e..d4b0b5d 100755 --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork @@ -28,6 +28,37 @@ setupPorts() { fi } +setAutoConf() { + # Sets ipv6 auto configuration on an interface to on/off + # Usage: enableAutoConf <interface> <[0|1]> + local iface=$1 + local on=$2 + + echo "# Generated from configurenetwork" > "/etc/sysctl.d/51-fff-network-$iface.conf" + echo "net.ipv6.conf.$iface.accept_ra_defrtr = $on" >> "/etc/sysctl.d/51-fff-network-$iface.conf" + echo "net.ipv6.conf.$iface.accept_ra_pinfo = $on" >> "/etc/sysctl.d/51-fff-network-$iface.conf" + echo "net.ipv6.conf.$iface.autoconf = $on" >> "/etc/sysctl.d/51-fff-network-$iface.conf" + echo "net.ipv6.conf.$iface.accept_ra_rtr_pref = $on" >> "/etc/sysctl.d/51-fff-network-$iface.conf" + + /sbin/sysctl -p "/etc/sysctl.d/51-fff-network-$iface.conf" +} + +enableAutoConf() { + # Enables ipv6 auto configuration on an interface + # Usage: enableAutoConf <interface> + local iface=$1 + + setAutoConf "$iface" "1" +} + +disableAutoConf() { + # Disables ipv6 auto configuration on an interface + # Usage: disableAutoConf <interface> + local iface=$1 + + setAutoConf "$iface" "0" +} + BOARD="$(uci get board.model.name)" . /etc/network.$BOARD @@ -86,23 +117,15 @@ if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then uci set network.${SWITCHDEV}_1.vlan=1 uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS" - echo "# Allow IPv6 RAs on WAN Port" >> /etc/sysctl.conf - if [[ "$WANDEV" = "$SWITCHDEV" ]] || ! [[ -z "$WAN_PORTS" ]]; then uci set network.${SWITCHDEV}_2=switch_vlan uci set network.${SWITCHDEV}_2.device=$SWITCHHW uci set network.${SWITCHDEV}_2.vlan=2 uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS" - echo "net.ipv6.conf.$WANDEV.2.accept_ra_defrtr = 1" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.2.accept_ra_pinfo = 1" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.2.autoconf = 1" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.2.accept_ra_rtr_pref = 1" >> /etc/sysctl.conf + enableAutoConf "$WANDEV.2" else - echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 1" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 1" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.autoconf = 1" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 1" >> /etc/sysctl.conf + enableAutoConf "$WANDEV" fi uci set network.${SWITCHDEV}_3=switch_vlan @@ -127,28 +150,19 @@ 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 - echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 1" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 1" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.autoconf = 1" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 1" >> /etc/sysctl.conf + 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 - echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 0" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 0" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.autoconf = 0" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 0" >> /etc/sysctl.conf + 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 - echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 0" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 0" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.autoconf = 0" >> /etc/sysctl.conf - echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 0" >> /etc/sysctl.conf + 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"
Hallo Tim, auch wenn es schon applied ist, siehe unten. > -----Original Message----- > From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf > Of Tim Niemeyer > Sent: Samstag, 3. März 2018 21:33 > To: franken-dev@freifunk.net > Subject: [PATCH v3 2/5] fff-network: move sysctl settings to a function > > Signed-off-by: Tim Niemeyer <tim@tn-x.org> > Reviewed-by: Robert Langhammer <rlanghammer@web.de> > Reviewed-by: Christian Dresel <fff@chrisi01.de> > Tested-by: Christian Dresel <fff@chrisi01.de> > > --- > > Changes in v3: None > Changes in v2: > - Add $iface to the filename > > .../fff-network/files/usr/sbin/configurenetwork | 58 ++++++++++++++---- > ---- > 1 file changed, 36 insertions(+), 22 deletions(-) > > diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork > b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork > index f318d8e..d4b0b5d 100755 > --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork > +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork > @@ -28,6 +28,37 @@ setupPorts() { > fi > } > > +setAutoConf() { > + # Sets ipv6 auto configuration on an interface to on/off > + # Usage: enableAutoConf <interface> <[0|1]> Der Name der Funktion bei Usage ist falsch. Ist aber nur ein Comment ... > + local iface=$1 > + local on=$2 > + > + echo "# Generated from configurenetwork" > "/etc/sysctl.d/51-fff- > network-$iface.conf" > + echo "net.ipv6.conf.$iface.accept_ra_defrtr = $on" >> "/etc/sysctl.d/51- > fff-network-$iface.conf" > + echo "net.ipv6.conf.$iface.accept_ra_pinfo = $on" >> "/etc/sysctl.d/51- > fff-network-$iface.conf" > + echo "net.ipv6.conf.$iface.autoconf = $on" >> "/etc/sysctl.d/51-fff- > network-$iface.conf" > + echo "net.ipv6.conf.$iface.accept_ra_rtr_pref = $on" >> > "/etc/sysctl.d/51-fff-network-$iface.conf" > + > + /sbin/sysctl -p "/etc/sysctl.d/51-fff-network-$iface.conf" Ich würde hier den Namen der Datei in eine Variable tun. Wenn ich einen Patch für beides baue, kommt der rein? Oder soll ich es lassen? Grüße Adrian > +} > + > +enableAutoConf() { > + # Enables ipv6 auto configuration on an interface > + # Usage: enableAutoConf <interface> > + local iface=$1 > + > + setAutoConf "$iface" "1" > +} > + > +disableAutoConf() { > + # Disables ipv6 auto configuration on an interface > + # Usage: disableAutoConf <interface> > + local iface=$1 > + > + setAutoConf "$iface" "0" > +} > + > BOARD="$(uci get board.model.name)" > . /etc/network.$BOARD > > @@ -86,23 +117,15 @@ if ! uci -q get network.$SWITCHDEV > /dev/null || [ > "$FORCEPARSE" = '1' ] ; then > uci set network.${SWITCHDEV}_1.vlan=1 > uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS" > > - echo "# Allow IPv6 RAs on WAN Port" >> /etc/sysctl.conf > - > if [[ "$WANDEV" = "$SWITCHDEV" ]] || ! [[ -z "$WAN_PORTS" ]]; then > uci set network.${SWITCHDEV}_2=switch_vlan > uci set network.${SWITCHDEV}_2.device=$SWITCHHW > uci set network.${SWITCHDEV}_2.vlan=2 > uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS" > > - echo "net.ipv6.conf.$WANDEV.2.accept_ra_defrtr = 1" >> > /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.2.accept_ra_pinfo = 1" >> > /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.2.autoconf = 1" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.2.accept_ra_rtr_pref = 1" >> > /etc/sysctl.conf > + enableAutoConf "$WANDEV.2" > else > - echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 1" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 1" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.autoconf = 1" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 1" >> > /etc/sysctl.conf > + enableAutoConf "$WANDEV" > fi > > uci set network.${SWITCHDEV}_3=switch_vlan > @@ -127,28 +150,19 @@ 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 > - echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 1" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 1" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.autoconf = 1" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 1" >> > /etc/sysctl.conf > + 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 > - echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 0" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 0" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.autoconf = 0" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 0" >> > /etc/sysctl.conf > + 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 > - echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 0" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 0" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.autoconf = 0" >> /etc/sysctl.conf > - echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 0" >> > /etc/sysctl.conf > + 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.11.0 > > -- > franken-dev mailing list > franken-dev@freifunk.net > http://lists.freifunk.net/mailman/listinfo/franken-dev-freifunk.net
Am Samstag, den 03.03.2018, 22:56 +0100 schrieb mail@adrianschmutzler.de: > Hallo Tim, > > auch wenn es schon applied ist, siehe unten. Jo, der Patch lag ja lange genug rum. > > -----Original Message----- > > From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On > > Behalf > > Of Tim Niemeyer > > Sent: Samstag, 3. März 2018 21:33 > > To: franken-dev@freifunk.net > > Subject: [PATCH v3 2/5] fff-network: move sysctl settings to a > > function > > > > Signed-off-by: Tim Niemeyer <tim@tn-x.org> > > Reviewed-by: Robert Langhammer <rlanghammer@web.de> > > Reviewed-by: Christian Dresel <fff@chrisi01.de> > > Tested-by: Christian Dresel <fff@chrisi01.de> > > > > --- > > > > Changes in v3: None > > Changes in v2: > > - Add $iface to the filename > > > > .../fff-network/files/usr/sbin/configurenetwork | 58 > > ++++++++++++++---- > > ---- > > 1 file changed, 36 insertions(+), 22 deletions(-) > > > > diff --git a/src/packages/fff/fff- > > network/files/usr/sbin/configurenetwork > > b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork > > index f318d8e..d4b0b5d 100755 > > --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork > > +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork > > @@ -28,6 +28,37 @@ setupPorts() { > > fi > > } > > > > +setAutoConf() { > > + # Sets ipv6 auto configuration on an interface to on/off > > + # Usage: enableAutoConf <interface> <[0|1]> > > Der Name der Funktion bei Usage ist falsch. Ist aber nur ein Comment > ... Hmm.. Shit.. > > + local iface=$1 > > + local on=$2 > > + > > + echo "# Generated from configurenetwork" > "/etc/sysctl.d/51- > > fff- > > network-$iface.conf" > > + echo "net.ipv6.conf.$iface.accept_ra_defrtr = $on" >> > > "/etc/sysctl.d/51- > > fff-network-$iface.conf" > > + echo "net.ipv6.conf.$iface.accept_ra_pinfo = $on" >> > > "/etc/sysctl.d/51- > > fff-network-$iface.conf" > > + echo "net.ipv6.conf.$iface.autoconf = $on" >> > > "/etc/sysctl.d/51-fff- > > network-$iface.conf" > > + echo "net.ipv6.conf.$iface.accept_ra_rtr_pref = $on" >> > > "/etc/sysctl.d/51-fff-network-$iface.conf" > > + > > + /sbin/sysctl -p "/etc/sysctl.d/51-fff-network-$iface.conf" > > Ich würde hier den Namen der Datei in eine Variable tun. Ich sehe da aktuell keinen Vorteil. > Wenn ich einen Patch für beides baue, kommt der rein? Oder soll ich > es lassen? Keine Ahnung. Tim > Grüße > > Adrian > > > +} > > + > > +enableAutoConf() { > > + # Enables ipv6 auto configuration on an interface > > + # Usage: enableAutoConf <interface> > > + local iface=$1 > > + > > + setAutoConf "$iface" "1" > > +} > > + > > +disableAutoConf() { > > + # Disables ipv6 auto configuration on an interface > > + # Usage: disableAutoConf <interface> > > + local iface=$1 > > + > > + setAutoConf "$iface" "0" > > +} > > + > > BOARD="$(uci get board.model.name)" > > . /etc/network.$BOARD > > > > @@ -86,23 +117,15 @@ if ! uci -q get network.$SWITCHDEV > /dev/null > > || [ > > "$FORCEPARSE" = '1' ] ; then > > uci set network.${SWITCHDEV}_1.vlan=1 > > uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS" > > > > - echo "# Allow IPv6 RAs on WAN Port" >> /etc/sysctl.conf > > - > > if [[ "$WANDEV" = "$SWITCHDEV" ]] || ! [[ -z "$WAN_PORTS" ]]; > > then > > uci set network.${SWITCHDEV}_2=switch_vlan > > uci set network.${SWITCHDEV}_2.device=$SWITCHHW > > uci set network.${SWITCHDEV}_2.vlan=2 > > uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS" > > > > - echo "net.ipv6.conf.$WANDEV.2.accept_ra_defrtr = 1" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.2.accept_ra_pinfo = 1" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.2.autoconf = 1" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.2.accept_ra_rtr_pref = 1" >> > > /etc/sysctl.conf > > + enableAutoConf "$WANDEV.2" > > else > > - echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 1" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 1" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.autoconf = 1" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 1" >> > > /etc/sysctl.conf > > + enableAutoConf "$WANDEV" > > fi > > > > uci set network.${SWITCHDEV}_3=switch_vlan > > @@ -127,28 +150,19 @@ 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 > > - echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 1" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 1" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.autoconf = 1" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 1" >> > > /etc/sysctl.conf > > + 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 > > - echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 0" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 0" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.autoconf = 0" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 0" >> > > /etc/sysctl.conf > > + 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 > > - echo "net.ipv6.conf.$WANDEV.accept_ra_defrtr = 0" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.accept_ra_pinfo = 0" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.autoconf = 0" >> > > /etc/sysctl.conf > > - echo "net.ipv6.conf.$WANDEV.accept_ra_rtr_pref = 0" >> > > /etc/sysctl.conf > > + 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.11.0 > > > > -- > > franken-dev mailing list > > franken-dev@freifunk.net > > http://lists.freifunk.net/mailman/listinfo/franken-dev-freifunk.net > >