Subject: route command fix
To: None <port-i386@NetBSD.ORG>
From: Jim Rees <rees@umich.edu>
List: port-i386
Date: 08/01/1996 01:43:45
The "route flush" command doesn't remove enough routes. It only removes
gateway routes, leaving behind cloned routes and manually added default
routes. This is a problem if you change your set of interfaces.
My fix is below. I also added a flushall command, but it's dangerous and
not recommended. If you remove everything, you can't add any back in.
*** route.c- Fri Oct 13 21:13:42 1995
--- route.c Thu Aug 1 01:21:59 1996
***************
*** 196,202 ****
/* NOTREACHED */
case K_FLUSH:
! flushroutes(argc, argv);
exit(0);
/* NOTREACHED */
}
--- 196,206 ----
/* NOTREACHED */
case K_FLUSH:
! flushroutes(argc, argv, 0);
! exit(0);
! /* NOTREACHED */
! case K_FLUSHALL:
! flushroutes(argc, argv, 1);
exit(0);
/* NOTREACHED */
}
***************
*** 209,217 ****
* associated with network interfaces.
*/
void
! flushroutes(argc, argv)
int argc;
char *argv[];
{
size_t needed;
int mib[6], rlen, seqno;
--- 213,222 ----
* associated with network interfaces.
*/
void
! flushroutes(argc, argv, doall)
int argc;
char *argv[];
+ int doall;
{
size_t needed;
int mib[6], rlen, seqno;
***************
*** 267,273 ****
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);
--- 272,278 ----
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);