diff options
author | David S. Miller <davem@davemloft.net> | 2008-09-23 03:50:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-09-23 03:50:13 -0400 |
commit | cd07a8ea0dd4b204919b4c9ced8d9efdd9924495 (patch) | |
tree | 1b8e24706b806ea3070ad335d98cd7d2daa4d4c8 | |
parent | 1164f52a244204830c7625b3c22812781996d7b4 (diff) |
tcp: Use SKB queue handling interfaces instead of by-hand versions.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/tcp.h | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 5c5327e9a557..12c9b4fec040 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -1181,49 +1181,45 @@ static inline void tcp_write_queue_purge(struct sock *sk) | |||
1181 | 1181 | ||
1182 | static inline struct sk_buff *tcp_write_queue_head(struct sock *sk) | 1182 | static inline struct sk_buff *tcp_write_queue_head(struct sock *sk) |
1183 | { | 1183 | { |
1184 | struct sk_buff *skb = sk->sk_write_queue.next; | 1184 | return skb_peek(&sk->sk_write_queue); |
1185 | if (skb == (struct sk_buff *) &sk->sk_write_queue) | ||
1186 | return NULL; | ||
1187 | return skb; | ||
1188 | } | 1185 | } |
1189 | 1186 | ||
1190 | static inline struct sk_buff *tcp_write_queue_tail(struct sock *sk) | 1187 | static inline struct sk_buff *tcp_write_queue_tail(struct sock *sk) |
1191 | { | 1188 | { |
1192 | struct sk_buff *skb = sk->sk_write_queue.prev; | 1189 | return skb_peek_tail(&sk->sk_write_queue); |
1193 | if (skb == (struct sk_buff *) &sk->sk_write_queue) | ||
1194 | return NULL; | ||
1195 | return skb; | ||
1196 | } | 1190 | } |
1197 | 1191 | ||
1198 | static inline struct sk_buff *tcp_write_queue_next(struct sock *sk, struct sk_buff *skb) | 1192 | static inline struct sk_buff *tcp_write_queue_next(struct sock *sk, struct sk_buff *skb) |
1199 | { | 1193 | { |
1200 | return skb->next; | 1194 | return skb_queue_next(&sk->sk_write_queue, skb); |
1201 | } | 1195 | } |
1202 | 1196 | ||
1203 | #define tcp_for_write_queue(skb, sk) \ | 1197 | #define tcp_for_write_queue(skb, sk) \ |
1204 | for (skb = (sk)->sk_write_queue.next; \ | 1198 | skb_queue_walk(&(sk)->sk_write_queue, skb) |
1205 | (skb != (struct sk_buff *)&(sk)->sk_write_queue); \ | ||
1206 | skb = skb->next) | ||
1207 | 1199 | ||
1208 | #define tcp_for_write_queue_from(skb, sk) \ | 1200 | #define tcp_for_write_queue_from(skb, sk) \ |
1209 | for (; (skb != (struct sk_buff *)&(sk)->sk_write_queue);\ | 1201 | skb_queue_walk_from(&(sk)->sk_write_queue, skb) |
1210 | skb = skb->next) | ||
1211 | 1202 | ||
1212 | #define tcp_for_write_queue_from_safe(skb, tmp, sk) \ | 1203 | #define tcp_for_write_queue_from_safe(skb, tmp, sk) \ |
1213 | for (tmp = skb->next; \ | 1204 | skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp) |
1214 | (skb != (struct sk_buff *)&(sk)->sk_write_queue); \ | ||
1215 | skb = tmp, tmp = skb->next) | ||
1216 | 1205 | ||
1217 | static inline struct sk_buff *tcp_send_head(struct sock *sk) | 1206 | static inline struct sk_buff *tcp_send_head(struct sock *sk) |
1218 | { | 1207 | { |
1219 | return sk->sk_send_head; | 1208 | return sk->sk_send_head; |
1220 | } | 1209 | } |
1221 | 1210 | ||
1211 | static inline bool tcp_skb_is_last(const struct sock *sk, | ||
1212 | const struct sk_buff *skb) | ||
1213 | { | ||
1214 | return skb_queue_is_last(&sk->sk_write_queue, skb); | ||
1215 | } | ||
1216 | |||
1222 | static inline void tcp_advance_send_head(struct sock *sk, struct sk_buff *skb) | 1217 | static inline void tcp_advance_send_head(struct sock *sk, struct sk_buff *skb) |
1223 | { | 1218 | { |
1224 | sk->sk_send_head = skb->next; | 1219 | if (tcp_skb_is_last(sk, skb)) |
1225 | if (sk->sk_send_head == (struct sk_buff *)&sk->sk_write_queue) | ||
1226 | sk->sk_send_head = NULL; | 1220 | sk->sk_send_head = NULL; |
1221 | else | ||
1222 | sk->sk_send_head = tcp_write_queue_next(sk, skb); | ||
1227 | } | 1223 | } |
1228 | 1224 | ||
1229 | static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unlinked) | 1225 | static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unlinked) |
@@ -1284,12 +1280,6 @@ static inline void tcp_unlink_write_queue(struct sk_buff *skb, struct sock *sk) | |||
1284 | __skb_unlink(skb, &sk->sk_write_queue); | 1280 | __skb_unlink(skb, &sk->sk_write_queue); |
1285 | } | 1281 | } |
1286 | 1282 | ||
1287 | static inline bool tcp_skb_is_last(const struct sock *sk, | ||
1288 | const struct sk_buff *skb) | ||
1289 | { | ||
1290 | return skb_queue_is_last(&sk->sk_write_queue, skb); | ||
1291 | } | ||
1292 | |||
1293 | static inline int tcp_write_queue_empty(struct sock *sk) | 1283 | static inline int tcp_write_queue_empty(struct sock *sk) |
1294 | { | 1284 | { |
1295 | return skb_queue_empty(&sk->sk_write_queue); | 1285 | return skb_queue_empty(&sk->sk_write_queue); |