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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

y-kzm
Copy link

@y-kzm y-kzm commented Nov 1, 2024

This PR enables prefixes to be sent in smaller chunks within the Route Information Options.

According to RFC 4191, Section 2.3:
The Length field is 1, 2, or 3 depending on the Prefix Length. If Prefix Length is greater than 64, then Length must be 3. If Prefix Length is greater than 0, then Length must be 2 or 3. If Prefix Length is zero, then Length must be 1, 2, or 3.

  • Before change
          route info option (24), length 24 (3):  2001:db8:1::1/128, pref=medium, lifetime=300s
            0x0000:  8000 0000 012c 2001 0db8 0001 0000 0000
            0x0010:  0000 0000 0001
          route info option (24), length 24 (3):  2001:db8:2::/64, pref=medium, lifetime=300s
            0x0000:  4000 0000 012c 2001 0db8 0002 0000 0000
            0x0010:  0000 0000 0000
  • After change
          route info option (24), length 24 (3):  2001:db8:1::1/128, pref=medium, lifetime=300s
            0x0000:  8000 0000 012c 2001 0db8 0001 0000 0000
            0x0010:  0000 0000 0001
          route info option (24), length 16 (2):  2001:db8:2::/64, pref=medium, lifetime=300s
            0x0000:  4000 0000 012c 2001 0db8 0002 0000

send.c Outdated
} else {
route = route->next;
continue;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

silently dropping the route here seems weird. At the very least it should drop; but also it should be IMPOSSIBLE to reach this if we validate routes earlier.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@y-kzm bump

@Neustradamus
Copy link
Member

@y-kzm: Have you seen @robbat2 review?

@y-kzm
Copy link
Author

y-kzm commented Nov 25, 2024

The test failed because the expected data for the prefix field of the RIO had a fixed length.
Before (expected data): test/send.c:164

	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,
	};

type: 0x18 (24)
length: 0x03 (3*8=24byte)
prefix length: 0x30 (/48)
Resvd|Prf|Resvd : 0x18 (0b000 11 000) low=0b11
Route Lifetime: 0x00002710 (=10000)
Prefix : 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 (fe80:000f:0001:0000:0000:0000:0000:0000) // fixed

After (expected data): test/send.c:164

	unsigned char expected[] = {
		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,
	};

type: 0x18 (24)
length: 0x02 (2*8=16byte)
prefix length: 0x30 (/48)
Resvd|Prf|Resvd : 0x18 (0b000 11 000) low=0b11
Route Lifetime: 0x00002710 (=10000)
Prefix : 0xfe, 0x80, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x00 (fe80:000f:0001:0000:) // variable
...

With this change, I have added a test case for when the prefix length is /128 in test/test1.conf.
Please review and approve the workflow again.
Thank you.

@stappersg
Copy link
Member

stappersg commented Dec 5, 2024 via email

@stappersg
Copy link
Member

Oh, #193 (comment) reminded me
on add Sign-off-by trailer

@y-kzm
Copy link
Author

y-kzm commented Dec 7, 2024

I added Signed-off-by trailer to the relevant commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants