Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the Prefix field of the Route Information Option to be variable-length. #234

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading