MCPcopy Create free account
hub / github.com/F-Stack/f-stack / flushroutes

Function flushroutes

tools/route/route.c:444–494  ·  view source on GitHub ↗

* Purge all entries in the routing tables not * associated with network interfaces. */

Source from the content-addressed store, hash-verified

442 * associated with network interfaces.
443 */
444static void
445flushroutes(int argc, char *argv[])
446{
447 struct fibl *fl;
448 int error;
449
450 if (uid != 0 && !debugonly && !tflag)
451 errx(EX_NOPERM, "must be root to alter routing table");
452 shutdown(s, SHUT_RD); /* Don't want to read back our messages */
453
454 TAILQ_INIT(&fibl_head);
455 while (argc > 1) {
456 argc--;
457 argv++;
458 if (**argv != '-')
459 usage(*argv);
460 switch (keyword(*argv + 1)) {
461#ifdef INET
462 case K_4:
463 case K_INET:
464 af = AF_INET;
465 break;
466#endif
467#ifdef INET6
468 case K_6:
469 case K_INET6:
470 af = AF_INET6;
471 break;
472#endif
473 case K_LINK:
474 af = AF_LINK;
475 break;
476 case K_FIB:
477 if (!--argc)
478 usage(*argv);
479 error = fiboptlist_csv(*++argv, &fibl_head);
480 if (error)
481 errx(EX_USAGE, "invalid fib number: %s", *argv);
482 break;
483 default:
484 usage(*argv);
485 }
486 }
487 if (TAILQ_EMPTY(&fibl_head)) {
488 error = fiboptlist_csv("default", &fibl_head);
489 if (error)
490 errx(EX_OSERR, "fiboptlist_csv failed.");
491 }
492 TAILQ_FOREACH(fl, &fibl_head, fl_next)
493 flushroutes_fib(fl->fl_num);
494}
495
496static int
497flushroutes_fib(int fib)

Callers 1

route.cFile · 0.85

Calls 5

shutdownFunction · 0.85
keywordFunction · 0.85
fiboptlist_csvFunction · 0.85
flushroutes_fibFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected