-
Notifications
You must be signed in to change notification settings - Fork 2.1k
pktbuf: port to use pkt_t instead of void* #2285
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
Conversation
bc02a0e
to
97ec2de
Compare
Rebased to #2158. |
97ec2de
to
fef162f
Compare
Rebased to current master |
uint8_t processing; | ||
_pktsize_t size; | ||
} _packet_t; | ||
pkt_hlist_t *header_ptr; |
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.
alignment problem, (header_ptr
) is 8-bit off?
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.
The struct is still packed, can you maybe test this on the platforms you are concerned this might occur? The unittests for pktbuf have a test for alignment problems (test_pktbuf_insert_packed_struct()
). In general I find it difficult to move the processing counter (and think int would be overkill), since the current implementation expects the pkt_t struct always directly before the data block (so you can find it very fast, if you only have the data pointer for e. g. copy).
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 just realized that this might be a problem if you received a packet and want to move the data pointer forward as the headers proceed... -.- I have to rethink the whole pkt_t
concept now, or at least it's relation with the packet buffer because this also leads to some sever problems in thread-safety...
The code looks clean good to me for the changes. By looking at the packet buffer in it's current form I am wondering however if there is a way to simplify the design by merging |
About the difference in
The reason for |
Problem I just discovered with this implementation (and pkt in general): as a packet moves up the network-stack the pkt->payload_data will start to move forward. If other threads use that they might not expect that... With the void pointer solution this was not a problem, since they only where of concern of two adjacent layers. The simplest solution I can think of right now while keeping the original goal of the pkt API (to reduce packet related code-duplication) is to revert the pktbuf to its original state (as it is in master right now) and put the packet-related pktbuf functions (allocate + add / remove + free header data; allocate packet data + header data) to the pkt module. What do you think? |
(to be clear: the pkt_t struct wouldn't be stored in the pktbuf with approach, but would be something the layers would be using locally and would only be used as a means to abstract the (headers, data, data_len) tuple of the current API. The pkt_hlist_t nodes however would be stored as chunks in the pktbuf but not as they are now. In general: the pktbuf would be more of a chunk buffer) |
I think your last proposal seems for me to be a huge step backwards. I think to identify packet data by a unified pointer (i.e. I think what we need to do is meet and put our ideas side-to-side on a white board to get on the same page. In the end I think we move in the right direction but we need to synchronize first before we spend more implementation efforts on this. Does this sound feasible? |
I don't think it of a step backwards, just in another direction. Have a look at my scetched-up version: miri64@9b6c9f3 |
Maybe I should also point out that currently stuff like pointing out headers on receive is not possible with the implementation in this PR, but I think for your ideas we need that ;-) |
Since this implementation is flawed, I close this PR and offer #2322 as an alternative. |
9c43028
to
0d898c6
Compare
And constantly changing commit hashes don't? |
Not for me at least. |
(Maybe it's because I'm not a computer and don't read hashes unless I really have to.) |
(That's not a hash problem: changing the hash changes the commit date, putting it in another place in the history as it is presented here. But let's discuss this over lunch sometime or in another context… not here ;-)) |
11c4cf8
to
e302574
Compare
Rebased to current master |
* @detail This variable is only available if @ref DEVELHELP is active and | ||
* @ref NG_PKTBUF_SIZE > 0. | ||
*/ | ||
extern unsigned int ng_pktbuf_max_bytes; |
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.
Do you have any special use case in mind to make this variable global? I think a function like ng_pktbuf_stats()
that is just available if compiled with DEVELHELP
and that just prints this kind of data should be sufficient.
de2c34b
to
4c067bb
Compare
Rebased to master and addressed comments |
4c067bb
to
1316753
Compare
Rebased to current master. Somebody cares to ACK? There are people waiting for this PR to get merged! |
I think there might be still room for improvement in the implementation in terms of code efficiency - but that is something for later. From my perspective the code looks fine -> ACK when squashed. |
2fa8a01
to
41f60ac
Compare
Squashed, rebased and changed commit summary |
Travis only failed due to the label still being present.. |
pktbuf: port to use pkt_t instead of void*
Depends on #2158(merged)Depends on #2440(merged)Prevents users from misusing packet buffer as malloc replacement and allows for executing hold/replace mechanism on associated headers, too.