gnrc_ndp2: Provide GNRC abstraction layer for NIB for sending#7064
gnrc_ndp2: Provide GNRC abstraction layer for NIB for sending#7064cgundogan merged 2 commits intoRIOT-OS:masterfrom
Conversation
|
@miri64, should we postponed this one ? I guess yes. |
|
The new ND wouldn't make it to 2017.07 anyway, so I guess yes. |
sys/include/net/gnrc/ndp2.h
Outdated
| */ | ||
| #ifndef GNRC_NETTYPE_NDP2 | ||
| # if defined(MODULE_GNRC_IPV6) || DOXYGEN | ||
| # define GNRC_NETTYPE_NDP2 (GNRC_NETTYPE_IPV6) |
There was a problem hiding this comment.
Is this conditional define necessary? When is NDP being used witout IPv6?
There was a problem hiding this comment.
so, maybe mention this fact here? It's really confusing to bend things in the implementation that are oly needed for testing.
sys/include/net/gnrc/ndp2.h
Outdated
| * | ||
| * @pre `(tgt != NULL) && !ipv6_addr_is_multicast(tgt)` | ||
| * | ||
| * @see [RFC 4861, section 4.3](https://tools.ietf.org/html/rfc4861#section-4.3") |
| * For and unsolicited advertisement, the address whose | ||
| * link-layer address has changed. | ||
| * May not be NULL and **MUST NOT** be multicast. | ||
| * @param[in] flags Neighbor advertisement flags: |
There was a problem hiding this comment.
shift everything starting from Neighbor one character to the right. That's what I mean (:
There was a problem hiding this comment.
Hm, appears to be a problem in my browser then. It's shifted wrongly here. There's no tab or thin whitespace there, right?
sys/include/net/gnrc/ndp2.h
Outdated
| * | ||
| * @param[in] cur_hl Default hop limit for outgoing IP packets, 0 if | ||
| * unspecified by this router. | ||
| * @param[in] flags Flags as defined above. |
sys/include/net/gnrc/ndp2.h
Outdated
| * @param[in] pref_ltime Length of time in seconds that addresses using | ||
| * @p prefix remain prefered. UINT32_MAX represents | ||
| * infinity. | ||
| * @param[in] flags Flags as defined above. |
| pkt = hdr; | ||
| } | ||
| } | ||
| /* TODO: also check if the node provides proxy servies for tgt */ |
| /* TODO: also check if the node provides proxy servies for tgt */ | ||
| if ((pkt != NULL) && | ||
| (!gnrc_ipv6_netif_addr_is_non_unicast(tgt) || supply_tl2a)) { | ||
| /* TL2A is not supplied and tgt is not anycast */ |
| DEBUG("ndp2: send router solicitation (iface: %" PRIkernel_pid | ||
| ", dst: %s)\n", netif->pid, | ||
| ipv6_addr_to_str(addr_str, dst, sizeof(addr_str))); | ||
| /* add SLLAO => check if there is a fitting source address to target */ |
There was a problem hiding this comment.
note: here you called it SLLAO
| bool try_long = false; | ||
| int res; | ||
| uint16_t l2src_len; | ||
| /* maximum address length that fits into a minimum length (8) S/TL2A option */ |
| TEST_RETRANS_TIMER, | ||
| NULL))); | ||
| TEST_ASSERT(gnrc_pktbuf_is_sane()); | ||
| /* check packet meta-data */ |
There was a problem hiding this comment.
please provide a macro or inline function for this meta-data check to reduce code redundancy
There was a problem hiding this comment.
(this will make the tests harder to debug if they fail, but okay).
|
Needed to change the API a little bit. I realized that I need access to the NIB internals for the ARO, so I removed it from the |
sys/include/net/gnrc/ndp2.h
Outdated
| */ | ||
|
|
||
| /** | ||
| * @defgroup net_gnrc_ndp2 IPv6 Neighbor discovery (v2) |
There was a problem hiding this comment.
Uppercase d for Discovery, otherwise lowercase n for Neighbor
| assert((tgt != NULL) && !ipv6_addr_is_multicast(tgt)); | ||
| DEBUG("ndp2: building neighbor solicitation message\n"); | ||
| pkt = gnrc_icmpv6_build(options, ICMPV6_NBR_SOL, 0, sizeof(ndp_nbr_sol_t)); | ||
| if (pkt != NULL) { |
There was a problem hiding this comment.
For debugging purposes, I would rather like an early exit in case of pkt == NULL and an appropriate DEBUG statement for that. Here and all following functions.
There was a problem hiding this comment.
Can we decide on one style please? I think in the end the given style will lead to cleaner code and smaller code size.
There was a problem hiding this comment.
I can add an else-statement at the end with the debug message as a compromise.
There was a problem hiding this comment.
The given style very quickly leads to nested if blocks. That's already the case for a lot of places in the existing NDP code. I don't think that an early exit leads to bigger code sizes, but definitely makes the code more readable by removing one block of indentation.
There was a problem hiding this comment.
Honestly it's a matter of taste. I could change it, but I remember that @OlegHahm was blocking early exits in the review of the old NDP. So which taste should I follow now?
|
|
||
| static inline size_t _ceil8(uint8_t length) | ||
| { | ||
| /* NDP options use units of 8 byte for there length field, so round up */ |
| memcpy(&real_dst, dst, sizeof(real_dst)); | ||
| adv_flags |= NDP_NBR_ADV_FLAGS_S; | ||
| } | ||
| /* add SL2AO based on target address */ |
There was a problem hiding this comment.
I don't know what you mean by alternative spellings. SLLAO is the official abbreviation for Source Link-Layer Address Option (cf. Appendix F of RFC4861):
o Clarified router behavior when receiving a Router Solicitation
without Source Link-Layer Address Option (SLLAO).
|
Addressed comments. |
|
Reply to #7064 (comment) in #7064 (comment) btw (why can't it show up under your reply above oO?) |
|
Latest commit is good, please squash! |
|
Squashed |
f7830ca to
e3b7f43
Compare
e3b7f43 to
d9a884e
Compare
|
Fixed issue Murdock had and amended. |
|
Another try :-) |
fb73e6e to
283cc51
Compare
283cc51 to
78474fc
Compare
|
And another -.- |
|
Murdock finally liked it \o/ |
|
GO! |
Not waiting for @OlegHahm's opinion on early exits? Oo.... but okay you are the reviewer, I will not complain :D |
dammit :P |
For the new NIB simply using the old sending functions as I previously hoped (and why #6380 exists) isn't possible, since it is too tightly integrated in the old NDP. This PR (apart from a few code and API beatifications) is mostly a copy of the sending and building functions of
gnrc_ndp, but it also introduces a set of tests.The 2 is supposed to be removed as soon as the old NDP is removed
This PR is part of the network layer remodelling effort:
