diff options
Diffstat (limited to 'networking/route.c')
-rw-r--r-- | networking/route.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/networking/route.c b/networking/route.c index b5490ddd8..530c51b10 100644 --- a/networking/route.c +++ b/networking/route.c | |||
@@ -327,9 +327,10 @@ static void INET_setroute(int action, char **args) | |||
327 | /* Create a socket to the INET kernel. */ | 327 | /* Create a socket to the INET kernel. */ |
328 | skfd = xsocket(AF_INET, SOCK_DGRAM, 0); | 328 | skfd = xsocket(AF_INET, SOCK_DGRAM, 0); |
329 | 329 | ||
330 | if (ioctl(skfd, ((action==RTACTION_ADD) ? SIOCADDRT : SIOCDELRT), &rt)<0) { | 330 | if (action == RTACTION_ADD) |
331 | bb_perror_msg_and_die("SIOC[ADD|DEL]RT"); | 331 | xioctl(skfd, SIOCADDRT, &rt); |
332 | } | 332 | else |
333 | xioctl(skfd, SIOCDELRT, &rt); | ||
333 | 334 | ||
334 | if (ENABLE_FEATURE_CLEAN_UP) close(skfd); | 335 | if (ENABLE_FEATURE_CLEAN_UP) close(skfd); |
335 | } | 336 | } |
@@ -423,17 +424,15 @@ static void INET6_setroute(int action, char **args) | |||
423 | struct ifreq ifr; | 424 | struct ifreq ifr; |
424 | memset(&ifr, 0, sizeof(ifr)); | 425 | memset(&ifr, 0, sizeof(ifr)); |
425 | strncpy(ifr.ifr_name, devname, sizeof(ifr.ifr_name)); | 426 | strncpy(ifr.ifr_name, devname, sizeof(ifr.ifr_name)); |
426 | 427 | xioctl(skfd, SIOGIFINDEX, &ifr); | |
427 | if (ioctl(skfd, SIOGIFINDEX, &ifr) < 0) { | ||
428 | bb_perror_msg_and_die("SIOGIFINDEX"); | ||
429 | } | ||
430 | rt.rtmsg_ifindex = ifr.ifr_ifindex; | 428 | rt.rtmsg_ifindex = ifr.ifr_ifindex; |
431 | } | 429 | } |
432 | 430 | ||
433 | /* Tell the kernel to accept this route. */ | 431 | /* Tell the kernel to accept this route. */ |
434 | if (ioctl(skfd, ((action==RTACTION_ADD) ? SIOCADDRT : SIOCDELRT), &rt)<0) { | 432 | if (action == RTACTION_ADD) |
435 | bb_perror_msg_and_die("SIOC[ADD|DEL]RT"); | 433 | xioctl(skfd, SIOCADDRT, &rt); |
436 | } | 434 | else |
435 | xioctl(skfd, SIOCDELRT, &rt); | ||
437 | 436 | ||
438 | if (ENABLE_FEATURE_CLEAN_UP) close(skfd); | 437 | if (ENABLE_FEATURE_CLEAN_UP) close(skfd); |
439 | } | 438 | } |