{
if (rtnl_send_check(&rth, filter.flushb, filter.flushp) < 0) {
perror("Failed to send flush request");
- return -1;
+ return -2;
}
filter.flushp = 0;
return 0;
struct rtattr *tb[RTA_MAX+1];
int host_len, family;
__u32 table;
+ int ret;
SPRINT_BUF(b1);
static int hz;
struct nlmsghdr *fn;
if (NLMSG_ALIGN(filter.flushp) + n->nlmsg_len > filter.flushe) {
- if (flush_update())
- return -1;
+ if ((ret = flush_update()) < 0)
+ return ret;
}
fn = (struct nlmsghdr *)(filter.flushb + NLMSG_ALIGN(filter.flushp));
memcpy(fn, n, n->nlmsg_len);
NEXT_ARG();
if ((rtnh->rtnh_ifindex = ll_name_to_index(*argv)) == 0) {
fprintf(stderr, "Cannot find device \"%s\"\n", *argv);
- exit(1);
+ return -1;
}
} else if (strcmp(*argv, "weight") == 0) {
unsigned int w;
char *od = NULL;
unsigned int mark = 0;
rtnl_filter_t filter_fn;
+ int ret;
if (action == IPROUTE_SAVE) {
if (save_route_prep())
for (;;) {
if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) {
perror("Cannot send dump request");
- exit(1);
+ return -2;
}
filter.flushed = 0;
if (rtnl_dump_filter(&rth, filter_fn, stdout) < 0) {
fprintf(stderr, "Flush terminated\n");
- exit(1);
+ return -2;
}
if (filter.flushed == 0) {
if (show_stats) {
return 0;
}
round++;
- if (flush_update() < 0)
- exit(1);
+ if ((ret = flush_update()) < 0)
+ return ret;
if (time(0) - start > 30) {
printf("\n*** Flush not completed after %ld seconds, %d entries remain ***\n",
(long)(time(0) - start), filter.flushed);
- exit(1);
+ return -1;
}
if (show_stats) {
if (!filter.cloned) {
if (rtnl_wilddump_request(&rth, do_ipv6, RTM_GETROUTE) < 0) {
perror("Cannot send dump request");
- exit(1);
+ return -2;
}
} else {
if (rtnl_rtcache_request(&rth, do_ipv6) < 0) {
perror("Cannot send dump request");
- exit(1);
+ return -2;
}
}
if (rtnl_dump_filter(&rth, filter_fn, stdout) < 0) {
fprintf(stderr, "Dump terminated\n");
- exit(1);
+ return -2;
}
- exit(0);
+ return 0;
}
if (req.r.rtm_dst_len == 0) {
fprintf(stderr, "need at least a destination address\n");
- exit(1);
+ return -1;
}
if (idev || odev) {
int pos, prio;
if (route_dump_check_magic())
- exit(-1);
+ return -1;
pos = ftell(stdin);
if (pos == -1) {
perror("Failed to restore: ftell");
- exit(-1);
+ return -1;
}
for (prio = 0; prio < 3; prio++) {
err = rtnl_from_file(stdin, &restore_handler, &prio);
if (err)
- exit(err);
+ return -2;
if (fseek(stdin, pos, SEEK_SET) == -1) {
perror("Failed to restore: fseek");
- exit(-1);
+ return -1;
}
}
- exit(0);
+ return 0;
}
static int show_handler(const struct sockaddr_nl *nl,
static int iproute_showdump(void)
{
if (route_dump_check_magic())
- exit(-1);
+ return -1;
- exit(rtnl_from_file(stdin, &show_handler, NULL));
+ if (rtnl_from_file(stdin, &show_handler, NULL))
+ return -2;
+
+ return 0;
}
void iproute_reset_filter(int ifindex)