From: Serhey Popovych Subject: Re: [PATCH iproute2-next 2/8] ipaddress: Use get_addr_rta() Date: Tue, 23 Jan 2018 19:47:55 +0200 Message-ID: References: <1516641978-24269-1-git-send-email-serhe.popovych@gmail.com> <1516641978-24269-3-git-send-email-serhe.popovych@gmail.com> <4dcd4ad7-680b-f8b8-2503-06646619f24d@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="edrN6VRdeT8gjJvmbP6gFGeGaQXPyAAED" To: David Ahern , netdev@vger.kernel.org Return-path: Received: from mail-wm0-f48.google.com ([74.125.82.48]:39724 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751436AbeAWRsH (ORCPT ); Tue, 23 Jan 2018 12:48:07 -0500 Received: by mail-wm0-f48.google.com with SMTP id b21so3567886wme.4 for ; Tue, 23 Jan 2018 09:48:06 -0800 (PST) In-Reply-To: <4dcd4ad7-680b-f8b8-2503-06646619f24d@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --edrN6VRdeT8gjJvmbP6gFGeGaQXPyAAED Content-Type: multipart/mixed; boundary="5ZNbZWLt9Jnc8xNNhLTr6N271zEBWoy0w"; protected-headers="v1" From: Serhey Popovych To: David Ahern , netdev@vger.kernel.org Message-ID: Subject: Re: [PATCH iproute2-next 2/8] ipaddress: Use get_addr_rta() References: <1516641978-24269-1-git-send-email-serhe.popovych@gmail.com> <1516641978-24269-3-git-send-email-serhe.popovych@gmail.com> <4dcd4ad7-680b-f8b8-2503-06646619f24d@gmail.com> In-Reply-To: <4dcd4ad7-680b-f8b8-2503-06646619f24d@gmail.com> --5ZNbZWLt9Jnc8xNNhLTr6N271zEBWoy0w Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable David Ahern wrote: > On 1/22/18 10:26 AM, Serhey Popovych wrote: >> diff --git a/ip/ipaddress.c b/ip/ipaddress.c >> index ba60125..38d994e 100644 >> --- a/ip/ipaddress.c >> +++ b/ip/ipaddress.c >> @@ -1523,19 +1523,20 @@ int print_addrinfo(const struct sockaddr_nl *w= ho, struct nlmsghdr *n, >> if (fnmatch(filter.label, label, 0) !=3D 0) >> return 0; >> } >> - if (filter.pfx.family) { >> - if (rta_tb[IFA_LOCAL]) { >> - inet_prefix dst =3D { .family =3D ifa->ifa_family }; >> - >> - memcpy(&dst.data, RTA_DATA(rta_tb[IFA_LOCAL]), RTA_PAYLOAD(rta_tb[= IFA_LOCAL])); >> - if (inet_addr_match(&dst, &filter.pfx, filter.pfx.bitlen)) >> - return 0; >> - } >> - } >> =20 >> if (filter.family && filter.family !=3D ifa->ifa_family) >> return 0; >> =20 >> + if (filter.pfx.family && rta_tb[IFA_LOCAL]) { >> + struct rtattr *rta =3D rta_tb[IFA_LOCAL]; >> + inet_prefix dst, *f_pfx =3D &filter.pfx; >> + >> + if (get_addr_rta(&dst, rta, f_pfx->family)) >> + return 0; >> + if (inet_addr_match(&dst, f_pfx, f_pfx->bitlen)) >> + return 0; >> + } >> + >=20 >=20 > Those 2 checks are a consistent them throughout the patches. Given that= > why not create a helper that takes an rta and an inet_prefix and return= s > the result of both checks? Good point, will address this in v2. Thanks. >=20 --5ZNbZWLt9Jnc8xNNhLTr6N271zEBWoy0w-- --edrN6VRdeT8gjJvmbP6gFGeGaQXPyAAED Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQEcBAEBAgAGBQJaZ3VTAAoJEBTawMmQ61bBVIoH/1LcSnT0A2g+cgPmBqgY2ISy KJ3NcPqJ8nQohX42OhCQ8PIvkz+p2lMA7WuyL3rLUYVpvdh6l10AB9ctK/+wan/m DSjmQQq89T7xK9InuZpHMSTN6GY4JMiEdNjvDg/0sjo0dclpg/85awyujEv7bovt 6BEL/awvzK/ObNIlNlmR2kc/GXFvrhjZXJ3EoGRhVSI2cB/zQi+i6SfvOCViQZ51 LUDliMMvq3UAyFAllSH5kiDx3xTfZTuY2FnvQuEv4Ony6bEsrfM5cIEBr3vO1FZj CtOrYKsXaxsXbMwxfQ8HCQVNPTljwhYzjEPrJDvBR6wKNjXU8VBEvQQGwh84aak= =8aip -----END PGP SIGNATURE----- --edrN6VRdeT8gjJvmbP6gFGeGaQXPyAAED--