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/network_layer added a core implementation of a FIB #2211

Merged
merged 1 commit into from
Apr 1, 2015

Conversation

BytesGalore
Copy link
Member

This PR introduces a Forwarding Information Base (FIB) implementation.
It will replace the ip_get_next_hop() call on registered functions from routing protocols (RPs), e.g. here.

  • It provides management functions that must be used by RPs to add, delete and update next hop entries.
  • It signals reactive routing protocols whenever the FIB does not provide a next hop towards a destination to start a route discovery.
  • Underneath it provides a universal address container that allows to use one added entry multiple times.
  • The FIB is completely event triggered (no threads used)
  • All access is mutually excluded to allow being operated from asynchronous sources.

@BytesGalore BytesGalore added Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: network Area: Networking labels Dec 17, 2014
@miri64
Copy link
Member

miri64 commented Dec 17, 2014

Wouldn't sys/net/routing be a more fitting directory?

* @return FIB_SUCCESS on success
* FIB_ERROR if the entry cannot be created due to unsufficient RAM
*/
int fib_table_add_entry(uint8_t iface_id, uint8_t *glob_dst, size_t glob_dst_size, uint8_t *next_hop, size_t next_hop_size, uint32_t lifetime);
Copy link
Member

Choose a reason for hiding this comment

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

Didn't we talk about this previously, to use kernel_pid_t as type for iface_id?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it was an attempt to save a byte for each entry.
I change it :)

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.

@BytesGalore
Copy link
Member Author

Wouldn't sys/net/routing be a more fitting directory?

Hmm don't know, its more forwarding than routing

@OlegHahm OlegHahm added the Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties label Jan 6, 2015
@miri64 miri64 mentioned this pull request Jan 12, 2015
36 tasks
@BytesGalore BytesGalore force-pushed the add_fib branch 2 times, most recently from 873c9bb to e7b924f Compare January 19, 2015 12:02
@miri64 miri64 modified the milestones: Release NEXT MAJOR, Network Stack Task Force Feb 11, 2015
@miri64 miri64 added the NSTF label Feb 11, 2015
@haukepetersen
Copy link
Contributor

actually I think network layer is the correct place for this module.

@miri64
Copy link
Member

miri64 commented Feb 11, 2015

I think it's pretty arbitrary, since the network layer uses it to find the next hop and routing (which is more or less part of the network layer) is filling it.

@haukepetersen
Copy link
Contributor

@BytesGalore, @authmillenon: does it makes sense to convert the test application into a unit test?

@BytesGalore
Copy link
Member Author

@haukepetersen definitely. I will migrate the tests this afternoon/tomorrow morning

@haukepetersen
Copy link
Contributor

nice!

@miri64
Copy link
Member

miri64 commented Feb 13, 2015

While researching for IPv6's neighbor cache I stumbled upon the data structure Destination Cache which is pretty similar (or probably the same thing, just another term for) the FIB, except that it is suggested to store things like path MTU or round-trip timers. Do we want to add such things to the FIB

[…] the Destination Cache maps
a destination IP address to the IP address of the
next-hop neighbor.  This cache is updated with
information learned from Redirect messages.
Implementations may find it convenient to store
additional information not directly related to
Neighbor Discovery in Destination Cache entries,
such as the Path MTU (PMTU) and round-trip timers
maintained by transport protocols.

@OlegHahm
Copy link
Member

No. Keep the FIB as simple as possible. And from what I read this destination cache is quite different from a FIB (e.g., it includes off-link destinations, too).

@BytesGalore
Copy link
Member Author

Usually I wouldn't expect to ask the FIB for the PMTU, or other path specific information directly.
The FIB is, for my understanding, only enquired to get the next-hop information for a given destination, i.e. next-hop IP and the out interface.
So an individual FIB entry must either provide this information directly to the requester, or for instance the PMTU must be obtained from somewhere else.
FIB Implementations such as in Linux mixes/shares this information between layers [1], and provides large linked data structures with diverse information used to speed up lookups and keep the information close together.
The question is if providing additional information per entry is reasonable for us.
For instance I wouldn't expect that the PMTU changes in 802.15.4 only networks per next-hop.
Also I wouldn't want to rely on measuring/using RTT in LLNs.

But this is just my individual opinion and does not take IPv6 capabilities of RIOT into account.

