Skip to content

Commit

Permalink
Merge pull request #234 from y-kzm/yykzm-rio-update
Browse files Browse the repository at this point in the history
Change the Prefix field of the Route Information Option to be variable-length.
  • Loading branch information
robbat2 authored Dec 27, 2024
2 parents f505b35 + a0d44a5 commit 9a62ece
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
11 changes: 8 additions & 3 deletions send.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,13 @@ static struct safe_buffer_list *add_ra_options_route(struct safe_buffer_list *sb
memset(&rinfo, 0, sizeof(rinfo));

rinfo.nd_opt_ri_type = ND_OPT_ROUTE_INFORMATION;
/* XXX: the prefixes are allowed to be sent in smaller chunks as well */
rinfo.nd_opt_ri_len = 3;
if (route->PrefixLen == 0) {
rinfo.nd_opt_ri_len = 1;
} else if (route->PrefixLen > 0 && route->PrefixLen <= 64) {
rinfo.nd_opt_ri_len = 2;
} else if (route->PrefixLen > 64 && route->PrefixLen <= 128) {
rinfo.nd_opt_ri_len = 3;
}
rinfo.nd_opt_ri_prefix_len = route->PrefixLen;

rinfo.nd_opt_ri_flags_reserved = (route->AdvRoutePreference << ND_OPT_RI_PRF_SHIFT) & ND_OPT_RI_PRF_MASK;
Expand All @@ -585,7 +590,7 @@ static struct safe_buffer_list *add_ra_options_route(struct safe_buffer_list *sb
memcpy(&rinfo.nd_opt_ri_prefix, &route->Prefix, sizeof(struct in6_addr));

sbl = safe_buffer_list_append(sbl);
safe_buffer_append(sbl->sb, &rinfo, sizeof(rinfo));
safe_buffer_append(sbl->sb, &rinfo, rinfo.nd_opt_ri_len * 8);

route = route->next;
}
Expand Down
9 changes: 5 additions & 4 deletions test/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ START_TEST(test_add_ra_options_route)
ck_assert_msg(0, "\n%s", (char*)&buf);
#else
unsigned char expected[] = {
0x18, 0x03, 0x30, 0x18, 0x00, 0x00, 0x27, 0x10, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x28, 0x08, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x80, 0x00, 0x0f,
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x03, 0x20, 0x00, 0x00, 0x00,
0x0b, 0xb8, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x18, 0x02, 0x30, 0x18, 0x00, 0x00, 0x27, 0x10, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00,
0x18, 0x02, 0x28, 0x08, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00,
0x18, 0x02, 0x20, 0x00, 0x00, 0x00, 0x0b, 0xb8, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00,
0x18, 0x03, 0x80, 0x00, 0x00, 0x00, 0x0b, 0xb8, 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x02, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

ck_assert_int_eq(sizeof(expected), sb.used);
Expand Down
3 changes: 3 additions & 0 deletions test/test1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ interface eth0 {
route fe80:f:2::/32 {
};

route fe80:f:2::/128 {
};

DNSSL office.branch.example.com branch.example.com example.com {
AdvDNSSLLifetime 1000;
};
Expand Down

0 comments on commit 9a62ece

Please sign in to comment.