* [PATCH net-next 1/3] skbuff: Add skb_list_linearize()
@ 2015-01-20 20:25 Pravin B Shelar
2015-01-20 21:16 ` Harout Hedeshian
2015-01-20 21:43 ` Eric Dumazet
0 siblings, 2 replies; 5+ messages in thread
From: Pravin B Shelar @ 2015-01-20 20:25 UTC (permalink / raw)
To: davem; +Cc: netdev, Pravin B Shelar
similar to skb_linearize(), this API takes skb list as arg and
linearize it into one big skb. STT driver patch will use this.
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
include/linux/skbuff.h | 2 ++
net/core/skbuff.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 85ab7d7..c9194c1 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2532,6 +2532,8 @@ static inline int skb_linearize(struct sk_buff *skb)
return skb_is_nonlinear(skb) ? __skb_linearize(skb) : 0;
}
+int skb_list_linearize(struct sk_buff *head, gfp_t gfp_mask);
+
/**
* skb_has_shared_frag - can any frag be overwritten
* @skb: buffer to test
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 56db472..9ef2881 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2329,6 +2329,41 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
}
EXPORT_SYMBOL(skb_copy_and_csum_dev);
+int skb_list_linearize(struct sk_buff *head, gfp_t gfp_mask)
+{
+ struct sk_buff *skb;
+ int tlen = 0;
+ int err;
+
+ err = skb_linearize(head);
+ if (err)
+ return err;
+
+ skb = head->next;
+ while (skb) {
+ tlen += skb->len;
+ skb = skb->next;
+ }
+ err = pskb_expand_head(head, 0, tlen, gfp_mask);
+ if (err)
+ return err;
+
+ skb = head->next;
+ while (skb) {
+ err = skb_copy_bits(skb, 0, skb_tail_pointer(head), skb->len);
+ if (err)
+ return err;
+ head->tail += skb->len;
+ skb = skb->next;
+ }
+ kfree_skb_list(head->next);
+ head->next = NULL;
+ head->len += tlen;
+ head->truesize = SKB_TRUESIZE(skb_end_offset(head));
+ return 0;
+}
+EXPORT_SYMBOL(skb_list_linearize);
+
/**
* skb_dequeue - remove from the head of the queue
* @list: list to dequeue from
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* RE: [PATCH net-next 1/3] skbuff: Add skb_list_linearize()
2015-01-20 20:25 [PATCH net-next 1/3] skbuff: Add skb_list_linearize() Pravin B Shelar
@ 2015-01-20 21:16 ` Harout Hedeshian
2015-01-20 21:43 ` Eric Dumazet
1 sibling, 0 replies; 5+ messages in thread
From: Harout Hedeshian @ 2015-01-20 21:16 UTC (permalink / raw)
To: 'Pravin B Shelar', davem; +Cc: netdev
> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]
> On Behalf Of Pravin B Shelar
> Sent: Tuesday, January 20, 2015 1:26 PM
> To: davem@davemloft.net
> Cc: netdev@vger.kernel.org; Pravin B Shelar
> Subject: [PATCH net-next 1/3] skbuff: Add skb_list_linearize()
>
> similar to skb_linearize(), this API takes skb list as arg and linearize
> it into one big skb. STT driver patch will use this.
>
> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
> ---
> include/linux/skbuff.h | 2 ++
> net/core/skbuff.c | 35 +++++++++++++++++++++++++++++++++++
> 2 files changed, 37 insertions(+)
>
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index
> 85ab7d7..c9194c1 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -2532,6 +2532,8 @@ static inline int skb_linearize(struct sk_buff
> *skb)
> return skb_is_nonlinear(skb) ? __skb_linearize(skb) : 0; }
>
> +int skb_list_linearize(struct sk_buff *head, gfp_t gfp_mask);
> +
> /**
> * skb_has_shared_frag - can any frag be overwritten
> * @skb: buffer to test
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c index
> 56db472..9ef2881 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -2329,6 +2329,41 @@ void skb_copy_and_csum_dev(const struct sk_buff
> *skb, u8 *to) } EXPORT_SYMBOL(skb_copy_and_csum_dev);
>
> +int skb_list_linearize(struct sk_buff *head, gfp_t gfp_mask) {
> + struct sk_buff *skb;
> + int tlen = 0;
> + int err;
> +
> + err = skb_linearize(head);
> + if (err)
> + return err;
> +
> + skb = head->next;
> + while (skb) {
> + tlen += skb->len;
> + skb = skb->next;
> + }
> + err = pskb_expand_head(head, 0, tlen, gfp_mask);
> + if (err)
> + return err;
> +
> + skb = head->next;
> + while (skb) {
> + err = skb_copy_bits(skb, 0, skb_tail_pointer(head),
skb->len);
> + if (err)
> + return err;
> + head->tail += skb->len;
> + skb = skb->next;
> + }
> + kfree_skb_list(head->next);
> + head->next = NULL;
> + head->len += tlen;
> + head->truesize = SKB_TRUESIZE(skb_end_offset(head));
> + return 0;
> +}
> +EXPORT_SYMBOL(skb_list_linearize);
> +
> /**
> * skb_dequeue - remove from the head of the queue
> * @list: list to dequeue from
> --
> 1.9.1
>
This looks useful for us as well.
Acked-by: Harout Hedeshian <harouth@codeaurora.org>
Thanks,
Harout
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux
Foundation Collaborative Project
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 1/3] skbuff: Add skb_list_linearize()
2015-01-20 20:25 [PATCH net-next 1/3] skbuff: Add skb_list_linearize() Pravin B Shelar
2015-01-20 21:16 ` Harout Hedeshian
@ 2015-01-20 21:43 ` Eric Dumazet
2015-01-20 22:46 ` Pravin Shelar
1 sibling, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2015-01-20 21:43 UTC (permalink / raw)
To: Pravin B Shelar; +Cc: davem, netdev
On Tue, 2015-01-20 at 12:25 -0800, Pravin B Shelar wrote:
> similar to skb_linearize(), this API takes skb list as arg and
> linearize it into one big skb. STT driver patch will use this.
>
> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
> ---
> include/linux/skbuff.h | 2 ++
> net/core/skbuff.c | 35 +++++++++++++++++++++++++++++++++++
> 2 files changed, 37 insertions(+)
>
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index 85ab7d7..c9194c1 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -2532,6 +2532,8 @@ static inline int skb_linearize(struct sk_buff *skb)
> return skb_is_nonlinear(skb) ? __skb_linearize(skb) : 0;
> }
>
> +int skb_list_linearize(struct sk_buff *head, gfp_t gfp_mask);
> +
> /**
> * skb_has_shared_frag - can any frag be overwritten
> * @skb: buffer to test
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 56db472..9ef2881 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -2329,6 +2329,41 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
> }
> EXPORT_SYMBOL(skb_copy_and_csum_dev);
>
> +int skb_list_linearize(struct sk_buff *head, gfp_t gfp_mask)
> +{
> + struct sk_buff *skb;
> + int tlen = 0;
> + int err;
> +
> + err = skb_linearize(head);
> + if (err)
> + return err;
> +
> + skb = head->next;
> + while (skb) {
> + tlen += skb->len;
> + skb = skb->next;
> + }
> + err = pskb_expand_head(head, 0, tlen, gfp_mask);
> + if (err)
> + return err;
> +
> + skb = head->next;
> + while (skb) {
> + err = skb_copy_bits(skb, 0, skb_tail_pointer(head), skb->len);
> + if (err)
> + return err;
> + head->tail += skb->len;
> + skb = skb->next;
> + }
> + kfree_skb_list(head->next);
> + head->next = NULL;
> + head->len += tlen;
> + head->truesize = SKB_TRUESIZE(skb_end_offset(head));
This is buggy : skb can have a destructor, like sock_wfree()
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 1/3] skbuff: Add skb_list_linearize()
2015-01-20 21:43 ` Eric Dumazet
@ 2015-01-20 22:46 ` Pravin Shelar
2015-01-20 23:51 ` Eric Dumazet
0 siblings, 1 reply; 5+ messages in thread
From: Pravin Shelar @ 2015-01-20 22:46 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev
On Tue, Jan 20, 2015 at 1:43 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Tue, 2015-01-20 at 12:25 -0800, Pravin B Shelar wrote:
>> similar to skb_linearize(), this API takes skb list as arg and
>> linearize it into one big skb. STT driver patch will use this.
>>
>> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
>> ---
...
>> @@ -2329,6 +2329,41 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
>> }
>> EXPORT_SYMBOL(skb_copy_and_csum_dev);
>>
>> +int skb_list_linearize(struct sk_buff *head, gfp_t gfp_mask)
>> +{
>> + struct sk_buff *skb;
>> + int tlen = 0;
>> + int err;
>> +
>> + err = skb_linearize(head);
>> + if (err)
>> + return err;
>> +
>> + skb = head->next;
>> + while (skb) {
>> + tlen += skb->len;
>> + skb = skb->next;
>> + }
>> + err = pskb_expand_head(head, 0, tlen, gfp_mask);
>> + if (err)
>> + return err;
>> +
>> + skb = head->next;
>> + while (skb) {
>> + err = skb_copy_bits(skb, 0, skb_tail_pointer(head), skb->len);
>> + if (err)
>> + return err;
>> + head->tail += skb->len;
>> + skb = skb->next;
>> + }
>> + kfree_skb_list(head->next);
>> + head->next = NULL;
>> + head->len += tlen;
>> + head->truesize = SKB_TRUESIZE(skb_end_offset(head));
>
> This is buggy : skb can have a destructor, like sock_wfree()
>
In current use-case it is never called for skb which is tied to
socket. But I agree it need to be fixed. I can call skb_orphan() to
fix it.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 1/3] skbuff: Add skb_list_linearize()
2015-01-20 22:46 ` Pravin Shelar
@ 2015-01-20 23:51 ` Eric Dumazet
0 siblings, 0 replies; 5+ messages in thread
From: Eric Dumazet @ 2015-01-20 23:51 UTC (permalink / raw)
To: Pravin Shelar; +Cc: David Miller, netdev
On Tue, 2015-01-20 at 14:46 -0800, Pravin Shelar wrote:
> In current use-case it is never called for skb which is tied to
> socket. But I agree it need to be fixed. I can call skb_orphan() to
> fix it.
I would do nothing at all, like skb_linearize()
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-01-20 23:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-20 20:25 [PATCH net-next 1/3] skbuff: Add skb_list_linearize() Pravin B Shelar
2015-01-20 21:16 ` Harout Hedeshian
2015-01-20 21:43 ` Eric Dumazet
2015-01-20 22:46 ` Pravin Shelar
2015-01-20 23:51 ` Eric Dumazet
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.