diff --git a/src/confd/bin/.confdrc b/src/confd/bin/.confdrc index b783e426..b8a5a1b6 100644 --- a/src/confd/bin/.confdrc +++ b/src/confd/bin/.confdrc @@ -18,7 +18,7 @@ FAILURE_CFG=$CFG_PATH_/failure-config.cfg STARTUP_CFG=$CFG_PATH_/startup-config.cfg # Uncomment this line in to create a bridge (br0) with all (classified -# 'gruop port') interfaces as bridge ports. The br0 interface will get +# 'group port') interfaces as bridge ports. The br0 interface will get # an IPv6 EUI64 SLAAC address as well as an IPv4 ZeroConf address, and a # DHCPv4 address if the device is attached to a LAN with a DHCP server. #GEN_IFACE_OPTS="-b -4 -d" diff --git a/src/confd/bin/gen-interfaces b/src/confd/bin/gen-interfaces index 8d80a0aa..d3611eba 100755 --- a/src/confd/bin/gen-interfaces +++ b/src/confd/bin/gen-interfaces @@ -8,13 +8,12 @@ # -b brN Bridged mode, set all interfaces as ports in brN # -4 Generic option for both modes, enables ZeroConf IPv4 # -d Generic option for both modes, enables DHCPv4 client -# -g grp Filter interfaces using 'ip link show group grp' # # By default this script generates plain interfaces with IPv6 autoconfig # (EUI64) enabled. Useful both in a plain router and a Fail Secure mode # where any switchcore-backed ports should be prevented from switching. # -# The default mode currently does not support the '-4' or '-d' options, +# The default mode currently does not support the '-4' or '-d' options # for IPv4 ZeroConf or DHCPv4 address, beacause they require source # routing, or similar, to work. IPv6 does not require that and is # therefore the recommended access method. A separate (and optional) @@ -22,18 +21,23 @@ # can be used to enable IPv4 and DHCP on a single service interface if # needed. # -# The -b option triggers the bridge mode, creating a 'brN' interface -# using all interfaces classified in 'group port' by the nameif script. -# In the bridge mode port interfaces do not have any IP address, the -# IPv6 autoconfig address is instead set on 'brN'. If the '-4' option -# is set, ZeroConfig (169.254.x.y) is anabled on 'brN'. If the '-d' -# option is set, a DHCPv4 client is enabled on 'brN'. - +# The '-b brname' option triggers the bridge mode, creating a 'brname' +# bridge interface using all interfaces classified in 'group port' by +# the nameif script. In the bridge mode port interfaces do not have any +# IP address, the IPv6 autoconfig address is instead set on 'brN'. If +# the '-4' option is set, ZeroConfig (169.254.x.y) is anabled on 'brN'. +# If the '-d' option is set, a DHCPv4 client is enabled on 'brN'. +# +# A "mixed mode" is also supported, where the system may have multiple +# ports in a switchcore, but some Ethernet interfaces directly connected +# to the SoC. In this case, if '-b brname' is given, all 'group port' +# interfaces will be placed in the bridge 'brname' and all other +# interfaces will be brought up and given an IPv6 address (like above). +# set -e bridge= ipv4=false -ipv6=true dhcp= gen_interface() @@ -66,27 +70,41 @@ while [ "$1" != "" ]; do -b) bridge="$2" shift - ipv6=false # for bridge port interfaces ;; -d) dhcp=true ;; - -g) - group="group $2" # -g port => 'ip link show group port' - shift - ;; *) break esac shift done -phys_ifaces=$(ip -d -j link show $group | jq -r ' +phys_ifaces=$(ip -d -j link show | jq -r ' .[] | select(.link_type == "ether") | select(.group != "internal") | select(has("parentbus")) | .ifname') +ports=$(ip -d -j link show group port | jq -r ' + .[] | + select(.link_type == "ether") | + select(.group != "internal") | + select(has("parentbus")) | + .ifname') +ifaces="" +for phy in $phys_ifaces; do + found="" + for port in $ports; do + if [ $port = $phy ]; then + found=true + break + fi + done + if [ -z "$found" ]; then + ifaces="$ifaces $phy" + fi +done cat <