udp - weird behavior of reply-to

Marek Zarychta zarychtam at plan-b.pwste.edu.pl
Sat Jan 14 08:26:49 UTC 2017


On Fri, Jan 13, 2017 at 10:54:40PM +0100, Kristof Provost wrote:
> On 9 Jan 2017, at 18:25, Marek Zarychta wrote:
> > On Sun, Jan 08, 2017 at 07:08:10PM +0100, Kristof Provost wrote:
> >> On 8 Jan 2017, at 15:55, Marek Zarychta wrote:
> >> The problem description doesn’t ring any bells with me, but I’m 
> >> also
> >> not sure
> >> I’ve fully understood it.  Can you document a minimal reproduction
> >> scenario,
> >> with a pf.conf and perhaps network captures documenting the problem?
> >>
> >> There’s certainly not been a conscious decision to break UDP 
> >> reply-to.
> >>
> >
> > Let me apologize, the problem wasn't previously properly identified.  
> > It
> > seems to be more problem of UDP protocol implementation than PF issue.
> > UDP sockets are opened and bound to address of the outgoing interface
> > (interface which has a route to the client). Because the socket is not
> > bound to the incoming interface, the PF reply-to rules couldn't be
> > evaluated.  By the way, TCP sockets are bound to the interface where 
> > the
> > traffic arrives and everything works fine.
> > This machine is i386 running 11.0-STABLE r311772
> >
> > The problem remains unresolved. Are there any corresponding sysctls
> > correcting this behavior and enabling the opportunity to use PF 
> > assisted
> > symmetric routing scenario again?
> >
> Thinking about this a bit more, I think the behaviour you see is 
> entirely
> correct and expected.  We’re talking about datagram sockets, and as 
> far as the
> kernel is concerned there’s no relationship between the packet 
> you’ve just
> received from address X and the packet you send to host X. There’s no
> established connection. As a result it’s entirely free to choose its 
> source
> address: you’re simply telling the kernel “Send this data to X”, 
> you’re not
> adding “it’s from Y”.
> 
> If you want this to behave differently I think you’ll have to convince 
> your
> application to open a socket per interface (binding it to that 
> interface), and
> reply using the correct socket.
> 

Let me apologize once again. It was application (OpenVPN) issue. After
upgrade to newer version, its behavior changed. While the daemon is run
in "multihome" mode it should reply with socket address of the
interface, which the client originates to. The daemon was misconfigured
because while running dual stack IPv4/IPv6 multihomed instance it was
trying to respond with IPv4-mapped IPv6 address thus not even evaluating
IP_RECVDSTADDR option. Changing configuration option "proto" from "udp"
to "udp4" did the job. 
Netcat couldn't be used in reproduction scenario, as simply app beeing
completely unaware of the destination address of the received datagram
(not evaluating the IP_RECVDSTADDR socket option at all).

Concluding and closing this thread: 

PF reply-to for UDP protocol still works great! 
God bless the people keeping code up to date! 
Thank all trying to help and figure out my weird misconfiguration case.
 

-- 
Marek Zarychta
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-pf/attachments/20170114/ac94e852/attachment.sig>


More information about the freebsd-pf mailing list