diff --git a/sbin/route/keywords.c b/sbin/route/keywords.c index 8cb304bf0634..c7839b788823 100644 --- a/sbin/route/keywords.c +++ b/sbin/route/keywords.c @@ -1,4 +1,4 @@ -/* $NetBSD: keywords.c,v 1.4 2001/01/27 04:51:25 itojun Exp $ */ +/* $NetBSD: keywords.c,v 1.5 2003/07/19 01:36:47 jrf Exp $ */ /* WARNING! This file was generated by keywords.sh */ @@ -54,6 +54,7 @@ struct keytab keywords[] = { {"x25", K_X25}, {"xns", K_XNS}, {"xresolve", K_XRESOLVE}, + {"flushall", K_FLUSHALL}, {0, 0} }; diff --git a/sbin/route/keywords.h b/sbin/route/keywords.h index bbc4f81be045..ec6eee71aa91 100644 --- a/sbin/route/keywords.h +++ b/sbin/route/keywords.h @@ -1,4 +1,4 @@ -/* $NetBSD: keywords.h,v 1.6 2001/01/27 04:51:25 itojun Exp $ */ +/* $NetBSD: keywords.h,v 1.7 2003/07/19 01:36:47 jrf Exp $ */ /* WARNING! This file was generated by keywords.sh */ @@ -56,3 +56,4 @@ extern struct keytab { #define K_X25 46 #define K_XNS 47 #define K_XRESOLVE 48 +#define K_FLUSHALL 49 diff --git a/sbin/route/keywords.sh b/sbin/route/keywords.sh index d0ce8712887e..41e998576bd1 100755 --- a/sbin/route/keywords.sh +++ b/sbin/route/keywords.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $NetBSD: keywords.sh,v 1.6 2001/01/27 04:51:17 itojun Exp $ +# $NetBSD: keywords.sh,v 1.7 2003/07/19 01:36:47 jrf Exp $ # @(#)keywords 8.2 (Berkeley) 3/19/94 # # WARNING! If you change this file, re-run it! @@ -56,6 +56,7 @@ static x25 xns xresolve +flushall _EOF_ diff --git a/sbin/route/route.8 b/sbin/route/route.8 index f72aa9dc2880..07672a3ae027 100644 --- a/sbin/route/route.8 +++ b/sbin/route/route.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: route.8,v 1.32 2003/06/03 04:41:42 itojun Exp $ +.\" $NetBSD: route.8,v 1.33 2003/07/19 01:36:48 jrf Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -110,6 +110,8 @@ utility provides several commands: 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 diff --git a/sbin/route/route.c b/sbin/route/route.c index cfde01b93625..937ab04e9d6f 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.66 2003/06/11 15:45:20 christos Exp $ */ +/* $NetBSD: route.c,v 1.67 2003/07/19 01:36:47 jrf Exp $ */ /* * Copyright (c) 1983, 1989, 1991, 1993 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1989, 1991, 1993\n\ #if 0 static char sccsid[] = "@(#)route.c 8.6 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: route.c,v 1.66 2003/06/11 15:45:20 christos Exp $"); +__RCSID("$NetBSD: route.c,v 1.67 2003/07/19 01:36:47 jrf Exp $"); #endif #endif /* not lint */ @@ -90,7 +90,7 @@ static void inet_makenetandmask __P((u_int32_t, struct sockaddr_in *)); 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 @@ main(argc, argv) 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 @@ main(argc, argv) #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 @@ main(argc, argv) * 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 @@ bad: usage(*argv); 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);