aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/cma.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-11 22:40:14 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-11 22:40:14 -0400
commit038a5008b2f395c85e6e71d6ddf3c684e7c405b0 (patch)
tree4735eab577e97e5a22c3141e3f60071c8065585e /drivers/infiniband/core/cma.c
parentdd6d1844af33acb4edd0a40b1770d091a22c94be (diff)
parent266918303226cceac7eca38ced30f15f277bd89c (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (867 commits) [SKY2]: status polling loop (post merge) [NET]: Fix NAPI completion handling in some drivers. [TCP]: Limit processing lost_retrans loop to work-to-do cases [TCP]: Fix lost_retrans loop vs fastpath problems [TCP]: No need to re-count fackets_out/sacked_out at RTO [TCP]: Extract tcp_match_queue_to_sack from sacktag code [TCP]: Kill almost unused variable pcount from sacktag [TCP]: Fix mark_head_lost to ignore R-bit when trying to mark L [TCP]: Add bytes_acked (ABC) clearing to FRTO too [IPv6]: Update setsockopt(IPV6_MULTICAST_IF) to support RFC 3493, try2 [NETFILTER]: x_tables: add missing ip6t_modulename aliases [NETFILTER]: nf_conntrack_tcp: fix connection reopening [QETH]: fix qeth_main.c [NETLINK]: fib_frontend build fixes [IPv6]: Export userland ND options through netlink (RDNSS support) [9P]: build fix with !CONFIG_SYSCTL [NET]: Fix dev_put() and dev_hold() comments [NET]: make netlink user -> kernel interface synchronious [NET]: unify netlink kernel socket recognition [NET]: cleanup 3rd argument in netlink_sendskb ... Fix up conflicts manually in Documentation/feature-removal-schedule.txt and my new least favourite crap, the "mod_devicetable" support in the files include/linux/mod_devicetable.h and scripts/mod/file2alias.c. (The latter files seem to be explicitly _designed_ to get conflicts when different subsystems work with them - that have an absolutely horrid lack of subsystem separation!) Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/infiniband/core/cma.c')
-rw-r--r--drivers/infiniband/core/cma.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 9ffb9987450..2e641b255db 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1866,13 +1866,14 @@ err1:
1866static int cma_alloc_any_port(struct idr *ps, struct rdma_id_private *id_priv) 1866static int cma_alloc_any_port(struct idr *ps, struct rdma_id_private *id_priv)
1867{ 1867{
1868 struct rdma_bind_list *bind_list; 1868 struct rdma_bind_list *bind_list;
1869 int port, ret; 1869 int port, ret, low, high;
1870 1870
1871 bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL); 1871 bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL);
1872 if (!bind_list) 1872 if (!bind_list)
1873 return -ENOMEM; 1873 return -ENOMEM;
1874 1874
1875retry: 1875retry:
1876 /* FIXME: add proper port randomization per like inet_csk_get_port */
1876 do { 1877 do {
1877 ret = idr_get_new_above(ps, bind_list, next_port, &port); 1878 ret = idr_get_new_above(ps, bind_list, next_port, &port);
1878 } while ((ret == -EAGAIN) && idr_pre_get(ps, GFP_KERNEL)); 1879 } while ((ret == -EAGAIN) && idr_pre_get(ps, GFP_KERNEL));
@@ -1880,18 +1881,19 @@ retry:
1880 if (ret) 1881 if (ret)
1881 goto err1; 1882 goto err1;
1882 1883
1883 if (port > sysctl_local_port_range[1]) { 1884 inet_get_local_port_range(&low, &high);
1884 if (next_port != sysctl_local_port_range[0]) { 1885 if (port > high) {
1886 if (next_port != low) {
1885 idr_remove(ps, port); 1887 idr_remove(ps, port);
1886 next_port = sysctl_local_port_range[0]; 1888 next_port = low;
1887 goto retry; 1889 goto retry;
1888 } 1890 }
1889 ret = -EADDRNOTAVAIL; 1891 ret = -EADDRNOTAVAIL;
1890 goto err2; 1892 goto err2;
1891 } 1893 }
1892 1894
1893 if (port == sysctl_local_port_range[1]) 1895 if (port == high)
1894 next_port = sysctl_local_port_range[0]; 1896 next_port = low;
1895 else 1897 else
1896 next_port = port + 1; 1898 next_port = port + 1;
1897 1899
@@ -2769,12 +2771,12 @@ static void cma_remove_one(struct ib_device *device)
2769 2771
2770static int cma_init(void) 2772static int cma_init(void)
2771{ 2773{
2772 int ret; 2774 int ret, low, high;
2773 2775
2774 get_random_bytes(&next_port, sizeof next_port); 2776 get_random_bytes(&next_port, sizeof next_port);
2775 next_port = ((unsigned int) next_port % 2777 inet_get_local_port_range(&low, &high);
2776 (sysctl_local_port_range[1] - sysctl_local_port_range[0])) + 2778 next_port = ((unsigned int) next_port % (high - low)) + low;
2777 sysctl_local_port_range[0]; 2779
2778 cma_wq = create_singlethread_workqueue("rdma_cm"); 2780 cma_wq = create_singlethread_workqueue("rdma_cm");
2779 if (!cma_wq) 2781 if (!cma_wq)
2780 return -ENOMEM; 2782 return -ENOMEM;