aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/sctp
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/sctp')
-rw-r--r--include/net/sctp/constants.h4
-rw-r--r--include/net/sctp/sctp.h10
-rw-r--r--include/net/sctp/sm.h3
-rw-r--r--include/net/sctp/structs.h34
-rw-r--r--include/net/sctp/tsnmap.h53
5 files changed, 38 insertions, 66 deletions
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index c32ddf0279c8..b05b0557211f 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -261,7 +261,9 @@ enum { SCTP_ARBITRARY_COOKIE_ECHO_LEN = 200 };
261 * must be less than 65535 (2^16 - 1), or we will have overflow 261 * must be less than 65535 (2^16 - 1), or we will have overflow
262 * problems creating SACK's. 262 * problems creating SACK's.
263 */ 263 */
264#define SCTP_TSN_MAP_SIZE 2048 264#define SCTP_TSN_MAP_INITIAL BITS_PER_LONG
265#define SCTP_TSN_MAP_INCREMENT SCTP_TSN_MAP_INITIAL
266#define SCTP_TSN_MAP_SIZE 4096
265#define SCTP_TSN_MAX_GAP 65535 267#define SCTP_TSN_MAX_GAP 65535
266 268
267/* We will not record more than this many duplicate TSNs between two 269/* We will not record more than this many duplicate TSNs between two
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 17b932b8a55a..703305d00365 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -406,10 +406,7 @@ struct sctp_association *sctp_id2assoc(struct sock *sk, sctp_assoc_t id);
406 406
407/* A macro to walk a list of skbs. */ 407/* A macro to walk a list of skbs. */
408#define sctp_skb_for_each(pos, head, tmp) \ 408#define sctp_skb_for_each(pos, head, tmp) \
409for (pos = (head)->next;\ 409 skb_queue_walk_safe(head, pos, tmp)
410 tmp = (pos)->next, pos != ((struct sk_buff *)(head));\
411 pos = tmp)
412
413 410
414/* A helper to append an entire skb list (list) to another (head). */ 411/* A helper to append an entire skb list (list) to another (head). */
415static inline void sctp_skb_list_tail(struct sk_buff_head *list, 412static inline void sctp_skb_list_tail(struct sk_buff_head *list,
@@ -420,10 +417,7 @@ static inline void sctp_skb_list_tail(struct sk_buff_head *list,
420 sctp_spin_lock_irqsave(&head->lock, flags); 417 sctp_spin_lock_irqsave(&head->lock, flags);
421 sctp_spin_lock(&list->lock); 418 sctp_spin_lock(&list->lock);
422 419
423 list_splice((struct list_head *)list, (struct list_head *)head->prev); 420 skb_queue_splice_tail_init(list, head);
424
425 head->qlen += list->qlen;
426 list->qlen = 0;
427 421
428 sctp_spin_unlock(&list->lock); 422 sctp_spin_unlock(&list->lock);
429 sctp_spin_unlock_irqrestore(&head->lock, flags); 423 sctp_spin_unlock_irqrestore(&head->lock, flags);
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 24811732bdb2..029a54a02396 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -227,6 +227,9 @@ struct sctp_chunk *sctp_make_abort_violation(const struct sctp_association *,
227 const struct sctp_chunk *, 227 const struct sctp_chunk *,
228 const __u8 *, 228 const __u8 *,
229 const size_t ); 229 const size_t );
230struct sctp_chunk *sctp_make_violation_paramlen(const struct sctp_association *,
231 const struct sctp_chunk *,
232 struct sctp_paramhdr *);
230struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *, 233struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *,
231 const struct sctp_transport *, 234 const struct sctp_transport *,
232 const void *payload, 235 const void *payload,
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index ab1c472ea753..9661d7b765f0 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -731,20 +731,23 @@ struct sctp_chunk {
731 */ 731 */
732 struct sk_buff *auth_chunk; 732 struct sk_buff *auth_chunk;
733 733
734 __u8 rtt_in_progress; /* Is this chunk used for RTT calculation? */ 734#define SCTP_CAN_FRTX 0x0
735 __u8 resent; /* Has this chunk ever been retransmitted. */ 735#define SCTP_NEED_FRTX 0x1
736 __u8 has_tsn; /* Does this chunk have a TSN yet? */ 736#define SCTP_DONT_FRTX 0x2
737 __u8 has_ssn; /* Does this chunk have a SSN yet? */ 737 __u16 rtt_in_progress:1, /* This chunk used for RTT calc? */
738 __u8 singleton; /* Was this the only chunk in the packet? */ 738 resent:1, /* Has this chunk ever been resent. */
739 __u8 end_of_packet; /* Was this the last chunk in the packet? */ 739 has_tsn:1, /* Does this chunk have a TSN yet? */
740 __u8 ecn_ce_done; /* Have we processed the ECN CE bit? */ 740 has_ssn:1, /* Does this chunk have a SSN yet? */
741 __u8 pdiscard; /* Discard the whole packet now? */ 741 singleton:1, /* Only chunk in the packet? */
742 __u8 tsn_gap_acked; /* Is this chunk acked by a GAP ACK? */ 742 end_of_packet:1, /* Last chunk in the packet? */
743 __s8 fast_retransmit; /* Is this chunk fast retransmitted? */ 743 ecn_ce_done:1, /* Have we processed the ECN CE bit? */
744 __u8 tsn_missing_report; /* Data chunk missing counter. */ 744 pdiscard:1, /* Discard the whole packet now? */
745 __u8 data_accepted; /* At least 1 chunk in this packet accepted */ 745 tsn_gap_acked:1, /* Is this chunk acked by a GAP ACK? */
746 __u8 auth; /* IN: was auth'ed | OUT: needs auth */ 746 data_accepted:1, /* At least 1 chunk accepted */
747 __u8 has_asconf; /* IN: have seen an asconf before */ 747 auth:1, /* IN: was auth'ed | OUT: needs auth */
748 has_asconf:1, /* IN: have seen an asconf before */
749 tsn_missing_report:2, /* Data chunk missing counter. */
750 fast_retransmit:2; /* Is this chunk fast retransmitted? */
748}; 751};
749 752
750void sctp_chunk_hold(struct sctp_chunk *); 753void sctp_chunk_hold(struct sctp_chunk *);
@@ -1225,7 +1228,7 @@ int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len,
1225 1228
1226sctp_scope_t sctp_scope(const union sctp_addr *); 1229sctp_scope_t sctp_scope(const union sctp_addr *);
1227int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope); 1230int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope);
1228int sctp_is_any(const union sctp_addr *addr); 1231int sctp_is_any(struct sock *sk, const union sctp_addr *addr);
1229int sctp_addr_is_valid(const union sctp_addr *addr); 1232int sctp_addr_is_valid(const union sctp_addr *addr);
1230 1233
1231 1234
@@ -1542,7 +1545,6 @@ struct sctp_association {
1542 * in tsn_map--we get it by calling sctp_tsnmap_get_ctsn(). 1545 * in tsn_map--we get it by calling sctp_tsnmap_get_ctsn().
1543 */ 1546 */
1544 struct sctp_tsnmap tsn_map; 1547 struct sctp_tsnmap tsn_map;
1545 __u8 _map[sctp_tsnmap_storage_size(SCTP_TSN_MAP_SIZE)];
1546 1548
1547 /* Ack State : This flag indicates if the next received 1549 /* Ack State : This flag indicates if the next received
1548 * : packet is to be responded to with a 1550 * : packet is to be responded to with a
diff --git a/include/net/sctp/tsnmap.h b/include/net/sctp/tsnmap.h
index 099211bf998d..4aabc5a96cf6 100644
--- a/include/net/sctp/tsnmap.h
+++ b/include/net/sctp/tsnmap.h
@@ -60,18 +60,7 @@ struct sctp_tsnmap {
60 * It points at one of the two buffers with which we will 60 * It points at one of the two buffers with which we will
61 * ping-pong between. 61 * ping-pong between.
62 */ 62 */
63 __u8 *tsn_map; 63 unsigned long *tsn_map;
64
65 /* This marks the tsn which overflows the tsn_map, when the
66 * cumulative ack point reaches this point we know we can switch
67 * maps (tsn_map and overflow_map swap).
68 */
69 __u32 overflow_tsn;
70
71 /* This is the overflow array for tsn_map.
72 * It points at one of the other ping-pong buffers.
73 */
74 __u8 *overflow_map;
75 64
76 /* This is the TSN at tsn_map[0]. */ 65 /* This is the TSN at tsn_map[0]. */
77 __u32 base_tsn; 66 __u32 base_tsn;
@@ -89,15 +78,15 @@ struct sctp_tsnmap {
89 */ 78 */
90 __u32 cumulative_tsn_ack_point; 79 __u32 cumulative_tsn_ack_point;
91 80
81 /* This is the highest TSN we've marked. */
82 __u32 max_tsn_seen;
83
92 /* This is the minimum number of TSNs we can track. This corresponds 84 /* This is the minimum number of TSNs we can track. This corresponds
93 * to the size of tsn_map. Note: the overflow_map allows us to 85 * to the size of tsn_map. Note: the overflow_map allows us to
94 * potentially track more than this quantity. 86 * potentially track more than this quantity.
95 */ 87 */
96 __u16 len; 88 __u16 len;
97 89
98 /* This is the highest TSN we've marked. */
99 __u32 max_tsn_seen;
100
101 /* Data chunks pending receipt. used by SCTP_STATUS sockopt */ 90 /* Data chunks pending receipt. used by SCTP_STATUS sockopt */
102 __u16 pending_data; 91 __u16 pending_data;
103 92
@@ -105,29 +94,19 @@ struct sctp_tsnmap {
105 * every SACK. Store up to SCTP_MAX_DUP_TSNS worth of 94 * every SACK. Store up to SCTP_MAX_DUP_TSNS worth of
106 * information. 95 * information.
107 */ 96 */
108 __be32 dup_tsns[SCTP_MAX_DUP_TSNS];
109 __u16 num_dup_tsns; 97 __u16 num_dup_tsns;
110 98 __be32 dup_tsns[SCTP_MAX_DUP_TSNS];
111 /* Record gap ack block information here. */
112 struct sctp_gap_ack_block gabs[SCTP_MAX_GABS];
113
114 int malloced;
115
116 __u8 raw_map[0];
117}; 99};
118 100
119struct sctp_tsnmap_iter { 101struct sctp_tsnmap_iter {
120 __u32 start; 102 __u32 start;
121}; 103};
122 104
123/* This macro assists in creation of external storage for variable length
124 * internal buffers. We double allocate so the overflow map works.
125 */
126#define sctp_tsnmap_storage_size(count) (sizeof(__u8) * (count) * 2)
127
128/* Initialize a block of memory as a tsnmap. */ 105/* Initialize a block of memory as a tsnmap. */
129struct sctp_tsnmap *sctp_tsnmap_init(struct sctp_tsnmap *, __u16 len, 106struct sctp_tsnmap *sctp_tsnmap_init(struct sctp_tsnmap *, __u16 len,
130 __u32 initial_tsn); 107 __u32 initial_tsn, gfp_t gfp);
108
109void sctp_tsnmap_free(struct sctp_tsnmap *map);
131 110
132/* Test the tracking state of this TSN. 111/* Test the tracking state of this TSN.
133 * Returns: 112 * Returns:
@@ -138,7 +117,7 @@ struct sctp_tsnmap *sctp_tsnmap_init(struct sctp_tsnmap *, __u16 len,
138int sctp_tsnmap_check(const struct sctp_tsnmap *, __u32 tsn); 117int sctp_tsnmap_check(const struct sctp_tsnmap *, __u32 tsn);
139 118
140/* Mark this TSN as seen. */ 119/* Mark this TSN as seen. */
141void sctp_tsnmap_mark(struct sctp_tsnmap *, __u32 tsn); 120int sctp_tsnmap_mark(struct sctp_tsnmap *, __u32 tsn);
142 121
143/* Mark this TSN and all lower as seen. */ 122/* Mark this TSN and all lower as seen. */
144void sctp_tsnmap_skip(struct sctp_tsnmap *map, __u32 tsn); 123void sctp_tsnmap_skip(struct sctp_tsnmap *map, __u32 tsn);
@@ -169,24 +148,16 @@ static inline __be32 *sctp_tsnmap_get_dups(struct sctp_tsnmap *map)
169} 148}
170 149
171/* How many gap ack blocks do we have recorded? */ 150/* How many gap ack blocks do we have recorded? */
172__u16 sctp_tsnmap_num_gabs(struct sctp_tsnmap *map); 151__u16 sctp_tsnmap_num_gabs(struct sctp_tsnmap *map,
152 struct sctp_gap_ack_block *gabs);
173 153
174/* Refresh the count on pending data. */ 154/* Refresh the count on pending data. */
175__u16 sctp_tsnmap_pending(struct sctp_tsnmap *map); 155__u16 sctp_tsnmap_pending(struct sctp_tsnmap *map);
176 156
177/* Return pointer to gap ack blocks as needed by SACK. */
178static inline struct sctp_gap_ack_block *sctp_tsnmap_get_gabs(struct sctp_tsnmap *map)
179{
180 return map->gabs;
181}
182
183/* Is there a gap in the TSN map? */ 157/* Is there a gap in the TSN map? */
184static inline int sctp_tsnmap_has_gap(const struct sctp_tsnmap *map) 158static inline int sctp_tsnmap_has_gap(const struct sctp_tsnmap *map)
185{ 159{
186 int has_gap; 160 return (map->cumulative_tsn_ack_point != map->max_tsn_seen);
187
188 has_gap = (map->cumulative_tsn_ack_point != map->max_tsn_seen);
189 return has_gap;
190} 161}
191 162
192/* Mark a duplicate TSN. Note: limit the storage of duplicate TSN 163/* Mark a duplicate TSN. Note: limit the storage of duplicate TSN