Installing -current the other day showed a broken list when picking
the IPv6 default route just like reported on bugs@ five days ago[1].

This behaviour can be reproduced manually running the code from
v6_defroute():

        $ # source/define bsort()
        $ _if=trunk0
        $ bsort $(ping6 -n -c 2 ff02::2%$_if 2>/dev/null |
                sed -n '/bytes from/{s/^.*from //;s/,.*$//;p;}' |
                sed -n 'G;s/\n/&&/;/^\(.*\n\).*\n\1/d;h;P')
        fe80::____:__ff:fe__:___%trunk0: hlim=64 icmp_seq=0 icmp_seq=1 ms 
time=0.431 time=0.802

The first sed filters for those lines containing the router addresses
and does two things:
        1. strip leading text up to the address
        2. strip trailing text after the first ','

However, as far as i can see 'ping6 -nc2' will never output lines that
would match the second criteria thus making this part of the command
obsolete.

The second sed removes duplicate addresses (not neccessarily consecutive
ones). This works fine for itself, but as seen above its input contains
more than just addresses. Besides that, sorting through sed just before
having bsort() cleaning the list is duplicate effort here.

With this patch bsort() gets passed possibly duplicate IPv6 addresses
one per line so _routers will eventually contain a sorted list of unique
router addresses; this fixes the list shown during the installer.


While debugging this, I noticed that stopping after two echo replies
would sometimes show only one router; increasing this limit to three
made both of my network's routers reply/show up reliably.


Feedback/OK?

Index: install.sub
===================================================================
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1014
diff -u -p -r1.1014 install.sub
--- install.sub 3 Jun 2017 22:27:41 -0000       1.1014
+++ install.sub 14 Jun 2017 00:59:28 -0000
@@ -997,9 +997,8 @@ v6_defroute() {

        route -n show -inet6 | egrep -q '^default[[:space:]]' && return

-       _routers=$(bsort $(ping6 -n -c 2 ff02::2%$_if 2>/dev/null |
-               sed -n '/bytes from/{s/^.*from //;s/,.*$//;p;}' |
-               sed -n 'G;s/\n/&&/;/^\(.*\n\).*\n\1/d;h;P'))
+       _routers=$(bsort $(ping6 -n -c 3 ff02::2%$_if 2>/dev/null |
+               sed -n 's/^.*from \(.*\): .*$/\1/p'))

        _prompt="IPv6 default router?"


Reply via email to