Skip to content

Commit 0201518

Browse files
Vlad Yasevichdavem330
authored andcommitted
sctp: shrink sctp_tsnmap some more by removing gabs array
The gabs array in the sctp_tsnmap structure is only used in one place, sctp_make_sack(). As such, carrying the array around in the sctp_tsnmap and thus directly in the sctp_association is rather pointless since most of the time it's just taking up space. Now, let sctp_make_sack create and populate it and then throw it away when it's done. Signed-off-by: Vlad Yasevich <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8e1ee18 commit 0201518

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

include/net/sctp/tsnmap.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,8 @@ struct sctp_tsnmap {
9494
* every SACK. Store up to SCTP_MAX_DUP_TSNS worth of
9595
* information.
9696
*/
97-
__be32 dup_tsns[SCTP_MAX_DUP_TSNS];
9897
__u16 num_dup_tsns;
99-
100-
/* Record gap ack block information here. */
101-
struct sctp_gap_ack_block gabs[SCTP_MAX_GABS];
98+
__be32 dup_tsns[SCTP_MAX_DUP_TSNS];
10299
};
103100

104101
struct sctp_tsnmap_iter {
@@ -151,17 +148,12 @@ static inline __be32 *sctp_tsnmap_get_dups(struct sctp_tsnmap *map)
151148
}
152149

153150
/* How many gap ack blocks do we have recorded? */
154-
__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);
155153

156154
/* Refresh the count on pending data. */
157155
__u16 sctp_tsnmap_pending(struct sctp_tsnmap *map);
158156

159-
/* Return pointer to gap ack blocks as needed by SACK. */
160-
static inline struct sctp_gap_ack_block *sctp_tsnmap_get_gabs(struct sctp_tsnmap *map)
161-
{
162-
return map->gabs;
163-
}
164-
165157
/* Is there a gap in the TSN map? */
166158
static inline int sctp_tsnmap_has_gap(const struct sctp_tsnmap *map)
167159
{

net/sctp/sm_make_chunk.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,12 +702,14 @@ struct sctp_chunk *sctp_make_sack(const struct sctp_association *asoc)
702702
__u32 ctsn;
703703
__u16 num_gabs, num_dup_tsns;
704704
struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map;
705+
struct sctp_gap_ack_block gabs[SCTP_MAX_GABS];
705706

707+
memset(gabs, 0, sizeof(gabs));
706708
ctsn = sctp_tsnmap_get_ctsn(map);
707709
SCTP_DEBUG_PRINTK("sackCTSNAck sent: 0x%x.\n", ctsn);
708710

709711
/* How much room is needed in the chunk? */
710-
num_gabs = sctp_tsnmap_num_gabs(map);
712+
num_gabs = sctp_tsnmap_num_gabs(map, gabs);
711713
num_dup_tsns = sctp_tsnmap_num_dups(map);
712714

713715
/* Initialize the SACK header. */
@@ -763,7 +765,7 @@ struct sctp_chunk *sctp_make_sack(const struct sctp_association *asoc)
763765
/* Add the gap ack block information. */
764766
if (num_gabs)
765767
sctp_addto_chunk(retval, sizeof(__u32) * num_gabs,
766-
sctp_tsnmap_get_gabs(map));
768+
gabs);
767769

768770
/* Add the duplicate TSN information. */
769771
if (num_dup_tsns)

net/sctp/tsnmap.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,11 @@ void sctp_tsnmap_renege(struct sctp_tsnmap *map, __u32 tsn)
335335
}
336336

337337
/* How many gap ack blocks do we have recorded? */
338-
__u16 sctp_tsnmap_num_gabs(struct sctp_tsnmap *map)
338+
__u16 sctp_tsnmap_num_gabs(struct sctp_tsnmap *map,
339+
struct sctp_gap_ack_block *gabs)
339340
{
340341
struct sctp_tsnmap_iter iter;
341-
int gabs = 0;
342+
int ngaps = 0;
342343

343344
/* Refresh the gap ack information. */
344345
if (sctp_tsnmap_has_gap(map)) {
@@ -348,14 +349,14 @@ __u16 sctp_tsnmap_num_gabs(struct sctp_tsnmap *map)
348349
&start,
349350
&end)) {
350351

351-
map->gabs[gabs].start = htons(start);
352-
map->gabs[gabs].end = htons(end);
353-
gabs++;
354-
if (gabs >= SCTP_MAX_GABS)
352+
gabs[ngaps].start = htons(start);
353+
gabs[ngaps].end = htons(end);
354+
ngaps++;
355+
if (ngaps >= SCTP_MAX_GABS)
355356
break;
356357
}
357358
}
358-
return gabs;
359+
return ngaps;
359360
}
360361

361362
static int sctp_tsnmap_grow(struct sctp_tsnmap *map, u16 gap)

0 commit comments

Comments
 (0)