Skip to content

Commit 68d57f3

Browse files
dsaherndavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d7e774f commit 68d57f3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/core/rtnetlink.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3054,7 +3054,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
30543054
if (ops->maxtype && linkinfo[IFLA_INFO_DATA]) {
30553055
err = nla_parse_nested(attr, ops->maxtype,
30563056
linkinfo[IFLA_INFO_DATA],
3057-
ops->policy, NULL);
3057+
ops->policy, extack);
30583058
if (err < 0)
30593059
return err;
30603060
data = attr;
@@ -3076,7 +3076,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
30763076
m_ops->slave_maxtype,
30773077
linkinfo[IFLA_INFO_SLAVE_DATA],
30783078
m_ops->slave_policy,
3079-
NULL);
3079+
extack);
30803080
if (err < 0)
30813081
return err;
30823082
slave_data = slave_attr;
@@ -3140,6 +3140,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
31403140
goto replay;
31413141
}
31423142
#endif
3143+
NL_SET_ERR_MSG(extack, "Unknown device type");
31433144
return -EOPNOTSUPP;
31443145
}
31453146

@@ -3160,6 +3161,7 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
31603161

31613162
link_net = get_net_ns_by_id(dest_net, id);
31623163
if (!link_net) {
3164+
NL_SET_ERR_MSG(extack, "Unknown network namespace id");
31633165
err = -EINVAL;
31643166
goto out;
31653167
}

0 commit comments

Comments
 (0)