aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTatyana Nikolova <Tatyana.E.Nikolova@intel.com>2015-07-02 13:47:44 -0400
committerDoug Ledford <dledford@redhat.com>2015-07-14 13:20:10 -0400
commita7f2f24cd716d7f1119d46929f41a8436f9c252f (patch)
tree2decdbe74a88cb4abf713dfa5ede7ce83c6b8bc4
parent58e9cc90cda7bc732856a2ad3210328fbc4f6ca2 (diff)
RDMA/core: Fixes for port mapper client registration
Fixes to allow clients to make remove mapping requests, after they have provided the user space service with the mapping information, they are using when the service is restarted. 1) Adding IWPM_REG_VALID, IWPM_REG_INCOMPL and IWPM_REG_UNDEF registration types for the port mapper clients and functions to set/check the registration type. 2) If the port mapper user space service is not available to register the client, then its registration stays IWPM_REG_UNDEF and the registration isn't checked until the service becomes available (no mappings are possible, if the user space service isn't running). 3) After the service is restarted, the user space port mapper pid is set to valid and the client registration is set to IWPM_REG_INCOMPL to allow the client to make remove mapping requests. Signed-off-by: Tatyana Nikolova <Tatyana.E.Nikolova@intel.com> Reviewed-by: Steve Wise <swise@opengridcomputing.com> Tested-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--drivers/infiniband/core/iwpm_msg.c33
-rw-r--r--drivers/infiniband/core/iwpm_util.c12
-rw-r--r--drivers/infiniband/core/iwpm_util.h28
3 files changed, 48 insertions, 25 deletions
diff --git a/drivers/infiniband/core/iwpm_msg.c b/drivers/infiniband/core/iwpm_msg.c
index e6ffa2e66c1a..22a3abee2a54 100644
--- a/drivers/infiniband/core/iwpm_msg.c
+++ b/drivers/infiniband/core/iwpm_msg.c
@@ -67,7 +67,8 @@ int iwpm_register_pid(struct iwpm_dev_data *pm_msg, u8 nl_client)
67 err_str = "Invalid port mapper client"; 67 err_str = "Invalid port mapper client";
68 goto pid_query_error; 68 goto pid_query_error;
69 } 69 }
70 if (iwpm_registered_client(nl_client)) 70 if (iwpm_check_registration(nl_client, IWPM_REG_VALID) ||
71 iwpm_user_pid == IWPM_PID_UNAVAILABLE)
71 return 0; 72 return 0;
72 skb = iwpm_create_nlmsg(RDMA_NL_IWPM_REG_PID, &nlh, nl_client); 73 skb = iwpm_create_nlmsg(RDMA_NL_IWPM_REG_PID, &nlh, nl_client);
73 if (!skb) { 74 if (!skb) {
@@ -106,7 +107,6 @@ int iwpm_register_pid(struct iwpm_dev_data *pm_msg, u8 nl_client)
106 ret = ibnl_multicast(skb, nlh, RDMA_NL_GROUP_IWPM, GFP_KERNEL); 107 ret = ibnl_multicast(skb, nlh, RDMA_NL_GROUP_IWPM, GFP_KERNEL);
107 if (ret) { 108 if (ret) {
108 skb = NULL; /* skb is freed in the netlink send-op handling */ 109 skb = NULL; /* skb is freed in the netlink send-op handling */
109 iwpm_set_registered(nl_client, 1);
110 iwpm_user_pid = IWPM_PID_UNAVAILABLE; 110 iwpm_user_pid = IWPM_PID_UNAVAILABLE;
111 err_str = "Unable to send a nlmsg"; 111 err_str = "Unable to send a nlmsg";
112 goto pid_query_error; 112 goto pid_query_error;
@@ -144,12 +144,12 @@ int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client)
144 err_str = "Invalid port mapper client"; 144 err_str = "Invalid port mapper client";
145 goto add_mapping_error; 145 goto add_mapping_error;
146 } 146 }
147 if (!iwpm_registered_client(nl_client)) { 147 if (!iwpm_valid_pid())
148 return 0;
149 if (!iwpm_check_registration(nl_client, IWPM_REG_VALID)) {
148 err_str = "Unregistered port mapper client"; 150 err_str = "Unregistered port mapper client";
149 goto add_mapping_error; 151 goto add_mapping_error;
150 } 152 }
151 if (!iwpm_valid_pid())
152 return 0;
153 skb = iwpm_create_nlmsg(RDMA_NL_IWPM_ADD_MAPPING, &nlh, nl_client); 153 skb = iwpm_create_nlmsg(RDMA_NL_IWPM_ADD_MAPPING, &nlh, nl_client);
154 if (!skb) { 154 if (!skb) {
155 err_str = "Unable to create a nlmsg"; 155 err_str = "Unable to create a nlmsg";
@@ -214,12 +214,12 @@ int iwpm_add_and_query_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client)
214 err_str = "Invalid port mapper client"; 214 err_str = "Invalid port mapper client";
215 goto query_mapping_error; 215 goto query_mapping_error;
216 } 216 }
217 if (!iwpm_registered_client(nl_client)) { 217 if (!iwpm_valid_pid())
218 return 0;
219 if (!iwpm_check_registration(nl_client, IWPM_REG_VALID)) {
218 err_str = "Unregistered port mapper client"; 220 err_str = "Unregistered port mapper client";
219 goto query_mapping_error; 221 goto query_mapping_error;
220 } 222 }
221 if (!iwpm_valid_pid())
222 return 0;
223 ret = -ENOMEM; 223 ret = -ENOMEM;
224 skb = iwpm_create_nlmsg(RDMA_NL_IWPM_QUERY_MAPPING, &nlh, nl_client); 224 skb = iwpm_create_nlmsg(RDMA_NL_IWPM_QUERY_MAPPING, &nlh, nl_client);
225 if (!skb) { 225 if (!skb) {
@@ -288,12 +288,12 @@ int iwpm_remove_mapping(struct sockaddr_storage *local_addr, u8 nl_client)
288 err_str = "Invalid port mapper client"; 288 err_str = "Invalid port mapper client";
289 goto remove_mapping_error; 289 goto remove_mapping_error;
290 } 290 }
291 if (!iwpm_registered_client(nl_client)) { 291 if (!iwpm_valid_pid())
292 return 0;
293 if (iwpm_check_registration(nl_client, IWPM_REG_UNDEF)) {
292 err_str = "Unregistered port mapper client"; 294 err_str = "Unregistered port mapper client";
293 goto remove_mapping_error; 295 goto remove_mapping_error;
294 } 296 }
295 if (!iwpm_valid_pid())
296 return 0;
297 skb = iwpm_create_nlmsg(RDMA_NL_IWPM_REMOVE_MAPPING, &nlh, nl_client); 297 skb = iwpm_create_nlmsg(RDMA_NL_IWPM_REMOVE_MAPPING, &nlh, nl_client);
298 if (!skb) { 298 if (!skb) {
299 ret = -ENOMEM; 299 ret = -ENOMEM;
@@ -388,7 +388,7 @@ int iwpm_register_pid_cb(struct sk_buff *skb, struct netlink_callback *cb)
388 pr_debug("%s: iWarp Port Mapper (pid = %d) is available!\n", 388 pr_debug("%s: iWarp Port Mapper (pid = %d) is available!\n",
389 __func__, iwpm_user_pid); 389 __func__, iwpm_user_pid);
390 if (iwpm_valid_client(nl_client)) 390 if (iwpm_valid_client(nl_client))
391 iwpm_set_registered(nl_client, 1); 391 iwpm_set_registration(nl_client, IWPM_REG_VALID);
392register_pid_response_exit: 392register_pid_response_exit:
393 nlmsg_request->request_done = 1; 393 nlmsg_request->request_done = 1;
394 /* always for found nlmsg_request */ 394 /* always for found nlmsg_request */
@@ -644,7 +644,6 @@ int iwpm_mapping_info_cb(struct sk_buff *skb, struct netlink_callback *cb)
644{ 644{
645 struct nlattr *nltb[IWPM_NLA_MAPINFO_REQ_MAX]; 645 struct nlattr *nltb[IWPM_NLA_MAPINFO_REQ_MAX];
646 const char *msg_type = "Mapping Info response"; 646 const char *msg_type = "Mapping Info response";
647 int iwpm_pid;
648 u8 nl_client; 647 u8 nl_client;
649 char *iwpm_name; 648 char *iwpm_name;
650 u16 iwpm_version; 649 u16 iwpm_version;
@@ -669,14 +668,14 @@ int iwpm_mapping_info_cb(struct sk_buff *skb, struct netlink_callback *cb)
669 __func__, nl_client); 668 __func__, nl_client);
670 return ret; 669 return ret;
671 } 670 }
672 iwpm_set_registered(nl_client, 0); 671 iwpm_set_registration(nl_client, IWPM_REG_INCOMPL);
673 atomic_set(&echo_nlmsg_seq, cb->nlh->nlmsg_seq); 672 atomic_set(&echo_nlmsg_seq, cb->nlh->nlmsg_seq);
673 iwpm_user_pid = cb->nlh->nlmsg_pid;
674 if (!iwpm_mapinfo_available()) 674 if (!iwpm_mapinfo_available())
675 return 0; 675 return 0;
676 iwpm_pid = cb->nlh->nlmsg_pid;
677 pr_debug("%s: iWarp Port Mapper (pid = %d) is available!\n", 676 pr_debug("%s: iWarp Port Mapper (pid = %d) is available!\n",
678 __func__, iwpm_pid); 677 __func__, iwpm_user_pid);
679 ret = iwpm_send_mapinfo(nl_client, iwpm_pid); 678 ret = iwpm_send_mapinfo(nl_client, iwpm_user_pid);
680 return ret; 679 return ret;
681} 680}
682EXPORT_SYMBOL(iwpm_mapping_info_cb); 681EXPORT_SYMBOL(iwpm_mapping_info_cb);
diff --git a/drivers/infiniband/core/iwpm_util.c b/drivers/infiniband/core/iwpm_util.c
index a626795bf9c7..5fb089e91353 100644
--- a/drivers/infiniband/core/iwpm_util.c
+++ b/drivers/infiniband/core/iwpm_util.c
@@ -78,6 +78,7 @@ init_exit:
78 mutex_unlock(&iwpm_admin_lock); 78 mutex_unlock(&iwpm_admin_lock);
79 if (!ret) { 79 if (!ret) {
80 iwpm_set_valid(nl_client, 1); 80 iwpm_set_valid(nl_client, 1);
81 iwpm_set_registration(nl_client, IWPM_REG_UNDEF);
81 pr_debug("%s: Mapinfo and reminfo tables are created\n", 82 pr_debug("%s: Mapinfo and reminfo tables are created\n",
82 __func__); 83 __func__);
83 } 84 }
@@ -106,6 +107,7 @@ int iwpm_exit(u8 nl_client)
106 } 107 }
107 mutex_unlock(&iwpm_admin_lock); 108 mutex_unlock(&iwpm_admin_lock);
108 iwpm_set_valid(nl_client, 0); 109 iwpm_set_valid(nl_client, 0);
110 iwpm_set_registration(nl_client, IWPM_REG_UNDEF);
109 return 0; 111 return 0;
110} 112}
111EXPORT_SYMBOL(iwpm_exit); 113EXPORT_SYMBOL(iwpm_exit);
@@ -397,17 +399,23 @@ void iwpm_set_valid(u8 nl_client, int valid)
397} 399}
398 400
399/* valid client */ 401/* valid client */
400int iwpm_registered_client(u8 nl_client) 402u32 iwpm_get_registration(u8 nl_client)
401{ 403{
402 return iwpm_admin.reg_list[nl_client]; 404 return iwpm_admin.reg_list[nl_client];
403} 405}
404 406
405/* valid client */ 407/* valid client */
406void iwpm_set_registered(u8 nl_client, int reg) 408void iwpm_set_registration(u8 nl_client, u32 reg)
407{ 409{
408 iwpm_admin.reg_list[nl_client] = reg; 410 iwpm_admin.reg_list[nl_client] = reg;
409} 411}
410 412
413/* valid client */
414u32 iwpm_check_registration(u8 nl_client, u32 reg)
415{
416 return (iwpm_get_registration(nl_client) & reg);
417}
418
411int iwpm_compare_sockaddr(struct sockaddr_storage *a_sockaddr, 419int iwpm_compare_sockaddr(struct sockaddr_storage *a_sockaddr,
412 struct sockaddr_storage *b_sockaddr) 420 struct sockaddr_storage *b_sockaddr)
413{ 421{
diff --git a/drivers/infiniband/core/iwpm_util.h b/drivers/infiniband/core/iwpm_util.h
index ee2d9ff095be..b7b9e194ce81 100644
--- a/drivers/infiniband/core/iwpm_util.h
+++ b/drivers/infiniband/core/iwpm_util.h
@@ -58,6 +58,10 @@
58#define IWPM_PID_UNDEFINED -1 58#define IWPM_PID_UNDEFINED -1
59#define IWPM_PID_UNAVAILABLE -2 59#define IWPM_PID_UNAVAILABLE -2
60 60
61#define IWPM_REG_UNDEF 0x01
62#define IWPM_REG_VALID 0x02
63#define IWPM_REG_INCOMPL 0x04
64
61struct iwpm_nlmsg_request { 65struct iwpm_nlmsg_request {
62 struct list_head inprocess_list; 66 struct list_head inprocess_list;
63 __u32 nlmsg_seq; 67 __u32 nlmsg_seq;
@@ -88,7 +92,7 @@ struct iwpm_admin_data {
88 atomic_t refcount; 92 atomic_t refcount;
89 atomic_t nlmsg_seq; 93 atomic_t nlmsg_seq;
90 int client_list[RDMA_NL_NUM_CLIENTS]; 94 int client_list[RDMA_NL_NUM_CLIENTS];
91 int reg_list[RDMA_NL_NUM_CLIENTS]; 95 u32 reg_list[RDMA_NL_NUM_CLIENTS];
92}; 96};
93 97
94/** 98/**
@@ -159,19 +163,31 @@ int iwpm_valid_client(u8 nl_client);
159void iwpm_set_valid(u8 nl_client, int valid); 163void iwpm_set_valid(u8 nl_client, int valid);
160 164
161/** 165/**
162 * iwpm_registered_client - Check if the port mapper client is registered 166 * iwpm_check_registration - Check if the client registration
167 * matches the given one
163 * @nl_client: The index of the netlink client 168 * @nl_client: The index of the netlink client
169 * @reg: The given registration type to compare with
164 * 170 *
165 * Call iwpm_register_pid() to register a client 171 * Call iwpm_register_pid() to register a client
172 * Returns true if the client registration matches reg,
173 * otherwise returns false
174 */
175u32 iwpm_check_registration(u8 nl_client, u32 reg);
176
177/**
178 * iwpm_set_registration - Set the client registration
179 * @nl_client: The index of the netlink client
180 * @reg: Registration type to set
166 */ 181 */
167int iwpm_registered_client(u8 nl_client); 182void iwpm_set_registration(u8 nl_client, u32 reg);
168 183
169/** 184/**
170 * iwpm_set_registered - Set the port mapper client to registered or not 185 * iwpm_get_registration
171 * @nl_client: The index of the netlink client 186 * @nl_client: The index of the netlink client
172 * @reg: 1 if registered or 0 if not 187 *
188 * Returns the client registration type
173 */ 189 */
174void iwpm_set_registered(u8 nl_client, int reg); 190u32 iwpm_get_registration(u8 nl_client);
175 191
176/** 192/**
177 * iwpm_send_mapinfo - Send local and mapped IPv4/IPv6 address info of 193 * iwpm_send_mapinfo - Send local and mapped IPv4/IPv6 address info of