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

gnrc_ipv6: fix UDP issue when a packet passes through another node #5596

Closed

Conversation

mattiantonini
Copy link
Contributor

@mattiantonini mattiantonini commented Jul 4, 2016

The issue was related to the marking of non-valid IPv6 pck and to payload length. The IPv6 Payload length contains just the length of the payload (eg. UDP header+UDP Payload) without the (fixed) ipv6 header length.

@@ -852,7 +852,6 @@ static void _receive(gnrc_pktsnip_t *pkt)
ipv6 = gnrc_pktbuf_mark(pkt, sizeof(ipv6_hdr_t), GNRC_NETTYPE_IPV6);

first_ext = pkt;
pkt->type = GNRC_NETTYPE_UNDEF; /* snip is no longer IPv6 */
Copy link
Member

Choose a reason for hiding this comment

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

Where is this set now?

Copy link
Member

Choose a reason for hiding this comment

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

@Yonezawa-T2 this line is your's. I'm not sure why it is here, but I'm also not sure how it is related to the rest of the fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

The 6LoWPAN module creates packet like this:

set_undef_after_mark_1

then the IPv6 module marks IPv6 header:

set_undef_after_mark_2

but pkt no longer contains IPv6 header, so that we have to change its type to GNRC_NETTYPE_UNDEF.

set_undef_after_mark_3

Copy link
Member

@jia200x jia200x Jul 22, 2016

Choose a reason for hiding this comment

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

I checked the implementation of gnrc_pkt_len_upto (here, line 147).

The sum is made before the if(pkt->type == type), so what I see is if type is GNRC_NETTYPE_UNDEF, it will count the payload plus ipv6 hdr.

So, the pkt->type = GNRC_NETTYPE_UNDEF line should be after the call to gnrc_pkt_len_upto

@miri64 miri64 added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: network Area: Networking GNRC labels Jul 4, 2016
@miri64 miri64 added this to the Release 2016.07 milestone Jul 4, 2016
@miri64 miri64 changed the title fix UDP issue when a pck passes through another node gnrc_ipv6: fix UDP issue when a packet passes through another node Jul 4, 2016
@miri64
Copy link
Member

miri64 commented Jul 4, 2016

@mattiantonini please always prefix commit titles with the module's name that is concerned: gnrc_ipv6: ...

@miri64
Copy link
Member

miri64 commented Jul 4, 2016

You can do that with

git commit --amend
git push -f

in your branch. The rest happens automatically.

@mattiantonini mattiantonini force-pushed the gnrc_ipv6/pr/udp-fix branch 6 times, most recently from be77ac1 to 6c09442 Compare July 4, 2016 15:59
@mattiantonini
Copy link
Contributor Author

I've changed the commit title, but for the wild whitespace I've to do a new commit, right? I'm sorry for my ignorance :)

@miri64
Copy link
Member

miri64 commented Jul 4, 2016

I've changed the commit title, but for the wild whitespace I've to do a new commit, right?

Yep, changes to the patch are made as fix up commits (e. g. with git commit --fixup=HEAD) and are only squashed (using git rebase -i --autosquash origin/master) when the review is finished.

I'm sorry for my ignorance :)

No problem, we've all been there ;)

@kYc0o
Copy link
Contributor

kYc0o commented Jul 14, 2016

So is this PR solving the problem?

@jia200x
Copy link
Member

jia200x commented Jul 22, 2016

If I'm not wrong:

This file in current master branch assigns the pkt type to GNRC_NETTYPE_UNDEF (line 855):
pkt->type = GNRC_NETTYPE_UNDEF; /* snip is no longer IPv6 */

and then call the gnrc_pkt_len_upto (line 889):

gnrc_pkt_len_upto(pkt, GNRC_NETTYPE_IPV6) - sizeof(ipv6_hdr_t)

So, basically the gnrc_pkt_len_upto will count the current packet (with GNRC_NETTYPE_UNDEF) and the next packet (GNRC_NETTYPE_IPV6). This is ipv6_hdr + ipv6_payload. So, the final result of gnrc_pkt_len_upto(pkt, GNRC_NETTYPE_IPV6) - sizeof(ipv6_hdr_t)) will be the length of the payload.

What I see if removing the GNRC_NETTYPE_UNDEF set, and removing the "- sizeof(ipv6_hdr_t)", the result should be the same. Only the first packet will be count if its type is GNRC_NETTYPE_IPv6.

Am I missing something? What do you think?

@Yonezawa-T2
Copy link
Contributor

The 6LoWPAN module creates packet like this:

tmp1

while other modules creates packet like this:

tmp2

This is correct because marking a packet as a IPv6 packet is responsibility of the IPv6 module in general. Only the 6LoWPAN module is special.

So this PR will not work in non-6LoWPAN setup.

@kYc0o
Copy link
Contributor

kYc0o commented Jul 25, 2016

Ok let's discuss this for the next release.

@kYc0o kYc0o modified the milestones: Release 2016.10, Release 2016.07 Jul 25, 2016
@mattiantonini mattiantonini deleted the gnrc_ipv6/pr/udp-fix branch October 11, 2016 13:17
@kYc0o
Copy link
Contributor

kYc0o commented Oct 11, 2016

Why is it closed? The problem is gone?

@mattiantonini
Copy link
Contributor Author

@kYc0o I opened a new PR with an update version

@kYc0o
Copy link
Contributor

kYc0o commented Oct 11, 2016

Great! Thanks! :)

@miri64 miri64 removed this from the Release 2016.10 milestone Oct 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants