aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute/iproute.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-02-23 01:20:44 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-02-23 01:20:44 +0100
commit3bb235c3b50ca072e8bcfc20d5030f5460439c07 (patch)
tree8704db0e2526381902606da0c5ba5f7a91fc8e1e /networking/libiproute/iproute.c
parentbac0a25f72cdf59f34638aa3fd95bb14b103c286 (diff)
downloadbusybox-3bb235c3b50ca072e8bcfc20d5030f5460439c07.tar.gz
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.c18
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,
{
struct rtmsg *r = NLMSG_DATA(n);
int len = n->nlmsg_len;
- struct rtattr * tb[RTA_MAX+1];
+ struct rtattr *tb[RTA_MAX+1];
char abuf[256];
inet_prefix dst;
inet_prefix src;
@@ -159,8 +159,21 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
}
memset(tb, 0, sizeof(tb));
+ memset(&src, 0, sizeof(src));
+ memset(&dst, 0, sizeof(dst));
parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len);
+ if (tb[RTA_SRC]) {
+ src.bitlen = r->rtm_src_len;
+ src.bytelen = (r->rtm_family == AF_INET6 ? 16 : 4);
+ memcpy(src.data, RTA_DATA(tb[RTA_SRC]), src.bytelen);
+ }
+ if (tb[RTA_DST]) {
+ dst.bitlen = r->rtm_dst_len;
+ dst.bytelen = (r->rtm_family == AF_INET6 ? 16 : 4);
+ memcpy(dst.data, RTA_DATA(tb[RTA_DST]), dst.bytelen);
+ }
+
if (G_filter.rdst.family
&& inet_addr_match(&dst, &G_filter.rdst, G_filter.rdst.bitlen)
) {
@@ -426,7 +439,8 @@ IF_FEATURE_IP_RULE(ARG_table,)
NEXT_ARG();
}
if ((**argv < '0' || **argv > '9')
- && rtnl_rtntype_a2n(&type, *argv) == 0) {
+ && rtnl_rtntype_a2n(&type, *argv) == 0
+ ) {
NEXT_ARG();
req.r.rtm_type = type;
ok |= type_ok;