diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2007-03-27 17:55:52 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:28:23 -0400 |
commit | d626f62b11e00c16e81e4308ab93d3f13551812a (patch) | |
tree | fac4af6ced853755e12fc709d55f0c2bec51265d /net/core | |
parent | 2a123b86e2b242a4a6db990d2851d45e192f88e5 (diff) |
[SK_BUFF]: Introduce skb_copy_from_linear_data{_offset}
To clearly state the intent of copying from linear sk_buffs, _offset being a
overly long variant but interesting for the sake of saving some bytes.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/skbuff.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index f16c72204cf6..17c6bb5927b6 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -576,7 +576,7 @@ struct sk_buff *pskb_copy(struct sk_buff *skb, gfp_t gfp_mask) | |||
576 | /* Set the tail pointer and length */ | 576 | /* Set the tail pointer and length */ |
577 | skb_put(n, skb_headlen(skb)); | 577 | skb_put(n, skb_headlen(skb)); |
578 | /* Copy the bytes */ | 578 | /* Copy the bytes */ |
579 | memcpy(n->data, skb->data, n->len); | 579 | skb_copy_from_linear_data(skb, n->data, n->len); |
580 | n->csum = skb->csum; | 580 | n->csum = skb->csum; |
581 | n->ip_summed = skb->ip_summed; | 581 | n->ip_summed = skb->ip_summed; |
582 | 582 | ||
@@ -1043,7 +1043,7 @@ int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len) | |||
1043 | if ((copy = start - offset) > 0) { | 1043 | if ((copy = start - offset) > 0) { |
1044 | if (copy > len) | 1044 | if (copy > len) |
1045 | copy = len; | 1045 | copy = len; |
1046 | memcpy(to, skb->data + offset, copy); | 1046 | skb_copy_from_linear_data_offset(skb, offset, to, copy); |
1047 | if ((len -= copy) == 0) | 1047 | if ((len -= copy) == 0) |
1048 | return 0; | 1048 | return 0; |
1049 | offset += copy; | 1049 | offset += copy; |
@@ -1362,7 +1362,7 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to) | |||
1362 | 1362 | ||
1363 | BUG_ON(csstart > skb_headlen(skb)); | 1363 | BUG_ON(csstart > skb_headlen(skb)); |
1364 | 1364 | ||
1365 | memcpy(to, skb->data, csstart); | 1365 | skb_copy_from_linear_data(skb, to, csstart); |
1366 | 1366 | ||
1367 | csum = 0; | 1367 | csum = 0; |
1368 | if (csstart != skb->len) | 1368 | if (csstart != skb->len) |
@@ -1536,8 +1536,8 @@ static inline void skb_split_inside_header(struct sk_buff *skb, | |||
1536 | { | 1536 | { |
1537 | int i; | 1537 | int i; |
1538 | 1538 | ||
1539 | memcpy(skb_put(skb1, pos - len), skb->data + len, pos - len); | 1539 | skb_copy_from_linear_data_offset(skb, len, skb_put(skb1, pos - len), |
1540 | 1540 | pos - len); | |
1541 | /* And move data appendix as is. */ | 1541 | /* And move data appendix as is. */ |
1542 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) | 1542 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) |
1543 | skb_shinfo(skb1)->frags[i] = skb_shinfo(skb)->frags[i]; | 1543 | skb_shinfo(skb1)->frags[i] = skb_shinfo(skb)->frags[i]; |
@@ -1927,8 +1927,8 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features) | |||
1927 | skb_set_network_header(nskb, skb->mac_len); | 1927 | skb_set_network_header(nskb, skb->mac_len); |
1928 | nskb->transport_header = (nskb->network_header + | 1928 | nskb->transport_header = (nskb->network_header + |
1929 | skb_network_header_len(skb)); | 1929 | skb_network_header_len(skb)); |
1930 | memcpy(skb_put(nskb, doffset), skb->data, doffset); | 1930 | skb_copy_from_linear_data(skb, skb_put(nskb, doffset), |
1931 | 1931 | doffset); | |
1932 | if (!sg) { | 1932 | if (!sg) { |
1933 | nskb->csum = skb_copy_and_csum_bits(skb, offset, | 1933 | nskb->csum = skb_copy_and_csum_bits(skb, offset, |
1934 | skb_put(nskb, len), | 1934 | skb_put(nskb, len), |
@@ -1941,7 +1941,8 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features) | |||
1941 | 1941 | ||
1942 | nskb->ip_summed = CHECKSUM_PARTIAL; | 1942 | nskb->ip_summed = CHECKSUM_PARTIAL; |
1943 | nskb->csum = skb->csum; | 1943 | nskb->csum = skb->csum; |
1944 | memcpy(skb_put(nskb, hsize), skb->data + offset, hsize); | 1944 | skb_copy_from_linear_data_offset(skb, offset, |
1945 | skb_put(nskb, hsize), hsize); | ||
1945 | 1946 | ||
1946 | while (pos < offset + len) { | 1947 | while (pos < offset + len) { |
1947 | BUG_ON(i >= nfrags); | 1948 | BUG_ON(i >= nfrags); |