commit - f2e98605612da20b0aea1d6c1de978f2a1456c06
commit + 03484caf3f8237aaf3a187dd7b5a947155452fee
blob - 58e53e15ac18acf7bfeb34903c17c935f6a4da37
blob + f2b1952af3cbb939e4621f53e24794dfb593e4fa
--- commands.c
+++ commands.c
* Data structures and routines for the "flush" command.
*/
+struct ghs flushtab[] = {
+ { "<cr>", "Type Enter to run command", CMPL0 NULL, 0 },
+ { "verbose", "Show verbose diagnostics", CMPL0 NULL, 0 },
+ { NULL, NULL, NULL, NULL, 0 }
+};
+
Menu flushlist[] = {
- { "routes", "IP routes", CMPL0 0, 0, 0, 0, flush_ip_routes },
- { "arp", "ARP cache", CMPL0 0, 0, 0, 0, flush_arp_cache },
+ { "routes", "IP routes", CMPL(h) (char **)flushtab,
+ sizeof(struct ghs), 0, 1, flush_ip_routes },
+ { "arp", "ARP cache", CMPL(h) (char **)flushtab,
+ sizeof(struct ghs), 0, 1, flush_arp_cache },
{ "ndp", "NDP cache", CMPL0 0, 0, 0, 0, flush_ndp_cache },
{ "line", "Active user", CMPL0 0, 0, 1, 1, flush_line },
{ "bridge-dyn", "Dynamically learned bridge addresses", CMPL0 0, 0, 1, 1, flush_bridgedyn },
static int
flush_ip_routes(int argc, char **argv, ...)
{
- flushroutes(AF_INET, AF_INET);
+ va_list ap;
+ char *verbose_arg;
+
+ va_start(ap, argv);
+ verbose_arg = va_arg(ap, char *);
+ va_end(ap);
+ flushroutes(AF_INET, AF_INET, verbose_arg != NULL);
+
return(0);
}
static int
flush_arp_cache(int argc, char **argv, ...)
{
- flushroutes(AF_INET, AF_LINK);
+ va_list ap;
+ char *verbose_arg;
+
+ va_start(ap, argv);
+ verbose_arg = va_arg(ap, char *);
+ va_end(ap);
+
+ flushroutes(AF_INET, AF_INET, verbose_arg != NULL);
return(0);
}
blob - c5a8966d0b3506a015dd105fb55b3044ddbe1d10
blob + aa5c777725bcff637d09e989a07d3fe6bfb3c51f
--- externs.h
+++ externs.h
void freertdump(struct rtdump *);
int monitor(int, char **, ...);
int rtmsg(int, int, int, int, int);
-void flushroutes(int, int);
+void flushroutes(int, int, int);
void bprintf(FILE *, int, u_char *);
#ifdef _NET_IF_DL_H_
char *mylink_ntoa(const struct sockaddr_dl *);
blob - 98febbd027c112d6992682db6bc022d91f222334
blob + c00c9bda0ced41a4cf7372e81357d2e33ad273a7
--- kroute.c
+++ kroute.c
char *mylink_ntoa(const struct sockaddr_dl *);
-void flushroutes(int, int);
void print_rtmsg(struct rt_msghdr *);
void print_getmsg(struct rt_msghdr *, int);
void pmsg_common(struct rt_msghdr *);
* sockaddrs match requested address families
*/
void
-flushroutes(int af, int af2)
+flushroutes(int af, int af2, int flush_verbose)
{
int rlen, seqno, s;
char *next;
rlen = write(s, next, rtm->rtm_msglen);
if (rlen < (int)rtm->rtm_msglen) {
if (errno == ESRCH) {
- printf("%% No such route to delete:");
- print_addrs((char *)rtm + rtm->rtm_hdrlen,
- rtm->rtm_addrs);
- putchar('\n');
- fflush(stdout);
-
+ if (flush_verbose) {
+ printf("%% No such route to delete:");
+ print_addrs((char *)rtm +
+ rtm->rtm_hdrlen, rtm->rtm_addrs);
+ putchar('\n');
+ fflush(stdout);
+ }
seqno++;
continue;
}
if (verbose) {
printf("\n%% Wrote message:\n");
print_rtmsg(rtm);
- } else {
+ } else if (flush_verbose) {
printf("%% %-20.20s ", routename(sa));
printf("%-20.20s flushed\n", routename(sa2));
}
printf("\n");
if (!seqno)
printf("%% No entires found to flush\n");
+ else
+ printf("%% %d routing table entr%s flushed\n", seqno,
+ seqno == 1 ? "y" : "ies");
freertdump(rtdump);
close(s);
return;
blob - 110dc23caec6958d0d55b5dfc9129ff2477c9467
blob + ff94a0cd653758713411d32d0a7792eb9d1be0c4
--- nsh.8
+++ nsh.8
.Pp
Clear various system tables.
.Pp
-.Ic flush routes
+.Ic flush routes Oo Ic verbose Oc
.Pp
Clear the system routing table.
+If the
+.Ic verbose
+flag is used then show which routes were deleted.
.Pp
-.Ic flush arp
+.Ic flush arp Oo Ic verbose Oc
.Pp
Clear the system arp cache and static arp table.
+If the
+.Ic verbose
+flag is used then show which ARP entries were deleted.
.Pp
.Ic flush ndp
.Pp