[haiku-commits] Re: haiku: hrev43730 - src/servers/net

  • From: Alexander von Gluck <kallisti5@xxxxxxxxxxx>
  • To: <haiku-commits@xxxxxxxxxxxxx>
  • Date: Fri, 10 Feb 2012 09:31:56 -0600

On 09.02.2012 17:14, Axel Dörfler wrote:
On 09.02.2012 21:45, kallisti5@xxxxxxxxxxx wrote:
   * Add new function to check for protocol support
   * If IPv6 support is present assign ::1 to loopback
   * ping6 ::1 functions 100%

Looks good!

   * Still some route strangeness with link local addresses

Define strangeness :-)

Somehow i'm getting two ::1 routes in the routing table.  While
it works, it worries me a bit. Also notice the incorrect one is
host local while the "correct" one is not.

--------------
route:

      127.0.0.1 mask                 loop, host local
  169.254.0.118 mask                 /dev/net/rtl81xx/0, host local
    169.254.0.0 mask 255.255.0.0     /dev/net/rtl81xx/0
      127.0.0.0 mask 255.0.0.0       loop
            ::1/-2147454933 loop, host local
            ::1/128 loop

--------------
ifconfig:

loop
    Hardware type: Local Loopback, Address: none
    inet addr: 127.0.0.1, Mask: 255.0.0.0
    inet6 addr: ::1, Prefix Length: 128
    MTU: 16384, Metric: 0, up loopback link
    Receive: 0 packets, 0 errors, 0 bytes, 0 mcasts, 0 dropped
    Transmit: 0 packets, 0 errors, 0 bytes, 0 mcasts, 0 dropped
    Collisions: 0

/dev/net/rtl81xx/0
    Hardware type: Ethernet, Address: 52:54:00:12:34:56
    Media type: 100 MBit, 100BASE-TX
    inet addr: 169.254.0.118, Bcast: 169.254.255.255, Mask: 255.255.0.0
inet6 addr: fe80::5054:ff:fe12:3456, Bcast: ffff:ffff:ffff:ffff::, Prefix Length: 64
    MTU: 1500, Metric: 0, up broadcast link auto-configured
    Receive: 0 packets, 0 errors, 0 bytes, 0 mcasts, 0 dropped
    Transmit: 9 packets, 0 errors, 2673 bytes, 0 mcasts, 0 dropped
    Collisions: 0



+NetServer::_IsValidFamily(uint32 family)
+{
+       // Mostly verifies add-on is present
+       int socket = ::socket(family, SOCK_DGRAM, 0);
+       if (socket<  0) {
+               return false;
+       }

Superfluous curly braces.

Oops, thanks for catching that one.  I had a close(socket) in there
until I realized just before pushing that closing a non-positive number
is pretty silly.

Will fix.

  NetServer::_BringUpInterfaces()
  {
        // we need a socket to talk to the networking stack
-       int socket = ::socket(AF_INET, SOCK_DGRAM, 0);
-       if (socket<  0) {
+       if (!_IsValidFamily(AF_INET)) {
                fprintf(stderr, "%s: The networking stack doesn't seem to be "
                        "available.\n", Name());

I know you didn't write it in the first place, but now that I see it, in case IPv4 is ever going to be phased out (no matter if we are still alive then), the check would better be for AF_LINK, as that one cannot go away, as it's part of
the core stack.

I agree.  Will fix.

 -- Alex

Other related posts: