-
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
ipv6: rpl: add source routing header for RPL #4774
Conversation
needs some re-work after an offline discussion with @authmillenon |
The call graph is following:
|
|
||
rh->seg_left--; | ||
i = n - rh->seg_left; | ||
memcpy(&addr.u8[pref_elided], &addr_vec[(i - 1) * addr_len], addr_len); |
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.
We should check addr_vec[(i - 1) * addr_len]
does not access outside of the IPv6 packet.
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.
CompE should be used when this is the last segment.
@Yonezawa-T2 thanks for the review. I addresse some of your and @authmillenon's comments |
@@ -36,6 +41,29 @@ bool gnrc_ipv6_ext_demux(kernel_pid_t iface, gnrc_pktsnip_t *pkt, | |||
case PROTNUM_IPV6_EXT_HOPOPT: | |||
case PROTNUM_IPV6_EXT_DST: | |||
case PROTNUM_IPV6_EXT_RH: | |||
pkt = gnrc_pktbuf_start_write(pkt); |
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.
gnrc_pktbuf_start_write
may return NULL.
I will review rest of the patch next week. |
bcee99c
to
ec8770d
Compare
@Yonezawa-T2 addressed your comments |
@@ -46,14 +58,16 @@ typedef struct __attribute__((packed)) { | |||
} ipv6_ext_rh_t; | |||
|
|||
/** | |||
* @brief Extract next hop from the routing header of an IPv6 packet. | |||
* @brief Process the routing header of an IPv6 packet. | |||
* | |||
* @param[in] ipv6 An IPv6 packet. |
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 should be [in, out]
.
@@ -36,6 +41,32 @@ bool gnrc_ipv6_ext_demux(kernel_pid_t iface, gnrc_pktsnip_t *pkt, | |||
case PROTNUM_IPV6_EXT_HOPOPT: | |||
case PROTNUM_IPV6_EXT_DST: | |||
case PROTNUM_IPV6_EXT_RH: | |||
if ((tmp = gnrc_pktbuf_start_write(pkt)) == NULL) { | |||
DEBUG("ipv6: could not get a copy of pkt\n"); | |||
gnrc_pktbuf_release(pkt); |
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.
return false; EDIT: addressed below
819b0dd
to
6e2c19c
Compare
rebased and addressed comments of @Yonezawa-T2 |
ipv6_ext_t *ext; | ||
unsigned int offset = 0; | ||
ipv6_hdr_t *hdr; | ||
int res; | ||
|
||
ext = ((ipv6_ext_t *)(((uint8_t *)pkt->data) + sizeof(ipv6_hdr_t))); |
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.
ext
is also updated by ipv6_ext_rh_process
.
Please insert
ext = ((ipv6_ext_t *)(((uint8_t *)pkt->data) + sizeof(ipv6_hdr_t) + offset));
before res = ipv6_ext_rh_process(hdr, (ipv6_ext_rh_t *)ext);
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 understand why we need to update ext
before the call to ipv6_ext_rh_process
?
ext
will be updated for each header extension (that is not a routing header extension) that was encountered before. Once we reach the routing header extension, ext
should point to the right place? That's why nh
is updated before getting the next ext
in line ~79.
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.
If pkt
is referred from multiple pointers, gnrc_pktbuf_start_write
duplicates the packet data:
ext
must point to the new byte array.
Note that the buffer referred from ext
is updated by this line:
https://github.com/RIOT-OS/RIOT/pull/4774/files#diff-6906777c73d641182b398573d3bdba0bR87
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.
addressed in cgundogan@4b18686
@Yonezawa-T2 addressed some of your comments in the last commit |
@Yonezawa-T2 addressed your last comment |
ACK and go when Travis is happy. |
Please squash first. |
@cgundogan, please squash |
c92aad9
to
170acbc
Compare
squashed |
ipv6: rpl: add source routing header for RPL
see https://tools.ietf.org/html/rfc6554
This PR only adds the parsing of the header, but does not integrate it into RPL.