diff options
author | Michael Brown | 2016-07-19 18:49:50 +0200 |
---|---|---|
committer | Michael Brown | 2016-07-20 14:02:44 +0200 |
commit | c34d1518eb446d596087ed2b9dda33a513f7e980 (patch) | |
tree | a15c1ffcaccdbe92803a55e0d41784039db46643 /src/net/ndp.c | |
parent | [ipv6] Match user expectations for IPv6 settings priorities (diff) | |
download | ipxe-c34d1518eb446d596087ed2b9dda33a513f7e980.tar.gz ipxe-c34d1518eb446d596087ed2b9dda33a513f7e980.tar.xz ipxe-c34d1518eb446d596087ed2b9dda33a513f7e980.zip |
[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>
Diffstat (limited to 'src/net/ndp.c')
-rw-r--r-- | src/net/ndp.c | 55 |
1 files changed, 2 insertions, 53 deletions
diff --git a/src/net/ndp.c b/src/net/ndp.c index a35a1219..21bbd999 100644 --- a/src/net/ndp.c +++ b/src/net/ndp.c @@ -342,11 +342,6 @@ ndp_rx_router_advertisement_prefix ( struct net_device *netdev, union ndp_option *option, size_t len ) { struct ndp_router_advertisement_header *radv = &ndp->radv; struct ndp_prefix_information_option *prefix_opt = &option->prefix; - struct in6_addr *router = &sin6_src->sin6_addr; - struct in6_addr address; - struct ipv6conf *ipv6conf; - int prefix_len; - int rc; /* Sanity check */ if ( sizeof ( *prefix_opt ) > len ) { @@ -355,59 +350,13 @@ ndp_rx_router_advertisement_prefix ( struct net_device *netdev, return -EINVAL; } - /* Identify IPv6 configurator, if any */ - ipv6conf = ipv6conf_demux ( netdev ); DBGC ( netdev, "NDP %s found %sdefault router %s ", netdev->name, ( radv->lifetime ? "" : "non-" ), inet6_ntoa ( &sin6_src->sin6_addr ) ); - DBGC ( netdev, "for %s-link %sautonomous prefix %s/%d%s\n", + DBGC ( netdev, "for %s-link %sautonomous prefix %s/%d\n", ( ( prefix_opt->flags & NDP_PREFIX_ON_LINK ) ? "on" : "off" ), ( ( prefix_opt->flags & NDP_PREFIX_AUTONOMOUS ) ? "" : "non-" ), - inet6_ntoa ( &prefix_opt->prefix ), - prefix_opt->prefix_len, ( ipv6conf ? "" : " (ignored)" ) ); - - /* Do nothing unless IPv6 autoconfiguration is in progress */ - if ( ! ipv6conf ) - return 0; - - /* Ignore off-link prefixes */ - if ( ! ( prefix_opt->flags & NDP_PREFIX_ON_LINK ) ) - return 0; - - /* Define prefix */ - if ( ( rc = ipv6_set_prefix ( netdev, &prefix_opt->prefix, - prefix_opt->prefix_len, - ( radv->lifetime ? - router : NULL ) ) ) != 0 ) { - DBGC ( netdev, "NDP %s could not define prefix %s/%d: %s\n", - netdev->name, inet6_ntoa ( &prefix_opt->prefix ), - prefix_opt->prefix_len, strerror ( rc ) ); - return rc; - } - - /* Perform stateless address autoconfiguration, if applicable */ - if ( prefix_opt->flags & NDP_PREFIX_AUTONOMOUS ) { - memcpy ( &address, &prefix_opt->prefix, sizeof ( address ) ); - prefix_len = ipv6_eui64 ( &address, netdev ); - if ( prefix_len < 0 ) { - rc = prefix_len; - DBGC ( netdev, "NDP %s could not construct SLAAC " - "address: %s\n", netdev->name, strerror ( rc ) ); - return rc; - } - if ( prefix_len != prefix_opt->prefix_len ) { - DBGC ( netdev, "NDP %s incorrect SLAAC prefix length " - "%d (expected %d)\n", netdev->name, - prefix_opt->prefix_len, prefix_len ); - return -EINVAL; - } - if ( ( rc = ipv6_set_address ( netdev, &address ) ) != 0 ) { - DBGC ( netdev, "NDP %s could not set address %s: %s\n", - netdev->name, inet6_ntoa ( &address ), - strerror ( rc ) ); - return rc; - } - } + inet6_ntoa ( &prefix_opt->prefix ), prefix_opt->prefix_len ); return 0; } |