netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: nisse@southpole.se (Niels Möller)
To: Florian Westphal <fw@strlen.de>, Lukas Tribus <luky-37@hotmail.com>
Cc: netdev@vger.kernel.org, Jonas Bonn <jonas@southpole.se>
Subject: Re: What's the right way to use a *large* number of source addresses?
Date: Fri, 23 May 2014 14:26:52 +0200	[thread overview]
Message-ID: <6zegzkvfxv.fsf@southpole.se> (raw)
In-Reply-To: <20140523101144.GH24523@breakpoint.cc> (Florian Westphal's message of "Fri, 23 May 2014 12:11:44 +0200")

Florian Westphal <fw@strlen.de> writes:

> Niels Möller <nisse@southpole.se> wrote:

>> 3. Just set the desired local address with the bind call. Currently,
>>    this gives an EADDRNOTAVAIL error, so the first step would be some
>>    option to allow arbitrary source addresses.
>
> See 'Making non-local sockets work' in Documentation/networking/tproxy.txt

Great! Sounds like it should work fine with no additional kernel hacking.

Lukas Tribus <luky-37@hotmail.com> writes:

> Yes, its a simple as setting IP_FREEBIND and then binding to the specific
> source IP.
>
> setsockopt(fd, SOL_IP, IP_FREEBIND, &one, sizeof(one))

This sounds even easier, but I'm not sure it works. For my first test, I just tried

  sysctl net.ipv4.ip_nonlocal_bind=1

(which is the global equivalent of IP_FREEBIND). Then bind succeeds, but
connect fails with EINVAL,

  socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
  bind(3, {sa_family=AF_INET, sin_port=htons(8000), sin_addr=inet_addr("10.200.0.1")}, 16) = 0
  connect(3, {sa_family=AF_INET, sin_port=htons(9), sin_addr=inet_addr("10.1.0.2")}, 16) = -1 EINVAL (Invalid argument)

I'll do some more experiments, using IP_TRANSPARENT, and setting up the
suggested iptables rules.

Thanks,
/Niels

  parent reply	other threads:[~2014-05-23 12:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23  9:38 What's the right way to use a *large* number of source addresses? Niels Möller
2014-05-23 10:11 ` Florian Westphal
2014-05-23 10:49   ` Lukas Tribus
2014-05-23 12:26   ` Niels Möller [this message]
2014-05-23 14:12   ` Niels Möller
2014-05-23 12:53 ` sowmini varadhan
2014-05-23 14:14   ` Eric Dumazet
2014-05-24 12:06     ` Jamal Hadi Salim
2014-05-23 22:39 ` Cong Wang
2014-05-26  6:39   ` Niels Möller
2014-05-24 11:58 ` Jamal Hadi Salim
2014-05-24 14:44   ` Richard Weinberger
2014-05-24 15:13     ` Jamal Hadi Salim
2014-05-24 16:02       ` Richard Weinberger
2014-05-24 17:54         ` David Miller
2014-05-24 18:30         ` Jamal Hadi Salim

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=6zegzkvfxv.fsf@southpole.se \
    --to=nisse@southpole.se \
    --cc=fw@strlen.de \
    --cc=jonas@southpole.se \
    --cc=luky-37@hotmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).