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

fixes several bugs on GNRC network stack #4447

Merged
merged 4 commits into from
Jan 7, 2016

Conversation

Yonezawa-T2
Copy link
Contributor

This PR fixes several bugs in GNRC network stack.

  • fixed buffer overrun results from off-by-one error
  • fixed crash when there are no 6LoWPAN routers
  • fixed crash when both 6LoWPAN network and convensional IPv6 network are enabled
  • fixed infinite loop in managing network prefixes
  • fixed crash in debug output code
  • fixed crash by cancelling timer no longer needed
  • adds extra debug outputs for FIB

See commit messages for details.

This PR may or may not be broken by #3622. I will investigate later.

Tested on OS X with modifications of #4443, #4444, #4445, and #4446.

@OlegHahm OlegHahm added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: network Area: Networking NSTF Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch labels Dec 9, 2015
@OlegHahm OlegHahm added this to the Release 2015.12 milestone Dec 9, 2015
@OlegHahm
Copy link
Member

OlegHahm commented Dec 9, 2015

Wow, I haven't looked at the changes in detail, but I'd like already thank you for sharing your findings and providing all these fixes!

@cgundogan
Copy link
Member

Thank you @Yonezawa-T2 ! I will take a look at your proposed fixes.

#endif
#if defined(MODULE_GNRC_NDP_ROUTER) || defined(MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER)
#if defined(MODULE_GNRC_NDP_ROUTER) || defined(MODULE_GNRC_SIXLOWPAN_ND_BORDER_ROUTER) || defined(MODULE_GNRC_SIXLOWPAN_ND_ROUTER)
Copy link
Member

Choose a reason for hiding this comment

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

rtr_adv_timer is not defined in gnrc_ipv6_nc_t for MODULE_GNRC_SIXLOWPAN_ND_ROUTER

@Yonezawa-T2
Copy link
Contributor Author

@cgundogan fixed.


gnrc_ipv6_netif_t *if_entry = gnrc_ipv6_netif_get(iface);

if (if_entry != NULL &&
Copy link
Member

Choose a reason for hiding this comment

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

could you put each condition in parenthesis?

@cgundogan
Copy link
Member

@Yonezawa-T2 can you also add a mutex_unlock() in https://github.com/RIOT-OS/RIOT/blob/master/sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c#L472 and following return statements?

While your fix for the infinite prefix loop works for me, it is still possible to run into the same problem if the pktbuf is full and returns without unlocking the mutex.

It would block here: https://github.com/RIOT-OS/RIOT/blob/master/sys/net/gnrc/network_layer/ipv6/netif/gnrc_ipv6_netif.c#L133

@Yonezawa-T2
Copy link
Contributor Author

Updated.

gnrc_ipv6_netif_t *if_entry = gnrc_ipv6_netif_get(iface);

if ((if_entry != NULL) &&
(if_entry->rtr_adv_msg.content.ptr == (char *) entry)) {
Copy link
Member

Choose a reason for hiding this comment

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

indentation (should however fit into 100 cols of the first line).

@miri64
Copy link
Member

miri64 commented Dec 18, 2015

Sorry for the late review, this PR wasn't on my radar somehow. Thank you for your contributions, but while most fixes you offer are legitimate, there are some that unnecessarily might make the code size bigger or assume things that might not be true in certain situations.

@Yonezawa-T2
Copy link
Contributor Author

All my fixes are based on concrete problems I met while running my application (#4448). Those fixes are necessary unless there are better solutions.

@kaspar030
Copy link
Contributor

@Yonezawa-T2 Again, thanks a lot for these fixes! For the next time, experience shows that reviewing is a lot faster when PR's are small, so PR'ing even seemingly trivial commits by themselves is usually a good idea.

@cgundogan
Copy link
Member

@Yonezawa-T2, could you create a new PR and cherry-pick the following commits:
Yonezawa-T2@18c0720
Yonezawa-T2@0981896
Yonezawa-T2@4466bab
Yonezawa-T2@9e5c188
Yonezawa-T2@a87d36a

The above commits are those that I would ACK immediately.

@OlegHahm OlegHahm added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Dec 22, 2015
@cgundogan
Copy link
Member

@Yonezawa-T2, could you rebase onto current master?

@Yonezawa-T2
Copy link
Contributor Author

Rebased.

@@ -481,6 +481,7 @@ ipv6_addr_t *gnrc_ipv6_netif_find_addr(kernel_pid_t pid, const ipv6_addr_t *addr
* @param[out] out The reference to the found address on the interface.
* Must be a pointer to NULL on calling and may stay
* unchanged if no match can be found.
* Must not be NULL.
Copy link
Member

Choose a reason for hiding this comment

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

Can you add this as a @pre tag instead?

@miri64
Copy link
Member

miri64 commented Jan 6, 2016

Apart from my last comment I'm fine with the changes. Please squash immediately, maybe there is a change to squeeze this one into the release, too.

When `gnrc_ndp_node_next_hop_l2addr` cannot resolve L2 address, it creates a
temporary neighbor cache entry with interface `KERNEL_PID_UNDEF` (unless the
interface is already known) to send a neighbor solicitation. When another packet
directed to the same address is going to sent before receiving a neighbor
advertisement, `gnrc_sixlowpan_nd_next_hop_l2addr` gets the temporary neighbor
cache entry and calls `gnrc_ipv6_netif_get` with `KERNEL_PID_UNDEF`, resulting
get a `NULL`. We must check `NULL` before dereference it.

FYI, both `gnrc_ndp_node_next_hop_l2addr` and
`gnrc_sixlowpan_nd_next_hop_l2addr` are enabled when
`gnrc_sixlowpan_border_router_default` module is enabled with `GNRC_NETIF_NUMOF`
is greater than 1:

gnrc_sixlowpan_border_router_default
→ gnrc_ipv6_router_default
→ gnrc_ndp_router (if GNRC_NETIF_NUMOF > 1)
→ gnrc_ndp_node
→ gnrc_ndp_node_next_hop_l2addr is called from _next_hop_l2addr

gnrc_sixlowpan_border_router_default
→ gnrc_sixlowpan_nd_border_router
→ gnrc_sixlowpan_nd_router
→ gnrc_sixlowpan_nd
→ gnrc_sixlowpan_nd_next_hop_l2addr is called from _next_hop_l2addr
When ENABLE_DEBUG is 1, `out` is dereferenced unconditionally, but
`_parse_options` in `gnrc_rpl_control_messages.c` calls it with NULL.

Clarified `out` must not NULL and fixed `_parse_options`.
@Yonezawa-T2
Copy link
Contributor Author

Added @pre tag and squashed commits. Thanks for reviewing. The commits are much sophisticated.

@miri64 miri64 added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable labels Jan 7, 2016
@miri64
Copy link
Member

miri64 commented Jan 7, 2016

ACK and go as soon as travis is happy. Please provide a backport to 2015.12-branch.

@miri64 miri64 added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 7, 2016
miri64 added a commit that referenced this pull request Jan 7, 2016
fixes several bugs on GNRC network stack
@miri64 miri64 merged commit 94e4a08 into RIOT-OS:master Jan 7, 2016
@miri64 miri64 removed the Process: needs backport Integration Process: The PR is required to be backported to a release or feature branch label Jan 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR 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.

None yet

5 participants