[Dnsmasq-discuss] [PATCH] Fix parsing of IPv6 addresses with peer from netlink
Beniamino Galvani
bgalvani at redhat.com
Thu May 19 09:43:45 UTC 2022
On Wed, May 18, 2022 at 04:10:52PM +0200, Geert Stappers via Dnsmasq-discuss wrote:
> There new lines and one old line
> > + if (rta->rta_type == IFA_LOCAL)
> > + addrp = ((struct in6_addr *)(rta+1));
> > + else if (rta->rta_type == IFA_ADDRESS && !addrp)
> > addrp = ((struct in6_addr *)(rta+1));
> rewritten as I see them
> + if (conditionLOCAL)
> + addrp = value
> + else if (conditionADDRESS && !addrp)
> addrp = value
>
>
> It is the "&& !addrp" that makes me feel uncomfortable.
>
>
> Would
> + if (conditionLOCAL)
> + addrp = value
> + else if (conditionADDRESS)
> addrp = value
>
> do?
It wouldn't work, because a netlink message for an address with peer
has:
IFA_LOCAL = addr
IFA_ADDRESS = peer
We would first evaluate IFA_LOCAL and set addrp = addr, then overwrite
it with peer when evaluating the next attribute IFA_ADDRESS.
Since we are interested in 'addr', when IFA_LOCAL is present it should
always override IFA_ADDRESS.
> P.S.
> @Beniamino welcome to dnsmasq
Thanks,
Beniamino
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20220519/02a64484/attachment.sig>
More information about the Dnsmasq-discuss
mailing list