mirror of https://github.com/ipxe/ipxe.git
[ipv6] Fix mask calculation when prefix length is not a multiple of 8
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/732/head
parent
131daf1aae
commit
bc19aeca5f
|
@ -251,7 +251,7 @@ int ipv6_add_miniroute ( struct net_device *netdev, struct in6_addr *address,
|
|||
*prefix_mask = 0xff;
|
||||
}
|
||||
if ( remaining )
|
||||
*prefix_mask <<= ( 8 - remaining );
|
||||
*prefix_mask = ( 0xff << ( 8 - remaining ) );
|
||||
}
|
||||
|
||||
/* Add to start of routing table */
|
||||
|
|
|
@ -131,9 +131,21 @@ static struct net_device ipv6_test_netdev = {
|
|||
.state = NETDEV_OPEN,
|
||||
};
|
||||
|
||||
/** /48 prefix */
|
||||
PREFIX ( prefix48, 48, "ffff:ffff:ffff::" );
|
||||
|
||||
/** /64 prefix */
|
||||
PREFIX ( prefix64, 64, "ffff:ffff:ffff:ffff::" );
|
||||
|
||||
/** /126 prefix */
|
||||
PREFIX ( prefix126, 126, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffc" );
|
||||
|
||||
/** /127 prefix */
|
||||
PREFIX ( prefix127, 127, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe" );
|
||||
|
||||
/** /128 prefix */
|
||||
PREFIX ( prefix128, 128, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" );
|
||||
|
||||
/** Routing table with only a link-local address */
|
||||
TABLE ( table_link_local,
|
||||
{ "fe80::69ff:fe50:5845", &prefix64, NULL } );
|
||||
|
@ -152,6 +164,13 @@ TABLE ( table_multi,
|
|||
{ "fd44:9112:6442::69ff:fe50:5845", &prefix64, "fe80::1" },
|
||||
{ "fd70:6ba9:50ae::69ff:fe50:5845", &prefix64, "fe80::3" } );
|
||||
|
||||
/** Routing table with unusual prefix lengths */
|
||||
TABLE ( table_unusual,
|
||||
{ "2001:db8:1::1", &prefix48, "fe80::1" },
|
||||
{ "2001:db8:2::1", &prefix126, NULL },
|
||||
{ "2001:db8:3::1", &prefix127, NULL },
|
||||
{ "2001:db8:4::1", &prefix128, NULL } );
|
||||
|
||||
/**
|
||||
* Report an inet6_ntoa() test result
|
||||
*
|
||||
|
@ -502,6 +521,7 @@ static void ipv6_test_exec ( void ) {
|
|||
ipv6_table_ok ( &table_link_local );
|
||||
ipv6_table_ok ( &table_normal );
|
||||
ipv6_table_ok ( &table_multi );
|
||||
ipv6_table_ok ( &table_unusual );
|
||||
|
||||
/* Routing table with only a link-local address */
|
||||
ipv6_route_ok ( &table_link_local, "fe80::1",
|
||||
|
@ -545,10 +565,27 @@ static void ipv6_test_exec ( void ) {
|
|||
ipv6_route_ok ( &table_multi, "ff02::1",
|
||||
"fe80::69ff:fe50:5845", NULL );
|
||||
|
||||
/* Routing table with unusual prefix lengths */
|
||||
ipv6_route_ok ( &table_unusual, "2001:db8:2::1",
|
||||
"2001:db8:2::1", NULL );
|
||||
ipv6_route_ok ( &table_unusual, "2001:db8:2::3",
|
||||
"2001:db8:2::1", NULL );
|
||||
ipv6_route_ok ( &table_unusual, "2001:db8:3::1",
|
||||
"2001:db8:3::1", NULL );
|
||||
ipv6_route_ok ( &table_unusual, "2001:db8:3::2",
|
||||
"2001:db8:1::1", "fe80::1" );
|
||||
ipv6_route_ok ( &table_unusual, "2001:db8:4::1",
|
||||
"2001:db8:4::1", NULL );
|
||||
ipv6_route_ok ( &table_unusual, "2001:db8:4::0",
|
||||
"2001:db8:1::1", "fe80::1" );
|
||||
ipv6_route_ok ( &table_unusual, "2001:db8:4::2",
|
||||
"2001:db8:1::1", "fe80::1" );
|
||||
|
||||
/* Destroy test routing tables */
|
||||
ipv6_table_del ( &table_link_local );
|
||||
ipv6_table_del ( &table_normal );
|
||||
ipv6_table_del ( &table_multi );
|
||||
ipv6_table_del ( &table_unusual );
|
||||
}
|
||||
|
||||
/** IPv6 self-test */
|
||||
|
|
Loading…
Reference in New Issue