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=<optimized out>, function=<optimized out>) at assert.c:94
    0x7ffff5dc39a0 "rtnl_link_bridge_get_flags") at assert.c:103

Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
Nicolas PLANEL 2013-10-10 20:51:38 +00:00 committed by Thomas Graf
parent 27019c5671
commit fdd1ba220d

View file

@ -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;