aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Campbell <Ian.Campbell@citrix.com>2011-10-19 19:01:49 -0400
committerDavid S. Miller <davem@davemloft.net>2011-10-21 02:52:53 -0400
commita8605c6063f785858c1bc431d0bfe66c41e71cfa (patch)
tree42ce7ce9a1679f09b54353dd1ea05a6581abe754
parent6a39a16a5ac07a156de91cfb9422bde574e59fa6 (diff)
net: add opaque struct around skb frag page
I've split this bit out of the skb frag destructor patch since it helps enforce the use of the fragment API. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/skbuff.h10
-rw-r--r--net/core/skbuff.c6
2 files changed, 9 insertions, 7 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 3411f22e7d16..94a23ffcc073 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -140,7 +140,9 @@ struct sk_buff;
140typedef struct skb_frag_struct skb_frag_t; 140typedef struct skb_frag_struct skb_frag_t;
141 141
142struct skb_frag_struct { 142struct skb_frag_struct {
143 struct page *page; 143 struct {
144 struct page *p;
145 } page;
144#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536) 146#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536)
145 __u32 page_offset; 147 __u32 page_offset;
146 __u32 size; 148 __u32 size;
@@ -1175,7 +1177,7 @@ static inline void __skb_fill_page_desc(struct sk_buff *skb, int i,
1175{ 1177{
1176 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 1178 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1177 1179
1178 frag->page = page; 1180 frag->page.p = page;
1179 frag->page_offset = off; 1181 frag->page_offset = off;
1180 skb_frag_size_set(frag, size); 1182 skb_frag_size_set(frag, size);
1181} 1183}
@@ -1699,7 +1701,7 @@ static inline void netdev_free_page(struct net_device *dev, struct page *page)
1699 */ 1701 */
1700static inline struct page *skb_frag_page(const skb_frag_t *frag) 1702static inline struct page *skb_frag_page(const skb_frag_t *frag)
1701{ 1703{
1702 return frag->page; 1704 return frag->page.p;
1703} 1705}
1704 1706
1705/** 1707/**
@@ -1785,7 +1787,7 @@ static inline void *skb_frag_address_safe(const skb_frag_t *frag)
1785 */ 1787 */
1786static inline void __skb_frag_set_page(skb_frag_t *frag, struct page *page) 1788static inline void __skb_frag_set_page(skb_frag_t *frag, struct page *page)
1787{ 1789{
1788 frag->page = page; 1790 frag->page.p = page;
1789} 1791}
1790 1792
1791/** 1793/**
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e27104039a39..ca4db40e75b8 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -668,14 +668,14 @@ int skb_copy_ubufs(struct sk_buff *skb, gfp_t gfp_mask)
668 668
669 /* skb frags release userspace buffers */ 669 /* skb frags release userspace buffers */
670 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) 670 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
671 put_page(skb_shinfo(skb)->frags[i].page); 671 skb_frag_unref(skb, i);
672 672
673 uarg->callback(uarg); 673 uarg->callback(uarg);
674 674
675 /* skb frags point to kernel buffers */ 675 /* skb frags point to kernel buffers */
676 for (i = skb_shinfo(skb)->nr_frags; i > 0; i--) { 676 for (i = skb_shinfo(skb)->nr_frags; i > 0; i--) {
677 skb_shinfo(skb)->frags[i - 1].page_offset = 0; 677 __skb_fill_page_desc(skb, i-1, head, 0,
678 skb_shinfo(skb)->frags[i - 1].page = head; 678 skb_shinfo(skb)->frags[i - 1].size);
679 head = (struct page *)head->private; 679 head = (struct page *)head->private;
680 } 680 }
681 681