Bug 210747 - Routing table screwed up when adding routes for IPv6
Summary: Routing table screwed up when adding routes for IPv6
Status: Closed Works As Intended
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-net (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-01 18:42 UTC by Michael Tuexen
Modified: 2019-02-03 23:09 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Tuexen freebsd_committer freebsd_triage 2016-07-01 18:42:16 UTC
Steps to reproduce:

1. Create an interface
sudo ifconfig tun0 create inet6 fd3d:fa7b:d17d::1/48

2. Check routing table
netstat -nrfinet6
Routing tables

Internet6:
Destination                       Gateway                       Flags     Netif Expire
::/96                             ::1                           UGRS        lo0
::1                               link#2                        UH          lo0
::ffff:0.0.0.0/96                 ::1                           UGRS        lo0
fd3d:fa7b:d17d::/48               link#3                        U          tun0
fd3d:fa7b:d17d::1                 link#3                        UHS         lo0
fe80::/10                         ::1                           UGRS        lo0
fe80::%em0/64                     link#1                        U           em0
fe80::20c:29ff:fe8a:8910%em0      link#1                        UHS         lo0
fe80::%lo0/64                     link#2                        U           lo0
fe80::1%lo0                       link#2                        UHS         lo0
fe80::%tun0/64                    link#3                        U          tun0
fe80::20c:29ff:fe8a:8910%tun0     link#3                        UHS         lo0
ff02::/16                         ::1                           UGRS        lo0

3. Add route
sudo route add -inet6 2001:DB8::1/32 -interface tun0 fd3d:fa7b:d17d::2
add net 2001:DB8::1/32: gateway tun0

4. Check routing table
[freebsd11:~] tuexen% netstat -nrfinet6
Routing tables

Internet6:
Destination                       Gateway                       Flags     Netif Expire
::/96                             ::1                           UGRS        lo0
::1                               link#2                        UH          lo0
::ffff:0.0.0.0/96                 ::1                           UGRS        lo0
illegal prefixlen
2001:838::/0                      tun0                          US         tun0
fd3d:fa7b:d17d::/48               link#3                        U          tun0
fd3d:fa7b:d17d::1                 link#3                        UHS         lo0
fe80::/10                         ::1                           UGRS        lo0
fe80::%em0/64                     link#1                        U           em0
fe80::20c:29ff:fe8a:8910%em0      link#1                        UHS         lo0
fe80::%lo0/64                     link#2                        U           lo0
fe80::1%lo0                       link#2                        UHS         lo0
fe80::%tun0/64                    link#3                        U          tun0
fe80::20c:29ff:fe8a:8910%tun0     link#3                        UHS         lo0
ff02::/16                         ::1                           UGRS        lo0

The problem is with "illegal prefixlen" and the network being displayed 2001:838::/0.

The problem does not occur when using
sudo route add -inet6 2001:DB8::1/32 fd3d:fa7b:d17d::2
in step 3.
Comment 1 Andrey V. Elsukov freebsd_committer freebsd_triage 2016-07-06 10:13:10 UTC
It looks like the address specified after `-interface tun0' argument is considered as netmask and since it is not contiguous, this leads to such results.
Comment 2 Michael Tuexen freebsd_committer freebsd_triage 2016-07-06 10:27:38 UTC
OK. Then I would expect the get an error instead of strange settings...