fff-network: fix support for CPE and provide two-port support #143
|
@ -6,10 +6,10 @@ images=("openwrt-${chipset}-${subtarget}-glinet_gl-ar150-squashfs-*"
|
||||||
"openwrt-${chipset}-${subtarget}-tplink_archer-c60-v2-squashfs-*"
|
"openwrt-${chipset}-${subtarget}-tplink_archer-c60-v2-squashfs-*"
|
||||||
"openwrt-${chipset}-${subtarget}-tplink_archer-c7-v2-squashfs-*"
|
"openwrt-${chipset}-${subtarget}-tplink_archer-c7-v2-squashfs-*"
|
||||||
"openwrt-${chipset}-${subtarget}-tplink_archer-c7-v5-squashfs-*"
|
"openwrt-${chipset}-${subtarget}-tplink_archer-c7-v5-squashfs-*"
|
||||||
# "openwrt-${chipset}-${subtarget}-tplink_cpe210-v1-squashfs-*"
|
"openwrt-${chipset}-${subtarget}-tplink_cpe210-v1-squashfs-*"
|
||||||
"openwrt-${chipset}-${subtarget}-tplink_cpe210-v2-squashfs-*"
|
"openwrt-${chipset}-${subtarget}-tplink_cpe210-v2-squashfs-*"
|
||||||
"openwrt-${chipset}-${subtarget}-tplink_cpe210-v3-squashfs-*"
|
"openwrt-${chipset}-${subtarget}-tplink_cpe210-v3-squashfs-*"
|
||||||
# "openwrt-${chipset}-${subtarget}-tplink_cpe510-v1-squashfs-*"
|
"openwrt-${chipset}-${subtarget}-tplink_cpe510-v1-squashfs-*"
|
||||||
"openwrt-${chipset}-${subtarget}-tplink_tl-wdr3500-v1-squashfs-*"
|
"openwrt-${chipset}-${subtarget}-tplink_tl-wdr3500-v1-squashfs-*"
|
||||||
"openwrt-${chipset}-${subtarget}-tplink_tl-wdr3600-v1-squashfs-*"
|
"openwrt-${chipset}-${subtarget}-tplink_tl-wdr3600-v1-squashfs-*"
|
||||||
"openwrt-${chipset}-${subtarget}-tplink_tl-wdr4300-v1-squashfs-*"
|
"openwrt-${chipset}-${subtarget}-tplink_tl-wdr4300-v1-squashfs-*"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=fff-network
|
PKG_NAME:=fff-network
|
||||||
PKG_RELEASE:=40
|
PKG_RELEASE:=43
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
|
|
@ -4,23 +4,6 @@
|
||||||
. /lib/functions/system.sh
|
. /lib/functions/system.sh
|
||||||
. /lib/functions/fff/network
|
. /lib/functions/fff/network
|
||||||
|
|
||||||
setupPorts() {
|
|
||||||
# Add a single port to the *_PORTS config
|
|
||||||
# Usage: setupPorts <port id> <port mode>
|
|
||||||
|
|
||||||
local port=$1
|
|
||||||
local mode=$2
|
|
||||||
|
|
||||||
#default: BATMAN
|
|
||||||
if [ "$mode" = "WAN" ] ; then
|
|
||||||
WAN_PORTS="${WAN_PORTS} $port"
|
|
||||||
elif [ "$mode" = "CLIENT" ] ; then
|
|
||||||
CLIENT_PORTS="${CLIENT_PORTS} $port"
|
|
||||||
else
|
|
||||||
BATMAN_PORTS="${BATMAN_PORTS} $port"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
BOARD="$(uci get board.model.name)"
|
BOARD="$(uci get board.model.name)"
|
||||||
. /etc/network.$BOARD
|
. /etc/network.$BOARD
|
||||||
[ -n "$ROUTERMAC" ] || ROUTERMAC=$(get_mac_label)
|
[ -n "$ROUTERMAC" ] || ROUTERMAC=$(get_mac_label)
|
||||||
|
@ -37,10 +20,8 @@ else
|
||||||
if [ "$ONE_PORT" = "YES" ] || [ -n "$ETHPORT" ] ; then
|
if [ "$ONE_PORT" = "YES" ] || [ -n "$ETHPORT" ] ; then
|
||||||
echo "ETHMODE='$ETHMODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
echo "ETHMODE='$ETHMODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
||||||
fi
|
fi
|
||||||
if [ -n "$LAN0PORT" ] ; then
|
if [ -n "$TWO_PORT" ] ; then
|
||||||
echo "LAN0MODE='$LAN0MODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
echo "LAN0MODE='$LAN0MODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
||||||
fi
|
|
||||||
if [ -n "$LAN1PORT" ] ; then
|
|
||||||
echo "LAN1MODE='$LAN1MODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
echo "LAN1MODE='$LAN1MODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
||||||
fi
|
fi
|
||||||
echo "FORCEPARSE='0' # Parse at: 0=first boot only, 1=every reboot, 2=next reboot (once)" >> /etc/network.config
|
echo "FORCEPARSE='0' # Parse at: 0=first boot only, 1=every reboot, 2=next reboot (once)" >> /etc/network.config
|
||||||
|
@ -52,79 +33,123 @@ if [ "$FORCEPARSE" = '2' ] ; then
|
||||||
FORCEPARSE='1'
|
FORCEPARSE='1'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$ETHPORT" ] ; then
|
if [ "$ONE_PORT" = "YES" ]; then
|
||||||
#LAN@AR150: default: BATMAN
|
if ! uci -q get network.$SWITCHDEV.ifname || [ "$FORCEPARSE" = '1' ] ; then
|
||||||
setupPorts "$ETHPORT" "${ETHMODE}"
|
uci set network.$SWITCHDEV=interface
|
||||||
fi
|
uci set network.$SWITCHDEV.ifname=$SWITCHDEV
|
||||||
if [ -n "$LAN0PORT" ] ; then
|
if [ "$ETHMODE" = "WAN" ]; then
|
||||||
#LAN0@two-port: default: BATMAN
|
uci set network.client.ifname="bat0"
|
||||||
setupPorts "$LAN0PORT" "${LAN0MODE}"
|
uci set network.wan.ifname="$WANDEV"
|
||||||
fi
|
uci del network.ethmesh.ifname
|
||||||
if [ -n "$LAN1PORT" ] ; then
|
uci del network.${SWITCHDEV}.macaddr
|
||||||
#LAN1@two-port: default: BATMAN
|
elif [ "$ETHMODE" = "CLIENT" ] ; then
|
||||||
setupPorts "$LAN1PORT" "${LAN1MODE}"
|
uci set network.client.ifname="bat0 $SWITCHDEV"
|
||||||
fi
|
uci set network.wan.ifname="eth2" #eth2 because it is default in config file
|
||||||
|
uci del network.ethmesh.ifname
|
||||||
if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
|
uci del network.${SWITCHDEV}.macaddr
|
||||||
|
elif [ "$ETHMODE" = "BATMAN" ] ; then
|
||||||
SWITCHHW=$(swconfig list | awk '{ print $4 }')
|
uci set network.client.ifname="bat0"
|
||||||
|
uci set network.wan.ifname="eth2" #eth2 because it is default in config file
|
||||||
uci set network.$SWITCHDEV=switch
|
uci set network.ethmesh.ifname="$SWITCHDEV"
|
||||||
uci set network.$SWITCHDEV.name=$SWITCHHW
|
ETH0DEV="$SWITCHDEV"
|
||||||
uci set network.$SWITCHDEV.enable=1
|
ETH0MAC="w2ap"
|
||||||
uci set network.$SWITCHDEV.reset=1
|
fi
|
||||||
uci set network.$SWITCHDEV.enable_vlan=1
|
uci commit network
|
||||||
|
|
||||||
uci set network.${SWITCHDEV}_1=switch_vlan
|
|
||||||
uci set network.${SWITCHDEV}_1.device=$SWITCHHW
|
|
||||||
uci set network.${SWITCHDEV}_1.vlan=1
|
|
||||||
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
|
|
||||||
|
|
||||||
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"
|
|
||||||
fi
|
fi
|
||||||
|
elif [ "$TWO_PORT" = "YES" ]; then
|
||||||
|
if ! uci -q get network.$WANDEV.ifname || [ "$FORCEPARSE" = '1' ] ; then
|
||||||
|
uci set network.$WANDEV=interface
|
||||||
|
uci set network.$WANDEV.ifname="$WANDEV"
|
||||||
|
uci set network.$SWITCHDEV=interface
|
||||||
|
uci set network.$SWITCHDEV.ifname="$SWITCHDEV"
|
||||||
|
# Only one WAN possible, second port will be unset if both are WAN
|
||||||
|
if [ "$LAN0MODE" = "WAN" ]; then
|
||||||
|
if [ "$LAN1MODE" = "CLIENT" ]; then
|
||||||
|
uci set network.client.ifname="bat0 $SWITCHDEV"; else
|
||||||
|
uci set network.client.ifname=bat0; fi
|
||||||
|
# WAN
|
||||||
|
uci set network.wan.ifname="$WANDEV"
|
||||||
|
if [ "$LAN1MODE" = "BATMAN" ]; then
|
||||||
|
uci set network.ethmesh.ifname="$SWITCHDEV"; else
|
||||||
|
uci del network.ethmesh.ifname; fi
|
||||||
|
# Two client ports are possible
|
||||||
|
elif [ "$LAN0MODE" = "CLIENT" ]; then
|
||||||
|
if [ "$LAN1MODE" = "CLIENT" ]; then
|
||||||
|
uci set network.client.ifname="bat0 $WANDEV $SWITCHDEV"; else
|
||||||
|
uci set network.client.ifname="bat0 $WANDEV"; fi
|
||||||
|
if [ "$LAN1MODE" = "WAN" ]; then
|
||||||
|
uci set network.wan.ifname="$SWITCHDEV"; else
|
||||||
|
uci set network.wan.ifname=eth2; fi #eth2 because it is default in config file
|
||||||
|
if [ "$LAN1MODE" = "BATMAN" ]; then
|
||||||
|
uci set network.ethmesh.ifname="$SWITCHDEV"; else
|
||||||
|
uci del network.ethmesh.ifname; fi
|
||||||
|
# Only one BATMAN port possible, second port will be unset if both are BATMAN
|
||||||
|
elif [ "$LAN0MODE" = "BATMAN" ] ; then
|
||||||
|
if [ "$LAN1MODE" = "CLIENT" ]; then
|
||||||
|
uci set network.client.ifname="bat0 $SWITCHDEV"; else
|
||||||
|
uci set network.client.ifname=bat0; fi
|
||||||
|
if [ "$LAN1MODE" = "WAN" ]; then
|
||||||
|
uci set network.wan.ifname="$SWITCHDEV"; else
|
||||||
|
uci set network.wan.ifname=eth2; fi #eth2 because it is default in config file
|
||||||
|
# BATMAN
|
||||||
|
uci set network.ethmesh.ifname="$WANDEV"
|
||||||
|
fi
|
||||||
|
if [ "$LAN0MODE" = "BATMAN" ]; then
|
||||||
|
ETH0DEV="$WANDEV" # only needed for setting macaddr
|
||||||
|
ETH0MAC=w2ap
|
||||||
|
uci del network.$SWITCHDEV.macaddr
|
||||||
|
elif [ "$LAN1MODE" = "BATMAN" ]; then
|
||||||
|
# $WANDEV will win if both are set to BATMAN, as above
|
||||||
|
ETH0DEV="$SWITCHDEV" # only needed for setting macaddr
|
||||||
|
ETH0MAC=w2ap
|
||||||
|
uci del network.$WANDEV.macaddr
|
||||||
|
else
|
||||||
|
uci del network.$WANDEV.macaddr
|
||||||
|
uci del network.$SWITCHDEV.macaddr
|
||||||
|
fi
|
||||||
|
|
||||||
uci set network.${SWITCHDEV}_3=switch_vlan
|
uci commit network
|
||||||
uci set network.${SWITCHDEV}_3.device=$SWITCHHW
|
|
||||||
uci set network.${SWITCHDEV}_3.vlan=3
|
|
||||||
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
|
|
||||||
|
|
||||||
uci set network.client.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
|
fi
|
||||||
|
else
|
||||||
|
if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
|
||||||
|
|
||||||
uci commit network
|
SWITCHHW=$(swconfig list | awk '{ print $4 }')
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$ONE_PORT" = "YES" ] && ( ! uci -q get network.$SWITCHDEV.ifname || [ "$FORCEPARSE" = '1' ] ) ; then
|
uci set network.$SWITCHDEV=switch
|
||||||
uci set network.$SWITCHDEV=interface
|
uci set network.$SWITCHDEV.name=$SWITCHHW
|
||||||
uci set network.$SWITCHDEV.ifname=$SWITCHDEV
|
uci set network.$SWITCHDEV.enable=1
|
||||||
if [ "$ETHMODE" = "WAN" ]; then
|
uci set network.$SWITCHDEV.reset=1
|
||||||
uci set network.client.ifname="bat0"
|
uci set network.$SWITCHDEV.enable_vlan=1
|
||||||
uci set network.wan.ifname="$WANDEV"
|
|
||||||
uci del network.ethmesh.ifname
|
uci set network.${SWITCHDEV}_1=switch_vlan
|
||||||
uci del network.${SWITCHDEV}.macaddr
|
uci set network.${SWITCHDEV}_1.device=$SWITCHHW
|
||||||
elif [ "$ETHMODE" = "CLIENT" ] ; then
|
uci set network.${SWITCHDEV}_1.vlan=1
|
||||||
uci set network.client.ifname="bat0 $SWITCHDEV"
|
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
|
||||||
uci set network.wan.ifname="eth2" #eth2 because it is default in config file
|
|
||||||
uci del network.ethmesh.ifname
|
if [ "$WANDEV" = "$SWITCHDEV" ] || [ -n "$WAN_PORTS" ]; then
|
||||||
uci del network.${SWITCHDEV}.macaddr
|
uci set network.${SWITCHDEV}_2=switch_vlan
|
||||||
elif [ "$ETHMODE" = "BATMAN" ] ; then
|
uci set network.${SWITCHDEV}_2.device=$SWITCHHW
|
||||||
uci set network.client.ifname="bat0"
|
uci set network.${SWITCHDEV}_2.vlan=2
|
||||||
uci set network.wan.ifname="eth2" #eth2 because it is default in config file
|
uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
|
||||||
uci set network.ethmesh.ifname="$SWITCHDEV"
|
fi
|
||||||
ETH0MAC="w2ap"
|
|
||||||
|
uci set network.${SWITCHDEV}_3=switch_vlan
|
||||||
|
uci set network.${SWITCHDEV}_3.device=$SWITCHHW
|
||||||
|
uci set network.${SWITCHDEV}_3.vlan=3
|
||||||
|
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
|
||||||
|
|
||||||
|
uci set network.client.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 network
|
||||||
fi
|
fi
|
||||||
uci commit network
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/etc/init.d/network restart
|
/etc/init.d/network restart
|
||||||
|
@ -166,14 +191,14 @@ if [ -n "$ROUTERMAC" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$ETH0MAC" ]; then
|
if [ -n "$ETH0MAC" ]; then
|
||||||
echo "Fixing MAC on $SWITCHDEV"
|
echo "Fixing MAC on $ETH0DEV"
|
||||||
sleep 10
|
sleep 10
|
||||||
NEW_MACADDR=$(cat "/sys/class/net/${ETH0MAC}/address")
|
NEW_MACADDR=$(cat "/sys/class/net/${ETH0MAC}/address")
|
||||||
uci set network.${SWITCHDEV}.macaddr=$NEW_MACADDR
|
uci set network.$ETH0DEV.macaddr=$NEW_MACADDR
|
||||||
uci commit network
|
uci commit network
|
||||||
ifconfig $SWITCHDEV down
|
ifconfig $ETH0DEV down
|
||||||
ifconfig $SWITCHDEV hw ether $NEW_MACADDR
|
ifconfig $ETH0DEV hw ether $NEW_MACADDR
|
||||||
ifconfig $SWITCHDEV up
|
ifconfig $ETH0DEV up
|
||||||
/etc/init.d/network restart
|
/etc/init.d/network restart
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
. /lib/functions/fff/network
|
WANDEV=eth1
|
||||||
|
|
||||||
WANDEV=eth0
|
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="0t"
|
TWO_PORT=YES
|
||||||
WAN_PORTS="0t"
|
|
||||||
BATMAN_PORTS="0t"
|
|
||||||
|
|
||||||
# use mac address from phy0 with 'locally administered' bit set to '1'
|
|
||||||
# only possible, because wXmesh is created first and therefore gets the 'universally administered address'
|
|
||||||
|
|
||||||
ETHMESHMAC=$(macFlipLocalBit "$(cat /sys/class/ieee80211/phy0/macaddress)")
|
|
||||||
|
|
||||||
. /etc/network.mode
|
. /etc/network.mode
|
||||||
|
|
||||||
LAN0PORT=5
|
|
||||||
LAN1PORT=4
|
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
. /lib/functions/fff/network
|
WANDEV=eth1
|
||||||
|
|
||||||
WANDEV=eth0
|
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="0t"
|
TWO_PORT=YES
|
||||||
WAN_PORTS="0t"
|
|
||||||
BATMAN_PORTS="0t"
|
|
||||||
|
|
||||||
# use mac address from phy0 with 'locally administered' bit set to '1'
|
|
||||||
# only possible, because wXmesh is created first and therefore gets the 'universally administered address'
|
|
||||||
|
|
||||||
ETHMESHMAC=$(macFlipLocalBit "$(cat /sys/class/ieee80211/phy0/macaddress)")
|
|
||||||
|
|
||||||
. /etc/network.mode
|
. /etc/network.mode
|
||||||
|
|
||||||
LAN0PORT=5
|
|
||||||
LAN1PORT=4
|
|
||||||
|
|
Loading…
Reference in New Issue