Skip to content

Conversation

@jukkar
Copy link
Member

@jukkar jukkar commented Feb 14, 2018

Instead of having K_FOREVER when allocating a packet in IPv4 ARP
and IPv6 ND, set a timeout so that we do not have a case where we
would wait net_buf forever.

Fixes #5484

Signed-off-by: Jukka Rissanen [email protected]

@codecov-io
Copy link

codecov-io commented Feb 14, 2018

Codecov Report

Merging #6208 into master will increase coverage by <.01%.
The diff coverage is 37.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6208      +/-   ##
==========================================
+ Coverage   53.16%   53.16%   +<.01%     
==========================================
  Files         412      412              
  Lines       40117    40131      +14     
  Branches     7726     7729       +3     
==========================================
+ Hits        21327    21335       +8     
- Misses      15653    15662       +9     
+ Partials     3137     3134       -3
Impacted Files Coverage Δ
subsys/net/ip/ipv6.c 24.02% <33.33%> (+0.09%) ⬆️
subsys/net/ip/l2/arp.c 58.88% <50%> (-0.61%) ⬇️
subsys/net/ip/net_if.c 55.07% <0%> (+0.27%) ⬆️
subsys/net/lib/app/init.c 69.44% <0%> (+2.77%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e84d1a4...6f0458d. Read the comment docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this should have a less generic name, but e.g. namespaced one, e.g. ND_NET_BUF_TIMEOUT ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Depending on the bearer, use-case, runtime context, it could be wise to let the actual user to set what he needs through Kconfig.

Copy link
Member Author

Choose a reason for hiding this comment

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

Having some config option would be nice but we could end up having multiple config options for various timeouts. I would like to avoid that as that would be very confusing to end user.

For the actual timeout value, I think almost every value is equally good. I mean that if the system is short on buffers (which typically means heavily loaded system), then any timeout value would be equally good. On the other hand, if there is a buffer leak, then any timeout value would not change anything.

So I suggest we go with one hard coded value atm and change this if we really need to.

Copy link
Contributor

Choose a reason for hiding this comment

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

So I suggest we go with one hard coded value atm and change this if we really need to.

I'm +1 for that. However, I'd still recommend a more distinctive name for such a define.

@pfalcon
Copy link
Contributor

pfalcon commented Feb 15, 2018

This definitely looks like a step in the right direction, a questions is: how do we handle these -ENOMEM's?

@jukkar
Copy link
Member Author

jukkar commented Feb 19, 2018

how do we handle these -ENOMEM

At the moment, the constructed message is just discarded. This might affect the functionality of the device of course.

@pfalcon
Copy link
Contributor

pfalcon commented Feb 19, 2018

At the moment, the constructed message is just discarded. This might affect the functionality of the device of course.

But does the caller at least prints a log message for this (preferrably, ERR-level). I hope, we don't have a silent discarding here.

Copy link
Contributor

@pfalcon pfalcon left a comment

Choose a reason for hiding this comment

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

Thanks for the answers. I'd still recommend checking that -ENOMEM has a good chance to be reported back to user (at least via logging). Otherwise, this is step in the right direction, so let me +1 it.

@jukkar
Copy link
Member Author

jukkar commented Feb 19, 2018

Uploaded new version:

  • renamed the IPv6 define from NET_BUF_TIMEOUT to ND_NET_BUF_TIMEOUT
  • added debug prints if buffer allocation fails

Instead of having K_FOREVER when allocating a packet in IPv4 ARP
and IPv6 ND, set a timeout so that we do not have a case where we
would wait net_buf forever.

Fixes zephyrproject-rtos#5484

Signed-off-by: Jukka Rissanen <[email protected]>
@jukkar
Copy link
Member Author

jukkar commented Feb 20, 2018

Uploaded version that fixes sanity error.

Copy link
Contributor

@pfalcon pfalcon left a comment

Choose a reason for hiding this comment

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

One thing which can be improved, otherwise, looks good, thanks for the added logging!

#include <net/arp.h>
#include "net_private.h"

#define NET_BUF_TIMEOUT MSEC(100)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, this would be ARP_NET_BUF_TIMEOUT then ;-).

@jukkar jukkar merged commit 023628f into zephyrproject-rtos:master Feb 20, 2018
@jukkar jukkar deleted the bug-5484-arp+nd branch June 21, 2018 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants