aboutsummaryrefslogtreecommitdiffstats
path: root/net/rds/transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/rds/transport.c')
-rw-r--r--net/rds/transport.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/net/rds/transport.c b/net/rds/transport.c
index 767da61ad2f3..7e1067901353 100644
--- a/net/rds/transport.c
+++ b/net/rds/transport.c
@@ -37,7 +37,7 @@
37#include "rds.h" 37#include "rds.h"
38#include "loop.h" 38#include "loop.h"
39 39
40static LIST_HEAD(rds_transports); 40static struct rds_transport *transports[RDS_TRANS_COUNT];
41static DECLARE_RWSEM(rds_trans_sem); 41static DECLARE_RWSEM(rds_trans_sem);
42 42
43int rds_trans_register(struct rds_transport *trans) 43int rds_trans_register(struct rds_transport *trans)
@@ -46,36 +46,44 @@ int rds_trans_register(struct rds_transport *trans)
46 46
47 down_write(&rds_trans_sem); 47 down_write(&rds_trans_sem);
48 48
49 list_add_tail(&trans->t_item, &rds_transports); 49 if (transports[trans->t_type])
50 printk(KERN_INFO "Registered RDS/%s transport\n", trans->t_name); 50 printk(KERN_ERR "RDS Transport type %d already registered\n",
51 trans->t_type);
52 else {
53 transports[trans->t_type] = trans;
54 printk(KERN_INFO "Registered RDS/%s transport\n", trans->t_name);
55 }
51 56
52 up_write(&rds_trans_sem); 57 up_write(&rds_trans_sem);
53 58
54 return 0; 59 return 0;
55} 60}
61EXPORT_SYMBOL_GPL(rds_trans_register);
56 62
57void rds_trans_unregister(struct rds_transport *trans) 63void rds_trans_unregister(struct rds_transport *trans)
58{ 64{
59 down_write(&rds_trans_sem); 65 down_write(&rds_trans_sem);
60 66
61 list_del_init(&trans->t_item); 67 transports[trans->t_type] = NULL;
62 printk(KERN_INFO "Unregistered RDS/%s transport\n", trans->t_name); 68 printk(KERN_INFO "Unregistered RDS/%s transport\n", trans->t_name);
63 69
64 up_write(&rds_trans_sem); 70 up_write(&rds_trans_sem);
65} 71}
72EXPORT_SYMBOL_GPL(rds_trans_unregister);
66 73
67struct rds_transport *rds_trans_get_preferred(__be32 addr) 74struct rds_transport *rds_trans_get_preferred(__be32 addr)
68{ 75{
69 struct rds_transport *trans;
70 struct rds_transport *ret = NULL; 76 struct rds_transport *ret = NULL;
77 int i;
71 78
72 if (IN_LOOPBACK(ntohl(addr))) 79 if (IN_LOOPBACK(ntohl(addr)))
73 return &rds_loop_transport; 80 return &rds_loop_transport;
74 81
75 down_read(&rds_trans_sem); 82 down_read(&rds_trans_sem);
76 list_for_each_entry(trans, &rds_transports, t_item) { 83 for (i = 0; i < RDS_TRANS_COUNT; i++)
77 if (trans->laddr_check(addr) == 0) { 84 {
78 ret = trans; 85 if (transports[i] && (transports[i]->laddr_check(addr) == 0)) {
86 ret = transports[i];
79 break; 87 break;
80 } 88 }
81 } 89 }
@@ -97,12 +105,15 @@ unsigned int rds_trans_stats_info_copy(struct rds_info_iterator *iter,
97 struct rds_transport *trans; 105 struct rds_transport *trans;
98 unsigned int total = 0; 106 unsigned int total = 0;
99 unsigned int part; 107 unsigned int part;
108 int i;
100 109
101 rds_info_iter_unmap(iter); 110 rds_info_iter_unmap(iter);
102 down_read(&rds_trans_sem); 111 down_read(&rds_trans_sem);
103 112
104 list_for_each_entry(trans, &rds_transports, t_item) { 113 for (i = 0; i < RDS_TRANS_COUNT; i++)
105 if (trans->stats_info_copy == NULL) 114 {
115 trans = transports[i];
116 if (!trans || !trans->stats_info_copy)
106 continue; 117 continue;
107 118
108 part = trans->stats_info_copy(iter, avail); 119 part = trans->stats_info_copy(iter, avail);