aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/sctp_input.c
diff options
context:
space:
mode:
authorRandall Stewart <rrs@FreeBSD.org>2011-02-04 13:50:30 +0000
committerRandall Stewart <rrs@FreeBSD.org>2011-02-04 13:50:30 +0000
commit0071ee5ede5c78319b9183a8a40ba2eedbee5483 (patch)
treeb693855b9d37ec6d12c98b48a336553899985d2c /sys/netinet/sctp_input.c
parent4e518ddb21db6abcade5cb3d67765a300ffce7e7 (diff)
downloadsrc-0071ee5ede5c78319b9183a8a40ba2eedbee5483.tar.gz
src-0071ee5ede5c78319b9183a8a40ba2eedbee5483.zip
1) Fix cpu mapping per JB's suggestions
2) Fix it so INIT's don't always end up on CPU0 MFC after: 3 months
Notes
Notes: svn path=/head/; revision=218269
Diffstat (limited to 'sys/netinet/sctp_input.c')
-rw-r--r--sys/netinet/sctp_input.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c
index a2215afb6cf8..250500ee23cc 100644
--- a/sys/netinet/sctp_input.c
+++ b/sys/netinet/sctp_input.c
@@ -1,8 +1,7 @@
/*-
* Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
- * Copyright (c) 2008-2011, by Randall Stewart, rrs@lakerest.net and
- * Michael Tuexen, tuexen@fh-muenster.de
- * All rights reserved.
+ * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved.
+ * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -5928,6 +5927,10 @@ bad:
return;
}
+#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
+extern int *sctp_cpuarry;
+
+#endif
void
sctp_input(struct mbuf *m, int off)
@@ -5937,8 +5940,9 @@ sctp_input(struct mbuf *m, int off)
struct sctphdr *sh;
int offset;
int cpu_to_use;
+ uint32_t tag;
- if (mp_maxid > 1) {
+ if (mp_ncpus > 1) {
ip = mtod(m, struct ip *);
offset = off + sizeof(*sh);
if (SCTP_BUF_LEN(m) < offset) {
@@ -5949,7 +5953,19 @@ sctp_input(struct mbuf *m, int off)
ip = mtod(m, struct ip *);
}
sh = (struct sctphdr *)((caddr_t)ip + off);
- cpu_to_use = ntohl(sh->v_tag) % mp_maxid;
+ if (sh->v_tag) {
+ tag = htonl(sh->v_tag);
+ } else {
+ /*
+ * Distribute new INIT's to all CPU's don't just
+ * pick on 0.
+ */
+ struct timeval tv;
+
+ (void)SCTP_GETTIME_TIMEVAL(&tv);
+ tag = (uint32_t) tv.tv_usec;
+ }
+ cpu_to_use = sctp_cpuarry[tag % mp_ncpus];
sctp_queue_to_mcore(m, off, cpu_to_use);
return;
}