-
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
gnrc_ndp2: Provide GNRC abstraction layer for NIB for sending #7064
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. |
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.
first round ...
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this conditional define necessary? When is NDP
being used witout IPv6
?
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.
In the tests :P
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.
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") |
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.
/"//
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
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.
Not sure, what you mean?
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.
shift everything starting from Neighbor
one character to the right. That's what I mean (:
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?
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.
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. |
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.
indent
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.
Not sure, what you mean?
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. |
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.
indent
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.
Not sure, what you mean?
pkt = hdr; | ||
} | ||
} | ||
/* TODO: also check if the node provides proxy servies for tgt */ |
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.
/servies/sevices/
/* 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 */ |
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.
/TL2AO/TLLAO/
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.
See #7064 (comment)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: here you called it SLLAO
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.
That's an error :P
bool try_long = false; | ||
int res; | ||
uint16_t l2src_len; | ||
/* maximum address length that fits into a minimum length (8) S/TL2A option */ |
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/TLLAO
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.
TEST_RETRANS_TIMER, | ||
NULL))); | ||
TEST_ASSERT(gnrc_pktbuf_is_sane()); | ||
/* check packet meta-data */ |
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.
please provide a macro or inline function for this meta-data check to reduce code redundancy
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.
(this will make the tests harder to debug if they fail, but okay).
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 btw)
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 |
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.
getting there.
sys/include/net/gnrc/ndp2.h
Outdated
*/ | ||
|
||
/** | ||
* @defgroup net_gnrc_ndp2 IPv6 Neighbor discovery (v2) |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add an else-statement at the end with the debug message as a compromise.
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
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.
then let's hear @OlegHahm's opinion about this.
|
||
static inline size_t _ceil8(uint8_t length) | ||
{ | ||
/* NDP options use units of 8 byte for there length field, so round up */ |
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/there/their/
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: