rtnetlink: Add more extack messages to rtnl_newlink
Add extack arg to the nla_parse_nested calls in rtnl_newlink, and add messages for unknown device type and link network namespace id. In particular, it improves the failure message when the wrong link type is used. From $ ip li add bond1 type bonding RTNETLINK answers: Operation not supported to $ ip li add bond1 type bonding Error: Unknown device type. (The module name is bonding but the link type is bond.) Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d7e774f356
commit
68d57f3b1d
|
@ -3054,7 +3054,7 @@ replay:
|
||||||
if (ops->maxtype && linkinfo[IFLA_INFO_DATA]) {
|
if (ops->maxtype && linkinfo[IFLA_INFO_DATA]) {
|
||||||
err = nla_parse_nested(attr, ops->maxtype,
|
err = nla_parse_nested(attr, ops->maxtype,
|
||||||
linkinfo[IFLA_INFO_DATA],
|
linkinfo[IFLA_INFO_DATA],
|
||||||
ops->policy, NULL);
|
ops->policy, extack);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
data = attr;
|
data = attr;
|
||||||
|
@ -3076,7 +3076,7 @@ replay:
|
||||||
m_ops->slave_maxtype,
|
m_ops->slave_maxtype,
|
||||||
linkinfo[IFLA_INFO_SLAVE_DATA],
|
linkinfo[IFLA_INFO_SLAVE_DATA],
|
||||||
m_ops->slave_policy,
|
m_ops->slave_policy,
|
||||||
NULL);
|
extack);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
slave_data = slave_attr;
|
slave_data = slave_attr;
|
||||||
|
@ -3140,6 +3140,7 @@ replay:
|
||||||
goto replay;
|
goto replay;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
NL_SET_ERR_MSG(extack, "Unknown device type");
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3160,6 +3161,7 @@ replay:
|
||||||
|
|
||||||
link_net = get_net_ns_by_id(dest_net, id);
|
link_net = get_net_ns_by_id(dest_net, id);
|
||||||
if (!link_net) {
|
if (!link_net) {
|
||||||
|
NL_SET_ERR_MSG(extack, "Unknown network namespace id");
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue