From: David Ahern <dsahern@gmail.com>
To: netdev@vger.kernel.org
Cc: jiri@mellanox.com, idosch@mellanox.com, johannes.berg@intel.com,
David Ahern <dsahern@gmail.com>
Subject: [PATCH net-next 1/3] netlink: Allow ext_ack to carry non-error messages
Date: Wed, 25 Oct 2017 22:08:03 -0700 [thread overview]
Message-ID: <1508994485-24533-2-git-send-email-dsahern@gmail.com> (raw)
In-Reply-To: <1508994485-24533-1-git-send-email-dsahern@gmail.com>
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: David Ahern <dsahern@gmail.com>
---
net/netlink/af_netlink.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 767c84e10e20..26ded4239611 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -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
* requested.
*/
+ if (nlk_has_extack && extack && extack->_msg)
+ tlvlen += nla_total_size(strlen(extack->_msg) + 1);
+
if (err) {
if (!(nlk->flags & NETLINK_F_CAP_ACK))
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;
@@ -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));
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 +
--
2.1.4
next prev parent reply other threads:[~2017-10-26 5:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-26 5:08 [PATCH net-next 0/3] net: Allow non-fatal messages to be passed in extack David Ahern
2017-10-26 5:08 ` David Ahern [this message]
2017-10-26 5:08 ` [PATCH net-next 2/3] net: Add extack to fib_notifier_info David Ahern
2017-10-26 5:08 ` [PATCH net-next 3/3] mlxsw: spectrum_router: Return extack message on abort due to fib rules David Ahern
2017-10-26 6:26 ` Jiri Pirko
2017-10-26 6:40 ` Ido Schimmel
2017-10-26 6:38 ` Ido Schimmel
2017-10-26 15:30 ` David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1508994485-24533-2-git-send-email-dsahern@gmail.com \
--to=dsahern@gmail.com \
--cc=idosch@mellanox.com \
--cc=jiri@mellanox.com \
--cc=johannes.berg@intel.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).