-
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
ng_pktbuf: change semantics for received packets #2563
Conversation
* that @p data is NULL and no data will be inserted into the | ||
* result | ||
* @param[in] type Protocol type of the ng_pktsnip_t. | ||
* @param[in] payload The packet you want to add the ng_pktsnip_t to. If |
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/payload/next/
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 think this is confusing.
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, I don't really like the re-naming of the |
But that was never the intent of the argument
Before it really reflected how the |
Just for comparison: If you just would call (as I imagine you understand what hdr = ng_pktbuf_add(NULL, pkt->data, sizeof(ng_ipv6_hdr_t), NG_NETTYPE_IPV6);
pkt->data += sizeof(ng_ipv6_hdr_t);
pkt->next = hdr; you would get:
|
Actually the data will not be leaked or copied with this fix, I realized now. Both |
I'll adapt the documentation of |
@haukepetersen better understandable now? |
54fee24
to
055fe19
Compare
@haukepetersen ping? |
* v +----->| | | ||
* +---------------------------+ | +------+ | ||
* | size = 5 | data | . . | ||
* | type = NETTYPE_COAP |---------------+ . . |
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 can be removed (as application protocols are identified on their endpoint, e.g. UDP, port 1234)
done |
|
||
_pktbuf_internal_free(pkt->data); | ||
_pktbuf_internal_free(pkt); | ||
if (pkt->users == 0 && _pktbuf_internal_contains(pkt->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.
don't we need to call _pktbuf_internal_free(pkt)
always if pkt->users == 0
, independent of pkt->data
? So this if condition needs to be split up in my opinion:
if (pkt->users == 0) {
if (_pktbuf_internal_contains(pkt->data)) {
_pktbuf_internal_free(pk->data);
}
_pktbuf_internal_free(pkt);
}
Done + added a check if |
looking good. ACK when squashed and Travis is happy. |
fe2d9ba
to
21204dc
Compare
Squashed |
Forgot to adapt the unittests >.< |
and go. |
ng_pktbuf: change semantics for received packets
Sending packets remain in the same order, receiving packets are reversed. This way we save memory on
ng_pktbuf_start_write()
, since only the parts of the packets of interest for later layers in the line are duplicated:Some extreme examples below (
next
pointer always points up). Normally, with sending this would only apply fornetif
headers in multicast and L3 in some corner cases. For receiving this can only happen if there are sniffers or dual stacks involved.