@@ -400,7 +400,7 @@ if_valid_hwaddr(const uint8_t *hwaddr, size_t hwlen)
400400 return false;
401401}
402402
403- #if defined( AF_PACKET ) && !defined(AF_LINK )
403+ #if !defined(AF_LINK )
404404static unsigned int
405405if_check_arphrd (struct interface * ifp , unsigned int active , bool if_noconf )
406406{
@@ -659,32 +659,22 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, int argc,
659659 ifp -> hwlen = sll -> sll_halen ;
660660 if (ifp -> hwlen != 0 )
661661 memcpy (ifp -> hwaddr , sll -> sll_addr , ifp -> hwlen );
662- active = if_check_arphrd (ifp , active , if_noconf );
663662#endif
664663 }
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 );
664+
665+ if (if_init (ifp ) == -1 ) {
666+ logerr ("%s: if_init" , ifp -> name );
667+ if_free (ifp );
668+ continue ;
681669 }
670+ #ifdef AF_PACKET
671+ active = if_check_arphrd (ifp , active , if_noconf );
682672#endif
683-
673+
684674 if (!(ctx -> options & (DHCPCD_DUMPLEASE | DHCPCD_TEST ))) {
685675 /* Handle any platform init for the interface */
686- if (active != IF_INACTIVE && if_init (ifp ) == -1 ) {
687- logerr ("%s: if_init " , ifp -> name );
676+ if (active != IF_INACTIVE && if_init_os (ifp ) == -1 ) {
677+ logerr ("%s: if_init_os " , ifp -> name );
688678 if_free (ifp );
689679 continue ;
690680 }
0 commit comments