mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-13 19:33:57 +00:00
ipneigh: Use inet_addr_match_rta()
While there check return from get_prefix() for filter address. Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com> Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
parent
ba6052df6d
commit
a4270fd8ae
13
ip/ipneigh.c
13
ip/ipneigh.c
@ -234,15 +234,9 @@ int print_neigh(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|||||||
|
|
||||||
parse_rtattr(tb, NDA_MAX, NDA_RTA(r), n->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
|
parse_rtattr(tb, NDA_MAX, NDA_RTA(r), n->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
|
||||||
|
|
||||||
if (tb[NDA_DST]) {
|
if (inet_addr_match_rta(&filter.pfx, tb[NDA_DST]))
|
||||||
if (filter.pfx.family) {
|
|
||||||
inet_prefix dst = { .family = r->ndm_family };
|
|
||||||
|
|
||||||
memcpy(&dst.data, RTA_DATA(tb[NDA_DST]), RTA_PAYLOAD(tb[NDA_DST]));
|
|
||||||
if (inet_addr_match(&dst, &filter.pfx, filter.pfx.bitlen))
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (filter.unused_only && tb[NDA_CACHEINFO]) {
|
if (filter.unused_only && tb[NDA_CACHEINFO]) {
|
||||||
struct nda_cacheinfo *ci = RTA_DATA(tb[NDA_CACHEINFO]);
|
struct nda_cacheinfo *ci = RTA_DATA(tb[NDA_CACHEINFO]);
|
||||||
|
|
||||||
@ -418,7 +412,8 @@ static int do_show_or_flush(int argc, char **argv, int flush)
|
|||||||
}
|
}
|
||||||
if (matches(*argv, "help") == 0)
|
if (matches(*argv, "help") == 0)
|
||||||
usage();
|
usage();
|
||||||
get_prefix(&filter.pfx, *argv, filter.family);
|
if (get_prefix(&filter.pfx, *argv, filter.family))
|
||||||
|
invarg("to value is invalid\n", *argv);
|
||||||
if (filter.family == AF_UNSPEC)
|
if (filter.family == AF_UNSPEC)
|
||||||
filter.family = filter.pfx.family;
|
filter.family = filter.pfx.family;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user