@@ -382,7 +382,7 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
382382static int ndisc_router_process_autonomous_prefix (Link * link , sd_ndisc_router * rt ) {
383383 uint32_t lifetime_valid , lifetime_preferred ;
384384 _cleanup_set_free_free_ Set * addresses = NULL ;
385- struct in6_addr addr , * a ;
385+ struct in6_addr prefix , * a ;
386386 unsigned prefixlen ;
387387 usec_t time_now ;
388388 int r ;
@@ -396,10 +396,23 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
396396 if (r < 0 )
397397 return log_link_error_errno (link , r , "Failed to get RA timestamp: %m" );
398398
399+ r = sd_ndisc_router_prefix_get_address (rt , & prefix );
400+ if (r < 0 )
401+ return log_link_error_errno (link , r , "Failed to get prefix address: %m" );
402+
399403 r = sd_ndisc_router_prefix_get_prefixlen (rt , & prefixlen );
400404 if (r < 0 )
401405 return log_link_error_errno (link , r , "Failed to get prefix length: %m" );
402406
407+ /* ndisc_router_generate_addresses() below requires the prefix length <= 64. */
408+ if (prefixlen > 64 ) {
409+ _cleanup_free_ char * buf = NULL ;
410+
411+ (void ) in6_addr_prefix_to_string (& prefix , prefixlen , & buf );
412+ log_link_debug (link , "Prefix is longer than 64, ignoring autonomous prefix %s." , strna (buf ));
413+ return 0 ;
414+ }
415+
403416 r = sd_ndisc_router_prefix_get_valid_lifetime (rt , & lifetime_valid );
404417 if (r < 0 )
405418 return log_link_error_errno (link , r , "Failed to get prefix valid lifetime: %m" );
@@ -417,11 +430,7 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
417430 if (lifetime_preferred > lifetime_valid )
418431 return 0 ;
419432
420- r = sd_ndisc_router_prefix_get_address (rt , & addr );
421- if (r < 0 )
422- return log_link_error_errno (link , r , "Failed to get prefix address: %m" );
423-
424- r = ndisc_router_generate_addresses (link , & addr , prefixlen , & addresses );
433+ r = ndisc_router_generate_addresses (link , & prefix , prefixlen , & addresses );
425434 if (r < 0 )
426435 return r ;
427436
0 commit comments