From: Balazs Scheidler <bazsi@balabit.hu>
To: KOVACS Krisztian <hidden@sch.bme.hu>
Cc: Andrey Luzgin <andrey@icomsw.com>,
tproxy@lists.balabit.hu, netfilter-devel@vger.kernel.org,
netdev@vger.kernel.org
Subject: Re: [tproxy] udp + tproxy
Date: Wed, 12 Nov 2008 20:27:10 +0100 [thread overview]
Message-ID: <1226518030.10667.68.camel@bzorp.balabit> (raw)
In-Reply-To: <20081112185910.GA1793@sch.bme.hu>
On Wed, 2008-11-12 at 19:59 +0100, KOVACS Krisztian wrote:
> Hi,
>
> On sze, nov 12, 2008 at 11:40:30 +0000, Andrey Luzgin wrote:
> > Hello,
> >
> > While I can see example of using udp on tproxy2 onto the
> > redirect-udp-recv.c
> > file, I can't find equivalent on tproxy4.
> >
> > For getting the original destination IP, I just use setsockopt
> > IP_PKTINFO:
> > setsockopt(sd, SOL_IP, IP_PKTINFO , &flags, sizeof(flags));
> >
> > But I don't know how to get the original destination port:
> >
> > a) I manually defined IP_RECVORIGADDRS to be 11273 as I find on
> > tproxy2:
> > setsockopt(sd, SOL_IP, IP_RECVORIGADDRS , &flags, sizeof(flags));
> > but the setsockopt failed.
> >
> > b) the getsockname give me the server listening port.
>
>
> Since tproxy 4 (unlike tproxy 2) doesn't modify the incoming packets in
> any way you should be able to get the correct destination address by
> simply calling recvfrom() and using the source address returned by the
> kernel.
>
This is not true, recvfrom() returns the client address and does not
return the original destination. There was a hack in 2.2 kernels, that
it could return the targeted address in the 2nd half of the "struct
sockaddr_in" structure.
But that hack was crude.
I can only see two options to proceed with full udp proxying: accept()
support for UDP, or a recvmsg() ancillary data (IP_RECVORIGADDRS) as
above.
I'll see whether I can come up with a patch for the latter.
In Zorp we're using accept() for UDP sockets, but I doubt it could be
integrated to mainline, the other option is doable, although potentially
racy.
--
Bazsi
next parent reply other threads:[~2008-11-12 19:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1226490030.31896.12.camel@sysandrey.icomswg.local>
[not found] ` <20081112185910.GA1793@sch.bme.hu>
2008-11-12 19:27 ` Balazs Scheidler [this message]
2008-11-13 7:17 ` [tproxy] udp + tproxy Jan Engelhardt
2008-11-13 7:25 ` Balazs Scheidler
2008-11-13 8:44 ` Henrik Nordstrom
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=1226518030.10667.68.camel@bzorp.balabit \
--to=bazsi@balabit.hu \
--cc=andrey@icomsw.com \
--cc=hidden@sch.bme.hu \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=tproxy@lists.balabit.hu \
/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