mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anton Ivanov <arivanov@sigsegv.cx>
To: linux-kernel@vger.kernel.org
Subject: Question on bind/connect/send in net/ipv4/udp.c in 2.4.25, possible bug in udp.c
Date: Tue, 09 Mar 2004 20:45:20 +0000	[thread overview]
Message-ID: <1078865119.18912.32.camel@gondor> (raw)

Hi list,

        First, sorry for the rather long post.

Background:

        I have been investigating some problems with tftpd-hpa. It does
not operate correctly on some multihomed machines and is sending from an
address different to the one it was told to bind. It uses the rather
uncommon for udp approach of bind(), connect(), send() instead of bind()
followed by simple sendto().

        After going through the tftpd code, glibc and the kernel and
discussing it with hpa@zytor.com himself I am think that the reason for
the behaviour of sending from an address different from the bound one
comes from the udp.c in the kernel ipv4. 

        The entire thing is filed with debian bug ID 234728

Problem (line numbers as of net/ipv4/udp.c in 2.4.25):

        If a udp socket is in a connected state on lines 533,534 it does
a sk_dst_check. As a side effect rt->rt_src is set. This is used after
that to fill the src of the udp packet and the bind is effectively
ignored as far as the ip address is concerned. 

        This is not the case for unconnected sockets which operate
correctly because they have the rt->rt_src filled with a correct value
around line 537.

Question:

        Should a connect udp socket honour bind() in first place?

        If it should current code does not seem quite right. I think  it
needs making the assignment of 

        ufh.saddr = rt->rt_src;

at line 552 conditional on ufh.saddr.

        Sorry for not suggesting a patch, but I have not looked at the
kernel internal for a while now and I do not think that I 100%
understand all cases where ufh.saddr is being filled by something
meaningful prior to that line so I'd rather ask first :-)

        Brgds,

A.

P.S. 
        I am not currently subscribed to the list. I would appreciate if
you cc me on any replies. 

Brgds,

A.


                 reply	other threads:[~2004-03-09 20:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1078865119.18912.32.camel@gondor \
    --to=arivanov@sigsegv.cx \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®