Skip to content

Commit ebb3773

Browse files
authored
Merge pull request #1177 from kernelkit/multi-dsa-tree-fixes
Multi DSA tree fixes
2 parents a096a56 + 94f8d1a commit ebb3773

File tree

3 files changed

+51
-18
lines changed

3 files changed

+51
-18
lines changed
Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,49 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
3+
IFQUIRKSFILE=${IFQUIRKSFILE:-/etc/product/interface-quirks.json}
4+
25
if [ $# -lt 2 ]; then
36
echo "usage: $0 <quirk-name> <ifname>"
47
exit 1
58
fi
9+
610
quirk=$1
711
ifname=$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"

board/common/rootfs/usr/libexec/infix/init.d/20-nameif

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ ports=$(devlink -j port | jq -r '.port[]
3434
| select(.flavour == "physical")
3535
| .netdev')
3636
for 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
3844
done
3945

src/confd/src/ietf-interfaces.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,8 @@
1717

1818
bool 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

3424
static bool iface_is_phys(const char *ifname)

0 commit comments

Comments
 (0)