Commit 2103d6b818fcdae15ffa04cf385f770e6c3892c3
Committed by
David S. Miller
1 parent
06a15f51cf
net: sctp: Don't use 64 kilobyte lookup table for four elements
Seemingly innocuous sctp_trans_state_to_prio_map[] array is way bigger than it looks, since "[SCTP_UNKNOWN] = 2" expands into "[0xffff] = 2" ! This patch replaces it with switch() statement. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com> CC: Vlad Yasevich <vyasevich@gmail.com> CC: Neil Horman <nhorman@tuxdriver.com> CC: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> CC: linux-sctp@vger.kernel.org CC: netdev@vger.kernel.org CC: linux-kernel@vger.kernel.org Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 11 additions and 9 deletions Side-by-side Diff
net/sctp/associola.c
... | ... | @@ -1208,20 +1208,22 @@ |
1208 | 1208 | * within this document. |
1209 | 1209 | * |
1210 | 1210 | * Our basic strategy is to round-robin transports in priorities |
1211 | - * according to sctp_state_prio_map[] e.g., if no such | |
1211 | + * according to sctp_trans_score() e.g., if no such | |
1212 | 1212 | * transport with state SCTP_ACTIVE exists, round-robin through |
1213 | 1213 | * SCTP_UNKNOWN, etc. You get the picture. |
1214 | 1214 | */ |
1215 | -static const u8 sctp_trans_state_to_prio_map[] = { | |
1216 | - [SCTP_ACTIVE] = 3, /* best case */ | |
1217 | - [SCTP_UNKNOWN] = 2, | |
1218 | - [SCTP_PF] = 1, | |
1219 | - [SCTP_INACTIVE] = 0, /* worst case */ | |
1220 | -}; | |
1221 | - | |
1222 | 1215 | static u8 sctp_trans_score(const struct sctp_transport *trans) |
1223 | 1216 | { |
1224 | - return sctp_trans_state_to_prio_map[trans->state]; | |
1217 | + switch (trans->state) { | |
1218 | + case SCTP_ACTIVE: | |
1219 | + return 3; /* best case */ | |
1220 | + case SCTP_UNKNOWN: | |
1221 | + return 2; | |
1222 | + case SCTP_PF: | |
1223 | + return 1; | |
1224 | + default: /* case SCTP_INACTIVE */ | |
1225 | + return 0; /* worst case */ | |
1226 | + } | |
1225 | 1227 | } |
1226 | 1228 | |
1227 | 1229 | static struct sctp_transport *sctp_trans_elect_tie(struct sctp_transport *trans1, |