]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Support bridge and VLAN interfaces on BSD.
authorRoy Marples <roy@marples.name>
Tue, 20 Mar 2012 09:19:01 +0000 (09:19 +0000)
committerRoy Marples <roy@marples.name>
Tue, 20 Mar 2012 09:19:01 +0000 (09:19 +0000)
Fall back to ethernet if unknown and specified.

net.c

diff --git a/net.c b/net.c
index 8e35adca8579bb6d0d8a60ea87ae0569cbf6e11e..c69d00979912622758380df0230fc84e7ca602d4 100644 (file)
--- a/net.c
+++ b/net.c
@@ -317,7 +317,7 @@ discover_interfaces(int argc, char * const *argv)
 {
        struct ifaddrs *ifaddrs, *ifa;
        char *p;
-       int i;
+       int i, sdl_type;
        struct interface *ifp, *ifs, *ifl;
 #ifdef __linux__
        char ifn[IF_NAMESIZE];
@@ -411,6 +411,7 @@ discover_interfaces(int argc, char * const *argv)
                                syslog(LOG_ERR, "%s: up_interface: %m", ifp->name);
                }
 
+               sdl_type = 0;
                /* Don't allow loopback unless explicit */
                if (ifp->flags & IFF_LOOPBACK) {
                        if (argc == 0 && ifac == 0) {
@@ -437,13 +438,20 @@ discover_interfaces(int argc, char * const *argv)
                        }
 #endif
 
+                       sdl_type = sdl->sdl_type;
                        switch(sdl->sdl_type) {
+                       case IFT_BRIDGE: /* FALLTHROUGH */
+                       case IFT_L2VLAN: /* FALLTHOUGH */
+                       case IFT_L3IPVLAN: /* FALLTHROUGH */
                        case IFT_ETHER:
                                ifp->family = ARPHRD_ETHER;
                                break;
                        case IFT_IEEE1394:
                                ifp->family = ARPHRD_IEEE1394;
                                break;
+                       case IFT_INFINIBAND:
+                               ifp->family = ARPHRD_INFINIBAND;
+                               break;
                        }
                        ifp->hwlen = sdl->sdl_alen;
 #ifndef CLLADDR
@@ -452,7 +460,7 @@ discover_interfaces(int argc, char * const *argv)
                        memcpy(ifp->hwaddr, CLLADDR(sdl), ifp->hwlen);
 #elif AF_PACKET
                        sll = (const struct sockaddr_ll *)(void *)ifa->ifa_addr;
-                       ifp->family = sll->sll_hatype;
+                       ifp->family = sdl_type = sll->sll_hatype;
                        ifp->hwlen = sll->sll_halen;
                        if (ifp->hwlen != 0)
                                memcpy(ifp->hwaddr, sll->sll_addr, ifp->hwlen);
@@ -474,7 +482,11 @@ discover_interfaces(int argc, char * const *argv)
                                break;
                        default:
                                syslog(LOG_WARNING,
-                                   "%s: unknown hardware family", p);
+                                   "%s: unsupported interface type %.2x"
+                                   ", falling back to ethernet",
+                                   ifp->name, sdl_type);
+                               ifp->family = ARPHRD_ETHER;
+                               break;
                        }
                }