Subject: kern/22849: rtrequest() w/ RTM_DELETE not honouring netmask.
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <seanb@qnx.com>
List: netbsd-bugs
Date: 09/19/2003 01:04:03
>Number:         22849
>Category:       kern
>Synopsis:       rtrequest() w/ RTM_DELETE not honouring netmask.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 19 01:05:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Sean Boudreau
>Release:        1-6
>Organization:
QNX
>Environment:
NetBSD  1.6 NetBSD 1.6 (GENERIC) #0: Sun Sep  8 19:43:40 UTC 2002     autobuild@tgm.daemon.org:/autobuild/i386/OBJ/autobuild/src/sys/arch/i386/compile/GENERIC i386
>Description:
rtrequest() w/ RTM_DELETE not honouring netmask as it does w/ RTM_ADD.
>How-To-Repeat:
# netstat -rnfinet
Routing tables

Internet:
Destination        Gateway            Flags     Refs     Use    Mtu  Interface
10                 link#2             UC          3        0      -  ex0
127.0.0.1          127.0.0.1          UH          0       62  33220  lo0
# route add -net 22.44.16.1 -netmask 255.255.248.0 10.0.0.1
add net 22.44.16.1: gateway 10.0.0.1
# netstat -rnfinet
Routing tables

Internet:
Destination        Gateway            Flags     Refs     Use    Mtu  Interface
10                 link#2             UC          4        0      -  ex0
10.0.0.1           link#2             UHLc        1        0      -  ex0
22.44.16/21        10.0.0.1           UGS         0        0      -  ex0
127.0.0.1          127.0.0.1          UH          0       62  33220  lo0
# route delete -net 22.44.16.1 -netmask 255.255.248.0 10.0.0.1
writing to routing socket: No such process
delete net 22.44.16.1: gateway 10.0.0.1: not in table

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Can't use same values used to add route.  Have to apply netmask
manually as below.

# route delete -net 22.44.16.0 -netmask 255.255.248.0 10.0.0.1
delete net 22.44.16.0: gateway 10.0.0.1
>Fix:
Index: net/route.c
===================================================================
RCS file: /cvsroot/src/sys/net/route.c,v
retrieving revision 1.58
diff -c -r1.58 route.c
*** net/route.c 2003/08/07 16:32:57     1.58
--- net/route.c 2003/09/18 19:05:23
***************
*** 583,588 ****
--- 583,590 ----
                netmask = 0;
        switch (req) {
        case RTM_DELETE:
+               if (netmask)
+                       rt_maskedcopy(dst, dst, netmask);
                if ((rn = rnh->rnh_lookup(dst, netmask, rnh)) == 0)
                        senderr(ESRCH);
                rt = (struct rtentry *)rn;
>Release-Note:
>Audit-Trail:
>Unformatted: