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

sys/net/fib: added function to request a set of destination addresses #2818

Merged

Conversation

BytesGalore
Copy link
Member

This PR introduces an access function to the FIB, that collects all destination addresses matching specific prefix.
(This is meant as a base for discussion)

Rationale:
Using the FIB with RPL requires in storing MOP that all destination addresses reachable from a node, which are constructed by receiving DIOs and all target options from all received DAOs recursively, are put in the DAO messages disseminated by the node.
The former FIB did not provided access for a set of destination addresses matching a specific prefix.

@BytesGalore BytesGalore added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: network Area: Networking Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR labels Apr 14, 2015
@BytesGalore BytesGalore force-pushed the fib_get_conditionlal_entry_set branch from 5118b0e to c010736 Compare April 27, 2015 05:40
for (size_t i = 0; i < FIB_MAX_FIB_TABLE_ENTRIES; ++i) {
if( (fib_table[i].global_flags & bitmap) == (type & bitmap) ) {

if( dst_set != NULL && found_entries < (*dst_set_size)-1 ) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you move the check dst_set != NULL outside of the loop?

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically yes, but the it would require a construct like:

if( dst_set != NULL ){
 for(...) ... // like above without the check
} else {
 for(...) ... // just counting the entries
}

Copy link
Member

Choose a reason for hiding this comment

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

I see. Actually I thought that this function should return an error when no dst_set was specified. Anyhow, can you extend the doc that this function still counts and returns the number of all matching entries even when they are not copied to dst_set?

And add parens to the condition, please (:

Copy link
Member Author

Choose a reason for hiding this comment

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

Added parens and wrote a line that the matching count is being determined.

The idea to allow a dst_set == NULL and continue, is that if you're interested at first in the current number of matching entries, to check if your out buffer can hold them, you probably don't want to have any copy operations.

@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 Apr 28, 2015
@@ -122,6 +130,27 @@ int fib_get_next_hop(kernel_pid_t *iface_id,
uint8_t *dst, size_t dst_size, uint32_t dst_flags);

/**
* @brief provides a set of destination addresses matching the bits specified with
* the provided bitmap and type.
* If the out buffer is insufficient low, the function will continue to count the
Copy link
Member

Choose a reason for hiding this comment

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

could you also add the fact, that the buffer is allowed to be null? Something like:

If the out buffer is insufficient low or null, ...

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, sorry for the delay.

@cgundogan
Copy link
Member

besides my comment this PR looks good and needs squashing

@cgundogan
Copy link
Member

does anyone else wants to participate in this discussion (because it's marked as RFC)? Otherwise, my ACK holds and my intention is to merge this ASAP

@BytesGalore BytesGalore force-pushed the fib_get_conditionlal_entry_set branch from 0ad152f to 6106c8f Compare April 28, 2015 18:45
@BytesGalore
Copy link
Member Author

squashed and rebased.

@cgundogan cgundogan removed the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Apr 28, 2015
@cgundogan
Copy link
Member

I guess I am satisfied with this PR and I am in favor of dropping the RFC label here and opt for a quick merge, since we need this functionality for #2765 . What do you say @BytesGalore @OlegHahm ?

@BytesGalore BytesGalore removed the Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR label Apr 28, 2015
@BytesGalore
Copy link
Member Author

@cgundogan sure, removed the RFC label

@BytesGalore
Copy link
Member Author

in a followup PR we could make this feature optional/exclusive when RPL is loaded

@emmanuelsearch
Copy link
Member

Do we need to think about a rationale such that their are no flag collisions between different protocols that write into the FIB? Like a prefix based on protocol ID, and then the rest of the bits are managed per protocol?

@BytesGalore
Copy link
Member Author

@emmanuelsearch definitely, I think an enum with define protected members will do, similar to [1]

[1] https:/RIOT-OS/RIOT/blob/master/sys/include/net/ng_nettype.h#L89

@BytesGalore
Copy link
Member Author

I don't expect that we will have like 100 routing-protocols available and using more than 3 at the same time on a node

@cgundogan
Copy link
Member

@BytesGalore are global_flags and next_hop_flags only used for routing protocol distinction? What other uses for them are out there? Introducing a mechanism for collision-free type definitions mentioned by @emmanuelsearch is favorable. Personally, I have no strong opinion of it being an enum or somehow encoding this information by using specific prefixes. I would argue however that this should be done in a separate PR and most preferably prior to this one.

regardless of the fact that we will not have more than max 3 routing protocols running at the same time, an enum or well-chosen ifdefs would make access to these flags more readable than some magic hex numbers?

@BytesGalore
Copy link
Member Author

@cgundogan the _flags are used also to identify the address type, e.g. NG_NETTYPE_IPV6.
Its beneficial to know what type of address hides behind the address bytes, and is necessary when we provide using multiple Protocols with different address types.

But I think you're both are right. A collision free mechanism based on protocol IDs and additional management bits is the right way to do it and this should be a done/merged prior to this PR.

@cgundogan
Copy link
Member

@BytesGalore do you have a concept in mind for such a mechanism?

@BytesGalore
Copy link
Member Author

@cgundogan after rethinking a bit I think using flags/protocol IDs for that purpose is not necessary.
A routing protocol is responsible for a specific prefix. All destination addresses are indirectly "assigned" to a protocol by the prefix.
So asking the FIB for a set of destination addresses based on a given prefix seems more reasonable for me here.

@BytesGalore
Copy link
Member Author

The prototype would change to:

int fib_get_destination_set(uint32_t* prefix, size_t prefix_length, fib_destination_set_entry_t *dst_set, size_t* dst_set_size);

@cgundogan what do you think, any cons on change it this way?

@cgundogan
Copy link
Member

@BytesGalore I guess your suggestion is reasonable. Assigning the routing protocols to handle certain prefixes may be the right way. To stress a point: What happens if prefix ranges overlap? longest prefix matches?

@BytesGalore
Copy link
Member Author

@cgundogan overlapping should MUST NOT happen since then both (or multiple) routing protocols would take responsibility/royalty over the intersected address range.
This way the overlapping entries would be repeatedly overwritten form multiple sources with distinct values, preventing a healthy topology for each routing protocol using that shared range.
In consequence such approach will eventually result in routing loops since no routing protocol knows the current state of the topology in the overlapping range.

@BytesGalore BytesGalore force-pushed the fib_get_conditionlal_entry_set branch from e4ff998 to cdbca42 Compare May 11, 2015 10:07
@BytesGalore
Copy link
Member Author

ok, changed the approach to use a prefix match instead of flags, and rebased.

@OlegHahm
Copy link
Member

I think there's only one choice: add it to BOARD_INSUFFICIENT_RAM in tests/unittests/Makefile.

@cgundogan
Copy link
Member

@OlegHahm isn't it the rom section, which is overflowing?

@OlegHahm
Copy link
Member

Ah, yes, you're right. Which is actually weird.

@miri64
Copy link
Member

miri64 commented May 26, 2015

The macro BOARD_INSUFFICIENT_RAM refers to both ROM and RAM, since it just triggers the test to ignore any linking errors...

@cgundogan
Copy link
Member

Then we should opt to change this macro's name to be more verbose and semantically correct

@OlegHahm
Copy link
Member

Maybe we should rename it to BOARD_INSUFFICIENT_MEMORY then.

@cgundogan
Copy link
Member

Maybe we should rename it to BOARD_INSUFFICIENT_MEMORY then.

+1

@BytesGalore
Copy link
Member Author

+1

@BytesGalore
Copy link
Member Author

I added the samr board to BOARD_INSUFFICIENT_RAM

@cgundogan
Copy link
Member

@BytesGalore please squash. Merge when travis is happy

@cgundogan
Copy link
Member

@BytesGalore I think this PR also needs a rebase?

@BytesGalore BytesGalore force-pushed the fib_get_conditionlal_entry_set branch from 72d0dc2 to 18c69e0 Compare June 2, 2015 09:55
@BytesGalore
Copy link
Member Author

rebased and squashed

@cgundogan cgundogan added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jun 2, 2015
@cgundogan
Copy link
Member

@BytesGalore can you trigger travis?

@BytesGalore
Copy link
Member Author

hmm seems that travis is currently not available :(

@cgundogan cgundogan closed this Jun 2, 2015
@cgundogan cgundogan reopened this Jun 2, 2015
@cgundogan
Copy link
Member

Why is travis not building this PR? It works for other PRs..

@cgundogan cgundogan added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jun 2, 2015
@cgundogan
Copy link
Member

@BytesGalore can you again rebase to master so that #2783 is also included in this branch? This would simplify the rebase of my branch in #3050 (:

@cgundogan
Copy link
Member

travis is green => GO

cgundogan added a commit that referenced this pull request Jun 5, 2015
sys/net/fib: added function to request a set of destination addresses
@cgundogan cgundogan merged commit ece6454 into RIOT-OS:master Jun 5, 2015
@BytesGalore BytesGalore deleted the fib_get_conditionlal_entry_set branch November 2, 2015 07:09
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 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