-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fib: changed handling of the net prefix by the FIB #4279
fib: changed handling of the net prefix by the FIB #4279
Conversation
@@ -243,7 +243,7 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent) | |||
kernel_pid_t if_id; | |||
if ((if_id = gnrc_ipv6_netif_find_by_addr(NULL, &all_RPL_nodes)) != KERNEL_PID_UNDEF) { | |||
fib_add_entry(&gnrc_ipv6_fib_table, if_id, def.u8, sizeof(ipv6_addr_t), | |||
(FIB_FLAG_NET_PREFIX | 0x0), | |||
(0x00 << FIB_FLAG_NET_PREFIX_SHIFT | 0x0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0x00 << FIB_FLAG_NET_PREFIX_SHIFT
== 0`?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, made it to keep all cases equal.
(0x00 << FIB_FLAG_NET_PREFIX_SHIFT)
flag for IPV6_ADDR_UNSPECIFIED
is now considered as default route by the FIB (inspired by ::/0
notation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you just write 0x0
instead of 0x00 << FIB_FLAG_NET_PREFIX_SHIFT | 0x0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it :)
75123b0
to
2464b25
Compare
I am just wondering: aren't 7 bits sufficient for storing the prefix? EDIT: nvm, since it is [0-128] it won't fit :/ |
For IPv6 yes. |
@@ -243,7 +243,7 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent) | |||
kernel_pid_t if_id; | |||
if ((if_id = gnrc_ipv6_netif_find_by_addr(NULL, &all_RPL_nodes)) != KERNEL_PID_UNDEF) { | |||
fib_add_entry(&gnrc_ipv6_fib_table, if_id, def.u8, sizeof(ipv6_addr_t), | |||
(FIB_FLAG_NET_PREFIX | 0x0), | |||
0x0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also need to adjust line 308 otherwise it won't compile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
arrrgh, done. |
2feca87
to
fbcd04a
Compare
rebased |
I am testing this change again |
fbcd04a
to
fb45f8c
Compare
@@ -74,15 +74,33 @@ static void _fib_usage(int info) | |||
|
|||
static void _fib_add(const char *dest, const char *next, kernel_pid_t pid, uint32_t lifetime) | |||
{ | |||
unsigned char *dst = (unsigned char *)dest; | |||
size_t dst_size = (strlen(dest)); | |||
uint32_t prefix = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If prefix is omitted, should it be 0 or 128?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The FIB omits the prefix if the specified byte in the falg is 0 or the length of the address in bits.
So 0 omits the prefix for any used address type, e.g. IPv6, IPv4, ..., and 128 omits an IPv6 prefix.
Sorry for delaying this so much. I will be able to look at it again at the end of next week. |
@cgundogan np :) , the release is/was way more important than this PR. |
fb45f8c
to
db736d9
Compare
@cgundogan nice thx for reviewing :) |
/* compare up to fist distinct byte, pretty clumsy method for now */ | ||
int idx = -1; | ||
bool test_all_zeros = true; | ||
for( size_t i = 0; i < entry->address_size; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
superfluous white-space before size_t
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and below
ACK |
& FIB_FLAG_NET_PREFIX_MASK) >> FIB_FLAG_NET_PREFIX_SHIFT; | ||
|
||
if ((match_size >= global_prefix_len) && | ||
((prefix_size == 0) || (match_size > prefix_size))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefix_size
is initialized as 0 and not set anywhere before to something else.
ACK - apart from minor comments. |
f559afa
to
79809ff
Compare
for(; i < entry->address_size; ++i) { | ||
if( entry->address[i] != 0 ) { | ||
ret = 1; | ||
for ( ; i < entry->address_size; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intentionally added the whitespace before the first ;
in the for
statement because I tend to overlook them in such cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's okay here.
@OlegHahm I guess I addressed all your comments, thx for reviewing :) @PeterSchmerzl welcome on the code side of the force, and thx for your ACK |
Murdock has some complaints. |
90930fe
to
2f83aab
Compare
ok, I think I got 'em |
* -ENOENT if the given adresses do not match | ||
* @return UNIVERSAL_ADDRESS_EQUAL if the entries are equal | ||
* @return UNIVERSAL_ADDRESS_MATCHING_PREFIX if the entry matches to a certain prefix | ||
* (trailing '0's in *entry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/*entry/@p entry/
Until now the prefix length has been determined automatically by the FIB This PR changes it to be provided as msb(yte) in the global_flags of an entry
2f83aab
to
52759f7
Compare
* -ENOENT if the given adresses do not match | ||
* @return UNIVERSAL_ADDRESS_EQUAL if the entries are equal | ||
* @return UNIVERSAL_ADDRESS_MATCHING_PREFIX if the entry matches to a certain prefix | ||
* (trailing '0's in *entry) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/*entry/@p entry/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* added and adjusted doxy for the new defined return values * stripped whitespaces for statements in the compare functions
cb09bcb
to
38d5fc2
Compare
Okay, I did a last test on the iotlab testbed with routing over 3 hops. Worked fine, my ACK upholds, @OlegHahm has already acked and Murdock is green => GO |
Congrats! |
nice thx again :D |
Until now the prefix length for a given destination has been determined automatically by the FIB.
This PR changes it to be provided as upper byte in the
global_flags
of an entry.Inspired by the IP scheme, the number of significant bits is stored in the designated most upper byte of the flags.
Rationale:
Before this change there was for instance no way to set a
>116
prefix for a private subnet like2001::1234:0000
.The API CHANGE Label belongs only to the reserved upper byte of the
global_flags
of a FIB entry used as storage for the prefix bits.