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

fib: changed handling of the net prefix by the FIB #4279

Merged
merged 2 commits into from
Mar 30, 2016

Conversation

BytesGalore
Copy link
Member

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 like 2001::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.

@BytesGalore BytesGalore added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: network Area: Networking Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. labels Nov 16, 2015
@@ -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),
Copy link
Member

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`?

Copy link
Member Author

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).

Copy link
Member

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 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed it :)

@BytesGalore BytesGalore added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Nov 16, 2015
@BytesGalore BytesGalore force-pushed the fib_prefix_handling_change branch from 75123b0 to 2464b25 Compare November 16, 2015 12:16
@cgundogan
Copy link
Member

I am just wondering: aren't 7 bits sufficient for storing the prefix?

EDIT: nvm, since it is [0-128] it won't fit :/

@BytesGalore
Copy link
Member Author

For IPv6 yes.
But I aim the FIB to be more flexible then just support up to IPv6 :)

@@ -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,
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@cgundogan
Copy link
Member

RIOT/sys/net/network_layer/fib/fib.c:1535:28: error: format '%d' expects argument
                     of type 'int', but argument 2 has type 'uint32_t
                     {aka long unsigned int}' [-Werror=format=]
                     printf("N /%d ", (prefix >> FIB_FLAG_NET_PREFIX_SHIFT));

@BytesGalore
Copy link
Member Author

arrrgh, done.

@BytesGalore BytesGalore force-pushed the fib_prefix_handling_change branch from 2feca87 to fbcd04a Compare November 24, 2015 05:50
@BytesGalore
Copy link
Member Author

rebased

@cgundogan
Copy link
Member

I am testing this change again

@OlegHahm OlegHahm modified the milestone: Release 2016.03 Dec 7, 2015
@BytesGalore BytesGalore force-pushed the fib_prefix_handling_change branch from fbcd04a to fb45f8c Compare December 9, 2015 16:14
@@ -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;
Copy link
Contributor

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?

Copy link
Member Author

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.

@cgundogan
Copy link
Member

Sorry for delaying this so much. I will be able to look at it again at the end of next week.

@BytesGalore
Copy link
Member Author

@cgundogan np :) , the release is/was way more important than this PR.

@BytesGalore
Copy link
Member Author

@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++) {
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

here and below

@PeterSchmerzl
Copy link

ACK

& FIB_FLAG_NET_PREFIX_MASK) >> FIB_FLAG_NET_PREFIX_SHIFT;

if ((match_size >= global_prefix_len) &&
((prefix_size == 0) || (match_size > prefix_size))) {
Copy link
Member

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.

@OlegHahm
Copy link
Member

ACK - apart from minor comments.

@BytesGalore BytesGalore force-pushed the fib_prefix_handling_change branch 3 times, most recently from f559afa to 79809ff Compare March 30, 2016 06:19
for(; i < entry->address_size; ++i) {
if( entry->address[i] != 0 ) {
ret = 1;
for ( ; i < entry->address_size; ++i) {
Copy link
Member Author

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.

Copy link
Member

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.

@BytesGalore
Copy link
Member Author

@OlegHahm I guess I addressed all your comments, thx for reviewing :)
I made a separate companion commit for the doxy/define changes in universal_address

@PeterSchmerzl welcome on the code side of the force, and thx for your ACK

@BytesGalore BytesGalore added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Mar 30, 2016
@OlegHahm
Copy link
Member

Murdock has some complaints.

@BytesGalore BytesGalore force-pushed the fib_prefix_handling_change branch 2 times, most recently from 90930fe to 2f83aab Compare March 30, 2016 07:50
@BytesGalore
Copy link
Member Author

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)
Copy link
Member

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
@BytesGalore BytesGalore force-pushed the fib_prefix_handling_change branch from 2f83aab to 52759f7 Compare March 30, 2016 08:18
* -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)
Copy link
Member

Choose a reason for hiding this comment

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

s/*entry/@p entry/

Copy link
Member Author

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
@BytesGalore BytesGalore force-pushed the fib_prefix_handling_change branch from cb09bcb to 38d5fc2 Compare March 30, 2016 08:29
@cgundogan
Copy link
Member

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

@cgundogan cgundogan merged commit 9dbfdca into RIOT-OS:master Mar 30, 2016
@cgundogan
Copy link
Member

Congrats!

@BytesGalore
Copy link
Member Author

nice thx again :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants