WIP FPC-III support
[linux/fpc-iii.git] / fs / cifs / cifs_swn.c
blobd35f599aa00e60cca149b67a47c37cc2520a6a32
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Witness Service client for CIFS
5 * Copyright (c) 2020 Samuel Cabrero <scabrero@suse.de>
6 */
8 #include <linux/kref.h>
9 #include <net/genetlink.h>
10 #include <uapi/linux/cifs/cifs_netlink.h>
12 #include "cifs_swn.h"
13 #include "cifsglob.h"
14 #include "cifsproto.h"
15 #include "fscache.h"
16 #include "cifs_debug.h"
17 #include "netlink.h"
19 static DEFINE_IDR(cifs_swnreg_idr);
20 static DEFINE_MUTEX(cifs_swnreg_idr_mutex);
22 struct cifs_swn_reg {
23 int id;
24 struct kref ref_count;
26 const char *net_name;
27 const char *share_name;
28 bool net_name_notify;
29 bool share_name_notify;
30 bool ip_notify;
32 struct cifs_tcon *tcon;
35 static int cifs_swn_auth_info_krb(struct cifs_tcon *tcon, struct sk_buff *skb)
37 int ret;
39 ret = nla_put_flag(skb, CIFS_GENL_ATTR_SWN_KRB_AUTH);
40 if (ret < 0)
41 return ret;
43 return 0;
46 static int cifs_swn_auth_info_ntlm(struct cifs_tcon *tcon, struct sk_buff *skb)
48 int ret;
50 if (tcon->ses->user_name != NULL) {
51 ret = nla_put_string(skb, CIFS_GENL_ATTR_SWN_USER_NAME, tcon->ses->user_name);
52 if (ret < 0)
53 return ret;
56 if (tcon->ses->password != NULL) {
57 ret = nla_put_string(skb, CIFS_GENL_ATTR_SWN_PASSWORD, tcon->ses->password);
58 if (ret < 0)
59 return ret;
62 if (tcon->ses->domainName != NULL) {
63 ret = nla_put_string(skb, CIFS_GENL_ATTR_SWN_DOMAIN_NAME, tcon->ses->domainName);
64 if (ret < 0)
65 return ret;
68 return 0;
72 * Sends a register message to the userspace daemon based on the registration.
73 * The authentication information to connect to the witness service is bundled
74 * into the message.
76 static int cifs_swn_send_register_message(struct cifs_swn_reg *swnreg)
78 struct sk_buff *skb;
79 struct genlmsghdr *hdr;
80 enum securityEnum authtype;
81 struct sockaddr_storage *addr;
82 int ret;
84 skb = genlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
85 if (skb == NULL) {
86 ret = -ENOMEM;
87 goto fail;
90 hdr = genlmsg_put(skb, 0, 0, &cifs_genl_family, 0, CIFS_GENL_CMD_SWN_REGISTER);
91 if (hdr == NULL) {
92 ret = -ENOMEM;
93 goto nlmsg_fail;
96 ret = nla_put_u32(skb, CIFS_GENL_ATTR_SWN_REGISTRATION_ID, swnreg->id);
97 if (ret < 0)
98 goto nlmsg_fail;
100 ret = nla_put_string(skb, CIFS_GENL_ATTR_SWN_NET_NAME, swnreg->net_name);
101 if (ret < 0)
102 goto nlmsg_fail;
104 ret = nla_put_string(skb, CIFS_GENL_ATTR_SWN_SHARE_NAME, swnreg->share_name);
105 if (ret < 0)
106 goto nlmsg_fail;
109 * If there is an address stored use it instead of the server address, because we are
110 * in the process of reconnecting to it after a share has been moved or we have been
111 * told to switch to it (client move message). In these cases we unregister from the
112 * server address and register to the new address when we receive the notification.
114 if (swnreg->tcon->ses->server->use_swn_dstaddr)
115 addr = &swnreg->tcon->ses->server->swn_dstaddr;
116 else
117 addr = &swnreg->tcon->ses->server->dstaddr;
119 ret = nla_put(skb, CIFS_GENL_ATTR_SWN_IP, sizeof(struct sockaddr_storage), addr);
120 if (ret < 0)
121 goto nlmsg_fail;
123 if (swnreg->net_name_notify) {
124 ret = nla_put_flag(skb, CIFS_GENL_ATTR_SWN_NET_NAME_NOTIFY);
125 if (ret < 0)
126 goto nlmsg_fail;
129 if (swnreg->share_name_notify) {
130 ret = nla_put_flag(skb, CIFS_GENL_ATTR_SWN_SHARE_NAME_NOTIFY);
131 if (ret < 0)
132 goto nlmsg_fail;
135 if (swnreg->ip_notify) {
136 ret = nla_put_flag(skb, CIFS_GENL_ATTR_SWN_IP_NOTIFY);
137 if (ret < 0)
138 goto nlmsg_fail;
141 authtype = cifs_select_sectype(swnreg->tcon->ses->server, swnreg->tcon->ses->sectype);
142 switch (authtype) {
143 case Kerberos:
144 ret = cifs_swn_auth_info_krb(swnreg->tcon, skb);
145 if (ret < 0) {
146 cifs_dbg(VFS, "%s: Failed to get kerberos auth info: %d\n", __func__, ret);
147 goto nlmsg_fail;
149 break;
150 case LANMAN:
151 case NTLM:
152 case NTLMv2:
153 case RawNTLMSSP:
154 ret = cifs_swn_auth_info_ntlm(swnreg->tcon, skb);
155 if (ret < 0) {
156 cifs_dbg(VFS, "%s: Failed to get NTLM auth info: %d\n", __func__, ret);
157 goto nlmsg_fail;
159 break;
160 default:
161 cifs_dbg(VFS, "%s: secType %d not supported!\n", __func__, authtype);
162 ret = -EINVAL;
163 goto nlmsg_fail;
166 genlmsg_end(skb, hdr);
167 genlmsg_multicast(&cifs_genl_family, skb, 0, CIFS_GENL_MCGRP_SWN, GFP_ATOMIC);
169 cifs_dbg(FYI, "%s: Message to register for network name %s with id %d sent\n", __func__,
170 swnreg->net_name, swnreg->id);
172 return 0;
174 nlmsg_fail:
175 genlmsg_cancel(skb, hdr);
176 nlmsg_free(skb);
177 fail:
178 return ret;
182 * Sends an uregister message to the userspace daemon based on the registration
184 static int cifs_swn_send_unregister_message(struct cifs_swn_reg *swnreg)
186 struct sk_buff *skb;
187 struct genlmsghdr *hdr;
188 int ret;
190 skb = genlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
191 if (skb == NULL)
192 return -ENOMEM;
194 hdr = genlmsg_put(skb, 0, 0, &cifs_genl_family, 0, CIFS_GENL_CMD_SWN_UNREGISTER);
195 if (hdr == NULL) {
196 ret = -ENOMEM;
197 goto nlmsg_fail;
200 ret = nla_put_u32(skb, CIFS_GENL_ATTR_SWN_REGISTRATION_ID, swnreg->id);
201 if (ret < 0)
202 goto nlmsg_fail;
204 ret = nla_put_string(skb, CIFS_GENL_ATTR_SWN_NET_NAME, swnreg->net_name);
205 if (ret < 0)
206 goto nlmsg_fail;
208 ret = nla_put_string(skb, CIFS_GENL_ATTR_SWN_SHARE_NAME, swnreg->share_name);
209 if (ret < 0)
210 goto nlmsg_fail;
212 ret = nla_put(skb, CIFS_GENL_ATTR_SWN_IP, sizeof(struct sockaddr_storage),
213 &swnreg->tcon->ses->server->dstaddr);
214 if (ret < 0)
215 goto nlmsg_fail;
217 if (swnreg->net_name_notify) {
218 ret = nla_put_flag(skb, CIFS_GENL_ATTR_SWN_NET_NAME_NOTIFY);
219 if (ret < 0)
220 goto nlmsg_fail;
223 if (swnreg->share_name_notify) {
224 ret = nla_put_flag(skb, CIFS_GENL_ATTR_SWN_SHARE_NAME_NOTIFY);
225 if (ret < 0)
226 goto nlmsg_fail;
229 if (swnreg->ip_notify) {
230 ret = nla_put_flag(skb, CIFS_GENL_ATTR_SWN_IP_NOTIFY);
231 if (ret < 0)
232 goto nlmsg_fail;
235 genlmsg_end(skb, hdr);
236 genlmsg_multicast(&cifs_genl_family, skb, 0, CIFS_GENL_MCGRP_SWN, GFP_ATOMIC);
238 cifs_dbg(FYI, "%s: Message to unregister for network name %s with id %d sent\n", __func__,
239 swnreg->net_name, swnreg->id);
241 return 0;
243 nlmsg_fail:
244 genlmsg_cancel(skb, hdr);
245 nlmsg_free(skb);
246 return ret;
250 * Try to find a matching registration for the tcon's server name and share name.
251 * Calls to this funciton must be protected by cifs_swnreg_idr_mutex.
252 * TODO Try to avoid memory allocations
254 static struct cifs_swn_reg *cifs_find_swn_reg(struct cifs_tcon *tcon)
256 struct cifs_swn_reg *swnreg;
257 int id;
258 const char *share_name;
259 const char *net_name;
261 net_name = extract_hostname(tcon->treeName);
262 if (IS_ERR(net_name)) {
263 int ret;
265 ret = PTR_ERR(net_name);
266 cifs_dbg(VFS, "%s: failed to extract host name from target '%s': %d\n",
267 __func__, tcon->treeName, ret);
268 return ERR_PTR(-EINVAL);
271 share_name = extract_sharename(tcon->treeName);
272 if (IS_ERR(share_name)) {
273 int ret;
275 ret = PTR_ERR(net_name);
276 cifs_dbg(VFS, "%s: failed to extract share name from target '%s': %d\n",
277 __func__, tcon->treeName, ret);
278 kfree(net_name);
279 return ERR_PTR(-EINVAL);
282 idr_for_each_entry(&cifs_swnreg_idr, swnreg, id) {
283 if (strcasecmp(swnreg->net_name, net_name) != 0
284 || strcasecmp(swnreg->share_name, share_name) != 0) {
285 continue;
288 cifs_dbg(FYI, "Existing swn registration for %s:%s found\n", swnreg->net_name,
289 swnreg->share_name);
291 kfree(net_name);
292 kfree(share_name);
294 return swnreg;
297 kfree(net_name);
298 kfree(share_name);
300 return ERR_PTR(-EEXIST);
304 * Get a registration for the tcon's server and share name, allocating a new one if it does not
305 * exists
307 static struct cifs_swn_reg *cifs_get_swn_reg(struct cifs_tcon *tcon)
309 struct cifs_swn_reg *reg = NULL;
310 int ret;
312 mutex_lock(&cifs_swnreg_idr_mutex);
314 /* Check if we are already registered for this network and share names */
315 reg = cifs_find_swn_reg(tcon);
316 if (!IS_ERR(reg)) {
317 kref_get(&reg->ref_count);
318 mutex_unlock(&cifs_swnreg_idr_mutex);
319 return reg;
320 } else if (PTR_ERR(reg) != -EEXIST) {
321 mutex_unlock(&cifs_swnreg_idr_mutex);
322 return reg;
325 reg = kmalloc(sizeof(struct cifs_swn_reg), GFP_ATOMIC);
326 if (reg == NULL) {
327 mutex_unlock(&cifs_swnreg_idr_mutex);
328 return ERR_PTR(-ENOMEM);
331 kref_init(&reg->ref_count);
333 reg->id = idr_alloc(&cifs_swnreg_idr, reg, 1, 0, GFP_ATOMIC);
334 if (reg->id < 0) {
335 cifs_dbg(FYI, "%s: failed to allocate registration id\n", __func__);
336 ret = reg->id;
337 goto fail;
340 reg->net_name = extract_hostname(tcon->treeName);
341 if (IS_ERR(reg->net_name)) {
342 ret = PTR_ERR(reg->net_name);
343 cifs_dbg(VFS, "%s: failed to extract host name from target: %d\n", __func__, ret);
344 goto fail_idr;
347 reg->share_name = extract_sharename(tcon->treeName);
348 if (IS_ERR(reg->share_name)) {
349 ret = PTR_ERR(reg->share_name);
350 cifs_dbg(VFS, "%s: failed to extract share name from target: %d\n", __func__, ret);
351 goto fail_net_name;
354 reg->net_name_notify = true;
355 reg->share_name_notify = true;
356 reg->ip_notify = (tcon->capabilities & SMB2_SHARE_CAP_SCALEOUT);
358 reg->tcon = tcon;
360 mutex_unlock(&cifs_swnreg_idr_mutex);
362 return reg;
364 fail_net_name:
365 kfree(reg->net_name);
366 fail_idr:
367 idr_remove(&cifs_swnreg_idr, reg->id);
368 fail:
369 kfree(reg);
370 mutex_unlock(&cifs_swnreg_idr_mutex);
371 return ERR_PTR(ret);
374 static void cifs_swn_reg_release(struct kref *ref)
376 struct cifs_swn_reg *swnreg = container_of(ref, struct cifs_swn_reg, ref_count);
377 int ret;
379 ret = cifs_swn_send_unregister_message(swnreg);
380 if (ret < 0)
381 cifs_dbg(VFS, "%s: Failed to send unregister message: %d\n", __func__, ret);
383 idr_remove(&cifs_swnreg_idr, swnreg->id);
384 kfree(swnreg->net_name);
385 kfree(swnreg->share_name);
386 kfree(swnreg);
389 static void cifs_put_swn_reg(struct cifs_swn_reg *swnreg)
391 mutex_lock(&cifs_swnreg_idr_mutex);
392 kref_put(&swnreg->ref_count, cifs_swn_reg_release);
393 mutex_unlock(&cifs_swnreg_idr_mutex);
396 static int cifs_swn_resource_state_changed(struct cifs_swn_reg *swnreg, const char *name, int state)
398 int i;
400 switch (state) {
401 case CIFS_SWN_RESOURCE_STATE_UNAVAILABLE:
402 cifs_dbg(FYI, "%s: resource name '%s' become unavailable\n", __func__, name);
403 for (i = 0; i < swnreg->tcon->ses->chan_count; i++) {
404 spin_lock(&GlobalMid_Lock);
405 if (swnreg->tcon->ses->chans[i].server->tcpStatus != CifsExiting)
406 swnreg->tcon->ses->chans[i].server->tcpStatus = CifsNeedReconnect;
407 spin_unlock(&GlobalMid_Lock);
409 break;
410 case CIFS_SWN_RESOURCE_STATE_AVAILABLE:
411 cifs_dbg(FYI, "%s: resource name '%s' become available\n", __func__, name);
412 for (i = 0; i < swnreg->tcon->ses->chan_count; i++) {
413 spin_lock(&GlobalMid_Lock);
414 if (swnreg->tcon->ses->chans[i].server->tcpStatus != CifsExiting)
415 swnreg->tcon->ses->chans[i].server->tcpStatus = CifsNeedReconnect;
416 spin_unlock(&GlobalMid_Lock);
418 break;
419 case CIFS_SWN_RESOURCE_STATE_UNKNOWN:
420 cifs_dbg(FYI, "%s: resource name '%s' changed to unknown state\n", __func__, name);
421 break;
423 return 0;
426 static bool cifs_sockaddr_equal(struct sockaddr_storage *addr1, struct sockaddr_storage *addr2)
428 if (addr1->ss_family != addr2->ss_family)
429 return false;
431 if (addr1->ss_family == AF_INET) {
432 return (memcmp(&((const struct sockaddr_in *)addr1)->sin_addr,
433 &((const struct sockaddr_in *)addr2)->sin_addr,
434 sizeof(struct in_addr)) == 0);
437 if (addr1->ss_family == AF_INET6) {
438 return (memcmp(&((const struct sockaddr_in6 *)addr1)->sin6_addr,
439 &((const struct sockaddr_in6 *)addr2)->sin6_addr,
440 sizeof(struct in6_addr)) == 0);
443 return false;
446 static int cifs_swn_store_swn_addr(const struct sockaddr_storage *new,
447 const struct sockaddr_storage *old,
448 struct sockaddr_storage *dst)
450 __be16 port;
452 if (old->ss_family == AF_INET) {
453 struct sockaddr_in *ipv4 = (struct sockaddr_in *)old;
455 port = ipv4->sin_port;
458 if (old->ss_family == AF_INET6) {
459 struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)old;
461 port = ipv6->sin6_port;
464 if (new->ss_family == AF_INET) {
465 struct sockaddr_in *ipv4 = (struct sockaddr_in *)new;
467 ipv4->sin_port = port;
470 if (new->ss_family == AF_INET6) {
471 struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)new;
473 ipv6->sin6_port = port;
476 *dst = *new;
478 return 0;
481 static int cifs_swn_reconnect(struct cifs_tcon *tcon, struct sockaddr_storage *addr)
483 int ret = 0;
485 /* Store the reconnect address */
486 mutex_lock(&tcon->ses->server->srv_mutex);
487 if (cifs_sockaddr_equal(&tcon->ses->server->dstaddr, addr))
488 goto unlock;
490 ret = cifs_swn_store_swn_addr(addr, &tcon->ses->server->dstaddr,
491 &tcon->ses->server->swn_dstaddr);
492 if (ret < 0) {
493 cifs_dbg(VFS, "%s: failed to store address: %d\n", __func__, ret);
494 goto unlock;
496 tcon->ses->server->use_swn_dstaddr = true;
499 * Unregister to stop receiving notifications for the old IP address.
501 ret = cifs_swn_unregister(tcon);
502 if (ret < 0) {
503 cifs_dbg(VFS, "%s: Failed to unregister for witness notifications: %d\n",
504 __func__, ret);
505 goto unlock;
509 * And register to receive notifications for the new IP address now that we have
510 * stored the new address.
512 ret = cifs_swn_register(tcon);
513 if (ret < 0) {
514 cifs_dbg(VFS, "%s: Failed to register for witness notifications: %d\n",
515 __func__, ret);
516 goto unlock;
519 spin_lock(&GlobalMid_Lock);
520 if (tcon->ses->server->tcpStatus != CifsExiting)
521 tcon->ses->server->tcpStatus = CifsNeedReconnect;
522 spin_unlock(&GlobalMid_Lock);
524 unlock:
525 mutex_unlock(&tcon->ses->server->srv_mutex);
527 return ret;
530 static int cifs_swn_client_move(struct cifs_swn_reg *swnreg, struct sockaddr_storage *addr)
532 struct sockaddr_in *ipv4 = (struct sockaddr_in *)addr;
533 struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)addr;
535 if (addr->ss_family == AF_INET)
536 cifs_dbg(FYI, "%s: move to %pI4\n", __func__, &ipv4->sin_addr);
537 else if (addr->ss_family == AF_INET6)
538 cifs_dbg(FYI, "%s: move to %pI6\n", __func__, &ipv6->sin6_addr);
540 return cifs_swn_reconnect(swnreg->tcon, addr);
543 int cifs_swn_notify(struct sk_buff *skb, struct genl_info *info)
545 struct cifs_swn_reg *swnreg;
546 char name[256];
547 int type;
549 if (info->attrs[CIFS_GENL_ATTR_SWN_REGISTRATION_ID]) {
550 int swnreg_id;
552 swnreg_id = nla_get_u32(info->attrs[CIFS_GENL_ATTR_SWN_REGISTRATION_ID]);
553 mutex_lock(&cifs_swnreg_idr_mutex);
554 swnreg = idr_find(&cifs_swnreg_idr, swnreg_id);
555 mutex_unlock(&cifs_swnreg_idr_mutex);
556 if (swnreg == NULL) {
557 cifs_dbg(FYI, "%s: registration id %d not found\n", __func__, swnreg_id);
558 return -EINVAL;
560 } else {
561 cifs_dbg(FYI, "%s: missing registration id attribute\n", __func__);
562 return -EINVAL;
565 if (info->attrs[CIFS_GENL_ATTR_SWN_NOTIFICATION_TYPE]) {
566 type = nla_get_u32(info->attrs[CIFS_GENL_ATTR_SWN_NOTIFICATION_TYPE]);
567 } else {
568 cifs_dbg(FYI, "%s: missing notification type attribute\n", __func__);
569 return -EINVAL;
572 switch (type) {
573 case CIFS_SWN_NOTIFICATION_RESOURCE_CHANGE: {
574 int state;
576 if (info->attrs[CIFS_GENL_ATTR_SWN_RESOURCE_NAME]) {
577 nla_strscpy(name, info->attrs[CIFS_GENL_ATTR_SWN_RESOURCE_NAME],
578 sizeof(name));
579 } else {
580 cifs_dbg(FYI, "%s: missing resource name attribute\n", __func__);
581 return -EINVAL;
583 if (info->attrs[CIFS_GENL_ATTR_SWN_RESOURCE_STATE]) {
584 state = nla_get_u32(info->attrs[CIFS_GENL_ATTR_SWN_RESOURCE_STATE]);
585 } else {
586 cifs_dbg(FYI, "%s: missing resource state attribute\n", __func__);
587 return -EINVAL;
589 return cifs_swn_resource_state_changed(swnreg, name, state);
591 case CIFS_SWN_NOTIFICATION_CLIENT_MOVE: {
592 struct sockaddr_storage addr;
594 if (info->attrs[CIFS_GENL_ATTR_SWN_IP]) {
595 nla_memcpy(&addr, info->attrs[CIFS_GENL_ATTR_SWN_IP], sizeof(addr));
596 } else {
597 cifs_dbg(FYI, "%s: missing IP address attribute\n", __func__);
598 return -EINVAL;
600 return cifs_swn_client_move(swnreg, &addr);
602 default:
603 cifs_dbg(FYI, "%s: unknown notification type %d\n", __func__, type);
604 break;
607 return 0;
610 int cifs_swn_register(struct cifs_tcon *tcon)
612 struct cifs_swn_reg *swnreg;
613 int ret;
615 swnreg = cifs_get_swn_reg(tcon);
616 if (IS_ERR(swnreg))
617 return PTR_ERR(swnreg);
619 ret = cifs_swn_send_register_message(swnreg);
620 if (ret < 0) {
621 cifs_dbg(VFS, "%s: Failed to send swn register message: %d\n", __func__, ret);
622 /* Do not put the swnreg or return error, the echo task will retry */
625 return 0;
628 int cifs_swn_unregister(struct cifs_tcon *tcon)
630 struct cifs_swn_reg *swnreg;
632 mutex_lock(&cifs_swnreg_idr_mutex);
634 swnreg = cifs_find_swn_reg(tcon);
635 if (IS_ERR(swnreg)) {
636 mutex_unlock(&cifs_swnreg_idr_mutex);
637 return PTR_ERR(swnreg);
640 mutex_unlock(&cifs_swnreg_idr_mutex);
642 cifs_put_swn_reg(swnreg);
644 return 0;
647 void cifs_swn_dump(struct seq_file *m)
649 struct cifs_swn_reg *swnreg;
650 struct sockaddr_in *sa;
651 struct sockaddr_in6 *sa6;
652 int id;
654 seq_puts(m, "Witness registrations:");
656 mutex_lock(&cifs_swnreg_idr_mutex);
657 idr_for_each_entry(&cifs_swnreg_idr, swnreg, id) {
658 seq_printf(m, "\nId: %u Refs: %u Network name: '%s'%s Share name: '%s'%s Ip address: ",
659 id, kref_read(&swnreg->ref_count),
660 swnreg->net_name, swnreg->net_name_notify ? "(y)" : "(n)",
661 swnreg->share_name, swnreg->share_name_notify ? "(y)" : "(n)");
662 switch (swnreg->tcon->ses->server->dstaddr.ss_family) {
663 case AF_INET:
664 sa = (struct sockaddr_in *) &swnreg->tcon->ses->server->dstaddr;
665 seq_printf(m, "%pI4", &sa->sin_addr.s_addr);
666 break;
667 case AF_INET6:
668 sa6 = (struct sockaddr_in6 *) &swnreg->tcon->ses->server->dstaddr;
669 seq_printf(m, "%pI6", &sa6->sin6_addr.s6_addr);
670 if (sa6->sin6_scope_id)
671 seq_printf(m, "%%%u", sa6->sin6_scope_id);
672 break;
673 default:
674 seq_puts(m, "(unknown)");
676 seq_printf(m, "%s", swnreg->ip_notify ? "(y)" : "(n)");
678 mutex_unlock(&cifs_swnreg_idr_mutex);
679 seq_puts(m, "\n");
682 void cifs_swn_check(void)
684 struct cifs_swn_reg *swnreg;
685 int id;
686 int ret;
688 mutex_lock(&cifs_swnreg_idr_mutex);
689 idr_for_each_entry(&cifs_swnreg_idr, swnreg, id) {
690 ret = cifs_swn_send_register_message(swnreg);
691 if (ret < 0)
692 cifs_dbg(FYI, "%s: Failed to send register message: %d\n", __func__, ret);
694 mutex_unlock(&cifs_swnreg_idr_mutex);