@@ -367,7 +367,7 @@ static int dhcp6_set_pd_address(Link *link,
367367 assert (link -> network );
368368 assert (prefix );
369369
370- if (!link -> network -> dhcp6_pd_assign_prefix )
370+ if (!link -> network -> dhcp6_pd_assign )
371371 return 0 ;
372372
373373 r = address_new (& address );
@@ -376,8 +376,8 @@ static int dhcp6_set_pd_address(Link *link,
376376
377377 address -> in_addr = * prefix ;
378378
379- if (!in_addr_is_null (AF_INET6 , & link -> network -> dhcp6_delegation_prefix_token ))
380- memcpy (address -> in_addr .in6 .s6_addr + 8 , link -> network -> dhcp6_delegation_prefix_token .in6 .s6_addr + 8 , 8 );
379+ if (!in_addr_is_null (AF_INET6 , & link -> network -> dhcp6_pd_token ))
380+ memcpy (address -> in_addr .in6 .s6_addr + 8 , link -> network -> dhcp6_pd_token .in6 .s6_addr + 8 , 8 );
381381 else {
382382 r = generate_ipv6_eui_64_address (link , & address -> in_addr .in6 );
383383 if (r < 0 )
@@ -437,7 +437,7 @@ static bool link_has_preferred_subnet_id(Link *link) {
437437 if (!link -> network )
438438 return false;
439439
440- return link -> network -> router_prefix_subnet_id >= 0 ;
440+ return link -> network -> dhcp6_pd_subnet_id >= 0 ;
441441}
442442
443443static int dhcp6_get_preferred_delegated_prefix (
@@ -461,7 +461,7 @@ static int dhcp6_get_preferred_delegated_prefix(
461461 prefix = * masked_pd_prefix ;
462462
463463 if (link_has_preferred_subnet_id (link )) {
464- uint64_t subnet_id = link -> network -> router_prefix_subnet_id ;
464+ uint64_t subnet_id = link -> network -> dhcp6_pd_subnet_id ;
465465
466466 /* If the link has a preference for a particular subnet id try to allocate that */
467467 if (subnet_id >= n_prefixes )
@@ -1556,7 +1556,18 @@ int config_parse_dhcp6_mud_url(
15561556 return free_and_replace (network -> dhcp6_mudurl , unescaped );
15571557}
15581558
1559- int config_parse_dhcp6_delegated_prefix_token (
1559+ DEFINE_CONFIG_PARSE_ENUM (config_parse_dhcp6_client_start_mode , dhcp6_client_start_mode , DHCP6ClientStartMode ,
1560+ "Failed to parse WithoutRA= setting" );
1561+
1562+ static const char * const dhcp6_client_start_mode_table [_DHCP6_CLIENT_START_MODE_MAX ] = {
1563+ [DHCP6_CLIENT_START_MODE_NO ] = "no" ,
1564+ [DHCP6_CLIENT_START_MODE_INFORMATION_REQUEST ] = "information-request" ,
1565+ [DHCP6_CLIENT_START_MODE_SOLICIT ] = "solicit" ,
1566+ };
1567+
1568+ DEFINE_STRING_TABLE_LOOKUP (dhcp6_client_start_mode , DHCP6ClientStartMode );
1569+
1570+ int config_parse_dhcp6_pd_subnet_id (
15601571 const char * unit ,
15611572 const char * filename ,
15621573 unsigned line ,
@@ -1568,42 +1579,78 @@ int config_parse_dhcp6_delegated_prefix_token(
15681579 void * data ,
15691580 void * userdata ) {
15701581
1571- Network * network = data ;
1582+ int64_t * p = data ;
1583+ uint64_t t ;
15721584 int r ;
15731585
15741586 assert (filename );
15751587 assert (lvalue );
15761588 assert (rvalue );
15771589 assert (data );
15781590
1579- if (isempty (rvalue )) {
1580- network -> dhcp6_delegation_prefix_token = IN_ADDR_NULL ;
1591+ if (isempty (rvalue ) || streq ( rvalue , "auto" ) ) {
1592+ * p = -1 ;
15811593 return 0 ;
15821594 }
15831595
1584- r = in_addr_from_string ( AF_INET6 , rvalue , & network -> dhcp6_delegation_prefix_token );
1596+ r = safe_atoux64 ( rvalue , & t );
15851597 if (r < 0 ) {
15861598 log_syntax (unit , LOG_WARNING , filename , line , r ,
1587- "Failed to parse DHCPv6 %s, ignoring: %s" , lvalue , rvalue );
1599+ "Failed to parse %s=, ignoring assignment: %s" ,
1600+ lvalue , rvalue );
15881601 return 0 ;
15891602 }
1590-
1591- if (in_addr_is_null (AF_INET6 , & network -> dhcp6_delegation_prefix_token )) {
1603+ if (t > INT64_MAX ) {
15921604 log_syntax (unit , LOG_WARNING , filename , line , 0 ,
1593- "DHCPv6 %s cannot be the ANY address, ignoring: %s" , lvalue , rvalue );
1605+ "Invalid subnet id '%s', ignoring assignment." ,
1606+ rvalue );
15941607 return 0 ;
15951608 }
15961609
1610+ * p = (int64_t ) t ;
1611+
15971612 return 0 ;
15981613}
15991614
1600- DEFINE_CONFIG_PARSE_ENUM (config_parse_dhcp6_client_start_mode , dhcp6_client_start_mode , DHCP6ClientStartMode ,
1601- "Failed to parse WithoutRA= setting" );
1615+ int config_parse_dhcp6_pd_token (
1616+ const char * unit ,
1617+ const char * filename ,
1618+ unsigned line ,
1619+ const char * section ,
1620+ unsigned section_line ,
1621+ const char * lvalue ,
1622+ int ltype ,
1623+ const char * rvalue ,
1624+ void * data ,
1625+ void * userdata ) {
16021626
1603- static const char * const dhcp6_client_start_mode_table [_DHCP6_CLIENT_START_MODE_MAX ] = {
1604- [DHCP6_CLIENT_START_MODE_NO ] = "no" ,
1605- [DHCP6_CLIENT_START_MODE_INFORMATION_REQUEST ] = "information-request" ,
1606- [DHCP6_CLIENT_START_MODE_SOLICIT ] = "solicit" ,
1607- };
1627+ union in_addr_union * addr = data , tmp ;
1628+ int r ;
16081629
1609- DEFINE_STRING_TABLE_LOOKUP (dhcp6_client_start_mode , DHCP6ClientStartMode );
1630+ assert (filename );
1631+ assert (lvalue );
1632+ assert (rvalue );
1633+ assert (data );
1634+
1635+ if (isempty (rvalue )) {
1636+ * addr = IN_ADDR_NULL ;
1637+ return 0 ;
1638+ }
1639+
1640+ r = in_addr_from_string (AF_INET6 , rvalue , & tmp );
1641+ if (r < 0 ) {
1642+ log_syntax (unit , LOG_WARNING , filename , line , r ,
1643+ "Failed to parse DHCPv6 Prefix Delegation token, ignoring: %s" , rvalue );
1644+ return 0 ;
1645+ }
1646+
1647+ if (in_addr_is_null (AF_INET6 , & tmp )) {
1648+ log_syntax (unit , LOG_WARNING , filename , line , 0 ,
1649+ "DHCPv6 Prefix Delegation token cannot be the ANY address, ignoring: %s" , rvalue );
1650+ return 0 ;
1651+ }
1652+
1653+ * addr = tmp ;
1654+
1655+ return 0 ;
1656+ }
0 commit comments