Issue with socket communication when specifying IP Alias
Chris Johns
chrisj at rtems.org
Wed Jun 8 23:31:18 UTC 2016
On 09/06/2016 02:50, Ben Dart wrote:
>
> The problem
>
> On our system running RTEMS 4.9.2 we are experiencing a very odd issue
> with socket communications. We are setting up a socket and using the
> following command to bind:
>
> if(bind(mSocket,(sockaddr
> *)&localSocketAddress,sizeof(sockaddr_in))==SOCKET_ERROR)
>
> {
>
> interrorOut =errno;
>
> ...
>
> And this works for UDP communications except in a strange specific
> scenario which is explained below. The problem that we experience is a
> failure of this|bind|call even though the setup is correct. We get the
> error|125|which for RTEMS is|EADDRNOTAVAIL|:
>
> A nonexistent interface was requested or the requested address was not
> local.
>
>
> The Apparent Cause
>
> At boot of the device we can set up our network in 1 of 2 ways:
>
> 1.The Network IP and SUBNET is autoconfigured based on what is in the
> default bootloader (UBOOT), and is set up through the RTEMS OS.
Do you have the addresses used for this set up for the interface?
> 2.The RTEMS interface function|rtems_bsdnet_ifconfig|is called to set up
> a custom user defined ethernet interface after boot time.
If you could please supply the exact address etc of the set up that
fails that would help?
The ifconfig and netstat shell commands in both cases would be helpful.
>
> For clarification, option 2 is called like this:
>
> rtems_bsdnet_ifconfig(eth_interface,SIOCSIFADDR,&ipaddr);
>
> If the network is set up as indicated by option 1, everything works as
> expected, but if option 2 is used (even in the case where the setup
> matches the network options defined by option 1) then the socket bind fails.
>
> *Is there a known reason or bug for RTEMS that indicates that this bind
> would fail if you set up your own IP Alias?*
>
>
> Additional Information
>
> We are setting up an IP alias (option 2) using a method foundhere
> <https://docs.rtems.org/doc-current/share/rtems/pdf/networking.pdf#page=[23]>under
> IP Alias
> (https://docs.rtems.org/doc-current/share/rtems/pdf/networking.pdf ).
>
> If we bind our socket without specifying a local ADDRESS (ie
> use|INADDR_ANY|) then it works in any case.
>
Have you looked at Section 20.6 Binding Interface Addresses in Steven's
UNIX Network Programming Volume 1 (2nd Edition). One of the nice
features of having FreeBSD code in RTEMS is the excellent available
references. Something else to considering is getting a FreeBSD live DVD
and running it up on a box and testing a simple example set up and code.
If it works on FreeBSD and fails on RTEMS it is something we are doing.
If it fails on FreeBSD is more likely something you are doing.
Chris
More information about the users
mailing list