Bug 276092

Summary: "route add 10/8 ip" adds 0.0.0.0/8, not 10.0.0.0/8
Product: Base System Reporter: Leo <grey.leo>
Component: binAssignee: Mike Karels <karels>
Status: Closed DUPLICATE    
Severity: Affects Some People CC: emaste, grey.leo, karels, zarychtam
Priority: ---    
Version: 13.2-RELEASE   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258874

Description Leo 2024-01-03 06:59:59 UTC
Hi!

It seems
route add D/N ip
does not work anymore (after upgrade from 12.4 to 13.2).
If D is only octet (without dots) and N is any (32,...,8,7...)
then route adds net 0.0.0.0/N

Example: route add 10/8 192.168.0.1

netstat -anr
Destination        Gateway            Flags     Netif Expire
0.0.0.0/8          192.168.0.1        UGS       re0
Comment 1 Marek Zarychta 2024-01-03 08:49:51 UTC
That's expected. Please see also bug 258874
Comment 2 Mike Karels freebsd_committer freebsd_triage 2024-01-07 14:26:54 UTC
I have a change to route to detect this error and complain about it.  In response to "route add 10.8 ip", it prints this and exits non-zero:

route: malformed address, bits set after mask; 10 means 0.0.0.10

Comments?  I'll put the change into review soon.
Comment 3 Mike Karels freebsd_committer freebsd_triage 2024-01-07 14:29:42 UTC
(In reply to Mike Karels from comment #2)
Sorry, that should have been "route add 10/8 ip".
Comment 4 Mike Karels freebsd_committer freebsd_triage 2024-01-09 21:18:40 UTC
https://reviews.freebsd.org/D43384
Comment 5 Mike Karels freebsd_committer freebsd_triage 2024-01-15 23:00:44 UTC
I committed a change to route that causes attempts to add such a route to fail with an error; see the note on the associated bug (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258874#c14).  I plan to close this bug as a duplicate of that bug when that bug is closed.
Comment 6 Mike Karels freebsd_committer freebsd_triage 2024-01-22 16:55:03 UTC
258874 was fixed by failing to add a bogus route, and explaining the problem in the error message.

*** This bug has been marked as a duplicate of bug 258874 ***