[PATCH v3 2/5] fff-network: move sysctl settings to a function

Tim Niemeyer tim at tn-x.org
Sa Mär 3 23:02:08 CET 2018


Am Samstag, den 03.03.2018, 22:56 +0100 schrieb
mail at 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 at freifunk.net] On
> > Behalf
> > Of Tim Niemeyer
> > Sent: Samstag, 3. März 2018 21:33
> > To: franken-dev at freifunk.net
> > Subject: [PATCH v3 2/5] fff-network: move sysctl settings to a
> > function
> > 
> > Signed-off-by: Tim Niemeyer <tim at tn-x.org>
> > Reviewed-by: Robert Langhammer <rlanghammer at web.de>
> > Reviewed-by: Christian Dresel <fff at chrisi01.de>
> > Tested-by: Christian Dresel <fff at 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 at freifunk.net
> > http://lists.freifunk.net/mailman/listinfo/franken-dev-freifunk.net
> 
> 
-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname   : signature.asc
Dateityp    : application/pgp-signature
Dateigröße  : 488 bytes
Beschreibung: This is a digitally signed message part
URL         : <http://lists.freifunk.net/pipermail/franken-dev-freifunk.net/attachments/20180303/5adbffea/attachment.sig>


Mehr Informationen über die Mailingliste franken-dev