diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-23 01:20:44 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-02-23 01:20:44 +0100 |
commit | 3bb235c3b50ca072e8bcfc20d5030f5460439c07 (patch) | |
tree | 8704db0e2526381902606da0c5ba5f7a91fc8e1e /networking/libiproute/iproute.c | |
parent | bac0a25f72cdf59f34638aa3fd95bb14b103c286 (diff) | |
download | busybox-w32-3bb235c3b50ca072e8bcfc20d5030f5460439c07.tar.gz busybox-w32-3bb235c3b50ca072e8bcfc20d5030f5460439c07.tar.bz2 busybox-w32-3bb235c3b50ca072e8bcfc20d5030f5460439c07.zip |
iproute: fix parsing and matching of of "short" IP addrs like 10/8
function old new delta
print_route 1613 1813 +200
get_addr_1 209 258 +49
get_prefix 393 356 -37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 249/-37) Total: 212 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/libiproute/iproute.c')
-rw-r--r-- | networking/libiproute/iproute.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 393a376ac..f8a67d9ee 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c | |||
@@ -82,7 +82,7 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, | |||
82 | { | 82 | { |
83 | struct rtmsg *r = NLMSG_DATA(n); | 83 | struct rtmsg *r = NLMSG_DATA(n); |
84 | int len = n->nlmsg_len; | 84 | int len = n->nlmsg_len; |
85 | struct rtattr * tb[RTA_MAX+1]; | 85 | struct rtattr *tb[RTA_MAX+1]; |
86 | char abuf[256]; | 86 | char abuf[256]; |
87 | inet_prefix dst; | 87 | inet_prefix dst; |
88 | inet_prefix src; | 88 | inet_prefix src; |
@@ -159,8 +159,21 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, | |||
159 | } | 159 | } |
160 | 160 | ||
161 | memset(tb, 0, sizeof(tb)); | 161 | memset(tb, 0, sizeof(tb)); |
162 | memset(&src, 0, sizeof(src)); | ||
163 | memset(&dst, 0, sizeof(dst)); | ||
162 | parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); | 164 | parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); |
163 | 165 | ||
166 | if (tb[RTA_SRC]) { | ||
167 | src.bitlen = r->rtm_src_len; | ||
168 | src.bytelen = (r->rtm_family == AF_INET6 ? 16 : 4); | ||
169 | memcpy(src.data, RTA_DATA(tb[RTA_SRC]), src.bytelen); | ||
170 | } | ||
171 | if (tb[RTA_DST]) { | ||
172 | dst.bitlen = r->rtm_dst_len; | ||
173 | dst.bytelen = (r->rtm_family == AF_INET6 ? 16 : 4); | ||
174 | memcpy(dst.data, RTA_DATA(tb[RTA_DST]), dst.bytelen); | ||
175 | } | ||
176 | |||
164 | if (G_filter.rdst.family | 177 | if (G_filter.rdst.family |
165 | && inet_addr_match(&dst, &G_filter.rdst, G_filter.rdst.bitlen) | 178 | && inet_addr_match(&dst, &G_filter.rdst, G_filter.rdst.bitlen) |
166 | ) { | 179 | ) { |
@@ -426,7 +439,8 @@ IF_FEATURE_IP_RULE(ARG_table,) | |||
426 | NEXT_ARG(); | 439 | NEXT_ARG(); |
427 | } | 440 | } |
428 | if ((**argv < '0' || **argv > '9') | 441 | if ((**argv < '0' || **argv > '9') |
429 | && rtnl_rtntype_a2n(&type, *argv) == 0) { | 442 | && rtnl_rtntype_a2n(&type, *argv) == 0 |
443 | ) { | ||
430 | NEXT_ARG(); | 444 | NEXT_ARG(); |
431 | req.r.rtm_type = type; | 445 | req.r.rtm_type = type; |
432 | ok |= type_ok; | 446 | ok |= type_ok; |