NetBSD Problem Report #3227
Received: (qmail-queue invoked from smtpd); 18 Feb 1997 08:32:41 -0000
Message-Id: <199702180828.DAA19381@glacier.MIT.EDU>
Date: Tue, 18 Feb 1997 03:28:29 -0500
From: Greg Hudson <ghudson@mit.edu>
Reply-To: ghudson@mit.edu
To: gnats-bugs@gnats.netbsd.org
Subject: "route flush" doesn't flush all routes
X-Send-Pr-Version: 3.95
>Number: 3227
>Category: misc
>Synopsis: "route flush" doesn't flush all routes
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: misc-bug-people
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Tue Feb 18 00:35:01 +0000 1997
>Closed-Date: Mon Jul 21 16:12:46 +0000 2003
>Last-Modified: Mon Jul 21 16:12:46 +0000 2003
>Originator: Greg Hudson
>Release: 1.1
>Organization:
MIT
>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);
>Release-Note:
>Audit-Trail:
From: "Jason R. Fink" <jrf@adresearch.com>
To: gnats-bugs@netbsd.org
Cc:
Subject: misc/3227
Date: Tue, 15 Jul 2003 16:05:06 -0400
Here is a version of it for 1.6.1, I had to make some
additional changes for it to work. When I get a -current
box going, I will try it there as well.
Index: keywords.h
===================================================================
RCS file: /cvsroot/src/sbin/route/keywords.h,v
retrieving revision 1.6
diff -u -r1.6 keywords.h
--- keywords.h 2001/01/27 04:51:25 1.6
+++ keywords.h 2003/07/14 19:23:27
@@ -56,3 +56,4 @@
#define K_X25 46
#define K_XNS 47
#define K_XRESOLVE 48
+#define K_FLUSHALL 49
Index: keywords.c
===================================================================
RCS file: /cvsroot/src/sbin/route/keywords.c,v
retrieving revision 1.4
diff -u -r1.4 keywords.c
--- keywords.c 2001/01/27 04:51:25 1.4
+++ keywords.c 2003/07/14 19:23:27
@@ -54,6 +54,7 @@
{"x25", K_X25},
{"xns", K_XNS},
{"xresolve", K_XRESOLVE},
+ {"flushall", K_FLUSHALL},
{0, 0}
};
Index: route.c
===================================================================
RCS file: /cvsroot/src/sbin/route/route.c,v
retrieving revision 1.54.2.4
diff -u -r1.54.2.4 route.c
--- route.c 2003/01/26 09:40:35 1.54.2.4
+++ route.c 2003/07/14 19:23:28
@@ -90,7 +90,7 @@
static int inet6_makenetandmask __P((struct sockaddr_in6 *));
#endif
static int getaddr __P((int, char *, struct hostent **));
-static int flushroutes __P((int, char *[]));
+static int flushroutes __P((int, char *[], int));
#ifndef SMALL
static int prefixlen __P((char *));
static int x25_makemask __P((void));
@@ -218,7 +218,7 @@
case K_ADD:
case K_DELETE:
if (doflush)
- (void)flushroutes(1, argv);
+ (void)flushroutes(1, argv, 0);
return newroute(argc, argv);
case K_SHOW:
@@ -232,8 +232,12 @@
#endif /* SMALL */
case K_FLUSH:
- return flushroutes(argc, argv);
+ return flushroutes(argc, argv, 0);
+ break;
+ case K_FLUSHALL:
+ return flushroutes(argc, argv, 1);
+ break;
no_cmd:
default:
usage(*argv);
@@ -246,9 +250,10 @@
* associated with network interfaces.
*/
static int
-flushroutes(argc, argv)
+flushroutes(argc, argv, doall)
int argc;
char *argv[];
+ int doall;
{
size_t needed;
int mib[6], rlen, seqno;
@@ -317,7 +322,8 @@
rtm = (struct rt_msghdr *)next;
if (verbose)
print_rtmsg(rtm, rtm->rtm_msglen);
- if ((rtm->rtm_flags & RTF_GATEWAY) == 0)
+ if (!(rtm->rtm_flags & (RTF_GATEWAY | RTF_STATIC |
+ RTF_LLINFO)) && !doall)
continue;
if (af) {
struct sockaddr *sa = (struct sockaddr *)(rtm + 1);
From: "Jason R. Fink" <jrf@adresearch.com>
To: gnats-bugs@NetBSD.org
Cc: ghudson@mit.edu
Subject: misc/3227
Date: Thu, 17 Jul 2003 15:11:36 -0400
Here is the patch for -current along with a man page
change. I am sure there are a few things someone may
want to change (doall??? etc.):
Index: keywords.c
===================================================================
RCS file: /cvsroot/src/sbin/route/keywords.c,v
retrieving revision 1.4
diff -u -r1.4 keywords.c
--- keywords.c 2001/01/27 04:51:25 1.4
+++ keywords.c 2003/07/17 19:07:54
@@ -54,6 +54,7 @@
{"x25", K_X25},
{"xns", K_XNS},
{"xresolve", K_XRESOLVE},
+ {"flushall", K_FLUSHALL},
{0, 0}
};
Index: keywords.h
===================================================================
RCS file: /cvsroot/src/sbin/route/keywords.h,v
retrieving revision 1.6
diff -u -r1.6 keywords.h
--- keywords.h 2001/01/27 04:51:25 1.6
+++ keywords.h 2003/07/17 19:07:54
@@ -56,3 +56,4 @@
#define K_X25 46
#define K_XNS 47
#define K_XRESOLVE 48
+#define K_FLUSHALL 49
Index: route.c
===================================================================
RCS file: /cvsroot/src/sbin/route/route.c,v
retrieving revision 1.66
diff -u -r1.66 route.c
--- route.c 2003/06/11 15:45:20 1.66
+++ route.c 2003/07/17 19:07:54
@@ -90,7 +90,7 @@
static int inet6_makenetandmask __P((struct sockaddr_in6 *));
#endif
static int getaddr __P((int, char *, struct hostent **));
-static int flushroutes __P((int, char *[]));
+static int flushroutes __P((int, char *[], int));
#ifndef SMALL
static int prefixlen __P((char *));
static int x25_makemask __P((void));
@@ -218,7 +218,7 @@
case K_ADD:
case K_DELETE:
if (doflush)
- (void)flushroutes(1, argv);
+ (void)flushroutes(1, argv, 0);
return newroute(argc, argv);
case K_SHOW:
@@ -232,8 +232,10 @@
#endif /* SMALL */
case K_FLUSH:
- return flushroutes(argc, argv);
+ return flushroutes(argc, argv, 0);
+ case K_FLUSHALL:
+ return flushroutes(argc, argv, 1);
no_cmd:
default:
usage(*argv);
@@ -246,9 +248,10 @@
* associated with network interfaces.
*/
static int
-flushroutes(argc, argv)
+flushroutes(argc, argv, doall)
int argc;
char *argv[];
+ int doall;
{
size_t needed;
int mib[6], rlen, seqno;
@@ -317,7 +320,8 @@
rtm = (struct rt_msghdr *)next;
if (verbose)
print_rtmsg(rtm, rtm->rtm_msglen);
- if ((rtm->rtm_flags & RTF_GATEWAY) == 0)
+ if (!(rtm->rtm_flags & (RTF_GATEWAY | RTF_STATIC |
+ RTF_LLINFO)) && !doall)
continue;
if (af) {
struct sockaddr *sa = (struct sockaddr *)(rtm + 1);
Index: route.8
===================================================================
RCS file: /cvsroot/src/sbin/route/route.8,v
retrieving revision 1.32
diff -u -r1.32 route.8
--- route.8 2003/06/03 04:41:42 1.32
+++ route.8 2003/07/17 19:07:55
@@ -110,6 +110,8 @@
Add a route.
.It Cm flush
Remove all routes.
+.It Cm flushall
+Remove all routes including the default gateway.
.It Cm delete
Delete a specific route.
.It Cm change
From: "Jason R. Fink" <jrf@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: pr/3227 CVS commit: src/sbin/route
Date: Sat, 19 Jul 2003 01:36:49 +0000 (UTC)
Module Name: src
Committed By: jrf
Date: Sat Jul 19 01:36:48 UTC 2003
Modified Files:
src/sbin/route: keywords.c keywords.h keywords.sh route.8 route.c
Log Message:
This is an updated submitted patch originally written by Jim Rees
and sent in by Greg Hudson as seen in PR misc/3227. Basically what it
does is adds a flushall option which deletes all but localhost routes.
This is done by andoring in a flag called doall (1 means do all routes
including gateway, 0 means do a regular flush). I have seen some
platforms that do this. I tested it out on ipv4 only, it works as
advertised. Commit was approved by christos@.
To generate a diff of this commit:
cvs rdiff -r1.4 -r1.5 src/sbin/route/keywords.c
cvs rdiff -r1.6 -r1.7 src/sbin/route/keywords.h src/sbin/route/keywords.sh
cvs rdiff -r1.32 -r1.33 src/sbin/route/route.8
cvs rdiff -r1.66 -r1.67 src/sbin/route/route.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: jrf
State-Changed-When: Mon Jul 21 16:11:38 UTC 2003
State-Changed-Why:
Committed the new changes with approval from christos@. Note, the patch
shown here omits the change to keywords.sh.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.