summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-06-11 14:23:23 +0200
committerSimon Rettberg2024-06-11 14:23:23 +0200
commit31047b2a892a7d958d7c45698913b4f056b75951 (patch)
tree557d7246ba72d7341ccb3e7e064a3b3852ce3ef9
parent[dhcpc-busybox] 1 is not a valid routing table index (diff)
downloadmltk-31047b2a892a7d958d7c45698913b4f056b75951.tar.gz
mltk-31047b2a892a7d958d7c45698913b4f056b75951.tar.xz
mltk-31047b2a892a7d958d7c45698913b4f056b75951.zip
[dhcpc-busybox] Fix calculating prefix size of secondary NICs
-rwxr-xr-xcore/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx16
1 files changed, 11 insertions, 5 deletions
diff --git a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
index 8db3c2d8..a90d5bfa 100755
--- a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
+++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
@@ -116,6 +116,11 @@ check_env() {
fi
}
+ipc() {
+ # Use the busybox ipcalc explicity as it's incompatible with the perl-one
+ busybox ipcalc -s "$@"
+}
+
mkdir -p "/run/network"
case "$1" in
@@ -130,13 +135,14 @@ case "$1" in
alt_table= # Use separate routing table?
if [ "$interface" != "$primary" ]; then
pri_net="$( ip addr show dev "${primary}" | awk '$1 == "inet" {print $2; exit}' )"
- pri_net="$( ipcalc -s -n "$pri_net" | sed 's/^.*=//' )"
- this_net="$( ipcalc -s -n "$ip" "$subnet" | sed 's/^.*=//' )"
+ [[ "$pri_net" == */* ]] || pri_net="${pri_net}/32"
+ pri_net="$( ipc -n "$pri_net" | sed 's/^.*=//' )/${pri_net#*/}"
+ this_net="$( ipc -n "$ip" "$subnet" | sed 's/^.*=//' )/$( ipc -p "$ip" "$subnet" | sed 's/^.*=//' )"
[ "$pri_net" = "$this_net" ] && alt_table=yes
fi
if [ -z "$alt_table" ]; then
# default table
- ip addr add "$ip/$( ipcalc -s -p "$ip" "$subnet" | sed 's/^.*=//' )" dev "$interface"
+ ip addr add "$ip/$( ipc -p "$ip" "$subnet" | sed 's/^.*=//' )" dev "$interface"
# Set default route, if given
if [ -n "$router" ]; then
# Only replace route if it's the same interface as the current default route, or we don't have any
@@ -162,7 +168,7 @@ case "$1" in
}' /etc/iproute2/rt_tables )"
echo "$alt_table $interface" >> /etc/iproute2/rt_tables
fi
- ip addr add "$ip/$( ipcalc -s -p "$ip" "$subnet" | sed 's/.*=//' )" dev "$interface" noprefixroute
+ ip addr add "$ip/$( ipc -p "$ip" "$subnet" | sed 's/.*=//' )" dev "$interface" noprefixroute
ip route add "$this_net" dev "$interface" scope link src "$ip" table "$interface"
ip rule add from "$ip" table "$interface"
# Set default route, if given
@@ -331,7 +337,7 @@ case "$1" in
else
echo 1 > "/proc/sys/net/ipv4/conf/$interface/promote_secondaries"
clientip=${ip%%:*}
- ip addr del "$clientip/$(ipcalc -s -p "$clientip" "$subnet" | sed s/.*=//)" dev "$interface"
+ ip addr del "$clientip/$(ipc -p "$clientip" "$subnet" | sed s/.*=//)" dev "$interface"
ip route flush table "$interface"
sed -i "/^$(escape_search "$ip")(\s|$)/d" /etc/hosts
fi