[ipv6] Create routing table based on IPv6 settings

Use the IPv6 settings to construct the routing table, in a matter
analogous to the construction of the IPv4 routing table.

This allows for manual assignment of IPv6 addresses via e.g.

  set net0/ip6 2001:ba8:0:1d4::6950:5845
  set net0/len6 64
  set net0/gateway6 fe80::226:bff:fedd:d3c0

The prefix length ("len6") may be omitted, in which case a default
prefix length of 64 will be assumed.

Multiple IPv6 addresses may be assigned manually by implicitly
creating child settings blocks.  For example:

  set net0/ip6 2001:ba8:0:1d4::6950:5845
  set net0.ula/ip6 fda4:2496:e992::6950:5845

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2016-07-19 17:49:50 +01:00
parent 4ad3c73b30
commit c34d1518eb
4 changed files with 142 additions and 195 deletions

View File

@@ -462,8 +462,6 @@ enum dhcpv6_session_state_flags {
DHCPV6_RX_RECORD_SERVER_ID = 0x04,
/** Record received IPv6 address */
DHCPV6_RX_RECORD_IAADDR = 0x08,
/** Apply received IPv6 address */
DHCPV6_RX_APPLY_IAADDR = 0x10,
};
/** DHCPv6 request state */
@@ -471,7 +469,7 @@ static struct dhcpv6_session_state dhcpv6_request = {
.tx_type = DHCPV6_REQUEST,
.rx_type = DHCPV6_REPLY,
.flags = ( DHCPV6_TX_IA_NA | DHCPV6_TX_IAADDR |
DHCPV6_RX_RECORD_IAADDR | DHCPV6_RX_APPLY_IAADDR ),
DHCPV6_RX_RECORD_IAADDR ),
.next = NULL,
};
@@ -870,19 +868,6 @@ static int dhcpv6_rx ( struct dhcpv6_session *dhcpv6,
dhcpv6->server_duid_len );
}
/* Apply identity association address, if applicable */
if ( dhcpv6->state->flags & DHCPV6_RX_APPLY_IAADDR ) {
if ( ( rc = ipv6_set_address ( dhcpv6->netdev,
&dhcpv6->lease ) ) != 0 ) {
DBGC ( dhcpv6, "DHCPv6 %s could not apply %s: %s\n",
dhcpv6->netdev->name,
inet6_ntoa ( &dhcpv6->lease ), strerror ( rc ) );
/* This is plausibly the error we want to return */
dhcpv6->rc = rc;
goto done;
}
}
/* Transition to next state, if applicable */
if ( dhcpv6->state->next ) {
dhcpv6_set_state ( dhcpv6, dhcpv6->state->next );