Commit 4f6265d4 authored by David Ahern's avatar David Ahern Committed by David S. Miller

netlink: Allow ext_ack to carry non-error messages

The NLMSGERR API already carries data (eg, a cookie) on the success path.
Allow a message string to be returned as well.
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a7b216b1
...@@ -2313,17 +2313,16 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err, ...@@ -2313,17 +2313,16 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
* requests to cap the error message, and get extra error data if * requests to cap the error message, and get extra error data if
* requested. * requested.
*/ */
if (nlk_has_extack && extack && extack->_msg)
tlvlen += nla_total_size(strlen(extack->_msg) + 1);
if (err) { if (err) {
if (!(nlk->flags & NETLINK_F_CAP_ACK)) if (!(nlk->flags & NETLINK_F_CAP_ACK))
payload += nlmsg_len(nlh); payload += nlmsg_len(nlh);
else else
flags |= NLM_F_CAPPED; flags |= NLM_F_CAPPED;
if (nlk_has_extack && extack) { if (nlk_has_extack && extack && extack->bad_attr)
if (extack->_msg) tlvlen += nla_total_size(sizeof(u32));
tlvlen += nla_total_size(strlen(extack->_msg) + 1);
if (extack->bad_attr)
tlvlen += nla_total_size(sizeof(u32));
}
} else { } else {
flags |= NLM_F_CAPPED; flags |= NLM_F_CAPPED;
...@@ -2348,10 +2347,11 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err, ...@@ -2348,10 +2347,11 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh)); memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh));
if (nlk_has_extack && extack) { if (nlk_has_extack && extack) {
if (extack->_msg) {
WARN_ON(nla_put_string(skb, NLMSGERR_ATTR_MSG,
extack->_msg));
}
if (err) { if (err) {
if (extack->_msg)
WARN_ON(nla_put_string(skb, NLMSGERR_ATTR_MSG,
extack->_msg));
if (extack->bad_attr && if (extack->bad_attr &&
!WARN_ON((u8 *)extack->bad_attr < in_skb->data || !WARN_ON((u8 *)extack->bad_attr < in_skb->data ||
(u8 *)extack->bad_attr >= in_skb->data + (u8 *)extack->bad_attr >= in_skb->data +
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment