Crap, please don't apply as this is broken for IPv6. I will rework them and resubmit a new set of patches.
- Eric On Sun, May 31, 2020 at 12:26 PM Eric Molitor <emoli...@molitor.org> wrote: > --- > toys/pending/route.c | 17 +++++++---------- > 1 file changed, 7 insertions(+), 10 deletions(-) > > diff --git a/toys/pending/route.c b/toys/pending/route.c > index 9c95d996..b37d3ecd 100644 > --- a/toys/pending/route.c > +++ b/toys/pending/route.c > @@ -290,20 +290,17 @@ static void setroute(sa_family_t family, char **argv) > char *targetip; > int sockfd, arg2_action; > int action = get_action(&argv, arglist1); //verify the arg for add/del. > + struct nlmsghdr buf[8192 / sizeof(struct nlmsghdr)]; > + struct nlmsghdr *nlMsg; > + struct rtmsg *rtMsg; > > if (!action || !*argv) help_exit("setroute"); > - > arg2_action = get_action(&argv, arglist2); //verify the arg for -net or > -host > if (!*argv) help_exit("setroute"); > - > targetip = *argv++; > - > - struct nlmsghdr *nlMsg; > - struct rtmsg *rtMsg; > - > sockfd = xsocket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); > - memset(toybuf, 0, sizeof(toybuf)); > - nlMsg = (struct nlmsghdr *) toybuf; > + memset(buf, 0, sizeof(buf)); > + nlMsg = (struct nlmsghdr *) buf; > rtMsg = (struct rtmsg *) NLMSG_DATA(nlMsg); > > nlMsg->nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); > @@ -350,7 +347,7 @@ static void setroute(sa_family_t family, char **argv) > } else if (!strcmp(*argv, "reject")) { > rtMsg->rtm_type = RTN_UNREACHABLE; > } else { > - if (!argv[1]) help_exit(0); > + if (!argv[1]) show_help(stdout, 1); > > if (!strcmp(*argv, "metric")) { > unsigned int priority = atolx_range(argv[1], 0, UINT_MAX); > @@ -423,7 +420,7 @@ void route_main(void) > if (!*toys.optargs) { > if (!strcmp(TT.family, "inet")) display_routes(AF_INET); > else if (!strcmp(TT.family, "inet6")) display_routes(AF_INET6); > - else help_exit(0); > + else show_help(stdout, 1); > } else { > if (!strcmp(TT.family, "inet")) setroute(AF_INET, toys.optargs); > else setroute(AF_INET6, toys.optargs); > -- > 2.25.1 > >
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net