]> granicus.if.org Git - libnl/commitdiff
route/addr: address attributes based on object
authorTobias Jungel <tobias.jungel@bisdn.de>
Thu, 4 Aug 2016 08:01:43 +0000 (10:01 +0200)
committerThomas Haller <thaller@redhat.com>
Sun, 14 Aug 2016 09:00:30 +0000 (11:00 +0200)
addr_id_attrs_get returned a fixed set of attributes for AF_INET. This
leads to an invalid cache in case the default cache manager is used.

The error was cause by nl_object_identical, which checkes the ce_mask
of an object against the req_attrs. For route/addr objects the ce_mask
may contain the ADDR_ATTR_PEER, but the addr_id_attrs_get always
includes this attribute. Thus nl_object_identical fails always in case
no peer exists, which is the default for local addresses.

Fixes: 83e851ca9c842ccb6dae411d3fff9c7e9561269a
https://github.com/thom311/libnl/pull/105

Signed-off-by: Thomas Haller <thaller@redhat.com>
lib/route/addr.c

index b699c6413d56305d9cf86f138097d77b03084cb3..7d3ff3957e89017d8f2bfae7106d5826402434b0 100644 (file)
@@ -467,12 +467,15 @@ static void addr_dump_stats(struct nl_object *obj, struct nl_dump_params *p)
 static uint32_t addr_id_attrs_get(struct nl_object *obj)
 {
        struct rtnl_addr *addr = (struct rtnl_addr *)obj;
+       uint32_t rv;
 
        switch (addr->a_family) {
        case AF_INET:
-               return (ADDR_ATTR_FAMILY | ADDR_ATTR_IFINDEX |
-                       ADDR_ATTR_LOCAL | ADDR_ATTR_PREFIXLEN |
-                       ADDR_ATTR_PEER);
+               rv = (ADDR_ATTR_FAMILY | ADDR_ATTR_IFINDEX |
+                     ADDR_ATTR_LOCAL | ADDR_ATTR_PREFIXLEN);
+               if (addr->a_peer)
+                       rv |= ADDR_ATTR_PEER;
+               return rv;
        case AF_INET6:
                return (ADDR_ATTR_FAMILY | ADDR_ATTR_IFINDEX |
                        ADDR_ATTR_LOCAL);