From: Julian Anastasov <ja@ssi.bg>
To: Chris Clark <chris.clark@alcatel-lucent.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: sendto() bug?
Date: Sat, 24 Aug 2013 11:35:44 +0300 (EEST) [thread overview]
Message-ID: <alpine.LFD.2.00.1308241105220.1641@ja.ssi.bg> (raw)
In-Reply-To: <alpine.DEB.2.02.1308231257140.10771@optio.utah.ind.alcatel.com>
Hello,
On Fri, 23 Aug 2013, Chris Clark wrote:
> In the same vein as 2ad5b9e4, I'm soliciting feedback on something
> similar for raw_sendmsg():
>
> =================================================================
> diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
> index dd44e0a..454d9c1 100644
> --- a/net/ipv4/raw.c
> +++ b/net/ipv4/raw.c
> @@ -571,7 +571,9 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
> flowi4_init_output(&fl4, ipc.oif, sk->sk_mark, tos,
> RT_SCOPE_UNIVERSE,
> inet->hdrincl ? IPPROTO_RAW : sk->sk_protocol,
> - inet_sk_flowi_flags(sk) | FLOWI_FLAG_CAN_SLEEP,
> + inet_sk_flowi_flags(sk) | FLOWI_FLAG_CAN_SLEEP
> + | ((msg->msg_namelen
> + && (tos & RTO_ONLINK)) ? FLOWI_FLAG_KNOWN_NH : 0),
> daddr, saddr, 0, 0);
>
> if (!inet->hdrincl) {
> =================================================================
>
> The thought here is to apply the FLOWI_FLAG_KNOWN_NH flag when:
> (a) The dest_addr is given explicitly (msg->msg_namelen), and
> (b) The socket is in MSG_DONTROUTE mode (tos & RTO_ONLINK).
IMHO, FLOWI_FLAG_KNOWN_NH should be set only
for the inet->hdrincl case, otherwise it is set from
routing result: ip_push_pending_frames -> ip_finish_skb ->
__ip_make_skb -> ip_copy_addrs.
The both cases for hdrincl (usin->sin_addr.s_addr
and inet->inet_daddr) can provide different address, so
it should work also for connected sockets.
And it should not depend on MSG_DONTROUTE because
daddr for routing and daddr in header can be two
different IPs in local subnet, the user should not
be restricted to use MSG_DONTROUTE just to send
correct ARP request.
So, something like
(inet->hdrincl ? FLOWI_FLAG_KNOWN_NH : 0) ?
Regards
--
Julian Anastasov <ja@ssi.bg>
next prev parent reply other threads:[~2013-08-24 8:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-23 19:19 sendto() bug? Chris Clark
2013-08-24 8:35 ` Julian Anastasov [this message]
2013-08-26 20:14 ` Chris Clark
2013-08-26 20:15 ` David Miller
2013-08-27 6:02 ` Julian Anastasov
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=alpine.LFD.2.00.1308241105220.1641@ja.ssi.bg \
--to=ja@ssi.bg \
--cc=chris.clark@alcatel-lucent.com \
--cc=davem@davemloft.net \
--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