net: add extack arg to lwtunnel build state
Pass extack arg down to lwtunnel_build_state and the build_state callbacks. Add messages for failures in lwtunnel_build_state, and add the extarg to nla_parse where possible in the build_state callbacks. Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
c255bd681d
commit
9ae2872748
@@ -103,25 +103,39 @@ EXPORT_SYMBOL(lwtunnel_encap_del_ops);
|
||||
|
||||
int lwtunnel_build_state(u16 encap_type,
|
||||
struct nlattr *encap, unsigned int family,
|
||||
const void *cfg, struct lwtunnel_state **lws)
|
||||
const void *cfg, struct lwtunnel_state **lws,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
const struct lwtunnel_encap_ops *ops;
|
||||
bool found = false;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (encap_type == LWTUNNEL_ENCAP_NONE ||
|
||||
encap_type > LWTUNNEL_ENCAP_MAX)
|
||||
encap_type > LWTUNNEL_ENCAP_MAX) {
|
||||
NL_SET_ERR_MSG_ATTR(extack, encap,
|
||||
"Unknown LWT encapsulation type");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = -EOPNOTSUPP;
|
||||
rcu_read_lock();
|
||||
ops = rcu_dereference(lwtun_encaps[encap_type]);
|
||||
if (likely(ops && ops->build_state && try_module_get(ops->owner))) {
|
||||
ret = ops->build_state(encap, family, cfg, lws);
|
||||
found = true;
|
||||
ret = ops->build_state(encap, family, cfg, lws, extack);
|
||||
if (ret)
|
||||
module_put(ops->owner);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
|
||||
/* don't rely on -EOPNOTSUPP to detect match as build_state
|
||||
* handlers could return it
|
||||
*/
|
||||
if (!found) {
|
||||
NL_SET_ERR_MSG_ATTR(extack, encap,
|
||||
"LWT encapsulation type not supported");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(lwtunnel_build_state);
|
||||
|
Reference in New Issue
Block a user