42 #define IPV6(...) { __VA_ARGS__ } 73 #define PREFIX( name, LEN, MASK ) \ 74 static const struct ipv6_test_prefix name = { \ 80 #define TABLE( name, ... ) \ 81 static const struct ipv6_test_route name ## _routes[] = { \ 84 static struct ipv6_test_table name = { \ 85 .routes = name ## _routes, \ 86 .count = ( sizeof ( name ## _routes ) / \ 87 sizeof ( name ## _routes[0] ) ), \ 88 .list = LIST_HEAD_INIT ( name.list ), \ 93 .s6_addr =
IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
94 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ),
99 .s6_addr =
IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
100 0x00, 0x00, 0x69, 0xff, 0xfe, 0x50, 0x58, 0x45 ),
105 .s6_addr =
IPV6 ( 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 ),
111 .s6_addr =
IPV6 ( 0xfd, 0x44, 0x91, 0x12, 0x64, 0x42, 0x00, 0x00,
112 0x00, 0x00, 0x69, 0xff, 0xfe, 0x50, 0x58, 0x45 ),
117 .s6_addr =
IPV6 ( 0x20, 0x01, 0x0b, 0xa8, 0x00, 0x00, 0x01, 0xd4,
118 0x00, 0x00, 0x00, 0x00, 0x69, 0x50, 0x58, 0x45 ),
123 .s6_addr =
IPV6 ( 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
124 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
135 PREFIX ( prefix48, 48,
"ffff:ffff:ffff::" );
138 PREFIX ( prefix64, 64,
"ffff:ffff:ffff:ffff::" );
141 PREFIX ( prefix126, 126,
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffc" );
144 PREFIX ( prefix127, 127,
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe" );
147 PREFIX ( prefix128, 128,
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" );
150 TABLE ( table_link_local,
151 {
"fe80::69ff:fe50:5845", &prefix64,
NULL } );
154 TABLE ( table_normal,
155 {
"fe80::69ff:fe50:5845", &prefix64,
NULL },
156 {
"2001:db8:3::1", &prefix64,
"fe80::1" } );
160 {
"fe80::69ff:fe50:5845", &prefix64,
NULL },
161 {
"2001:db8:3::1", &prefix64,
"fe80::1" },
162 {
"2001:db8:5::1", &prefix64,
NULL },
163 {
"2001:db8:42::1", &prefix64,
"fe80::2" },
164 {
"fd44:9112:6442::69ff:fe50:5845", &prefix64,
"fe80::1" },
165 {
"fd70:6ba9:50ae::69ff:fe50:5845", &prefix64,
"fe80::3" } );
168 TABLE ( table_unusual,
169 {
"2001:db8:1::1", &prefix48,
"fe80::1" },
170 {
"2001:db8:2::1", &prefix126,
NULL },
171 {
"2001:db8:3::1", &prefix127,
NULL },
172 {
"2001:db8:4::1", &prefix128,
NULL } );
183 const char *file,
unsigned int line ) {
187 DBG (
"inet6_ntoa ( %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x ) " 193 okx (
strcmp ( actual, text ) == 0, file, line );
195 #define inet6_ntoa_ok( addr, text ) do { \ 196 static const struct in6_addr in = { \ 199 inet6_ntoa_okx ( &in, text, __FILE__, __LINE__ ); \ 211 const char *file,
unsigned int line ) {
215 DBG (
"inet6_aton ( \"%s\" ) = %s\n", text,
inet6_ntoa ( &actual ) );
219 #define inet6_aton_ok( text, addr ) do { \ 220 static const struct in6_addr in = { \ 223 inet6_aton_okx ( text, &in, __FILE__, __LINE__ ); \ 234 unsigned int line ) {
239 #define inet6_aton_fail_ok( text ) \ 240 inet6_aton_fail_okx ( text, __FILE__, __LINE__ ) 250 unsigned int line ) {
267 for ( i = 0 ; i < table->
count ; i++ ) {
273 if (
route->router ) {
284 &router :
NULL ) ) == 0,
290 okx ( miniroute !=
NULL, file, line );
292 sizeof (
address ) ) == 0, file, line );
296 sizeof ( mask ) ) == 0, file, line );
297 if (
route->router ) {
299 sizeof ( router ) ) == 0, file, line );
312 #define ipv6_table_ok( table ) \ 313 ipv6_table_okx ( table, __FILE__, __LINE__ ) 326 const char *
src,
const char *
next,
327 const char *file,
unsigned int line ) {
347 memcpy ( &in_next, &in_dest,
sizeof ( in_next ) );
358 okx ( miniroute !=
NULL, file, line );
364 sizeof ( in_src ) ) == 0, file, line );
367 okx (
memcmp ( actual, &in_next,
sizeof ( *actual ) ) == 0,
373 okx ( miniroute ==
NULL, file, line );
380 #define ipv6_route_ok( table, dest, src, next ) \ 381 ipv6_route_okx ( table, dest, src, next, __FILE__, __LINE__ ) 446 0x00, 0x00, 0x00, 0x00, 0x69, 0x50, 0x58, 0x45 ),
447 "2001:ba8:0:1d4::6950:5845" );
450 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 ),
451 "2001:db8:1:1:1:1:1:1" );
454 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
458 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 ),
459 "2001:db8:0:1:1:1:1:1" );
462 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
466 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
467 "2001:db8::1:0:0:1" );
470 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ),
474 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ),
478 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ),
482 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ),
483 "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" );
487 IPV6 ( 0x20, 0x01, 0x0b, 0xa8, 0x00, 0x00, 0x01, 0xd4,
488 0x00, 0x00, 0x00, 0x00, 0x69, 0x50, 0x58, 0x45));
491 IPV6 ( 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x01, 0x00, 0x01,
492 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01));
495 IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
496 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01));
499 IPV6 ( 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
500 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
503 IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
504 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01));
507 IPV6 ( 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
508 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00));
528 "fe80::69ff:fe50:5845",
NULL );
532 "fe80::69ff:fe50:5845",
NULL );
536 "fe80::69ff:fe50:5845",
NULL );
538 "2001:db8:3::1",
NULL );
540 "2001:db8:3::1",
"fe80::1" );
542 "fe80::69ff:fe50:5845",
NULL );
544 "2001:db8:3::1",
NULL );
548 "fe80::69ff:fe50:5845",
NULL );
550 "2001:db8:3::1",
NULL );
552 "2001:db8:5::1",
NULL );
554 "2001:db8:42::1",
NULL );
556 "2001:db8:3::1",
"fe80::1" );
558 "fd44:9112:6442::69ff:fe50:5845",
NULL );
560 "fd70:6ba9:50ae::69ff:fe50:5845",
NULL );
562 "fd44:9112:6442::69ff:fe50:5845",
"fe80::1" );
564 "fd70:6ba9:50ae::69ff:fe50:5845",
"fe80::3" );
566 "fe80::69ff:fe50:5845",
NULL );
570 "2001:db8:2::1",
NULL );
572 "2001:db8:2::1",
NULL );
574 "2001:db8:3::1",
NULL );
576 "2001:db8:1::1",
"fe80::1" );
578 "2001:db8:4::1",
NULL );
580 "2001:db8:1::1",
"fe80::1" );
582 "2001:db8:1::1",
"fe80::1" );
const struct ipv6_test_route * routes
Test routing table entries.
#define IPV6(...)
Define inline IPv6 address.
char * inet6_ntoa(const struct in6_addr *in)
Convert IPv6 address to standard notation.
#define inet6_aton_fail_ok(text)
uint32_t next
Next descriptor address.
static const struct in6_addr sample_link_local
A sample link-local IPv6 address.
#define NETDEV_OPEN
Network device is open.
struct ipv6_miniroute * ipv6_route(unsigned int scope_id, struct in6_addr **dest)
Perform IPv6 routing.
uint64_t address
Base address.
#define IN6_IS_ADDR_SITELOCAL(addr)
static const struct in6_addr sample_ula
A sample ULA IPv6 address.
const struct ipv6_test_prefix * prefix
Prefix.
static void inet6_ntoa_okx(const struct in6_addr *addr, const char *text, const char *file, unsigned int line)
Report an inet6_ntoa() test result.
static void inet6_aton_fail_okx(const char *text, const char *file, unsigned int line)
Report an inet6_aton() failure test result.
int ipv6_add_miniroute(struct net_device *netdev, struct in6_addr *address, unsigned int prefix_len, struct in6_addr *router)
Add IPv6 routing table entry.
static const struct in6_addr sample_unspecified
The unspecified IPv6 address.
Self-test infrastructure.
const char * name
Test set name.
static void ipv6_table_okx(struct ipv6_test_table *table, const char *file, unsigned int line)
Create test routing table.
unsigned int scope_id
Scope ID.
int inet6_aton(const char *string, struct in6_addr *in)
Parse IPv6 address.
struct self_test ipv6_test __self_test
IPv6 self-test.
A doubly-linked list entry (or list head)
An IPv6 address/routing table entry.
#define list_empty(list)
Test whether a list is empty.
struct in6_addr router
Router address.
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
static void ipv6_table_del(struct ipv6_test_table *table)
Destroy test routing table.
void ipv6_del_miniroute(struct ipv6_miniroute *miniroute)
Delete IPv6 minirouting table entry.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static const struct in6_addr sample_multicast
A sample multicast IPv6 address.
#define okx(success, file, line)
Report test result.
static void inet6_aton_okx(const char *text, const struct in6_addr *addr, const char *file, unsigned int line)
Report an inet6_aton() test result.
#define PREFIX(name, LEN, MASK)
Define a test prefix.
void route(void)
Print routing table.
unsigned int count
Number of table entries.
#define list_splice_init(list, entry)
Move all entries from one list into another list and reinitialise empty list.
static void ipv6_test_exec(void)
Perform IPv6 self-tests.
#define TABLE(name,...)
Define a test routing table.
#define IN6_IS_ADDR_LINKLOCAL(addr)
#define IN6_IS_ADDR_UNSPECIFIED(addr)
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
struct refcnt refcnt
Reference counter.
static void ipv6_route_okx(struct ipv6_test_table *table, const char *dest, const char *src, const char *next, const char *file, unsigned int line)
Report an ipv6_route() test result.
struct list_head ipv6_miniroutes
List of IPv6 miniroutes.
struct list_head list
Constructed routing table.
#define INIT_LIST_HEAD(list)
Initialise a list head.
#define ipv6_route_ok(table, dest, src, next)
unsigned int len
Prefix length.
int strcmp(const char *first, const char *second)
Compare strings.
#define inet6_aton_ok(text, addr)
static struct net_device ipv6_test_netdev
Dummy network device used for routing tests.
#define list_splice(list, entry)
Move all entries from one list into another list.
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
const char * address
Local address.
#define REF_INIT(free_fn)
Initialise a static reference counter.
#define IN6_IS_ADDR_MULTICAST(addr)
#define ipv6_table_ok(table)
#define IN6_IS_ADDR_ULA(addr)
unsigned int prefix_len
Prefix length.
#define DBG(...)
Print a debugging message.
static const struct in6_addr sample_site_local
A sample site-local IPv6 address.
const char * mask
Prefix mask.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
void ref_no_free(struct refcnt *refcnt __unused)
Do not free reference-counted object.
#define NULL
NULL pointer (VOID *)
#define inet6_ntoa_ok(addr, text)
struct in6_addr address
IPv6 address (or prefix if no address is defined)
static const struct in6_addr sample_global
A sample global IPv6 address.
const char * router
Router address (if any)
struct in6_addr prefix_mask
IPv6 prefix mask (derived from prefix length)
An IPv6 test routing table.
An IPv6 test routing table entry.