aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-02-09 04:39:09 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-02-09 04:39:09 +0100
commitf13347130245f9fb86ecb3b9c217d3c558a717a9 (patch)
tree1fac3607260cd679d6a8e56501d89265de7d8ebf
parente7212a4ce5aa3570f7195c48335f0280a0fd4383 (diff)
downloadbusybox-w32-f13347130245f9fb86ecb3b9c217d3c558a717a9.tar.gz
busybox-w32-f13347130245f9fb86ecb3b9c217d3c558a717a9.tar.bz2
busybox-w32-f13347130245f9fb86ecb3b9c217d3c558a717a9.zip
iproute: fix handling of "dev IFACE" selector
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/libiproute/iproute.c38
-rw-r--r--networking/libiproute/libnetlink.c1
2 files changed, 25 insertions, 14 deletions
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index f6071b463..14fc16c4d 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -31,8 +31,8 @@ struct filter_t {
31 //int type; - read-only 31 //int type; - read-only
32 //int typemask; - unused 32 //int typemask; - unused
33 //int tos, tosmask; - unused 33 //int tos, tosmask; - unused
34 int iif, iifmask; 34 int iif;
35 int oif, oifmask; 35 int oif;
36 //int realm, realmmask; - unused 36 //int realm, realmmask; - unused
37 //inet_prefix rprefsrc; - read-only 37 //inet_prefix rprefsrc; - read-only
38 inet_prefix rvia; 38 inet_prefix rvia;
@@ -182,17 +182,25 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
182 ) { 182 ) {
183 return 0; 183 return 0;
184 } 184 }
185 if (G_filter.flushb 185 if (G_filter.oif != 0) {
186 && r->rtm_family == AF_INET6 186 if (!tb[RTA_OIF])
187 && r->rtm_dst_len == 0 187 return 0;
188 && r->rtm_type == RTN_UNREACHABLE 188 if (G_filter.oif != *(int*)RTA_DATA(tb[RTA_OIF]))
189 && tb[RTA_PRIORITY] 189 return 0;
190 && *(int*)RTA_DATA(tb[RTA_PRIORITY]) == -1
191 ) {
192 return 0;
193 } 190 }
194 191
195 if (G_filter.flushb) { 192 if (G_filter.flushb) {
193 /* We are creating route flush commands */
194
195 if (r->rtm_family == AF_INET6
196 && r->rtm_dst_len == 0
197 && r->rtm_type == RTN_UNREACHABLE
198 && tb[RTA_PRIORITY]
199 && *(int*)RTA_DATA(tb[RTA_PRIORITY]) == -1
200 ) {
201 return 0;
202 }
203
196 struct nlmsghdr *fn; 204 struct nlmsghdr *fn;
197 if (NLMSG_ALIGN(G_filter.flushp) + n->nlmsg_len > G_filter.flushe) { 205 if (NLMSG_ALIGN(G_filter.flushp) + n->nlmsg_len > G_filter.flushe) {
198 if (flush_update()) 206 if (flush_update())
@@ -208,6 +216,8 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
208 return 0; 216 return 0;
209 } 217 }
210 218
219 /* We are printing routes */
220
211 if (n->nlmsg_type == RTM_DELROUTE) { 221 if (n->nlmsg_type == RTM_DELROUTE) {
212 printf("Deleted "); 222 printf("Deleted ");
213 } 223 }
@@ -257,10 +267,12 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
257 RTA_DATA(tb[RTA_GATEWAY]), 267 RTA_DATA(tb[RTA_GATEWAY]),
258 abuf, sizeof(abuf))); 268 abuf, sizeof(abuf)));
259 } 269 }
260 if (tb[RTA_OIF] && G_filter.oifmask != -1) { 270 if (tb[RTA_OIF]) {
261 printf("dev %s ", ll_index_to_name(*(int*)RTA_DATA(tb[RTA_OIF]))); 271 printf("dev %s ", ll_index_to_name(*(int*)RTA_DATA(tb[RTA_OIF])));
262 } 272 }
263 273
274 /* Todo: parse & show "proto kernel", "scope link" here */
275
264 if (tb[RTA_PREFSRC] && /*G_filter.rprefsrc.bitlen - always 0*/ 0 != host_len) { 276 if (tb[RTA_PREFSRC] && /*G_filter.rprefsrc.bitlen - always 0*/ 0 != host_len) {
265 /* Do not use format_host(). It is our local addr 277 /* Do not use format_host(). It is our local addr
266 and symbolic name will not be useful. 278 and symbolic name will not be useful.
@@ -292,7 +304,7 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
292 printf(" error %d", ci->rta_error); 304 printf(" error %d", ci->rta_error);
293 } 305 }
294 } 306 }
295 if (tb[RTA_IIF] && G_filter.iifmask != -1) { 307 if (tb[RTA_IIF] && G_filter.iif == 0) {
296 printf(" iif %s", ll_index_to_name(*(int*)RTA_DATA(tb[RTA_IIF]))); 308 printf(" iif %s", ll_index_to_name(*(int*)RTA_DATA(tb[RTA_IIF])));
297 } 309 }
298 bb_putchar('\n'); 310 bb_putchar('\n');
@@ -662,12 +674,10 @@ static int iproute_list_or_flush(char **argv, int flush)
662 if (id) { 674 if (id) {
663 idx = xll_name_to_index(id); 675 idx = xll_name_to_index(id);
664 G_filter.iif = idx; 676 G_filter.iif = idx;
665 G_filter.iifmask = -1;
666 } 677 }
667 if (od) { 678 if (od) {
668 idx = xll_name_to_index(od); 679 idx = xll_name_to_index(od);
669 G_filter.oif = idx; 680 G_filter.oif = idx;
670 G_filter.oifmask = -1;
671 } 681 }
672 } 682 }
673 683
diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c
index 7291ee2f1..547013ff6 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
55 return rtnl_send(rth, (void*)&req, sizeof(req)); 55 return rtnl_send(rth, (void*)&req, sizeof(req));
56} 56}
57 57
58//TODO: pass rth->fd instead of full rth?
58int FAST_FUNC rtnl_send(struct rtnl_handle *rth, char *buf, int len) 59int FAST_FUNC rtnl_send(struct rtnl_handle *rth, char *buf, int len)
59{ 60{
60 struct sockaddr_nl nladdr; 61 struct sockaddr_nl nladdr;