All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Colitti <lorenzo@google.com>
To: Lorenzo Colitti <lorenzo@google.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>,
	David Miller <davem@davemloft.net>,
	Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [PATCH net-next v3 1/3] net: ipv6: Unduplicate {raw,udp}v6_sendmsg code
Date: Wed, 23 Apr 2014 15:37:13 +0900	[thread overview]
Message-ID: <CAKD1Yr1N43cA5DqV2kPi3hGpTF5uqPgLvtcuF7Ac8uDuj_ZyTw@mail.gmail.com> (raw)
In-Reply-To: <20140422154842.GC1960@order.stressinduktion.org>

On Wed, Apr 23, 2014 at 12:48 AM, Hannes Frederic Sowa
<hannes@stressinduktion.org> wrote:
>> +     *optp = NULL;
>> +     *dstp = NULL;
>> +     *hlimit = *tclass = *dontfrag = -1;
>
> Do we need those? If we return != 0 from ip6_datagram_send_common we
> know the in/out arguments may or maybe got an update an as such cannot
> use them.
>
> Caller can initialize dstp = NULL so we can pass dstp to dst_release in the
> error path in the caller function (dst_release checks for argument != NULL).

Initalizing optp was not useful. As you say, the callers won't use it
if we return an error. I've removed it.

I've also removed the initialization of dstp. After thinking about it,
I agree it's bad for the callers to rely on this function to set dstp
to NULL on failure. It's more reasonable for the callers to assume
that the dst pointer they pass in won't be touched on failure.

As for hlimit, tclass and dontfrag, they (and connected), I think it's
useful to initialize them here because it simplifies the code. Since
we set them to -1 early on, we can later do things like "if (*hlimit <
0) { set the default hop limit }" and have things work regardless of
whether a hop limit was passed in via cmsg. I don't think it's
confusing: variables are all calculated and returned by this function,
and the callers should not be setting them since they have no
information on what to set them to. Also, they don't need to be freed.
I've moved them closer to where they are actually set.

>> +     if (!ipv6_addr_any(daddr))
>> +             fl6->daddr = *daddr;
>> +     else
>> +             fl6->daddr.s6_addr[15] = 0x1; /* :: means loopback (BSD'ism) */
>
> Maybe a newline?

Added.

> We would also need a fl6_sock_release here because we finished processing
> it.
>
> You could also release the flowlabel after fl6_merge_options and could remove
> the fl6_sock_release after ip6_sk_dst_lookup_flow in the error handling.

Yes, that's better. Done.

  reply	other threads:[~2014-04-23  6:37 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-22  8:13 [PATCH net-next 1/3] net: ipv6: unduplicate {raw,udp}v6_sendmsg code Lorenzo Colitti
2014-04-22  8:13 ` [PATCH net-next 2/3] net: ipv6: Use ip6_datagram_send_common in L2TP IPv6 Lorenzo Colitti
2014-04-22  8:13 ` [PATCH net-next 3/3] net: ipv6: Use ip6_datagram_send_common in ping Lorenzo Colitti
2014-04-22  9:06 ` [PATCH net-next 1/3] net: ipv6: unduplicate {raw,udp}v6_sendmsg code YOSHIFUJI Hideaki
2014-04-22  9:38 ` [PATCH net-next v2 " Lorenzo Colitti
2014-04-22  9:38   ` [PATCH net-next v2 2/3] net: ipv6: Use ip6_datagram_send_common in L2TP IPv6 Lorenzo Colitti
2014-04-22 14:23     ` Eric Dumazet
2014-04-22 15:11       ` Lorenzo Colitti
2014-04-22  9:38   ` [PATCH net-next v2 3/3] net: ipv6: Use ip6_datagram_send_common in ping Lorenzo Colitti
2014-04-22 15:14 ` [PATCH net-next v3 1/3] net: ipv6: Unduplicate {raw,udp}v6_sendmsg code Lorenzo Colitti
2014-04-22 15:14   ` [PATCH net-next v3 2/3] net: ipv6: Use ip6_datagram_send_common in L2TP IPv6 Lorenzo Colitti
2014-04-22 15:14   ` [PATCH net-next v3 3/3] net: ipv6: Use ip6_datagram_send_common in ping Lorenzo Colitti
2014-04-22 15:48   ` [PATCH net-next v3 1/3] net: ipv6: Unduplicate {raw,udp}v6_sendmsg code Hannes Frederic Sowa
2014-04-23  6:37     ` Lorenzo Colitti [this message]
2014-04-22 15:59   ` Eric Dumazet
2014-04-23  6:38     ` Lorenzo Colitti
2014-04-23  6:37 ` [PATCH net-next v4 " Lorenzo Colitti
2014-04-23  6:37   ` [PATCH net-next v4 2/3] net: ipv6: Use ip6_datagram_send_common in L2TP IPv6 Lorenzo Colitti
2014-04-23  6:37   ` [PATCH net-next v4 3/3] net: ipv6: Use ip6_datagram_send_common in ping Lorenzo Colitti
2014-04-23 11:11     ` Florent Fourcot
2014-04-23 12:22       ` Lorenzo Colitti
2014-04-24 15:06         ` Hannes Frederic Sowa
2014-04-24 15:35           ` Lorenzo Colitti
2014-04-24 16:06             ` Lorenzo Colitti
2014-04-24 15:00   ` [PATCH net-next v4 1/3] net: ipv6: Unduplicate {raw,udp}v6_sendmsg code Hannes Frederic Sowa
2014-04-24 15:02     ` Hannes Frederic Sowa
2014-04-24 15:13       ` Lorenzo Colitti
2014-04-24 15:43         ` Hannes Frederic Sowa
2014-04-25 11:09           ` Lorenzo Colitti

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=CAKD1Yr1N43cA5DqV2kPi3hGpTF5uqPgLvtcuF7Ac8uDuj_ZyTw@mail.gmail.com \
    --to=lorenzo@google.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.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.