diff options
author | Denys Vlasenko | 2011-02-09 04:39:09 +0100 |
---|---|---|
committer | Denys Vlasenko | 2011-02-09 04:39:09 +0100 |
commit | f13347130245f9fb86ecb3b9c217d3c558a717a9 (patch) | |
tree | 1fac3607260cd679d6a8e56501d89265de7d8ebf /networking | |
parent | e7212a4ce5aa3570f7195c48335f0280a0fd4383 (diff) | |
download | busybox-f13347130245f9fb86ecb3b9c217d3c558a717a9.zip busybox-f13347130245f9fb86ecb3b9c217d3c558a717a9.tar.gz |
iproute: fix handling of "dev IFACE" selector
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r-- | networking/libiproute/iproute.c | 38 | ||||
-rw-r--r-- | networking/libiproute/libnetlink.c | 1 |
2 files changed, 25 insertions, 14 deletions
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index f6071b4..14fc16c 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c @@ -31,8 +31,8 @@ struct filter_t { //int type; - read-only //int typemask; - unused //int tos, tosmask; - unused - int iif, iifmask; - int oif, oifmask; + int iif; + int oif; //int realm, realmmask; - unused //inet_prefix rprefsrc; - read-only inet_prefix rvia; @@ -182,17 +182,25 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, ) { return 0; } - if (G_filter.flushb - && r->rtm_family == AF_INET6 - && r->rtm_dst_len == 0 - && r->rtm_type == RTN_UNREACHABLE - && tb[RTA_PRIORITY] - && *(int*)RTA_DATA(tb[RTA_PRIORITY]) == -1 - ) { - return 0; + if (G_filter.oif != 0) { + if (!tb[RTA_OIF]) + return 0; + if (G_filter.oif != *(int*)RTA_DATA(tb[RTA_OIF])) + return 0; } if (G_filter.flushb) { + /* We are creating route flush commands */ + + if (r->rtm_family == AF_INET6 + && r->rtm_dst_len == 0 + && r->rtm_type == RTN_UNREACHABLE + && tb[RTA_PRIORITY] + && *(int*)RTA_DATA(tb[RTA_PRIORITY]) == -1 + ) { + return 0; + } + struct nlmsghdr *fn; if (NLMSG_ALIGN(G_filter.flushp) + n->nlmsg_len > G_filter.flushe) { if (flush_update()) @@ -208,6 +216,8 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, return 0; } + /* We are printing routes */ + if (n->nlmsg_type == RTM_DELROUTE) { printf("Deleted "); } @@ -257,10 +267,12 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, RTA_DATA(tb[RTA_GATEWAY]), abuf, sizeof(abuf))); } - if (tb[RTA_OIF] && G_filter.oifmask != -1) { + if (tb[RTA_OIF]) { printf("dev %s ", ll_index_to_name(*(int*)RTA_DATA(tb[RTA_OIF]))); } + /* Todo: parse & show "proto kernel", "scope link" here */ + if (tb[RTA_PREFSRC] && /*G_filter.rprefsrc.bitlen - always 0*/ 0 != host_len) { /* Do not use format_host(). It is our local addr and symbolic name will not be useful. @@ -292,7 +304,7 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, printf(" error %d", ci->rta_error); } } - if (tb[RTA_IIF] && G_filter.iifmask != -1) { + if (tb[RTA_IIF] && G_filter.iif == 0) { printf(" iif %s", ll_index_to_name(*(int*)RTA_DATA(tb[RTA_IIF]))); } bb_putchar('\n'); @@ -662,12 +674,10 @@ static int iproute_list_or_flush(char **argv, int flush) if (id) { idx = xll_name_to_index(id); G_filter.iif = idx; - G_filter.iifmask = -1; } if (od) { idx = xll_name_to_index(od); G_filter.oif = idx; - G_filter.oifmask = -1; } } diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c index 7291ee2..547013f 100644 --- a/networking/libiproute/libnetlink.c +++ b/networking/libiproute/libnetlink.c @@ -55,6 +55,7 @@ int FAST_FUNC xrtnl_wilddump_request(struct rtnl_handle *rth, int family, int ty return rtnl_send(rth, (void*)&req, sizeof(req)); } +//TODO: pass rth->fd instead of full rth? int FAST_FUNC rtnl_send(struct rtnl_handle *rth, char *buf, int len) { struct sockaddr_nl nladdr; |