link: allow overwriting IFLA_EXT_MASK flag in ao_get_af() function

Instead of setting it twice, once during link_request_update() and
later in bridge_get_af(), pass ext_filter_mask to ao_get_af().

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2016-05-29 16:26:59 +02:00
parent 90c6ebec9b
commit 8dce6de701
3 changed files with 13 additions and 11 deletions

View File

@ -126,7 +126,8 @@ struct rtnl_link_af_ops
/** Called for GETLINK message to the kernel. Used to append
* link address family specific attributes to the request message. */
int (*ao_get_af)(struct nl_msg *msg);
int (*ao_get_af)(struct nl_msg *msg,
uint32_t *ext_filter_mask);
/** Dump address family specific link attributes */
void (*ao_dump[NL_DUMP_MAX+1])(struct rtnl_link *,

View File

@ -677,7 +677,7 @@ static int link_request_update(struct nl_cache *cache, struct nl_sock *sk)
struct rtnl_link_af_ops *ops;
struct nl_msg *msg;
int err;
__u32 vf_mask = RTEXT_FILTER_VF;
__u32 ext_filter_mask = RTEXT_FILTER_VF;
msg = nlmsg_alloc_simple(RTM_GETLINK, NLM_F_DUMP);
if (!msg)
@ -687,13 +687,15 @@ static int link_request_update(struct nl_cache *cache, struct nl_sock *sk)
if (nlmsg_append(msg, &hdr, sizeof(hdr), NLMSG_ALIGNTO) < 0)
goto nla_put_failure;
err = nla_put(msg, IFLA_EXT_MASK, sizeof(vf_mask), &vf_mask);
if (err)
goto nla_put_failure;
ops = rtnl_link_af_ops_lookup(family);
if (ops && ops->ao_get_af) {
err = ops->ao_get_af(msg);
err = ops->ao_get_af(msg, &ext_filter_mask);
if (err)
goto nla_put_failure;
}
if (ext_filter_mask) {
err = nla_put(msg, IFLA_EXT_MASK, sizeof(ext_filter_mask), &ext_filter_mask);
if (err)
goto nla_put_failure;
}

View File

@ -224,11 +224,10 @@ static int bridge_parse_af_full(struct rtnl_link *link, struct nlattr *attr_full
return 0;
}
static int bridge_get_af(struct nl_msg *msg)
static int bridge_get_af(struct nl_msg *msg, uint32_t *ext_filter_mask)
{
__u32 ext_filter_mask = RTEXT_FILTER_BRVLAN;
return nla_put(msg, IFLA_EXT_MASK, sizeof(ext_filter_mask), &ext_filter_mask);
*ext_filter_mask |= RTEXT_FILTER_BRVLAN;
return 0;
}
static void dump_bitmap(struct nl_dump_params *p, const uint32_t *b)