[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/net/ip6_fib.h

@OlegHahm
Copy link
Member

I fully agree with @BytesGalore here.

@miri64
Copy link
Member

miri64 commented Mar 6, 2015

If you rebase, I start reviewing this, since I come to the point, were I need it in IPv6 :D

@@ -73,6 +73,10 @@ ifneq (,$(filter oneway_malloc,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/sys/oneway-malloc/include
endif

ifneq (,$(filter fib,$(USEMODULE)))
USEMODULE_INCLUDES += $(RIOTBASE)/sys/net/include
Copy link
Member

Choose a reason for hiding this comment

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

move fib/fib.h to sys/include/net/ng_fib.h and all its sub-headers to sys/include/net/ng_fib/ and remove this line to make this part of NTSF.

#define UNIVERSAL_ADDRESS_SIZE (16) /**< size of the used addresses in bytes */
#define UNIVERSAL_ADDRESS_SUCCESS (0) /**< return value for success */
#define UNIVERSAL_ADDRESS_ERROR_MEMORY (-1) /**< error value for invalid output buffer size */
#define UNIVERSAL_ADDRESS_NO_HIT (-2) /**< value for a address compare failed */
Copy link
Member

Choose a reason for hiding this comment

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

-ENOENT?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok changed that

@miri64
Copy link
Member

miri64 commented Mar 31, 2015

Apart from my issue with universal_address_compare() in particular and custom return value defines in general I'm fine with this PR.

* NULL if the size is unsufficient for copy
*/
uint8_t* universal_address_get_address(universal_address_container_t *entry,
uint8_t *addr, size_t *addr_size);
Copy link
Member

Choose a reason for hiding this comment

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

indentation

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 this

@miri64
Copy link
Member

miri64 commented Mar 31, 2015

So you did not consider to move ng_fib.h directly to sys/include/net? But apart from that (which would be nice, because of consistency and an include always looking like #include "net/ng_fib/ng_fib.h" instead of #include "net/ng_fib.h", but not necessary). ACK for my part. Please squash.

@BytesGalore
Copy link
Member Author

ah sorry I did that but forgot to commit the changes 😊

@BytesGalore
Copy link
Member Author

squashed

@BytesGalore BytesGalore 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 1, 2015
@miri64
Copy link
Member

miri64 commented Apr 1, 2015

ACK when Travis is happy :)

@BytesGalore
Copy link
Member Author

To make travis happy I need to suppress a cppcheck warning due to a buffer I reuse in a unittest twice.
When travis is happy I will squash again.

memset(addr_nxt, 0, add_buf_size);
memset(addr_lookup, 0, add_buf_size);

/* cppcheck: addr_lookup is only passed but not required to be read */
Copy link
Member

Choose a reason for hiding this comment

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

s# \*/$#since we test prefix matching \*/#?

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

@miri64
Copy link
Member

miri64 commented Apr 1, 2015

Re-ACK, please squash.

@BytesGalore
Copy link
Member Author

re-squashed

@miri64
Copy link
Member

miri64 commented Apr 1, 2015

Waiting for Travis…

memset(addr_nxt, 0, add_buf_size);
memset(addr_lookup, 0, add_buf_size);

/* cppcheck: addr_lookup is only passed but not required to be read,
Copy link
Member

Choose a reason for hiding this comment

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

s/ \+$// ;-)

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 and squashed since the change will not destroy anything (hopefully)

Copy link
Member

Choose a reason for hiding this comment

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

(please squash immediately to speed things up ;-))

Copy link
Member

Choose a reason for hiding this comment

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

There is still a whitespace at the end.

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 think github tricks us, inspecting the file in raw shows the whitespace is gone :)

Copy link
Member

Choose a reason for hiding this comment

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

You're right... Travis just passed this test.

Copy link
Member Author

Choose a reason for hiding this comment

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

hurray :)

@miri64
Copy link
Member

miri64 commented Apr 1, 2015

And go \o/

miri64 added a commit that referenced this pull request Apr 1, 2015
sys/net/network_layer added a core implementation of a FIB
@miri64 miri64 merged commit 9372d95 into RIOT-OS:master Apr 1, 2015
@BytesGalore
Copy link
Member Author

Woohooo 😄
@authmillenon thx for reviewing

@BytesGalore BytesGalore deleted the add_fib branch April 27, 2015 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking Community: Hack'n'ACK candidate This PR is a candidate for review and discussion during one of RIOT's monthly Hack'n'ACK parties Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/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