aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2015-09-28 08:34:04 -0400
committerDavid S. Miller <davem@davemloft.net>2015-09-29 01:52:21 -0400
commit2103d6b818fcdae15ffa04cf385f770e6c3892c3 (patch)
tree090a856639c742e94a8553f853a36e821b40fe30
parent06a15f51cf3618e32a73871ee6a547ef7fd902b5 (diff)
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>
-rw-r--r--net/sctp/associola.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 197c3f59ecbf..b00f1f9611d6 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -1208,20 +1208,22 @@ void sctp_assoc_update(struct sctp_association *asoc,
1208 * within this document. 1208 * within this document.
1209 * 1209 *
1210 * Our basic strategy is to round-robin transports in priorities 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 * transport with state SCTP_ACTIVE exists, round-robin through 1212 * transport with state SCTP_ACTIVE exists, round-robin through
1213 * SCTP_UNKNOWN, etc. You get the picture. 1213 * SCTP_UNKNOWN, etc. You get the picture.
1214 */ 1214 */
1215static 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
1222static u8 sctp_trans_score(const struct sctp_transport *trans) 1215static 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
1227static struct sctp_transport *sctp_trans_elect_tie(struct sctp_transport *trans1, 1229static struct sctp_transport *sctp_trans_elect_tie(struct sctp_transport *trans1,