Hi,

These patches implement some changes I had to make on the translator
to better integrate dhcpcd:

[PATCH 1/4] ioctl: Make SIOCGIFHWADDR set sa_len

I made some changes in dhcpcd to simplify how it takes info about
interfaces. Instead of quering the mach device, now dhcpcd uses ioctls.
AFAIK the Hurd implements sa_len, so it's good to return it from
SIOCGIFHWADDR, I'm actually using it from dhcpcd.


[PATCH 2/4] ioctl: Fix SIOCGIFINDEX

This ioctl was just wrong, it was returning an index which didn't match
the actual value in lwip, so it was useless. Now we need it from dhcpcd
so I'm fixing it.

The patch is reading the index from the netif object without taking the
core lock, but I think that's fine because AFAIK lwip will never change
the index of an interface after it has been initialized.


[PATCH 3/4] socket: Fill in control block on recv calls

This modifies the recv operation to actually set the control block. When
I wrote the translator, I took this code from pfinet, which doesn't seem
to care about the control block. Maybe because `IP_PKTINFO` was not
supported? Anyway, now we need it for `in_pktinfo`.


[PATCH 4/4] lwip: Don't set IFF_RUNNING

If I understood this correctly, IFF_RUNNING flag should be true when there is
carrier, when the cable is physically connected. This is different to IFF_UP,
which is set by the network stack to mark the interface as managed and active.
So according to my understanding, it's the resposibility of the networks stack
to set IFF_UP, but IFF_RUNNING should come from gnumach, which is implementing
the device driver, right?

This patch stops setting IFF_RUNNING for eth devices, it still sets it for
loopback and tunif.

dhcpcd expects us to implement a function called `if_carrier` to determine
whether the cable is plugged or not. In my last implementation. This calls
the `SIOCGIFFLAGS` ioctl, which after the changes in this patch, will take
the IFF_RUNNING flag from the gnumach driver. 


On the other hand, see this code from glibc, in sysdeps/mach/hurd/ifaddrs.c:

```
  else if (!strncmp (cur, "--address=", 10))
    {
      i++;
      /* IPv4 address */
      addr = cur + 10;

      storage[i].ia.ifa_next = &storage[i + 1].ia;
      storage[i].ia.ifa_name = strncpy (storage[i].name, ifa_name, sizeof 
(storage[i].name));

      storage[i].ia.ifa_addr = (struct sockaddr *) &storage[i].addr;
      sin = ((struct sockaddr_in *) &storage[i].addr);
      sin->sin_family = AF_INET;
      sin->sin_len = sizeof(*sin);
      sin->sin_port = 0;
      inet_pton (AF_INET, addr, &sin->sin_addr);

      storage[i].ia.ifa_netmask = NULL;
      storage[i].ia.ifa_broadaddr = NULL;

      storage[i].ia.ifa_flags = IFF_UP | IFF_BROADCAST | IFF_RUNNING | 
IFF_MULTICAST;
      storage[i].ia.ifa_data = NULL; /* Nothing here for now.  */
    }
```

So the call to `getifaddrs()` will set the IFF_RUNNING flag if the interface has
an IP address set. This doesn't seem right to me because the cable could be
unplugged and still the iface would be up and have an IP in the network stack.
WDYT?

Reply via email to