Commit 7976f8f6 authored by David S. Miller's avatar David S. Miller

[NET]: Mark skb_linearize() as deprecated.

parent 80b3ea5b
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/compiler.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/cache.h> #include <linux/cache.h>
...@@ -1127,7 +1128,11 @@ static inline struct sk_buff *skb_padto(struct sk_buff *skb, unsigned int len) ...@@ -1127,7 +1128,11 @@ static inline struct sk_buff *skb_padto(struct sk_buff *skb, unsigned int len)
* If there is no free memory -ENOMEM is returned, otherwise zero * If there is no free memory -ENOMEM is returned, otherwise zero
* is returned and the old skb data released. * is returned and the old skb data released.
*/ */
int skb_linearize(struct sk_buff *skb, int gfp); extern int __skb_linearize(struct sk_buff *skb, int gfp);
static inline int __deprecated skb_linearize(struct sk_buff *skb, int gfp)
{
return __skb_linearize(skb, gfp);
}
static inline void *kmap_skb_frag(const skb_frag_t *frag) static inline void *kmap_skb_frag(const skb_frag_t *frag)
{ {
......
...@@ -1018,6 +1018,66 @@ static inline int illegal_highdma(struct net_device *dev, struct sk_buff *skb) ...@@ -1018,6 +1018,66 @@ static inline int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
#define illegal_highdma(dev, skb) (0) #define illegal_highdma(dev, skb) (0)
#endif #endif
extern void skb_release_data(struct sk_buff *);
/* Keep head the same: replace data */
int __skb_linearize(struct sk_buff *skb, int gfp_mask)
{
unsigned int size;
u8 *data;
long offset;
struct skb_shared_info *ninfo;
int headerlen = skb->data - skb->head;
int expand = (skb->tail + skb->data_len) - skb->end;
if (skb_shared(skb))
BUG();
if (expand <= 0)
expand = 0;
size = skb->end - skb->head + expand;
size = SKB_DATA_ALIGN(size);
data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
if (!data)
return -ENOMEM;
/* Copy entire thing */
if (skb_copy_bits(skb, -headerlen, data, headerlen + skb->len))
BUG();
/* Set up shinfo */
ninfo = (struct skb_shared_info*)(data + size);
atomic_set(&ninfo->dataref, 1);
ninfo->tso_size = skb_shinfo(skb)->tso_size;
ninfo->tso_segs = skb_shinfo(skb)->tso_segs;
ninfo->nr_frags = 0;
ninfo->frag_list = NULL;
/* Offset between the two in bytes */
offset = data - skb->head;
/* Free old data. */
skb_release_data(skb);
skb->head = data;
skb->end = data + size;
/* Set up new pointers */
skb->h.raw += offset;
skb->nh.raw += offset;
skb->mac.raw += offset;
skb->tail += offset;
skb->data += offset;
/* We are no longer a clone, even if we were. */
skb->cloned = 0;
skb->tail += skb->data_len;
skb->data_len = 0;
return 0;
}
/** /**
* dev_queue_xmit - transmit a buffer * dev_queue_xmit - transmit a buffer
* @skb: buffer to transmit * @skb: buffer to transmit
...@@ -1039,7 +1099,7 @@ int dev_queue_xmit(struct sk_buff *skb) ...@@ -1039,7 +1099,7 @@ int dev_queue_xmit(struct sk_buff *skb)
if (skb_shinfo(skb)->frag_list && if (skb_shinfo(skb)->frag_list &&
!(dev->features & NETIF_F_FRAGLIST) && !(dev->features & NETIF_F_FRAGLIST) &&
skb_linearize(skb, GFP_ATOMIC)) __skb_linearize(skb, GFP_ATOMIC))
goto out_kfree_skb; goto out_kfree_skb;
/* Fragmented skb is linearized if device does not support SG, /* Fragmented skb is linearized if device does not support SG,
...@@ -1048,7 +1108,7 @@ int dev_queue_xmit(struct sk_buff *skb) ...@@ -1048,7 +1108,7 @@ int dev_queue_xmit(struct sk_buff *skb)
*/ */
if (skb_shinfo(skb)->nr_frags && if (skb_shinfo(skb)->nr_frags &&
(!(dev->features & NETIF_F_SG) || illegal_highdma(dev, skb)) && (!(dev->features & NETIF_F_SG) || illegal_highdma(dev, skb)) &&
skb_linearize(skb, GFP_ATOMIC)) __skb_linearize(skb, GFP_ATOMIC))
goto out_kfree_skb; goto out_kfree_skb;
/* If packet is not checksummed and device does not support /* If packet is not checksummed and device does not support
...@@ -1356,7 +1416,7 @@ static int deliver_to_old_ones(struct packet_type *pt, ...@@ -1356,7 +1416,7 @@ static int deliver_to_old_ones(struct packet_type *pt,
if (!skb) if (!skb)
goto out; goto out;
} }
if (skb_is_nonlinear(skb) && skb_linearize(skb, GFP_ATOMIC)) if (skb_is_nonlinear(skb) && __skb_linearize(skb, GFP_ATOMIC))
goto out_kfree; goto out_kfree;
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
......
...@@ -181,7 +181,7 @@ static void skb_clone_fraglist(struct sk_buff *skb) ...@@ -181,7 +181,7 @@ static void skb_clone_fraglist(struct sk_buff *skb)
skb_get(list); skb_get(list);
} }
static void skb_release_data(struct sk_buff *skb) void skb_release_data(struct sk_buff *skb)
{ {
if (!skb->cloned || if (!skb->cloned ||
atomic_dec_and_test(&(skb_shinfo(skb)->dataref))) { atomic_dec_and_test(&(skb_shinfo(skb)->dataref))) {
...@@ -412,64 +412,6 @@ struct sk_buff *skb_copy(const struct sk_buff *skb, int gfp_mask) ...@@ -412,64 +412,6 @@ struct sk_buff *skb_copy(const struct sk_buff *skb, int gfp_mask)
return n; return n;
} }
/* Keep head the same: replace data */
int skb_linearize(struct sk_buff *skb, int gfp_mask)
{
unsigned int size;
u8 *data;
long offset;
struct skb_shared_info *ninfo;
int headerlen = skb->data - skb->head;
int expand = (skb->tail + skb->data_len) - skb->end;
if (skb_shared(skb))
BUG();
if (expand <= 0)
expand = 0;
size = skb->end - skb->head + expand;
size = SKB_DATA_ALIGN(size);
data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
if (!data)
return -ENOMEM;
/* Copy entire thing */
if (skb_copy_bits(skb, -headerlen, data, headerlen + skb->len))
BUG();
/* Set up shinfo */
ninfo = (struct skb_shared_info*)(data + size);
atomic_set(&ninfo->dataref, 1);
ninfo->tso_size = skb_shinfo(skb)->tso_size;
ninfo->tso_segs = skb_shinfo(skb)->tso_segs;
ninfo->nr_frags = 0;
ninfo->frag_list = NULL;
/* Offset between the two in bytes */
offset = data - skb->head;
/* Free old data. */
skb_release_data(skb);
skb->head = data;
skb->end = data + size;
/* Set up new pointers */
skb->h.raw += offset;
skb->nh.raw += offset;
skb->mac.raw += offset;
skb->tail += offset;
skb->data += offset;
/* We are no longer a clone, even if we were. */
skb->cloned = 0;
skb->tail += skb->data_len;
skb->data_len = 0;
return 0;
}
/** /**
* pskb_copy - create copy of an sk_buff with private head. * pskb_copy - create copy of an sk_buff with private head.
......
...@@ -148,7 +148,7 @@ EXPORT_SYMBOL(sock_rfree); ...@@ -148,7 +148,7 @@ EXPORT_SYMBOL(sock_rfree);
EXPORT_SYMBOL(sock_wfree); EXPORT_SYMBOL(sock_wfree);
EXPORT_SYMBOL(sock_wmalloc); EXPORT_SYMBOL(sock_wmalloc);
EXPORT_SYMBOL(sock_rmalloc); EXPORT_SYMBOL(sock_rmalloc);
EXPORT_SYMBOL(skb_linearize); EXPORT_SYMBOL(__skb_linearize);
EXPORT_SYMBOL(skb_checksum); EXPORT_SYMBOL(skb_checksum);
EXPORT_SYMBOL(skb_checksum_help); EXPORT_SYMBOL(skb_checksum_help);
EXPORT_SYMBOL(skb_recv_datagram); EXPORT_SYMBOL(skb_recv_datagram);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment