Path: csiph.com!news.mixmin.net!news2.arglkargh.de!news.karotte.org!fu-berlin.de!bofh.it!news.nic.it!robomod From: Thorsten Glaser Newsgroups: linux.debian.bugs.dist,linux.debian.kernel Subject: Bug#627164: klibc-utils: ipconfig does not support IPv6 (was Re: ipconfig: fails to add default gateway) Date: Tue, 02 Jan 2024 03:00:01 +0100 Message-ID: References: X-Original-To: klibc@zytor.com, 627164@bugs.debian.org, 627164-submitter@bugs.debian.org X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org Tue Jan 2 01:51:11 2024 Old-Return-Path: X-Spam-Flag: NO X-Spam-Score: 0.24 Reply-To: 627164@bugs.debian.org, 627164-submitter@bugs.debian.org, tg@debian.org, 627164@bugs.debian.org Resent-To: debian-bugs-dist@lists.debian.org Resent-Cc: Debian Kernel Team X-Debian-Pr-Message: followup 627164 X-Debian-Pr-Package: klibc-utils X-Debian-Pr-Keywords: upstream ipv6 X-Debian-Pr-Source: klibc X-X-Sender: tg@herc.mirbsd.org Content-Language: de-Zsym-DE-1901-u-em-text-rg-denw-tz-utc, en-Zsym-GB-u-cu-eur-em-text-fw-mon-hc-h23-ms-metric-mu-celsius-rg-denw-tz-utc-va-posix MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Crossassassin-Score: 2 X-Debian-Message: from BTS X-Mailing-List: archive/latest/1813919 List-ID: List-URL: Approved: robomod@news.nic.it Lines: 362 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Date: Tue, 2 Jan 2024 01:46:57 +0000 (UTC) X-Original-Message-ID: X-Original-References: <20110518110337.25305.37428.reportbug@OptiPlex960.ruk.cuni.cz> Xref: csiph.com linux.debian.bugs.dist:1180745 linux.debian.kernel:81400 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA384 Dixi quod=E2=80=A6 >>(I will probably have to see how I can rip ipconfig off initramfs-tools >>and plug iproute2 in (YAAAAY! (NOT!)) since I also got a v6-only machine >>and the =E2=80=9Cip=3D=E2=80=9D kernel parameter is Legacy IP-only. Unles= s both are solved >>problems already. I could use v6 for this machine, too, if that would >>be easier.) > >And that would be Debian #627164 from 2011. > >Damn, I guess this means I=E2=80=99ll have to hack this up myself, perhaps= [=E2=80=A6] >(Adding this mostly for thread completeness, as the only thing of >this that pertains to klibc would be lack of IPv6 support and lack >of =E2=80=9Conlink=E2=80=9D flag support for a Legacy IP default route.) I did it! Extract the following shar archive into /etc/initramfs-tools/ first=E2=80= =A6 # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # #=09hooks/ipv6 #=09scripts/init-top/ipv6 #=09scripts/init-bottom/ipv6 # echo x - hooks/ipv6 sed 's/^X//' >hooks/ipv6 << 'END-of-hooks/ipv6' X#!/bin/sh X XPREREQ=3D"dropbear klibc-utils zz-busybox" Xprereqs() { X=09echo "$PREREQ" X} X Xcase $1 in X(prereqs) X=09prereqs X=09exit 0 X=09;; Xesac X X. /usr/share/initramfs-tools/hook-functions X Xset -e X Xtest -x "$DESTDIR/bin/ipconfig" || { X=09echo >&2 "E: klibc ipconfig not found" X=09exit 1 X} Xtest -x "$DESTDIR/bin/ip" || test -x "$DESTDIR/sbin/ip" || { X=09echo >&2 "E: ip(8), busybox or normal, not found" X=09exit 1 X} X Xmv "$DESTDIR/bin/ipconfig" "$DESTDIR/bin/ipconfig.klibc-dist" Xcat >"$DESTDIR/bin/ipconfig" <<\EOSCRIPT X#!/bin/sh Xcase ${1}=01${3}=01${4} in X(-t=01-d=01ipv6:*) X=09;; X(*) X=09echo >&2 "I: configuring something other than IPv6" X=09exec /bin/ipconfig.klibc-dist "$@" X=09exit 126 X=09;; Xesac Xset -e Xecho >&2 "I: configuring IPv6" X. /conf/param.conf Xcase $ipv6_ra:$ipv6_if in X([01]:?*) X=09;; X(*) X=09echo >&2 "E: cannot find IPv6 configuration" X=09exit 1 X=09;; Xesac Xtest -e "/proc/sys/net/ipv6/conf/$ipv6_if/accept_ra" || { X=09echo >&2 "E: cannot find interface for IPv6 configuration: $ipv6_if" X=09( ( ip a | sed 's/^/N: /' >&3) 2>&1 | sed 's/^/E: /') >&2 3>&2 X=09exit 1 X} X Xcat >"/run/net-$ipv6_if.conf" <>/conf/param.conf Xecho $ipv6_ra >"/proc/sys/net/ipv6/conf/$ipv6_if/accept_ra" X Xip link set dev "$ipv6_if" up || { X=09echo >&2 E: could not enable interface X=09exit 1 X} Xmaxwait=3D Xwhile test x"$(cat "/sys/class/net/$ipv6_if/operstate")" !=3D x"up"; do X=09if test x"$maxwait" =3D x"111111111111111"; then X=09=09echo >&2 X=09=09echo >&2 'W: link still not up? continuing anyway :/' X=09=09maxwait=3D X=09=09break X=09else X=09=09test -n "$maxwait" || echo -n >&2 \ X=09=09 'I: waiting until link comes up or 15 seconds ' X=09=09maxwait=3D1$maxwait X=09=09sleep 1 X=09=09echo -n >&2 . X=09fi Xdone Xtest -z "$maxwait" || echo >&2 ' done' Xif test -n "$ipv6_na"; then X=09ip -6 addr add "$ipv6_na" dev "$ipv6_if" || { X=09=09echo >&2 E: could not set up IP X=09=09exit 1 X=09} X=09if ip -6 addr show dev "$ipv6_if" to "$ipv6_na" dadfailed >/dev/null 2>= &1; then X=09=09maxwait=3D X=09=09while test -n "$(ip -6 addr show dev "$ipv6_if" to "$ipv6_na" tentat= ive)"; do X=09=09=09if test x"$maxwait" =3D x"1111111"; then X=09=09=09=09echo -n >&2 'timeout' X=09=09=09=09break X=09=09=09else X=09=09=09=09test -n "$maxwait" || echo -n >&2 \ X=09=09=09=09 'I: waiting for duplicate address detection ' X=09=09=09=09maxwait=3D1$maxwait X=09=09=09=09sleep 1 X=09=09=09=09echo -n >&2 . X=09=09=09fi X=09=09done X=09=09if test -z "$(ip -6 addr show dev "$ipv6_if" to "$ipv6_na" dadfailed= )"; then X=09=09=09test -z "$maxwait" || echo >&2 ' done' X=09=09elif test -z "$maxwait"; then X=09=09=09echo >&2 'E: duplicate address detection FAILED!' X=09=09else X=09=09=09echo >&2 ' FAILED!' X=09=09fi X=09else X=09=09echo >&2 'W: busybox ip(8) cannot handle duplicate address detection= ' X=09=09sleep 1 # justin case X=09fi Xfi Xif test -n "$ipv6_gw"; then X=09ip -6 route replace default via "$ipv6_gw" dev "$ipv6_if" onlink || { X=09=09echo >&2 E: could not set up default route X=09=09exit 1 X=09} Xfi Xtest -z "$ipv6_hn" || echo "$ipv6_hn" >/proc/sys/kernel/hostname Xip addr show dev "$ipv6_if" | sed 's/^/N: /' >&2 Xip -6 route list | sed 's/^/N: /' >&2 Xecho >&2 I: IPv6 set up successfully XEOSCRIPT Xchmod 555 "$DESTDIR/bin/ipconfig" END-of-hooks/ipv6 echo x - scripts/init-top/ipv6 sed 's/^X//' >scripts/init-top/ipv6 << 'END-of-scripts/init-top/ipv6' X#!/bin/sh X XPREREQ=3D"" Xprereqs() { X=09echo "$PREREQ" X} X Xcase $1 in X(prereqs) X=09prereqs X=09exit 0 X=09;; Xesac X X. /scripts/functions X Xcase $IP in X(6,[01],*[!0-9a-zA-Z/:.,-]*) X=09log_failure_msg "init-top/ipv6: IPv6 \$ip contains invalid characters" X=09exit 0 X=09;; X(6,[01],?*) X=09;; X(*) X=09exit 0 X=09;; Xesac X X# incoming syntax (ra is 0 or 1, keepup is 1 or absent=3D0): X#=09ip=3D6,ra,iface[,[hostname][,[ip/netmask][,[gw][,keepup]]]] X# examples: X#=09ip=3D6,1,eth0 X#=09ip=3D6,0,enx78e7d1ea46dc,0,,2001:db8::1/64 X#=09ip=3D6,0,wlan0,0,meow.example.org,2001:db8::1/64,fe80::1,1 X# but mind IFDOWN in /etc/dropbear-initramfs/config X# do also note that klibc/initramfs cannot do NFS over IPv6 either in 2024= (!) X Xset -o noglob XsaveIFS=3D$IFS XIFS=3D, Xset -- $IP XIFS=3D$saveIFS Xset +o noglob X Xip_ra=3D$2 Xip_if=3D$3 Xip_hn=3D$4 Xip_na=3D$5 Xip_gw=3D$6 Xip_up=3D$7 X Xcase $ip_if in X(*/*) X=09log_failure_msg "init-top/ipv6: IPv6 \$ip device contains a slash" X=09exit 0 X=09;; Xesac X Xcase x$ip_up in X(x|x0)=09ip_up=3D0 ;; X(*)=09ip_up=3D1 ;; Xesac X X# ip=3D::::::::: Xfakex=3Dipv6::::$ip_hn:$ip_if X Xmsg=3D"Preparing on $ip_if to" Xcase $ip_ra in X(0) X=09msg=3D"$msg not" X=09;; X(1) X=09;; X(*) X=09log_failure_msg "init-top/ipv6: bogus ra? cannot happen!" X=09exit 0 X=09;; Xesac Xmsg=3D"$msg accept router advertisements" Xtest -z "$ip_na" || msg=3D"$msg, IP $ip_na" Xtest -z "$ip_gw" || msg=3D"$msg, default route $ip_gw" Xtest -z "$ip_hn" || msg=3D"$msg, hostname $ip_hn" X Xcat >>/conf/param.conf <scripts/init-bottom/ipv6 << 'END-of-scripts/init-bottom/ipv6' X#!/bin/sh X XPREREQ=3D"dropbear" Xprereqs() { X=09echo "$PREREQ" X} X Xcase $1 in X(prereqs) X=09prereqs X=09exit 0 X=09;; Xesac X X. /scripts/functions X. /conf/param.conf X Xcase x$ipv6_keepup in X(x) X=09exit 0 X=09;; X(x1) X=09log_success_msg "init-bottom/ipv6: keeping interface $ipv6_if up" X=09exit 0 X=09;; Xesac X Xlog_begin_msg "init-bottom/ipv6: bringing interface $ipv6_if down" Xtest x"$ipv6_restore_ra" =3D x"NO" || \ X echo "$ipv6_restore_ra" >"/proc/sys/net/ipv6/conf/$ipv6_if/accept_ra" = || \ X log_failure_msg "could not restore accept_ra flag to $ipv6_restore_ra" Xip link set dev "$ipv6_if" down Xip addr flush dev "$ipv6_if" Xip route flush dev "$ipv6_if" Xlog_end_msg END-of-scripts/init-bottom/ipv6 exit =E2=80=A6 then put something like (with net.ifnames=3D0 of course)=E2=80=A6 =09ip=3D6,0,eth0,debian.example.org,2001:db8::1/128,fe80::1 =E2=80=A6 in GRUB_CMDLINE_LINUX in /etc/default/grub then regenerate the initramfs and update-grub and you=E2=80=99ll be set for some use cases, namely =E2=80=9Cremotely unlock full disc encryption with dropbear=E2=80=9D= =2E NFS over IPv6 still relies on klibc=E2=80=99s nfsmount utility (which is also insistent on using Legacy IP). But this is a start =E2=98=BB Enjoy, //mirabilos - --=20 Support mksh as /bin/sh and RoQA dash NOW! =E2=80=A3 src:bash (429 (458) bugs: 0 RC, 295 (315) I&N, 134 (143) M&W, 0 F= &P) + 209 =E2=80=A3 src:dash (90 (104) bugs: 0 RC, 51 (54) I&N, 39 (50) M&W, 0 F&P) += 62 ubu =E2=80=A3 src:mksh (1 bug: 0 RC, 0 I&N, 1 M&W, 0 F&P) dash has two RC bugs they just closed because they don=E2=80=99t care about= quality=E2=80=A6 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (MirBSD) Comment: =E2=98=83=C2=A0=D0=A6=CE=A4=E2=84=B1=E2=80=94=EF=BC=98=E3=80=80=E2= =98=95=E2=98=82=E2=98=84 iQIcBAEBCQAGBQJlk2rnAAoJEHa1NLLpkAfgw4EP/jzPt2jW3nv9Kajj54JWthfg 0u0upte/naWXr8Bh2RuwR/SSDBqMK5lIje95r98sEM8vyIYSOi+squuUFD+m6crd CSytntamw93Q2n3QMe44LYzx8U604lo/oDucxEPwvrvQek8UvXF2HEUYrlj+Tivz 89IHU6uF2TZK4kJFYjVZEy8XG7tsrICxjy1DQXmMTVZ+637MLul0p98rUTg5XfNL 4kprKT6VcZYxMsDWkU+xMWJd3Zrr+uMqT/JDKCACkQ1QsD7Zp2N1md7D0oPkYuqc po2QnIa5j56gHc7DLwxI8AvV8/awFsVBZhGkPHqTlU4mSRZE3E1CuAOq5if1YLmG TBV7MevD/LOOAr4noPeJd0mWDfCg1+3Tgwlt0exbveDqsrc3xL6Yfhim4hK6dZpc Lg/KkUQ0j5/uSByIdnII24g9m4ak2VTltORRJQyk3SpYfLuvhDQCsUti3KenanXv oewX2RbQ4dkn5PpNdOSmdT67iUjTw8YxoDOpM5Z4YMN0NY925dzk5RahwRfjUKlk jb5/rXjfBYsqnJuwK6Oy/ozQx4H7tVMq2xlGvaRk52Fy8BTSLz9QeHI3lU2Vgw1A dvB/DNfEK2zxEOoZtVbAIoN4ObONnKaT+6eVdKkwaS1Na4NahHYrGl9lLmLUYxGk pLo5P5WNnbcngyRxvgCm =3DW7Cl -----END PGP SIGNATURE-----