Subject: misc/3227: "route flush" doesn't flush all routes
To: None <gnats-bugs@gnats.netbsd.org>
From: Greg Hudson <ghudson@mit.edu>
List: netbsd-bugs
Date: 02/18/1997 03:28:29
>Number:         3227
>Category:       misc
>Synopsis:       "route flush" doesn't flush all routes
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people (Misc Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 18 00:35:01 1997
>Last-Modified:
>Originator:     Greg Hudson
>Organization:
MIT
>Release:        1.1
>Environment:
System: NetBSD glacier 1.2B NetBSD 1.2B (GLACIER) #14: Sat Jan 25 15:04:33 EST 1997 ghudson@glacier:/u1/GLACIER i386


>Description:
In August of 1996, Jim Rees requested the addition of a "route flushall"
command which would flush all routes.
>How-To-Repeat:
>Fix:
Here is Jim's patch, propagated to the current version of route.c.  It
appears to affect the operation of a straight "route flush" if rtm->flags
contains RTF_STATIC or RTF_LLINFO.  Presumably, a change to route.1 would
also be appropriate.

*** route.c.orig	Tue Feb 18 03:22:44 1997
--- route.c	Tue Feb 18 03:23:40 1997
***************
*** 202,208 ****
  		break;
  
  	case K_FLUSH:
! 		flushroutes(argc, argv);
  		break;
  #endif /* SMALL */
  
--- 202,212 ----
  		break;
  
  	case K_FLUSH:
! 		flushroutes(argc, argv, 0);
! 		break;
! 
! 	case K_FLUSHALL:
! 		flushroutes(argc, argv, 1);
  		break;
  #endif /* SMALL */
  
***************
*** 220,228 ****
   * associated with network interfaces.
   */
  void
! flushroutes(argc, argv)
  	int argc;
  	char *argv[];
  {
  	size_t needed;
  	int mib[6], rlen, seqno;
--- 224,233 ----
   * associated with network interfaces.
   */
  void
! flushroutes(argc, argv, doall)
  	int argc;
  	char *argv[];
+ 	int doall;
  {
  	size_t needed;
  	int mib[6], rlen, seqno;
***************
*** 280,286 ****
  		rtm = (struct rt_msghdr *)next;
  		if (verbose)
  			print_rtmsg(rtm, rtm->rtm_msglen);
! 		if ((rtm->rtm_flags & RTF_GATEWAY) == 0)
  			continue;
  		if (af) {
  			struct sockaddr *sa = (struct sockaddr *)(rtm + 1);
--- 285,291 ----
  		rtm = (struct rt_msghdr *)next;
  		if (verbose)
  			print_rtmsg(rtm, rtm->rtm_msglen);
! 		if (!(rtm->rtm_flags & (RTF_GATEWAY | RTF_STATIC | RTF_LLINFO)) && !doall)
  			continue;
  		if (af) {
  			struct sockaddr *sa = (struct sockaddr *)(rtm + 1);
>Audit-Trail:
>Unformatted: