diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/skbuff.h | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index fe2c58e5306f..830f58fa03a2 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h | |||
@@ -1169,18 +1169,34 @@ static inline int skb_can_coalesce(struct sk_buff *skb, int i, | |||
1169 | return 0; | 1169 | return 0; |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | static inline int __skb_linearize(struct sk_buff *skb) | ||
1173 | { | ||
1174 | return __pskb_pull_tail(skb, skb->data_len) ? 0 : -ENOMEM; | ||
1175 | } | ||
1176 | |||
1172 | /** | 1177 | /** |
1173 | * skb_linearize - convert paged skb to linear one | 1178 | * skb_linearize - convert paged skb to linear one |
1174 | * @skb: buffer to linarize | 1179 | * @skb: buffer to linarize |
1175 | * @gfp: allocation mode | ||
1176 | * | 1180 | * |
1177 | * If there is no free memory -ENOMEM is returned, otherwise zero | 1181 | * If there is no free memory -ENOMEM is returned, otherwise zero |
1178 | * is returned and the old skb data released. | 1182 | * is returned and the old skb data released. |
1179 | */ | 1183 | */ |
1180 | extern int __skb_linearize(struct sk_buff *skb, gfp_t gfp); | 1184 | static inline int skb_linearize(struct sk_buff *skb) |
1181 | static inline int skb_linearize(struct sk_buff *skb, gfp_t gfp) | 1185 | { |
1186 | return skb_is_nonlinear(skb) ? __skb_linearize(skb) : 0; | ||
1187 | } | ||
1188 | |||
1189 | /** | ||
1190 | * skb_linearize_cow - make sure skb is linear and writable | ||
1191 | * @skb: buffer to process | ||
1192 | * | ||
1193 | * If there is no free memory -ENOMEM is returned, otherwise zero | ||
1194 | * is returned and the old skb data released. | ||
1195 | */ | ||
1196 | static inline int skb_linearize_cow(struct sk_buff *skb) | ||
1182 | { | 1197 | { |
1183 | return __skb_linearize(skb, gfp); | 1198 | return skb_is_nonlinear(skb) || skb_cloned(skb) ? |
1199 | __skb_linearize(skb) : 0; | ||
1184 | } | 1200 | } |
1185 | 1201 | ||
1186 | /** | 1202 | /** |