Skip to content

Commit ad7836d

Browse files
authored
Update dhcp and vlan scripts to be more precise: (#155)
## Description Scripts now only work off specific interfaces instead of manipulating all interfaces. ## Why is this needed Fixes: # ## How Has This Been Tested? ## How are existing users impacted? What migration steps/scripts do we need? ## Checklist: I have: - [ ] updated the documentation and/or roadmap (if required) - [ ] added unit or e2e tests - [ ] provided instructions on how to upgrade
2 parents 5084ed3 + 38803b5 commit ad7836d

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ jobs:
5050
run: nix-shell --run .github/workflows/formatters-and-linters.sh
5151

5252
- name: Build Hook Tarballs
53-
run: nix-shell --run 'make TAG=${{steps.commitid.outputs.short}} dist'
53+
run: |
54+
# fixes "write /run/user/1001/355792648: no space left on device" error
55+
sudo mount -o remount,size=3G /run/user/1001 || true
56+
nix-shell --run 'make TAG=${{steps.commitid.outputs.short}} dist'
5457
5558
- name: Publish Hook
5659
if: github.ref == 'refs/heads/main'

files/dhcp.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@
77
# false: run the dhcp client as a service
88
set -x
99

10+
parse_cmdline() {
11+
c=$(cat /proc/cmdline)
12+
c="${c##*"$1"=}"
13+
c="${c%% *}"
14+
echo "$c"
15+
}
16+
1017
run_dhcp_client() {
1118
one_shot="$1"
1219
al="eth*"
1320

14-
# shellcheck disable=SC2013
15-
for x in $(cat /proc/cmdline); do
16-
# shellcheck disable=SC2022
17-
echo "$x" | grep -qe 'vlan_id*' || continue
18-
vlan_id="${x#vlan_id=}"
19-
if [ -n "$vlan_id" ]; then
20-
al="eth*.*"
21-
fi
22-
done
21+
vlan_id=$(parse_cmdline vlan_id)
22+
if [ -n "$vlan_id" ]; then
23+
al="eth*.*"
24+
fi
2325

2426
# Boots send kernel command line parameter "ip=dhcp", this causes the system to configure the network interface(s) with DHCP.
2527
# When an environment's network configuration has this machine connected a trunked interface with a default/native VLAN, the

files/vlan.sh

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
# This script will set up VLAN interfaces if `vlan_id=` in `/proc/cmdline` has a value
44
set -x
55

6+
parse_cmdline() {
7+
c=$(cat /proc/cmdline)
8+
c="${c##*"$1"=}"
9+
c="${c%% *}"
10+
echo "$c"
11+
}
12+
613
add_vlan_interface() {
7-
# shellcheck disable=SC2013
8-
for param in $(cat /proc/cmdline); do
9-
# shellcheck disable=SC2022
10-
echo "$param" | grep -qe 'vlan_id*' || continue
11-
vlan_id="${param#vlan_id=}"
12-
if [ -n "$vlan_id" ]; then
13-
for ifname in $(ip -4 -o link show | awk -F': ' '{print $2}'); do
14-
[ "$ifname" = "lo" ] && continue
15-
[ "$ifname" = "docker0" ] && continue
16-
ip link add link "$ifname" name "$ifname.$vlan_id" type vlan id "$vlan_id"
17-
ip link set "$ifname.$vlan_id" up
18-
done
19-
return
14+
vlan_id=$(parse_cmdline vlan_id)
15+
if [ -n "$vlan_id" ]; then
16+
hw_addr=$(parse_cmdline hw_addr)
17+
if [ -n "$hw_addr" ]; then
18+
ifname=$(ip -br link | awk '$3 ~ /'"${hw_addr}"'/ {print $1}')
19+
if [ -n "$ifname" ]; then
20+
ip link set dev "${ifname}" up || true
21+
ip link add link "${ifname}" name "${ifname}.${vlan_id}" type vlan id "${vlan_id}" || true
22+
ip link set "${ifname}.${vlan_id}" up || true
23+
return
24+
fi
2025
fi
21-
done
26+
fi
2227
}
2328

2429
# we always return true so that a failure here doesn't block the next container service from starting. Ideally, we always

0 commit comments

Comments
 (0)