Issue with socket communication when specifying IP Alias
Ben Dart
Ben.Dart at adept.com
Thu Jun 9 17:24:33 UTC 2016
We get the following information from netstat and ifconfig, as far as I can tell there is no significant difference:
___________________________________________________________________________
Broken system with setup using rtems_bsdnet_ifconfig socket bind fails
NETSTATS
Destination Gateway/Mask/Hw Flags Refs Use Expire Interface
default 172.17.0.1 UGS 2 2 0 eth1
127.0.0.1 127.0.0.1 UH 0 0 0 lo0
172.17.0.0 255.255.0.0 U 0 0 16 eth1
172.17.0.1 00:23:05:61:93:4F UHL 2 0 1225 eth1
172.17.4.47 00:10:EA:93:01:9E UHL 1 4 0 lo0
172.17.15.12 54:EE:75:25:CA:94 UHL 5 2818 1652 eth1
172.17.255.255 FF:FF:FF:FF:FF:FF UHL 0 2 0 eth1
172.21.15.119 172.17.0.1 UGH 1 20 0 eth1
************ MBUF STATISTICS ************
mbufs:2048 clusters: 384 free: 320
drops: 0 waits: 0 drains: 0
free:1969 data:74 header:5 socket:0
pcb:0 rtable:0 htable:0 atable:0
soname:0 soopts:0 ftable:0 rights:0
ifaddr:0 control:0 oobdata:0
************ INTERFACE STATISTICS ************
***** eth1 *****
Ethernet Address: 00:10:EA:93:01:9E
Address:172.17.4.47 Broadcast Address:172.17.255.255 Net mask:255.255.0.0
Flags: Up Broadcast Running Active Multicast
Send queue limit:50 length:2 Dropped:0
Rx Interrupts:4235 Not First:0 Not Last:0
Giant:0 Non-octet:0
Bad CRC:0 Overrun:0 Collision:0
Tx Interrupts:2849 Deferred:0 Late Collision:0
Retransmit Limit:0 Underrun:0 Misaligned:0
***** lo0 *****
Address:127.0.0.1 Net mask:255.0.0.0
Flags: Up Loopback Running Multicast
Send queue limit:50 length:0 Dropped:0
************ IP Statistics ************
total packets received 4053
packets rcvd for unreachable dest 992
unknown or unsupported protocol 2
datagrams delivered to upper level 3059
total ip packets generated here 2845
************ ICMP Statistics ************
Calls to icmp_error() 4
Type 0 sent 3
Type 3 sent 2
number of responses 3
Type 3 received 2
Type 8 received 3
ICMP panic avoided 2
************ UDP Statistics ************
total input packets 1912
no socket on port 4
of above, arrived as broadcast 166
total output packets 1749
************ TCP Statistics ************
connections accepted 4
connections established 4
conn. closed (includes drops) 1
segs where we tried to get rtt 943
times we succeeded 942
delayed acks sent 19
total packets sent 1090
data packets sent 1065
data bytes sent 132550
ack-only packets sent 24
control (SYN|FIN|RST) packets sent 1
total packets received 1144
packets received in sequence 836
bytes received in sequence 26219
rcvd duplicate acks 1
rcvd ack packets 953
bytes acked by rcvd acks 130034
times hdr predict ok for acks 92
times hdr predict ok for data pkts 180
bogus SYN, e.g. premature ACK 2
IFCONFIG
ifconfig ************ INTERFACE STATISTICS ************
***** eth1 *****
Ethernet Address: 00:10:EA:93:01:9E
Address:172.17.4.47 Broadcast Address:172.17.255.255 Net mask:255.255.0.0
Flags: Up Broadcast Running Active Multicast
Send queue limit:50 length:1 Dropped:0
Rx Interrupts:4409 Not First:0 Not Last:0
Giant:0 Non-octet:0
Bad CRC:0 Overrun:0 Collision:0
Tx Interrupts:2927 Deferred:0 Late Collision:0
Retransmit Limit:0 Underrun:0 Misaligned:0
***** lo0 *****
Address:127.0.0.1 Net mask:255.0.0.0
Flags: Up Loopback Running Multicast
Send queue limit:50 length:0 Dropped:0
________________________________________________________________________
Working with no IP Alias Set up - Bind succeeds
NETSTATS
Destination Gateway/Mask/Hw Flags Refs Use Expire Interface
default 172.17.0.1 UGS 0 0 0 eth1
127.0.0.1 127.0.0.1 UH 0 0 0 lo0
172.17.0.0 255.255.0.0 U 0 0 1 eth1
172.17.0.1 UHL 1 0 1 eth1
172.17.4.47 00:10:EA:93:01:9E UHL 1 2 0 lo0
172.17.15.12 54:EE:75:25:CA:94 UHL 7 2481 1428 eth1
172.17.255.255 FF:FF:FF:FF:FF:FF UHL 0 1 0 eth1
************ MBUF STATISTICS ************
mbufs:2048 clusters: 384 free: 320
drops: 0 waits: 0 drains: 0
free:1970 data:73 header:5 socket:0
pcb:0 rtable:0 htable:0 atable:0
soname:0 soopts:0 ftable:0 rights:0
ifaddr:0 control:0 oobdata:0
************ INTERFACE STATISTICS ************
***** eth1 *****
Ethernet Address: 00:10:EA:93:01:9E
Address:172.17.4.47 Broadcast Address:172.17.255.255 Net mask:255.255.0.0
Flags: Up Broadcast Running Active Multicast
Send queue limit:50 length:1 Dropped:0
Rx Interrupts:3217 Not First:0 Not Last:0
Giant:0 Non-octet:0
Bad CRC:0 Overrun:0 Collision:0
Tx Interrupts:2486 Deferred:0 Late Collision:0
Retransmit Limit:0 Underrun:0 Misaligned:0
***** lo0 *****
Address:127.0.0.1 Net mask:255.0.0.0
Flags: Up Loopback Running Multicast
Send queue limit:50 length:0 Dropped:0
************ IP Statistics ************
total packets received 3105
packets rcvd for unreachable dest 518
unknown or unsupported protocol 1
datagrams delivered to upper level 2586
total ip packets generated here 2485
************ ICMP Statistics ************
Calls to icmp_error() 2
Type 0 sent 4
Type 3 sent 1
number of responses 4
Type 3 received 1
Type 8 received 4
ICMP panic avoided 1
************ UDP Statistics ************
total input packets 1827
no socket on port 2
of above, arrived as broadcast 73
total output packets 1759
************ TCP Statistics ************
connections accepted 3
connections established 3
segs where we tried to get rtt 610
times we succeeded 609
delayed acks sent 17
total packets sent 721
data packets sent 701
data bytes sent 94096
ack-only packets sent 20
total packets received 755
packets received in sequence 537
bytes received in sequence 11862
rcvd ack packets 618
bytes acked by rcvd acks 91578
times hdr predict ok for acks 108
times hdr predict ok for data pkts 131
bogus SYN, e.g. premature ACK 1
IFCONFIG
ifconfig ************ INTERFACE STATISTICS ************
***** eth1 *****
Ethernet Address: 00:10:EA:93:01:9E
Address:172.17.4.47 Broadcast Address:172.17.255.255 Net mask:255.255.0.0
Flags: Up Broadcast Running Active Multicast
Send queue limit:50 length:1 Dropped:0
Rx Interrupts:2612 Not First:0 Not Last:0
Giant:0 Non-octet:0
Bad CRC:0 Overrun:0 Collision:0
Tx Interrupts:2337 Deferred:0 Late Collision:0
Retransmit Limit:0 Underrun:0 Misaligned:0
***** lo0 *****
Address:127.0.0.1 Net mask:255.0.0.0
Flags: Up Loopback Running Multicast
Send queue limit:50 length:0 Dropped:0
____________________________________________________________________________
I am looking into the FreeBSD stuff now.
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#pag
> e=[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