Skip to content

Commit 5c6070e

Browse files
committed
Fix LLDP in hhnet script
Signed-off-by: Pau Capdevila <pau@githedgehog.com>
1 parent 9e15aee commit 5c6070e

File tree

1 file changed

+5
-35
lines changed

1 file changed

+5
-35
lines changed

pkg/hhfab/hhnet.sh

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function cleanup() {
2424
sudo rm -f "$NETWORKD_PATH"/20-slave*.network
2525
sudo rm -f "$NETWORKD_PATH"/30-vlan*.network "$NETWORKD_PATH"/30-vlan*.netdev
2626

27-
sudo systemctl restart systemd-networkd 2> /dev/null || true
27+
sudo networkctl reload 2> /dev/null || true
2828
sleep 2
2929
}
3030

@@ -53,12 +53,14 @@ EOF
5353
Name=$iface
5454
[Network]
5555
Bond=$bond_name
56+
LLDP=yes
57+
EmitLLDP=yes
5658
[Link]
5759
MTUBytes=9036
5860
EOF
5961
done
6062

61-
sudo systemctl restart systemd-networkd 2> /dev/null || true
63+
sudo networkctl reload 2> /dev/null || true
6264
sleep 5
6365
}
6466

@@ -102,39 +104,10 @@ VLAN=$parent_iface.$vlan_id
102104
MTUBytes=9036
103105
EOF
104106

105-
sudo systemctl restart systemd-networkd 2> /dev/null || true
107+
sudo networkctl reload 2> /dev/null || true
106108
sleep 5
107109
}
108110

109-
function wait_for_interface() {
110-
local iface_name=$1
111-
local max_attempts=60
112-
local attempt=0
113-
local retry_delay=1
114-
115-
while true; do
116-
attempt=$((attempt + 1))
117-
118-
local status
119-
status=$(sudo networkctl status "$iface_name" 2> /dev/null)
120-
121-
if echo "$status" | grep -q "State: routable" 2> /dev/null; then
122-
return 0
123-
elif echo "$status" | grep -q "State: carrier" 2> /dev/null; then
124-
return 0
125-
elif echo "$status" | grep -q "State: degraded" 2> /dev/null; then
126-
return 0
127-
fi
128-
129-
if [ "$attempt" -ge "$max_attempts" ]; then
130-
echo "Interface $iface_name failed to become ready after $max_attempts attempts"
131-
return 1
132-
fi
133-
134-
sleep "$retry_delay"
135-
done
136-
}
137-
138111
function get_ip() {
139112
local iface_name=$1
140113
local ip=""
@@ -177,9 +150,7 @@ elif [ "$1" == "bond" ]; then
177150
fi
178151
setup_bond bond0 "${@:3}" || exit 1
179152
sleep 1
180-
wait_for_interface bond0 || exit 1
181153
setup_vlan bond0 "$2" || exit 1
182-
wait_for_interface "bond0.$2" || exit 1
183154
get_ip "bond0.$2" || exit 1
184155
exit 0
185156
elif [ "$1" == "vlan" ]; then
@@ -188,7 +159,6 @@ elif [ "$1" == "vlan" ]; then
188159
exit 1
189160
fi
190161
setup_vlan "$3" "$2" || exit 1
191-
wait_for_interface "$3.$2" || exit 1
192162
get_ip "$3.$2" || exit 1
193163
exit 0
194164
else

0 commit comments

Comments
 (0)