aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute/iproute.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/libiproute/iproute.c')
-rw-r--r--networking/libiproute/iproute.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index c8a58c11c..27d37ac79 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -469,21 +469,15 @@ static int rtnl_rtcache_request(struct rtnl_handle *rth, int family)
469 469
470static int iproute_flush_cache(void) 470static int iproute_flush_cache(void)
471{ 471{
472#define ROUTE_FLUSH_PATH "/proc/sys/net/ipv4/route/flush" 472 static const char fn[] = "/proc/sys/net/ipv4/route/flush";
473 473 int flush_fd = open(fn, O_WRONLY);
474 int len;
475 int flush_fd = open (ROUTE_FLUSH_PATH, O_WRONLY);
476 char *buffer = "-1";
477
478 if (flush_fd < 0) { 474 if (flush_fd < 0) {
479 fprintf(stderr, "Cannot open \"%s\"\n", ROUTE_FLUSH_PATH); 475 bb_perror_msg("cannot open '%s'", fn);
480 return -1; 476 return -1;
481 } 477 }
482 478
483 len = strlen (buffer); 479 if (write(flush_fd, "-1", 2) < 2) {
484 480 bb_perror_msg("cannot flush routing cache");
485 if ((write (flush_fd, (void *)buffer, len)) < len) {
486 fprintf(stderr, "Cannot flush routing cache\n");
487 return -1; 481 return -1;
488 } 482 }
489 close(flush_fd); 483 close(flush_fd);