Networking Forums

Networking Forums > Computer Networking > Linux Networking > SO_BINDTODEVICE socket option on an aliased interface

Reply
Thread Tools Display Modes

SO_BINDTODEVICE socket option on an aliased interface

 
 
Christophe Lohr
Guest
Posts: n/a

 
      01-16-2009, 11:44 AM
Hi,
I do something like :

char * device = "eth0:1";
int s;
s = socket(PF_INET, SOCK_STREAM, 0);
if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, device, strlen(device)))
perror("setsockopt");

the result is:
setsockopt: No such device

Why?
SO_BINDTODEVICE is not supposed to work on an aliased interface?

Regards,
Christophe.
 
Reply With Quote
 
 
 
 
David Schwartz
Guest
Posts: n/a

 
      01-16-2009, 03:53 PM
On Jan 16, 4:44*am, Christophe Lohr <christophe.l...@enst-bretagne.fr>
wrote:

> char * device = "eth0:1";
> int s;
> s = socket(PF_INET, SOCK_STREAM, 0);
> if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, device, strlen(device)))
> * * perror("setsockopt");


> the result is:
> * setsockopt: No such device


> Why?
> SO_BINDTODEVICE is not supposed to work on an aliased interface?


Just bind to the main interface. The aliased interface is an alias for
the main interface, that is, it's another name for the same interface.

DS
 
Reply With Quote
 
Christophe Lohr
Guest
Posts: n/a

 
      01-19-2009, 08:06 AM
David Schwartz a écrit :
> On Jan 16, 4:44 am, Christophe Lohr <christophe.l...@enst-bretagne.fr>
>> SO_BINDTODEVICE is not supposed to work on an aliased interface?

>
> Just bind to the main interface. The aliased interface is an alias for
> the main interface, that is, it's another name for the same interface.


Ok.

I have another question: according to man socket(7), it is not
supported for packet sockets. So, why? (It's not yet implmented, or is
it impossible?)

Regards
Christophe.
 
Reply With Quote
 
Christophe Lohr
Guest
Posts: n/a

 
      01-23-2009, 11:59 AM
Christophe Lohr a écrit :
> David Schwartz a écrit :
>> On Jan 16, 4:44 am, Christophe Lohr <christophe.l...@enst-bretagne.fr>
>>> SO_BINDTODEVICE is not supposed to work on an aliased interface?

>> Just bind to the main interface. The aliased interface is an alias for
>> the main interface, that is, it's another name for the same interface.

>
> Ok.
>
> I have another question: according to man socket(7), it is not
> supported for packet sockets. So, why? (It's not yet implmented, or is
> it impossible?)


I have a new question (again): what is the behavior of outgoing packets?
Are they routed through the given interface?

Regards.
 
Reply With Quote
 
David Schwartz
Guest
Posts: n/a

 
      01-23-2009, 09:19 PM
On Jan 23, 4:59*am, Christophe Lohr <christophe.l...@enst-bretagne.fr>
wrote:

> I have a new question (again): what is the behavior of outgoing packets?
> Are they routed through the given interface?


If they can be routed, they will be routed through the best interface.
If they cannot be routed, the given interface will be used. (For
example, an arbitrary Ethernet packet that is not in a protocol known
to the OS cannot be routed by the OS.)

DS
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting/setting eth frame interface for raw socket boltar2003@yahoo.co.uk Linux Networking 1 09-30-2009 11:54 AM
Is there a socket option to set the fwmark? Christophe Lohr Linux Networking 0 01-07-2009 03:58 PM
SO_BINDTODEVICE socket option Gaurav Linux Networking 0 04-26-2007 12:36 PM
Packet socket attached to 802.11 interface? jski Wireless Internet 0 08-15-2006 07:10 PM
unable to resolve aliased network interface name ziupiu Linux Networking 3 11-04-2004 05:06 AM



1 2 3 4 5 6 7 8 9 10 11