[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHA+R7OufGJEAZ6d7DB6YaCkqXdjDU9bgwjramRtZT=9z_Hk4w@mail.gmail.com>
Date: Wed, 20 May 2015 10:51:22 -0700
From: Cong Wang <cwang@...pensource.com>
To: Hannes Frederic Sowa <hannes@...essinduktion.org>
Cc: netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next 1/4] net: skbuff: add skb_append_pagefrags and
use it
On Wed, May 20, 2015 at 8:35 AM, Hannes Frederic Sowa
<hannes@...essinduktion.org> wrote:
> +int skb_append_pagefrags(struct sk_buff *skb, struct page *page,
> + int offset, size_t size)
> +{
> + int i = skb_shinfo(skb)->nr_frags;
> +
> + if (skb_can_coalesce(skb, i, page, offset)) {
> + skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], size);
> + } else if (i < MAX_SKB_FRAGS) {
> + get_page(page);
> + skb_fill_page_desc(skb, i, page, offset, size);
> + } else {
> + return -EMSGSIZE;
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(skb_append_pagefrags);
> +
> /**
> * skb_pull_rcsum - pull skb and update receive checksum
> * @skb: buffer to update
> diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
> index 8d91b92..35ff40f 100644
> --- a/net/ipv4/ip_output.c
> +++ b/net/ipv4/ip_output.c
> @@ -1292,12 +1292,8 @@ ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page,
> i = skb_shinfo(skb)->nr_frags;
> if (len > size)
> len = size;
> - if (skb_can_coalesce(skb, i, page, offset)) {
> - skb_frag_size_add(&skb_shinfo(skb)->frags[i-1], len);
> - } else if (i < MAX_SKB_FRAGS) {
> - get_page(page);
> - skb_fill_page_desc(skb, i, page, offset, len);
> - } else {
> +
> + if (skb_append_pagefrags(skb, page, offset, len)) {
> err = -EMSGSIZE;
> goto error;
> }
The 'i' can be removed now.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists