All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Cc: pablo@netfilter.org, Jamal Hadi Salim <jhs@mojatatu.com>,
	Jiri Benc <jbenc@redhat.com>,
	David Ahern <dsa@cumulusnetworks.com>,
	jiri@resnulli.us
Subject: Re: [PATCH v2 1/5] netlink: extended ACK reporting
Date: Mon, 10 Apr 2017 12:15:40 +0200	[thread overview]
Message-ID: <1491819340.2455.7.camel@sipsolutions.net> (raw)
In-Reply-To: <20170408183444.2796-2-johannes@sipsolutions.net> (sfid-20170408_203507_265684_7230C4D6)


> @@ -2300,14 +2332,35 @@ void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err)
        rep = __nlmsg_put(skb, NETLINK_CB(in_skb).portid, nlh->nlmsg_seq,
>  			  NLMSG_ERROR, payload, 0);
>  	errmsg = nlmsg_data(rep);
>  	errmsg->error = err;

This is still wrong - now the message length is too short.

At the very least,

> -	memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh-
> >nlmsg_len : sizeof(*nlh));
> +	memcpy(&errmsg->msg, nlh,
> +	       !(nlk->flags & NETLINK_F_CAP_ACK) ? nlh->nlmsg_len
> +						 : sizeof(*nlh));
> +
> +	if (err && nlk->flags & NETLINK_F_EXT_ACK && extack) {
> +		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
> +
> +						       in_skb->len))
> +			WARN_ON(nla_put_u32(skb, NLMSGERR_ATTR_OFFS,
> +					    (u8 *)extack->bad_attr -
> +					    in_skb->data));
> +		if (extack->missing_attr)
> +			WARN_ON(nla_put_u16(skb, NLMSGERR_ATTR_ATTR,
> +					    extack->missing_attr));
> +	}

I need to add
 rep->nlmsg_len = skb->len;

>  	netlink_unicast(in_skb->sk, skb, NETLINK_CB(in_skb).portid,
> MSG_DONTWAIT);

Here, but at that point I think it makes sense to rewrite this nlmsg
put stuff here as well.

johannes

  reply	other threads:[~2017-04-10 10:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-08 18:34 [PATCH v2 0/5] Johannes Berg
2017-04-08 18:34 ` [PATCH v2 1/5] netlink: extended ACK reporting Johannes Berg
2017-04-08 18:34   ` Johannes Berg
2017-04-10 10:15   ` Johannes Berg [this message]
2017-04-08 18:34 ` [PATCH v2 2/5] genetlink: pass extended ACK report down Johannes Berg
2017-04-08 18:34   ` Johannes Berg
2017-04-08 18:34 ` [PATCH v2 3/5] netlink: allow sending extended ACK with cookie on success Johannes Berg
2017-04-08 19:07   ` David Ahern
2017-04-08 19:07     ` David Ahern
2017-04-08 18:34 ` [PATCH v2 4/5] netlink: pass extended ACK struct to parsing functions Johannes Berg
2017-04-08 18:34   ` Johannes Berg
2017-04-08 18:34 ` [PATCH v2 5/5] netlink: pass extended ACK struct where available Johannes Berg
2017-04-08 18:34   ` Johannes Berg

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=1491819340.2455.7.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=dsa@cumulusnetworks.com \
    --cc=jbenc@redhat.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.