File tree Expand file tree Collapse file tree 3 files changed +51
-18
lines changed
board/common/rootfs/usr/libexec/infix Expand file tree Collapse file tree 3 files changed +51
-18
lines changed Original file line number Diff line number Diff line change 1- #! /bin/sh
1+ #! /bin/bash
2+
3+ IFQUIRKSFILE=${IFQUIRKSFILE:-/ etc/ product/ interface-quirks.json}
4+
25if [ $# -lt 2 ]; then
36 echo " usage: $0 <quirk-name> <ifname>"
47 exit 1
58fi
9+
610quirk=$1
711ifname=$2
8- if [ -f " /etc/product/interface-quirks.json" ]; then
9- echo " $( jq -r --arg iface " $ifname " --arg quirk " $quirk " ' .[$iface][$quirk] // "false"' /etc/product/interface-quirks.json) "
10- else
11- echo " false"
12- fi
12+
13+ [ -f " $IFQUIRKSFILE " ] || { echo false && exit ; }
14+
15+ match ()
16+ {
17+ jq -e \
18+ --arg quirk " $quirk " --arg pattern " $1 " \
19+ ' .[$pattern][$quirk]' " $IFQUIRKSFILE " > /dev/null || return
20+
21+ echo true
22+ exit 0
23+ }
24+
25+ ethtoolmatch ()
26+ {
27+ local pattern=" ${1#@ ethtool: } "
28+
29+ grep -qFxvf \
30+ <( ethtool -i " $ifname " ) \
31+ <( echo -n " $pattern " | awk -v FS=" =" -v RS=" ;" ' { printf("%s: %s\n", $1, $2); }' ) \
32+ && return
33+
34+ match " @ethtool:$pattern "
35+ }
36+
37+
38+ for pattern in $( jq -r ' keys[]' " $IFQUIRKSFILE " ) ; do
39+ case " $pattern " in
40+ @ethtool:* )
41+ ethtoolmatch " $pattern "
42+ ;;
43+ " $ifname " )
44+ match " $ifname "
45+ ;;
46+ esac
47+ done
48+
49+ echo " false"
Original file line number Diff line number Diff line change @@ -34,6 +34,12 @@ ports=$(devlink -j port | jq -r '.port[]
3434 | select(.flavour == "physical")
3535 | .netdev' )
3636for iface in $ports ; do
37+ # On systems with multiple switch trees, a port may be _both_
38+ # a physical port, registered with devlink, _and_ a DSA
39+ # port. In those cases, hold on to our initial "internal"
40+ # classification.
41+ [ $( ip -j link show dev " $iface " | jq -r ' .[0].group' ) = internal ] && continue
42+
3743 ip link set " $iface " group port
3844done
3945
Original file line number Diff line number Diff line change 1717
1818bool iface_has_quirk (const char * ifname , const char * quirkname )
1919{
20- struct json_t * iface , * quirk ;
21-
22- if (!confd .ifquirks )
23- return false;
24-
25- iface = json_object_get (confd .ifquirks , ifname );
26- if (!iface )
27- return false;
28-
29- quirk = json_object_get (iface , quirkname );
30-
31- return quirk ? json_is_true (quirk ) : false;
20+ return systemf ("[ $(/usr/libexec/infix/has-quirk %s %s) = true ]" ,
21+ quirkname , ifname ) == 0 ;
3222}
3323
3424static bool iface_is_phys (const char * ifname )
You can’t perform that action at this time.
0 commit comments