suggestions for improvement in java.net APIs

John Zavgren john.zavgren at oracle.com
Mon May 6 18:18:13 PDT 2013


SO_BINDTODEVICE can be used in cases where an IP network application doesn't want the existing routing table entries to determine the interface that packets are transmitted from. This is often the case when one is writing a router that needs to do neighbor discovery. I used this extensively a few years back to create a "link aggregator" that dynamically and adaptively distributed traffic to a particular destination across multiple interfaces. (They were PPP interfaces that were created by unreliable unpredictable CDMA data cards, and we had to do the best with what mother nature gave us for sending high-bandwidth video. Even one good card couldn't support the video stream and the product looked like a porcupine studded with data cards.) An other reason for binding a socket to a device, is when Ethernet is used as a control plane inside a product. Packets intended to go between cards within a chassis cannot be allowed to leave the chassis, ever. You don't want bugs or misconfiguration to result in leaking control traffic.

People who build "network appliances" use SO_BINDTODEVICE. And I can also imagine android developers wanting it for applications that want to use multiple interfaces intelligently (maybe to divert traffic from cellular data to WiFi when WiFi is available to save money and get better performance. You could write an App that will ONLY use the WiFi interface, regardless of what the routing table says.)

I've used SO_BINDTODEVICE for years and when I started using Java last year, I was stunned that it wasn't available.

I guess the question is whether or not there is a reason to support "network appliance" developers.







----- Original Message -----
From: dmitry.samersoff at oracle.com
To: Alan.Bateman at oracle.com
Cc: mkomu at cs.hut.fi, net-dev at openjdk.java.net
Sent: Monday, May 6, 2013 5:50:06 PM GMT -05:00 US/Canada Eastern
Subject: Re: suggestions for improvement in java.net APIs

Alan,

Not sure what is real usecase for this requirements for ipv4.

For ipv6 it should be done by sendmsg() and msg_control.

-Dmitry


On 2013-05-06 11:28, Alan Bateman wrote:
> On 05/05/2013 12:19, Dmitry Samersoff wrote:
>> Alan,
>>
>> SO_BINDTODEVICE shouldn't be used in modern applications because it
>> causes more problems than solves.
>>
>> e.g. prevents application from handling on-fly device changes.
>>
> The use-case is where an application wants to control the network or
> source address.
> 
> -Alan.


-- 
Dmitry Samersoff
Oracle Java development team, Saint Petersburg, Russia
* Give Rabbit time, and he'll always get the answer



More information about the net-dev mailing list