From e514cf419db7af0133ee131cc347c62bb24e6286 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 16 Jan 2023 18:16:43 +0100 Subject: [PATCH] board/common: use swup to ensure port and iface groups exist Used by the 'show' script for grouping and filtering Linux interfaces. Signed-off-by: Joachim Wiberg --- board/common/rootfs/lib/infix/swup | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/board/common/rootfs/lib/infix/swup b/board/common/rootfs/lib/infix/swup index f2a52bf2..68c3c0c3 100755 --- a/board/common/rootfs/lib/infix/swup +++ b/board/common/rootfs/lib/infix/swup @@ -29,11 +29,14 @@ for netif in /sys/class/net/*; do num=$((num + 1)) done -# Verify that the 'port' group exists +# Verify that the 'port' and 'iface' groups exists +[ -d /etc/iproute2 ] || mkdir -p /etc/iproute2 if ! grep -q port /etc/iproute2/group; then - mkdir -p /etc/iproute2 echo "1 port" >> /etc/iproute2/group fi +if ! grep -q iface /etc/iproute2/group; then + echo "2 iface" >> /etc/iproute2/group +fi # Find and mark all switch ports ports=$(devlink port 2>/dev/null | awk '/flavour physical/{print $5}') @@ -48,6 +51,9 @@ for iface in $ports; do ip link set "$iface" group port done +# At least loopback in iface group +ip link set lo group iface + # Factory default: all switch ports in VLAN 1 of br0 # need to check for 'length > 0' because ip command # outputs empty json objects for non-port group ifs @@ -66,4 +72,5 @@ if [ ! -f /etc/network/interfaces.d/br0 ] && [ -n "$ports" ]; then vlan-id 1 vlan-raw-device br0 EOF + ip link set vlan1 group iface fi