]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
Only include local addr as peer addr if provided
authorWolfgang Steudel <Wolfgang.Steudel@Stud.TU-Ilmenau.de>
Tue, 7 Oct 2008 04:43:59 +0000 (06:43 +0200)
committerThomas Graf <tgr@plip.localdomain>
Fri, 10 Oct 2008 10:32:23 +0000 (12:32 +0200)
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).

lib/route/addr.c

index b30c96dd606478d8df80f80255b215a87c981494..33bdace4ee019e4886b39d91d77607fb3d1a861f 100644 (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)