From d791f31d510b538b49d3efc8211bda46d6d1500e Mon Sep 17 00:00:00 2001 From: minoplhy Date: Wed, 11 Dec 2024 23:38:50 +0700 Subject: [PATCH] alpine-initramfs: fix ipv6 routing priorities --- .../initramfs-dropbear-ipv6 | 7 +++++-- .../initramfs-dropbear-ipv6.patch | 19 +++++++++++-------- alpine-initramfs-ipv6/alpine-initramfs-ipv6 | 13 ++++++++----- .../alpine-initramfs-ipv6.patch | 19 +++++++++++-------- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/alpine-initramfs-dropbear/initramfs-dropbear-ipv6 b/alpine-initramfs-dropbear/initramfs-dropbear-ipv6 index 8c85001..36a7b42 100644 --- a/alpine-initramfs-dropbear/initramfs-dropbear-ipv6 +++ b/alpine-initramfs-dropbear/initramfs-dropbear-ipv6 @@ -332,8 +332,11 @@ configure_ip6() { if ip -6 addr add $client6_ip dev $iface; then # this is definitely not required by all ipv6 implementation - # but it's better to keep working imo for. - [ -z "$gw6_ip" ] || ip route add "$client6_ip" via "$gw6_ip" dev "$iface" + # but it's better to keep things working for all deployment possible + # + # metric is mandatory! + [ -z "$gw6_ip" ] || ip -6 route add "$gw6_ip" dev $iface metric 256 + [ -z "$gw6_ip" ] || ip -6 route add ::0/0 via "$gw6_ip" dev "$iface" metric 128 fi eend $? diff --git a/alpine-initramfs-dropbear/initramfs-dropbear-ipv6.patch b/alpine-initramfs-dropbear/initramfs-dropbear-ipv6.patch index 7ba6f38..21beda9 100644 --- a/alpine-initramfs-dropbear/initramfs-dropbear-ipv6.patch +++ b/alpine-initramfs-dropbear/initramfs-dropbear-ipv6.patch @@ -1,4 +1,4 @@ -271a272,347 +271a272,350 > # configure ipv6 on initramfs > # Valid syntaxes: > # ip6=client-ip/gateway-ip/interface/dns1/dns2 @@ -62,8 +62,11 @@ > > if ip -6 addr add $client6_ip dev $iface; then > # this is definitely not required by all ipv6 implementation -> # but it's better to keep working imo for. -> [ -z "$gw6_ip" ] || ip route add "$client6_ip" via "$gw6_ip" dev "$iface" +> # but it's better to keep things working for all deployment possible +> # +> # metric is mandatory! +> [ -z "$gw6_ip" ] || ip -6 route add "$gw6_ip" dev $iface metric 256 +> [ -z "$gw6_ip" ] || ip -6 route add ::0/0 via "$gw6_ip" dev "$iface" metric 128 > fi > eend $? > @@ -75,7 +78,7 @@ > MAC_ADDRESS=$(cat "$ROOT/sys/class/net/$iface/address") > } > -325a402,416 +325a405,419 > setup_dropbear() { > local port="${KOPT_dropbear}" > local keys="" @@ -91,10 +94,10 @@ > dropbear -R -E -s -j -k -p $port > } > -513a605,606 +513a608,609 > dropbear > ip6 -642c735,743 +642c738,746 < if [ -n "$KOPT_cryptroot" ]; then --- > if [ -n "$KOPT_dropbear" ]; then @@ -106,12 +109,12 @@ > > # Add Workaround for dropbear > if [ -n "$KOPT_cryptroot" ] && [ ! -b /dev/mapper/"${KOPT_cryptdm}" ]; then -706a808,811 +706a811,814 > # Kill all struck nlplug-findfs jobs and dropbear > killall -9 nlplug-findfs > killall -9 dropbear > -789a895,898 +789a898,901 > > # Kill all struck nlplug-findfs jobs and dropbear > killall -9 nlplug-findfs diff --git a/alpine-initramfs-ipv6/alpine-initramfs-ipv6 b/alpine-initramfs-ipv6/alpine-initramfs-ipv6 index ee4173d..8fbd513 100644 --- a/alpine-initramfs-ipv6/alpine-initramfs-ipv6 +++ b/alpine-initramfs-ipv6/alpine-initramfs-ipv6 @@ -286,8 +286,8 @@ configure_ip6() { local client6_ip="$1" local gw6_ip="$2" local iface="$3" - local dns1="$4" - local dns2="$5" + local dns1="$4" + local dns2="$5" if [ -e "$ROOT"/etc/mactab ]; then $MOCK nameif -s @@ -331,9 +331,12 @@ configure_ip6() { ebegin "Setting IP ($iface)" if ip -6 addr add $client6_ip dev $iface; then - # this is definitely not required by all ipv6 implementation - # but it's better to keep working imo for. - [ -z "$gw6_ip" ] || ip route add "$client6_ip" via "$gw6_ip" dev "$iface" + # this is definitely not required by all ipv6 implementation + # but it's better to keep things working for all deployment possible + # + # metric is mandatory! + [ -z "$gw6_ip" ] || ip -6 route add "$gw6_ip" dev $iface metric 256 + [ -z "$gw6_ip" ] || ip -6 route add ::0/0 via "$gw6_ip" dev "$iface" metric 128 fi eend $? diff --git a/alpine-initramfs-ipv6/alpine-initramfs-ipv6.patch b/alpine-initramfs-ipv6/alpine-initramfs-ipv6.patch index f27a47c..a10a44a 100644 --- a/alpine-initramfs-ipv6/alpine-initramfs-ipv6.patch +++ b/alpine-initramfs-ipv6/alpine-initramfs-ipv6.patch @@ -1,4 +1,4 @@ -271a272,347 +271a272,350 > # configure ipv6 on initramfs > # Valid syntaxes: > # ip6=client-ip/gateway-ip/interface/dns1/dns2 @@ -16,8 +16,8 @@ > local client6_ip="$1" > local gw6_ip="$2" > local iface="$3" -> local dns1="$4" -> local dns2="$5" +> local dns1="$4" +> local dns2="$5" > > if [ -e "$ROOT"/etc/mactab ]; then > $MOCK nameif -s @@ -61,9 +61,12 @@ > ebegin "Setting IP ($iface)" > > if ip -6 addr add $client6_ip dev $iface; then -> # this is definitely not required by all ipv6 implementation -> # but it's better to keep working imo for. -> [ -z "$gw6_ip" ] || ip route add "$client6_ip" via "$gw6_ip" dev "$iface" +> # this is definitely not required by all ipv6 implementation +> # but it's better to keep things working for all deployment possible +> # +> # metric is mandatory! +> [ -z "$gw6_ip" ] || ip -6 route add "$gw6_ip" dev $iface metric 256 +> [ -z "$gw6_ip" ] || ip -6 route add ::0/0 via "$gw6_ip" dev "$iface" metric 128 > fi > eend $? > @@ -75,5 +78,5 @@ > MAC_ADDRESS=$(cat "$ROOT/sys/class/net/$iface/address") > } > -513a590 -> ip6 +513a593 +> ip6