File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -544,10 +544,21 @@ void dhcpv6_reset_stats(void)
544544 memset (& dhcpv6_stats , 0 , sizeof (dhcpv6_stats ));
545545}
546546
547- uint32_t hash_ifname (const char * s ) {
548- uint32_t h = 0 ;
549- while (* s ) h = h * 31 + * s ++ ;
550- return h ;
547+ static uint32_t dhcpv6_generate_iface_iaid (const char * ifname ) {
548+ uint8_t hash [16 ] = {0 };
549+ uint32_t iaid ;
550+ md5_ctx_t md5 ;
551+
552+ md5_begin (& md5 );
553+ md5_hash (ifname , strlen (ifname ), & md5 );
554+ md5_end (hash , & md5 );
555+
556+ iaid = hash [0 ] << 24 ;
557+ iaid |= hash [1 ] << 16 ;
558+ iaid |= hash [2 ] << 8 ;
559+ iaid |= hash [3 ];
560+
561+ return iaid ;
551562}
552563
553564int init_dhcpv6 (const char * ifname )
@@ -574,7 +585,7 @@ int init_dhcpv6(const char *ifname)
574585 if (ioctl (sock , SIOCGIFINDEX , & ifr ) < 0 )
575586 goto failure ;
576587
577- ifname_hash_iaid = hash_ifname (ifname );
588+ ifname_hash_iaid = dhcpv6_generate_iface_iaid (ifname );
578589
579590 ifindex = ifr .ifr_ifindex ;
580591
You can’t perform that action at this time.
0 commit comments