#5716 closed enhancement (fixed)
[RFC][PATCH][gsoc2010] Enhancements in networking code
Reported by: | atis.elsts | Owned by: | zooey |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | Network & Internet | Version: | R1/alpha1 |
Keywords: | gsoc2010 | Cc: | |
Blocked By: | Blocking: | ||
Platform: | All |
Description
This patch fixes one bug and two TODOs in network related Haiku code.
Description:
- connect() to INADDR_ANY should means the same as connect() INADDR_LOOPBACK:
- fix this behaviour for TCP - it was not working because INADDR_LOOPBACK was used in wrong byte order;
- move IPv4 specific code out of TCP module to IPv4 address family module;
- support this behaviour for UDP too.
- bind() and connect() should fail if the passed as argument has wrong address family. Note: this is stricter behaviour than in Linux kernel. See my tests for details.
Attachments (3)
Change History (9)
by , 15 years ago
Attachment: | bind_connect_enhancements.diff added |
---|
comment:1 by , 15 years ago
by , 15 years ago
Attachment: | test_client.cpp added |
---|
by , 15 years ago
Attachment: | test_server.cpp added |
---|
comment:2 by , 15 years ago
Tests:
The two test files attached, test_client.cpp and test_server.cpp, implement a server and client functionality respectively. I used behaviour on Linux as the reference behaviour for testing. Test results on Haiku are given after applying the patch.
- Test TCP connection to localhost with zero address as connect() parameter.
IPv4:
./test_server tcp 4
./test_client tcp 4 4
IPv6 (on Linux only ATM):
./test_server tcp 6
./test_client tcp 6 6
Result: success.
- Test UDP connection to localhost with zero address as connect() parameter.
IPv4:
./test_server udp 4
./test_client udp 4 4
IPv6 (on Linux only ATM):
./test_server udp 6
./test_client udp 6 6
Result: success.
- Check the behaviour of bind() with AF_INET6 address family on AF_INET socket.
TCP:
./test_server tcp 4 ::1
UDP:
./test_server udp 4 ::1
Result on Linux: Was expecting this to fail on Linux. But it did not fail! Probably because of the layout of sockaddr_in and sockaddr_in6. This seems rather strange behaviour of Linux, if not a bug then at least an unexected "feature". Strange things like this also work:
./test_server udp 4 0:0:1234:5678:9abc::def
so it's obvious that only the first 32 bits are used of the address passed from user. Probably a backwards compatibility feature? But then again, the applications that use (and rely on) something like this must be REALLY broken. It's probably safe to ignore this case.
Result on Haiku: bind() fails with "Address family not supported by protocol family" messages.
- Check the behaviour of connect() with AF_INET6 address family on AF_INET socket.
TCP:
./test_client tcp 4 6
UDP:
./test_client udp 4 6
Result on Linux: connect() fails with "Address family not supported by protocol" message.
Result on Haiku: connect() fails with "Address family not supported by protocol family" message.
comment:3 by , 15 years ago
Keywords: | gsoc2010 added |
---|
comment:4 by , 15 years ago
Owner: | changed from | to
---|---|
Status: | new → in-progress |
comment:5 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | in-progress → closed |
Hi Atis,
decent stuff, got applied in hrev36192 - thanks!
comment:6 by , 15 years ago
I had some remarks to the patch that I wrote to the commit lists, Atis - maybe you want to have a look at them:
The patch also adds two new funcion pointers to struct net_datalink_module_info:
and
It implements is_same_family() function for IPv4, UNIX, and L2CAP address families, and get_loopback_address() function for IPv4 address family.