diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2011-10-18 17:00:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-10-19 03:10:46 -0400 |
commit | 9e903e085262ffbf1fc44a17ac06058aca03524a (patch) | |
tree | 4acefc97ba38c1733474d25c0b2053b56af97db1 /include/linux/skbuff.h | |
parent | dd767856a36e00b631d65ebc4bb81b19915532d6 (diff) |
net: add skb frag size accessors
To ease skb->truesize sanitization, its better to be able to localize
all references to skb frags size.
Define accessors : skb_frag_size() to fetch frag size, and
skb_frag_size_{set|add|sub}() to manipulate it.
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/skbuff.h')
-rw-r--r-- | include/linux/skbuff.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 64f86951ef74..6fcbbbd12ceb 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -150,6 +150,26 @@ struct skb_frag_struct { | |||
150 | #endif | 150 | #endif |
151 | }; | 151 | }; |
152 | 152 | ||
153 | static inline unsigned int skb_frag_size(const skb_frag_t *frag) | ||
154 | { | ||
155 | return frag->size; | ||
156 | } | ||
157 | |||
158 | static inline void skb_frag_size_set(skb_frag_t *frag, unsigned int size) | ||
159 | { | ||
160 | frag->size = size; | ||
161 | } | ||
162 | |||
163 | static inline void skb_frag_size_add(skb_frag_t *frag, int delta) | ||
164 | { | ||
165 | frag->size += delta; | ||
166 | } | ||
167 | |||
168 | static inline void skb_frag_size_sub(skb_frag_t *frag, int delta) | ||
169 | { | ||
170 | frag->size -= delta; | ||
171 | } | ||
172 | |||
153 | #define HAVE_HW_TIME_STAMP | 173 | #define HAVE_HW_TIME_STAMP |
154 | 174 | ||
155 | /** | 175 | /** |
@@ -1132,7 +1152,7 @@ static inline int skb_pagelen(const struct sk_buff *skb) | |||
1132 | int i, len = 0; | 1152 | int i, len = 0; |
1133 | 1153 | ||
1134 | for (i = (int)skb_shinfo(skb)->nr_frags - 1; i >= 0; i--) | 1154 | for (i = (int)skb_shinfo(skb)->nr_frags - 1; i >= 0; i--) |
1135 | len += skb_shinfo(skb)->frags[i].size; | 1155 | len += skb_frag_size(&skb_shinfo(skb)->frags[i]); |
1136 | return len + skb_headlen(skb); | 1156 | return len + skb_headlen(skb); |
1137 | } | 1157 | } |
1138 | 1158 | ||
@@ -1156,7 +1176,7 @@ static inline void __skb_fill_page_desc(struct sk_buff *skb, int i, | |||
1156 | 1176 | ||
1157 | frag->page = page; | 1177 | frag->page = page; |
1158 | frag->page_offset = off; | 1178 | frag->page_offset = off; |
1159 | frag->size = size; | 1179 | skb_frag_size_set(frag, size); |
1160 | } | 1180 | } |
1161 | 1181 | ||
1162 | /** | 1182 | /** |
@@ -1907,10 +1927,10 @@ static inline int skb_can_coalesce(struct sk_buff *skb, int i, | |||
1907 | const struct page *page, int off) | 1927 | const struct page *page, int off) |
1908 | { | 1928 | { |
1909 | if (i) { | 1929 | if (i) { |
1910 | struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1]; | 1930 | const struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1]; |
1911 | 1931 | ||
1912 | return page == skb_frag_page(frag) && | 1932 | return page == skb_frag_page(frag) && |
1913 | off == frag->page_offset + frag->size; | 1933 | off == frag->page_offset + skb_frag_size(frag); |
1914 | } | 1934 | } |
1915 | return 0; | 1935 | return 0; |
1916 | } | 1936 | } |