All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Mohandass, Roobesh" <Roobesh_Mohandass@McAfee.com>
To: Florian Westphal <fw@strlen.de>, Willy Tarreau <w@1wt.eu>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: RE: : getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, sa, &salen) is in fact sometimes returning the source IP instead the destination IP
Date: Mon, 7 Jan 2019 14:57:54 +0000	[thread overview]
Message-ID: <MWHPR16MB15028CBA19A3F62217A834A6ED890@MWHPR16MB1502.namprd16.prod.outlook.com> (raw)
In-Reply-To: <20190107111753.aiabujukqx3eteqb@breakpoint.cc>

+Willy 

Willy,

Do you mind looking into Florian comments below ? 

-Roobesh G M

-----Original Message-----
From: Florian Westphal <fw@strlen.de> 
Sent: Monday, January 7, 2019 4:48 PM
To: Mohandass, Roobesh <Roobesh_Mohandass@McAfee.com>
Cc: netdev@vger.kernel.org
Subject: Re: [NETDEV]: getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, sa, &salen) is in fact sometimes returning the source IP instead the destination IP

This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Mohandass, Roobesh <Roobesh_Mohandass@McAfee.com> wrote:
> Issue: getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, sa, &salen) is in fact 
> sometimes returning the source IP instead the destination IP

SO_ORIGINAL_DST returns the original address (before DNAT/REDIRECT rewrite) that conntrack believes to be the originator.

> What you expected to happen:
> getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, sa, &salen) - should return always destination IP(connected IP).
> 
> What happened instead:
> getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, sa, &salen) is in fact sometimes returning the source IP instead the destination IP. Using getsockname() instead looks like solving the issue.
> 
> For just an example: 
> Out of 6569124 requests , 4 requests were wrong 0.000060891 % (this is 
> just an rough estimate to give you idea on frequency)
> 
> Some old reference: (similar behavior observed) 
> https://stackoverflow.com/questions/11417187/getsockopt-so-original-ds
> t-occasionally-returns-client-address

I ask exactly same question as in your url.
If you use TPROXY, why do you use SO_ORIGINAL_DST?

Its only required with -j REDIRECT.

If you need to use REDIRECT for some reason, make sure you limit REDIRECT to -p tcp --syn to prevent it from triggering on other packets.

You might also want to turn off midstream pickup (sysctl
nf_conntrack_tcp_loose=0) in conntrack.

  reply	other threads:[~2019-01-07 14:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <MWHPR16MB1502549F7BAAE102EF1D5DF4EDB50@MWHPR16MB1502.namprd16.prod.outlook.com>
     [not found] ` <MWHPR16MB150233EF69CFD4562BFA65ABEDB60@MWHPR16MB1502.namprd16.prod.outlook.com>
     [not found]   ` <MWHPR16MB1502DC55542EBA8121631B16EDB20@MWHPR16MB1502.namprd16.prod.outlook.com>
2018-12-31  6:20     ` : getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, sa, &salen) is in fact sometimes returning the source IP instead the destination IP Mohandass, Roobesh
2019-01-07 11:17       ` Florian Westphal
2019-01-07 14:57         ` Mohandass, Roobesh [this message]
2019-01-12 14:37         ` Lukas Tribus
2019-01-12 14:37           ` [NETDEV]: " Lukas Tribus
2019-01-12 16:04           ` : " Florian Westphal
2019-01-12 16:04             ` [NETDEV]: " Florian Westphal
2019-01-12 17:26             ` : " Willy Tarreau
2019-01-12 17:26               ` [NETDEV]: " Willy Tarreau
2019-01-12 18:01               ` : " Lukas Tribus
2019-01-12 18:01                 ` [NETDEV]: " Lukas Tribus
2019-01-12 18:33                 ` : " Willy Tarreau
2019-01-12 18:33                   ` [NETDEV]: " Willy Tarreau
2019-01-17  5:23                   ` Mohandass, Roobesh
2019-01-23  8:07                     ` Mohandass, Roobesh
2019-01-23  8:54                       ` Willy Tarreau
     [not found]     ` <MWHPR16MB1502A336CCB4EF3F0FCB69ECEDB20@MWHPR16MB1502.namprd16.prod.outlook.com>
2019-01-07  7:58       ` : " Mohandass, Roobesh

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=MWHPR16MB15028CBA19A3F62217A834A6ED890@MWHPR16MB1502.namprd16.prod.outlook.com \
    --to=roobesh_mohandass@mcafee.com \
    --cc=fw@strlen.de \
    --cc=netdev@vger.kernel.org \
    --cc=w@1wt.eu \
    /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.