From: Jiri Pirko <jiri@resnulli.us>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
pablo@netfilter.org, Jamal Hadi Salim <jhs@mojatatu.com>,
Jiri Benc <jbenc@redhat.com>,
David Ahern <dsa@cumulusnetworks.com>,
Johannes Berg <johannes.berg@intel.com>
Subject: Re: [PATCH net-next v5 1/5] netlink: extended ACK reporting
Date: Wed, 12 Apr 2017 15:41:37 +0200 [thread overview]
Message-ID: <20170412134137.GE1952@nanopsycho> (raw)
In-Reply-To: <20170412123408.22012-2-johannes@sipsolutions.net>
Wed, Apr 12, 2017 at 02:34:04PM CEST, johannes@sipsolutions.net wrote:
>From: Johannes Berg <johannes.berg@intel.com>
>
>Add the base infrastructure and UAPI for netlink extended ACK
>reporting. All "manual" calls to netlink_ack() pass NULL for
>now and thus don't get extended ACK reporting.
>
>Big thanks goes to Pablo Neira Ayuso for not only bringing up
>the whole topic at netconf (again) but also coming up with the
>nlattr passing trick and various other ideas.
>
>Signed-off-by: Johannes Berg <johannes.berg@intel.com>
>---
[...]
>diff --git a/include/uapi/linux/netlink.h b/include/uapi/linux/netlink.h
>index b2c9c26ea30f..7df88770e029 100644
>--- a/include/uapi/linux/netlink.h
>+++ b/include/uapi/linux/netlink.h
>@@ -69,6 +69,10 @@ struct nlmsghdr {
> #define NLM_F_CREATE 0x400 /* Create, if it does not exist */
> #define NLM_F_APPEND 0x800 /* Add to end of list */
>
>+/* Flags for ACK message */
>+#define NLM_F_CAPPED 0x100 /* request was capped */
The comment did not help me. What is this supposed to signalize?
>+#define NLM_F_ACK_TLVS 0x200 /* extended ACK TVLs were included */
>+
> /*
> 4.4BSD ADD NLM_F_CREATE|NLM_F_EXCL
> 4.4BSD CHANGE NLM_F_REPLACE
>@@ -101,6 +105,33 @@ struct nlmsghdr {
[...]
>diff --git a/net/decnet/netfilter/dn_rtmsg.c b/net/decnet/netfilter/dn_rtmsg.c
>index 85f2fdc360c2..c8bf5136a72b 100644
>--- a/net/decnet/netfilter/dn_rtmsg.c
>+++ b/net/decnet/netfilter/dn_rtmsg.c
>@@ -96,7 +96,7 @@ static unsigned int dnrmg_hook(void *priv,
> }
>
>
>-#define RCV_SKB_FAIL(err) do { netlink_ack(skb, nlh, (err)); return; } while (0)
>+#define RCV_SKB_FAIL(err) do { netlink_ack(skb, nlh, (err), NULL); return; } while (0)
You can easily break this into multiple lines to avoid over-80
>
> static inline void dnrmg_receive_user_skb(struct sk_buff *skb)
> {
[...]
>-void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err)
>+void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err,
>+ const struct netlink_ext_ack *extack)
> {
> struct sk_buff *skb;
> struct nlmsghdr *rep;
> struct nlmsgerr *errmsg;
> size_t payload = sizeof(*errmsg);
>+ size_t tlvlen = 0;
> struct netlink_sock *nlk = nlk_sk(NETLINK_CB(in_skb).sk);
>+ unsigned int flags = 0;
>
> /* Error messages get the original request appened, unless the user
>- * requests to cap the error message.
>+ * requests to cap the error message, and get extra error data if
>+ * requested.
> */
>- if (!(nlk->flags & NETLINK_F_CAP_ACK) && err)
>- payload += nlmsg_len(nlh);
>+ if (err) {
>+ if (!(nlk->flags & NETLINK_F_CAP_ACK))
>+ payload += nlmsg_len(nlh);
>+ else
>+ flags |= NLM_F_CAPPED;
>+ if (nlk->flags & NETLINK_F_EXT_ACK && extack) {
>+ if (extack->_msg)
>+ tlvlen += nla_total_size(strlen(extack->_msg) + 1);
>+ if (extack->bad_attr)
>+ tlvlen += nla_total_size(sizeof(u32));
>+ }
>+ } else {
>+ flags |= NLM_F_CAPPED;
>+ }
>
>- skb = nlmsg_new(payload, GFP_KERNEL);
>+ if (tlvlen)
>+ flags |= NLM_F_ACK_TLVS;
You can move this check and bitset to the end of
"if (nlk->flags & NETLINK_F_EXT_ACK && extack) { "
as it is directly related to that.
>+
>+ skb = nlmsg_new(payload + tlvlen, GFP_KERNEL);
> if (!skb) {
> struct sock *sk;
>
next prev parent reply other threads:[~2017-04-12 13:41 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-12 12:34 [PATCH net-next v5 0/5] netlink extended ACK reporting Johannes Berg
2017-04-12 12:34 ` [PATCH net-next v5 1/5] netlink: " Johannes Berg
2017-04-12 13:41 ` Jiri Pirko [this message]
2017-04-12 15:06 ` David Ahern
2017-04-12 15:13 ` Jiri Pirko
2017-04-12 15:28 ` David Miller
2017-04-12 15:21 ` Johannes Berg
2017-04-12 15:30 ` David Miller
2017-04-12 15:32 ` David Ahern
2017-04-12 12:34 ` [PATCH net-next v5 2/5] genetlink: pass extended ACK report down Johannes Berg
2017-04-12 14:01 ` Jiri Pirko
2017-04-12 12:34 ` [PATCH net-next v5 3/5] netlink: allow sending extended ACK with cookie on success Johannes Berg
2017-04-12 13:47 ` Jiri Pirko
2017-04-12 13:54 ` Johannes Berg
2017-04-12 12:34 ` [PATCH net-next v5 4/5] netlink: pass extended ACK struct to parsing functions Johannes Berg
2017-04-12 13:17 ` Jiri Pirko
2017-04-12 13:20 ` Johannes Berg
2017-04-12 13:24 ` Jiri Pirko
2017-04-12 14:02 ` Kalle Valo
2017-04-12 14:08 ` Jiri Pirko
2017-04-12 13:56 ` Jiri Pirko
2017-04-12 12:34 ` [PATCH net-next v5 5/5] netlink: pass extended ACK struct where available Johannes Berg
2017-04-12 14:00 ` Jiri Pirko
2017-04-12 14:55 ` David Ahern
2017-04-12 15:15 ` Jiri Pirko
2017-04-12 15:29 ` David Miller
2017-04-12 14:57 ` [PATCH net-next v5 0/5] netlink extended ACK reporting 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=20170412134137.GE1952@nanopsycho \
--to=jiri@resnulli.us \
--cc=dsa@cumulusnetworks.com \
--cc=jbenc@redhat.com \
--cc=jhs@mojatatu.com \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pablo@netfilter.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).