From fdd1ba220dd7b780400e9d0652cde80e59f63572 Mon Sep 17 00:00:00 2001 From: Nicolas PLANEL Date: Thu, 10 Oct 2013 20:51:38 +0000 Subject: route/link: fixup link->l_af_ops must be set for some kind of links Lookup on IFLA_INFO_KIND information to setup the right link->l_af_ops callbacks For example, if you setup a bridge this is avoid to trig IS_BRIDGE_LINK_ASSERT() on rtnl_link_bridge_get_flags() call. line=, function=) at assert.c:94 0x7ffff5dc39a0 "rtnl_link_bridge_get_flags") at assert.c:103 Signed-off-by: Nicolas PLANEL Signed-off-by: Thomas Graf --- lib/route/link.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/route/link.c b/lib/route/link.c index 0bb90a0..a016899 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -523,6 +523,7 @@ static int link_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, if (li[IFLA_INFO_KIND]) { struct rtnl_link_info_ops *ops; char *kind; + int af; kind = nla_strdup(li[IFLA_INFO_KIND]); if (kind == NULL) { @@ -532,6 +533,16 @@ static int link_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, link->l_info_kind = kind; link->ce_mask |= LINK_ATTR_LINKINFO; + if ((af = nl_str2af(kind)) >= 0 && + !af_ops && (af_ops = af_lookup_and_alloc(link, af))) { + + if (af_ops->ao_protinfo_policy) { + tb[IFLA_PROTINFO] = (struct nlattr *)af_ops->ao_protinfo_policy; + } + link->l_family = family = af; + link->l_af_ops = af_ops; + } + ops = rtnl_link_info_ops_lookup(kind); link->l_info_ops = ops; -- cgit v0.12