diff options
author | roopa <roopa@cumulusnetworks.com> | 2013-01-28 15:46:16 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2013-01-31 09:09:12 (GMT) |
commit | b06c23a9dd6e93fc7325421897dbaa81af7a9e8c (patch) | |
tree | 572e87fa1fcdda66524bcf178bc6e0e46562bd21 /lib/route | |
parent | 6cc5fdc0e915c76d43055bf58e1e133f6ad2f1c8 (diff) | |
download | libnl-b06c23a9dd6e93fc7325421897dbaa81af7a9e8c.zip libnl-b06c23a9dd6e93fc7325421897dbaa81af7a9e8c.tar.gz libnl-b06c23a9dd6e93fc7325421897dbaa81af7a9e8c.tar.bz2 |
link cache: remove AF_UNSPEC check in rtnl_get_link and rtnl_get_link_by_name
This patch reverts back the AF_UNSPEC check introduced by AF_BRIDGE
changes at http://lists.infradead.org/pipermail/libnl/2012-November/000796.html
After the addition of AF_BRIDGE support, link cache can now contain objects of
type AF_BRIDGE. To make sure existing api's did not return AF_BRIDGE objects
and surprise existing callers, I introduced the check for AF_UNSPEC.
But from what Andy Wang reported, rtnl_link_get_by_name returns the first
link object with matching ifindex and that could have not only been AF_UNSPEC
but also of family AF_INET6. And his app always got an AF_INET6 object prior
to the patch that introduced the AF_UNSPEC check.
I could just add AF_INET6 family check along with AF_UNSPEC in the apis and that
should work well.
But thinking about it some more, removing the AF_UNSPEC change seems to be safer at
this point. That way this api will retain its semantics and return the first object
with matching ifindex. It could be of any supported family. The user will know if the
cache contains bridge objects, because they are available only with the cache flag
NL_CACHE_AF_ITER. Besides, if new users want to search for a specific object,
nl_cache_find is a better option.
Reported-by: Andy Wang <Andy.Wang@watchguard.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Diffstat (limited to 'lib/route')
-rw-r--r-- | lib/route/link.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/route/link.c b/lib/route/link.c index 3171513..8b5227e 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -986,7 +986,7 @@ struct rtnl_link *rtnl_link_get(struct nl_cache *cache, int ifindex) return NULL; nl_list_for_each_entry(link, &cache->c_items, ce_list) { - if (link->l_family == AF_UNSPEC && link->l_index == ifindex) { + if (link->l_index == ifindex) { nl_object_get((struct nl_object *) link); return link; } @@ -1019,8 +1019,7 @@ struct rtnl_link *rtnl_link_get_by_name(struct nl_cache *cache, return NULL; nl_list_for_each_entry(link, &cache->c_items, ce_list) { - if (link->l_family == AF_UNSPEC && - !strcmp(name, link->l_name)) { + if (!strcmp(name, link->l_name)) { nl_object_get((struct nl_object *) link); return link; } |