Only include local addr as peer addr if provided

we're using libnl-1.1 for a project. When trying to delete all
addresses of an interface by only setting interface index and
address family of an rtnl_addr and executing rtnl_addr_delete()
we received some error (I don't remember what it was).

The bug(?) is in build_addr_msg() in lib/route/addr.c:
IFA_ADDRESS is set to a_local when a_peer is not set,
without checking if a_local was set. We just added
   if (tmpl->ce_mask & ADDR_ATTR_LOCAL)
after the "else" (line 496 in the current git).
This commit is contained in:
Wolfgang Steudel 2008-10-07 06:43:59 +02:00 committed by Thomas Graf
parent b12918df16
commit 5702d4c1b9

View file

@ -493,7 +493,7 @@ static int build_addr_msg(struct rtnl_addr *tmpl, int cmd, int flags,
if (tmpl->ce_mask & ADDR_ATTR_PEER)
NLA_PUT_ADDR(msg, IFA_ADDRESS, tmpl->a_peer);
else
else if (tmpl->ce_mask & ADDR_ATTR_LOCAL)
NLA_PUT_ADDR(msg, IFA_ADDRESS, tmpl->a_local);
if (tmpl->ce_mask & ADDR_ATTR_LABEL)