From 055232d13bc698770a2a46565dcc516dde27708e Mon Sep 17 00:00:00 2001 From: Tim Niemeyer Date: Fri, 11 Apr 2014 22:39:34 +0200 Subject: [PATCH] bsp: wr841: make dynamic network functions available for all Signed-off-by: Tim Niemeyer --- bsp/default/root_file_system/etc/network.sh | 49 ++++++++++++ bsp/default/root_file_system/etc/rc.local.tpl | 5 ++ bsp/default/root_file_system/etc/sysctl.conf | 9 --- .../root_file_system/etc/network.tl-wr841n-v9 | 7 ++ .../etc/rc.local.tl-wr841n-v9 | 39 ---------- bsp/wr841n9/root_file_system/etc/sysctl.conf | 78 ------------------- 6 files changed, 61 insertions(+), 126 deletions(-) create mode 100644 bsp/default/root_file_system/etc/network.sh create mode 100644 bsp/wr841n9/root_file_system/etc/network.tl-wr841n-v9 delete mode 100644 bsp/wr841n9/root_file_system/etc/sysctl.conf diff --git a/bsp/default/root_file_system/etc/network.sh b/bsp/default/root_file_system/etc/network.sh new file mode 100644 index 0000000..6ae6992 --- /dev/null +++ b/bsp/default/root_file_system/etc/network.sh @@ -0,0 +1,49 @@ + +if ! uci get network.$SWITCHDEV.ifname; then + uci set network.$SWITCHDEV=switch + uci set network.$SWITCHDEV.enable=1 + uci set network.$SWITCHDEV.reset=1 + uci set network.$SWITCHDEV.enable_vlan=1 + + uci set network.${SWITCHDEV}_1=switch_vlan + uci set network.${SWITCHDEV}_1.device=$SWITCHDEV + 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" ]]; then + uci set network.${SWITCHDEV}_2=switch_vlan + uci set network.${SWITCHDEV}_2.device=$SWITCHDEV + 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 + 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 + fi + + uci set network.${SWITCHDEV}_3=switch_vlan + uci set network.${SWITCHDEV}_3.device=$SWITCHDEV + uci set network.${SWITCHDEV}_3.vlan=3 + uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS" + + uci set network.mesh.ifname="$SWITCHDEV.1 bat0" + + uci set network.ethmesh.ifname="$SWITCHDEV.3" + + if [[ "$WANDEV" = "$SWITCHDEV" ]]; then + uci set network.wan.ifname=$WANDEV.2 + else + uci set network.wan.ifname=$WANDEV + fi + + uci commit + /etc/init.d/network reload +fi diff --git a/bsp/default/root_file_system/etc/rc.local.tpl b/bsp/default/root_file_system/etc/rc.local.tpl index bddf87e..4516c15 100755 --- a/bsp/default/root_file_system/etc/rc.local.tpl +++ b/bsp/default/root_file_system/etc/rc.local.tpl @@ -5,6 +5,11 @@ BOARD=$(cat /var/sysinfo/board_name) if ! uci get board.model.name; then uci set board.model.name=BOARD fi + +. /etc/network.$BOARD + +. /etc/network.sh + . /etc/rc.local.$BOARD # collect environment info and write to dot-script diff --git a/bsp/default/root_file_system/etc/sysctl.conf b/bsp/default/root_file_system/etc/sysctl.conf index 96bf30d..e9b92c2 100644 --- a/bsp/default/root_file_system/etc/sysctl.conf +++ b/bsp/default/root_file_system/etc/sysctl.conf @@ -71,12 +71,3 @@ net.ipv6.conf.default.max_addresses = 0 net.ipv6.conf.all.max_addresses = 0 -# Allow IPv6 RAs on WAN Port -net.ipv6.conf.eth0.2.accept_ra_defrtr = 1 -net.ipv6.conf.eth0.2.accept_ra_pinfo = 1 -net.ipv6.conf.eth0.2.autoconf = 1 -net.ipv6.conf.eth0.2.accept_ra_rtr_pref = 1 -net.ipv6.conf.eth1.accept_ra_defrtr = 1 -net.ipv6.conf.eth1.accept_ra_pinfo = 1 -net.ipv6.conf.eth1.autoconf = 1 -net.ipv6.conf.eth1.accept_ra_rtr_pref = 1 diff --git a/bsp/wr841n9/root_file_system/etc/network.tl-wr841n-v9 b/bsp/wr841n9/root_file_system/etc/network.tl-wr841n-v9 new file mode 100644 index 0000000..0414a14 --- /dev/null +++ b/bsp/wr841n9/root_file_system/etc/network.tl-wr841n-v9 @@ -0,0 +1,7 @@ + +WANDEV=eth1 +# WANDEV=eth0 +SWITCHDEV=eth0 +CLIENT_PORTS="1 2 0t" +WAN_PORTS= +BATMAN_PORTS="3 4 0t" diff --git a/bsp/wr841n9/root_file_system/etc/rc.local.tl-wr841n-v9 b/bsp/wr841n9/root_file_system/etc/rc.local.tl-wr841n-v9 index ed69d2f..ddd79b8 100755 --- a/bsp/wr841n9/root_file_system/etc/rc.local.tl-wr841n-v9 +++ b/bsp/wr841n9/root_file_system/etc/rc.local.tl-wr841n-v9 @@ -6,45 +6,6 @@ if ! uci get nodewatcher.@network[0].client_interfaces; then uci commit fi -WANDEV=eth1 -SWITCHDEV=eth0 -CLIENT_PORTS="1 2 0t" -WAN_PORTS= -BATMAN_PORTS="3 4 0t" - -if ! uci get network.$SWITCHDEV.ifname; then - uci set network.$SWITCHDEV=switch - uci set network.$SWITCHDEV.enable=1 - uci set network.$SWITCHDEV.reset=1 - uci set network.$SWITCHDEV.enable_vlan=1 - - uci set network.${SWITCHDEV}_1=switch_vlan - uci set network.${SWITCHDEV}_1.device=$SWITCHDEV - uci set network.${SWITCHDEV}_1.vlan=1 - uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS" - - if [[ "$WANDEV" = "$SWITCHDEV" ]]; then - uci set network.${SWITCHDEV}_2=switch_vlan - uci set network.${SWITCHDEV}_2.device=$SWITCHDEV - uci set network.${SWITCHDEV}_2.vlan=2 - uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS" - fi - - uci set network.${SWITCHDEV}_3=switch_vlan - uci set network.${SWITCHDEV}_3.device=$SWITCHDEV - uci set network.${SWITCHDEV}_3.vlan=3 - uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS" - - uci set network.mesh.ifname="$SWITCHDEV.1 bat0" - - uci set network.ethmesh.ifname="$SWITCHDEV.3" - - uci set network.wan.ifname=$WANDEV - - uci commit - /etc/init.d/network reload -fi - if uci get network.ethmesh.macaddr then echo "MAC for ethmesh is set already" diff --git a/bsp/wr841n9/root_file_system/etc/sysctl.conf b/bsp/wr841n9/root_file_system/etc/sysctl.conf deleted file mode 100644 index 626af0c..0000000 --- a/bsp/wr841n9/root_file_system/etc/sysctl.conf +++ /dev/null @@ -1,78 +0,0 @@ -kernel.panic=3 -net.ipv4.conf.default.arp_ignore=1 -net.ipv4.conf.all.arp_ignore=1 -net.ipv4.conf.all.forwarding=0 -net.ipv4.conf.all.send_redirects=0 -net.ipv4.tcp_ecn=0 -net.ipv4.tcp_fin_timeout=30 -net.ipv4.tcp_keepalive_time=120 -net.ipv4.tcp_syncookies=1 -net.ipv4.tcp_timestamps=0 -net.ipv4.netfilter.ip_conntrack_checksum=0 -net.ipv4.netfilter.ip_conntrack_max=16384 -net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=3600 -net.ipv4.netfilter.ip_conntrack_udp_timeout=60 -net.ipv4.netfilter.ip_conntrack_udp_timeout_stream=180 -net.core.netdev_max_backlog=30 -net.netfilter.nf_conntrack_checksum=0 - -#Controls source route verification -net.ipv4.conf.default.rp_filter=1 - -#Do not accept source routing -net.ipv4.conf.all.accept_source_route=0 -net.ipv4.conf.all.accept_redirects=0 -net.ipv4.conf.default.accept_source_route=0 -net.ipv4.conf.default.accept_redirects=0 -net.ipv4.icmp_echo_ignore_broadcasts=1 -net.ipv4.icmp_ignore_bogus_error_responses=1 -net.ipv4.ip_forward=0 -# net.ipv6.conf.all.forwarding=1 - -# disable bridge firewalling by default -net.bridge.bridge-nf-call-arptables=0 -net.bridge.bridge-nf-call-ip6tables=0 -net.bridge.bridge-nf-call-iptables=0 - -net.ipv6.conf.default.accept_dad=0 -net.ipv6.conf.default.accept_ra=0 -net.ipv6.conf.default.accept_redirects=0 -net.ipv6.conf.all.accept_dad=0 -net.ipv6.conf.all.accept_ra=1 -net.ipv6.conf.all.accept_redirects=0 - -# Number of Router Solicitations to send until assuming no routers are present. -# This is host and not router -net.ipv6.conf.default.router_solicitations = 0 -net.ipv6.conf.all.router_solicitations = 0 - -# Accept Router Preference in RA? -net.ipv6.conf.default.accept_ra_rtr_pref = 0 -net.ipv6.conf.all.accept_ra_rtr_pref = 1 - -# Learn Prefix Information in Router Advertisement -net.ipv6.conf.default.accept_ra_pinfo = 0 -net.ipv6.conf.all.accept_ra_pinfo = 1 - -# Setting controls whether the system will accept Hop Limit settings from a router advertisement -net.ipv6.conf.default.accept_ra_defrtr = 0 -net.ipv6.conf.all.accept_ra_defrtr = 1 - -#router advertisements can cause the system to assign a global unicast address to an interface -net.ipv6.conf.default.autoconf = 0 -net.ipv6.conf.all.autoconf = 1 - -#how many neighbor solicitations to send out per address? -net.ipv6.conf.default.dad_transmits = 3 -net.ipv6.conf.all.dad_transmits = 3 - -# How many global unicast IPv6 addresses can be assigned to each interface? -net.ipv6.conf.default.max_addresses = 0 -net.ipv6.conf.all.max_addresses = 0 - - -# Allow IPv6 RAs on WAN Port -net.ipv6.conf.eth0.accept_ra_defrtr = 1 -net.ipv6.conf.eth0.accept_ra_pinfo = 1 -net.ipv6.conf.eth0.autoconf = 1 -net.ipv6.conf.eth0.accept_ra_rtr_pref = 1