@@ -400,15 +400,17 @@ if_valid_hwaddr(const uint8_t *hwaddr, size_t hwlen)
400400 return false;
401401}
402402
403- #if defined( AF_PACKET ) && !defined( AF_LINK )
403+ #ifndef AF_LINK
404404static unsigned int
405405if_check_arphrd (struct interface * ifp , unsigned int active , bool if_noconf )
406406{
407407 switch (ifp -> hwtype ) {
408+ #ifdef ARPHRD_NONE
409+ case ARPHRD_NONE : /* FALLTHROUGH */
410+ #endif
408411 case ARPHRD_ETHER : /* FALLTHROUGH */
409412 case ARPHRD_IEEE1394 : /* FALLTHROUGH */
410413 case ARPHRD_INFINIBAND : /* FALLTHROUGH */
411- case ARPHRD_NONE : /* FALLTHROUGH */
412414 break ;
413415 case ARPHRD_LOOPBACK :
414416 case ARPHRD_PPP :
@@ -659,32 +661,22 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, int argc,
659661 ifp -> hwlen = sll -> sll_halen ;
660662 if (ifp -> hwlen != 0 )
661663 memcpy (ifp -> hwaddr , sll -> sll_addr , ifp -> hwlen );
662- active = if_check_arphrd (ifp , active , if_noconf );
663664#endif
664665 }
665- #ifdef __linux__
666- else {
667- struct ifreq ifr = { .ifr_flags = 0 };
668-
669- /* This is a huge bug in getifaddrs(3) as there
670- * is no reason why this can't be returned in
671- * ifa_addr. */
672- strlcpy (ifr .ifr_name , ifa -> ifa_name ,
673- sizeof (ifr .ifr_name ));
674- if (ioctl (ctx -> pf_inet_fd , SIOCGIFHWADDR , & ifr ) == -1 )
675- logerr ("%s: SIOCGIFHWADDR" , ifa -> ifa_name );
676- ifp -> hwtype = ifr .ifr_hwaddr .sa_family ;
677- if (ioctl (ctx -> pf_inet_fd , SIOCGIFINDEX , & ifr ) == -1 )
678- logerr ("%s: SIOCGIFINDEX" , ifa -> ifa_name );
679- ifp -> index = (unsigned int )ifr .ifr_ifindex ;
680- if_check_arphrd (ifp , active , if_noconf );
666+
667+ if (if_init (ifp ) == -1 ) {
668+ logerr ("%s: if_init" , ifp -> name );
669+ if_free (ifp );
670+ continue ;
681671 }
672+ #ifndef AF_LINK
673+ active = if_check_arphrd (ifp , active , if_noconf );
682674#endif
683675
684676 if (!(ctx -> options & (DHCPCD_DUMPLEASE | DHCPCD_TEST ))) {
685677 /* Handle any platform init for the interface */
686- if (active != IF_INACTIVE && if_init (ifp ) == -1 ) {
687- logerr ("%s: if_init " , ifp -> name );
678+ if (active != IF_INACTIVE && if_init_os (ifp ) == -1 ) {
679+ logerr ("%s: if_init_os " , ifp -> name );
688680 if_free (ifp );
689681 continue ;
690682 }
0 commit comments