netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Greear <greearb@candelatech.com>
To: NetDev <netdev@vger.kernel.org>
Cc: Patrick McHardy <kaber@trash.net>
Subject: SO_BINDTODEVICE mismatch with man page & comments.
Date: Tue, 04 Sep 2007 15:45:14 -0700	[thread overview]
Message-ID: <46DDDFFA.6090705@candelatech.com> (raw)

According to the comment in the net/core/sock.c code (in 2.6.20), I should be able to pass a zero
optlen to the setsockopt method for SO_BINDTODEVICE:

                 case SO_BINDTODEVICE:
                 {
                         char devname[IFNAMSIZ];

                         /* Sorry... */
                         if (!capable(CAP_NET_RAW)) {
                                 ret = -EPERM;
                                 break;
                         }

                         /* Bind this socket to a particular device like "eth0",
                          * as specified in the passed interface name. If the
                          * name is "" or the option length is zero the socket
                          * is not bound.
                          */

However, earlier in that method it returns -EINVAL if optlen is < sizeof(int).

The man page has comments similar to that in the code above.

Also, even when I get the un-bind call working with code similar to:

int z = 0;
setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, &z, sizeof(z));

The app I'm working on (Xorp) does not appear to work.  Perhaps because
the kernel does not clean up the cached route when you un-bind
as it does in the (re)bind logic?

                                 /* Remove any cached route for this socket. */
                                 sk_dst_reset(sk);


Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


             reply	other threads:[~2007-09-04 22:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-04 22:45 Ben Greear [this message]
2007-09-12 15:08 ` SO_BINDTODEVICE mismatch with man page & comments David Miller
2007-09-14 20:12 ` David Miller
2007-09-14 22:11   ` Ben Greear
2007-09-14 22:29     ` David Miller
2007-09-14 22:37       ` Ben Greear
2007-09-14 22:43         ` David Miller
2007-09-14 23:09           ` Ben Greear

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=46DDDFFA.6090705@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=kaber@trash.net \
    --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).