From: Serhey Popovych Subject: [PATCH iproute2-next 5/8] ipneigh: Use get_addr_rta() Date: Mon, 22 Jan 2018 19:26:15 +0200 Message-ID: <1516641978-24269-6-git-send-email-serhe.popovych@gmail.com> References: <1516641978-24269-1-git-send-email-serhe.popovych@gmail.com> To: netdev@vger.kernel.org Return-path: Received: from mail-wm0-f66.google.com ([74.125.82.66]:39388 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751174AbeAVR04 (ORCPT ); Mon, 22 Jan 2018 12:26:56 -0500 Received: by mail-wm0-f66.google.com with SMTP id b21so18400795wme.4 for ; Mon, 22 Jan 2018 09:26:55 -0800 (PST) Received: from tuxracer.localdomain ([2a01:6d80::195:20:96:53]) by smtp.gmail.com with ESMTPSA id k11sm12285959eda.22.2018.01.22.09.26.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Jan 2018 09:26:54 -0800 (PST) In-Reply-To: <1516641978-24269-1-git-send-email-serhe.popovych@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: Setting ->family in @inet_prefix seems pointless: inet_addr_match() does not consider it's value: better is to force get_addr_rta() to use address family from filter to ensure we get correct one. Signed-off-by: Serhey Popovych --- ip/ipneigh.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ip/ipneigh.c b/ip/ipneigh.c index 11f280d..d9de935 100644 --- a/ip/ipneigh.c +++ b/ip/ipneigh.c @@ -234,14 +234,14 @@ 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))); - if (tb[NDA_DST]) { - if (filter.pfx.family) { - inet_prefix dst = { .family = r->ndm_family }; + if (filter.pfx.family && tb[NDA_DST]) { + struct rtattr *rta = tb[NDA_DST]; + inet_prefix dst, *f_pfx = &filter.pfx; - 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; - } + if (get_addr_rta(&dst, rta, f_pfx->family)) + return 0; + if (inet_addr_match(&dst, f_pfx, f_pfx->bitlen)) + return 0; } if (filter.unused_only && tb[NDA_CACHEINFO]) { struct nda_cacheinfo *ci = RTA_DATA(tb[NDA_CACHEINFO]); -- 1.7.10.4