diff options
author | Johannes Berg <johannes.berg@intel.com> | 2017-11-13 08:57:05 +0100 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2017-11-13 08:57:05 +0100 |
commit | 3d9856fc66b6cd4f9be640506278d12df7a5d0fb (patch) | |
tree | eef3193b359d722489344c7e0246ea6b31999776 | |
parent | 75fadbc1381e4aef826177591a02968998f5ebe7 (diff) |
backports: netlink extack: Allow ext_ack to carry non-error messages
Backport upstream
commit 4f6265d485ea0a2507692ded8ed47b323f49587c
Author: David Ahern <dsahern@gmail.com>
Date: Fri Oct 27 17:37:12 2017 -0700
netlink: Allow ext_ack to carry non-error messages
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r-- | backport/compat/backport-4.12.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/backport/compat/backport-4.12.c b/backport/compat/backport-4.12.c index 767ecb98..f997b6c5 100644 --- a/backport/compat/backport-4.12.c +++ b/backport/compat/backport-4.12.c @@ -87,17 +87,16 @@ static void extack_netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, * requested. * (ignored in backports) */ + if (nlk_has_extack && extack && extack->_msg) + tlvlen += nla_total_size(strlen(extack->_msg) + 1); + if (err) { if (1) payload += nlmsg_len(nlh); else flags |= NLM_F_CAPPED; - if (nlk_has_extack && extack) { - if (extack->_msg) - tlvlen += nla_total_size(strlen(extack->_msg) + 1); - if (extack->bad_attr) - tlvlen += nla_total_size(sizeof(u32)); - } + if (nlk_has_extack && extack && extack->bad_attr) + tlvlen += nla_total_size(sizeof(u32)); } else { flags |= NLM_F_CAPPED; @@ -122,10 +121,11 @@ static void extack_netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh)); if (nlk_has_extack && extack) { + if (extack->_msg) { + WARN_ON(nla_put_string(skb, NLMSGERR_ATTR_MSG, + extack->_msg)); + } if (err) { - if (extack->_msg) - WARN_ON(nla_put_string(skb, NLMSGERR_ATTR_MSG, - extack->_msg)); if (extack->bad_attr && !WARN_ON((u8 *)extack->bad_attr < in_skb->data || (u8 *)extack->bad_attr >= in_skb->data + |