]> www.infradead.org Git - users/jedix/linux-maple.git/commit
skbuff: Add pskb_extract() helper function
authorSowmini Varadhan <sowmini.varadhan@oracle.com>
Tue, 26 Apr 2016 10:51:46 +0000 (03:51 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Sun, 15 May 2016 16:13:22 +0000 (09:13 -0700)
commitb818346fc47b34c29f5d3aea9cca8404dbdc17f6
tree33ddf06f7be5e12c5e74f242205515d870ed17cf
parent80c1b26051c9aabd6cd7b7f40d73fc0e7fde8617
skbuff: Add pskb_extract() helper function

Orabug 23180876

Upstream commit 6fa01ccd8830 ("skbuff: Add pskb_extract() helper function")

A pattern of skb usage seen in modules such as RDS-TCP is to
extract `to_copy' bytes from the received TCP segment, starting
at some offset `off' into a new skb `clone'. This is done in
the ->data_ready callback, where the clone skb is queued up for rx on
the PF_RDS socket, while the parent TCP segment is returned unchanged
back to the TCP engine.

The existing code uses the sequence
        clone = skb_clone(..);
        pskb_pull(clone, off, ..);
        pskb_trim(clone, to_copy, ..);
with the intention of discarding the first `off' bytes. However,
skb_clone() + pskb_pull() implies pksb_expand_head(), which ends
up doing a redundant memcpy of bytes that will then get discarded
in __pskb_pull_tail().

To avoid this inefficiency, this commit adds pskb_extract() that
creates the clone, and memcpy's only the relevant header/frag/frag_list
to the start of `clone'. pskb_trim() is then invoked to trim clone
down to the requested to_copy bytes.

Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
net/core/skbuff.c