scsi_netlink.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. /*
  2. * scsi_netlink.c - SCSI Transport Netlink Interface
  3. *
  4. * Copyright (C) 2006 James Smart, Emulex Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. */
  21. #include <linux/time.h>
  22. #include <linux/jiffies.h>
  23. #include <linux/security.h>
  24. #include <linux/delay.h>
  25. #include <linux/slab.h>
  26. #include <linux/export.h>
  27. #include <net/sock.h>
  28. #include <net/netlink.h>
  29. #include <scsi/scsi_netlink.h>
  30. #include "scsi_priv.h"
  31. struct sock *scsi_nl_sock = NULL;
  32. EXPORT_SYMBOL_GPL(scsi_nl_sock);
  33. static DEFINE_SPINLOCK(scsi_nl_lock);
  34. static struct list_head scsi_nl_drivers;
  35. static u32 scsi_nl_state;
  36. #define STATE_EHANDLER_BSY 0x00000001
  37. struct scsi_nl_transport {
  38. int (*msg_handler)(struct sk_buff *);
  39. void (*event_handler)(struct notifier_block *, unsigned long, void *);
  40. unsigned int refcnt;
  41. int flags;
  42. };
  43. /* flags values (bit flags) */
  44. #define HANDLER_DELETING 0x1
  45. static struct scsi_nl_transport transports[SCSI_NL_MAX_TRANSPORTS] =
  46. { {NULL, }, };
  47. struct scsi_nl_drvr {
  48. struct list_head next;
  49. int (*dmsg_handler)(struct Scsi_Host *shost, void *payload,
  50. u32 len, u32 pid);
  51. void (*devt_handler)(struct notifier_block *nb,
  52. unsigned long event, void *notify_ptr);
  53. struct scsi_host_template *hostt;
  54. u64 vendor_id;
  55. unsigned int refcnt;
  56. int flags;
  57. };
  58. /**
  59. * scsi_nl_rcv_msg - Receive message handler.
  60. * @skb: socket receive buffer
  61. *
  62. * Description: Extracts message from a receive buffer.
  63. * Validates message header and calls appropriate transport message handler
  64. *
  65. *
  66. **/
  67. static void
  68. scsi_nl_rcv_msg(struct sk_buff *skb)
  69. {
  70. struct nlmsghdr *nlh;
  71. struct scsi_nl_hdr *hdr;
  72. unsigned long flags;
  73. u32 rlen;
  74. int err, tport;
  75. while (skb->len >= NLMSG_SPACE(0)) {
  76. err = 0;
  77. nlh = nlmsg_hdr(skb);
  78. if ((nlh->nlmsg_len < (sizeof(*nlh) + sizeof(*hdr))) ||
  79. (skb->len < nlh->nlmsg_len)) {
  80. printk(KERN_WARNING "%s: discarding partial skb\n",
  81. __func__);
  82. return;
  83. }
  84. rlen = NLMSG_ALIGN(nlh->nlmsg_len);
  85. if (rlen > skb->len)
  86. rlen = skb->len;
  87. if (nlh->nlmsg_type != SCSI_TRANSPORT_MSG) {
  88. err = -EBADMSG;
  89. goto next_msg;
  90. }
  91. hdr = NLMSG_DATA(nlh);
  92. if ((hdr->version != SCSI_NL_VERSION) ||
  93. (hdr->magic != SCSI_NL_MAGIC)) {
  94. err = -EPROTOTYPE;
  95. goto next_msg;
  96. }
  97. if (!capable(CAP_SYS_ADMIN)) {
  98. err = -EPERM;
  99. goto next_msg;
  100. }
  101. if (nlh->nlmsg_len < (sizeof(*nlh) + hdr->msglen)) {
  102. printk(KERN_WARNING "%s: discarding partial message\n",
  103. __func__);
  104. goto next_msg;
  105. }
  106. /*
  107. * Deliver message to the appropriate transport
  108. */
  109. spin_lock_irqsave(&scsi_nl_lock, flags);
  110. tport = hdr->transport;
  111. if ((tport < SCSI_NL_MAX_TRANSPORTS) &&
  112. !(transports[tport].flags & HANDLER_DELETING) &&
  113. (transports[tport].msg_handler)) {
  114. transports[tport].refcnt++;
  115. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  116. err = transports[tport].msg_handler(skb);
  117. spin_lock_irqsave(&scsi_nl_lock, flags);
  118. transports[tport].refcnt--;
  119. } else
  120. err = -ENOENT;
  121. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  122. next_msg:
  123. if ((err) || (nlh->nlmsg_flags & NLM_F_ACK))
  124. netlink_ack(skb, nlh, err);
  125. skb_pull(skb, rlen);
  126. }
  127. }
  128. /**
  129. * scsi_nl_rcv_event - Event handler for a netlink socket.
  130. * @this: event notifier block
  131. * @event: event type
  132. * @ptr: event payload
  133. *
  134. **/
  135. static int
  136. scsi_nl_rcv_event(struct notifier_block *this, unsigned long event, void *ptr)
  137. {
  138. struct netlink_notify *n = ptr;
  139. struct scsi_nl_drvr *driver;
  140. unsigned long flags;
  141. int tport;
  142. if (n->protocol != NETLINK_SCSITRANSPORT)
  143. return NOTIFY_DONE;
  144. spin_lock_irqsave(&scsi_nl_lock, flags);
  145. scsi_nl_state |= STATE_EHANDLER_BSY;
  146. /*
  147. * Pass event on to any transports that may be listening
  148. */
  149. for (tport = 0; tport < SCSI_NL_MAX_TRANSPORTS; tport++) {
  150. if (!(transports[tport].flags & HANDLER_DELETING) &&
  151. (transports[tport].event_handler)) {
  152. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  153. transports[tport].event_handler(this, event, ptr);
  154. spin_lock_irqsave(&scsi_nl_lock, flags);
  155. }
  156. }
  157. /*
  158. * Pass event on to any drivers that may be listening
  159. */
  160. list_for_each_entry(driver, &scsi_nl_drivers, next) {
  161. if (!(driver->flags & HANDLER_DELETING) &&
  162. (driver->devt_handler)) {
  163. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  164. driver->devt_handler(this, event, ptr);
  165. spin_lock_irqsave(&scsi_nl_lock, flags);
  166. }
  167. }
  168. scsi_nl_state &= ~STATE_EHANDLER_BSY;
  169. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  170. return NOTIFY_DONE;
  171. }
  172. static struct notifier_block scsi_netlink_notifier = {
  173. .notifier_call = scsi_nl_rcv_event,
  174. };
  175. /*
  176. * GENERIC SCSI transport receive and event handlers
  177. */
  178. /**
  179. * scsi_generic_msg_handler - receive message handler for GENERIC transport messages
  180. * @skb: socket receive buffer
  181. **/
  182. static int
  183. scsi_generic_msg_handler(struct sk_buff *skb)
  184. {
  185. struct nlmsghdr *nlh = nlmsg_hdr(skb);
  186. struct scsi_nl_hdr *snlh = NLMSG_DATA(nlh);
  187. struct scsi_nl_drvr *driver;
  188. struct Scsi_Host *shost;
  189. unsigned long flags;
  190. int err = 0, match, pid;
  191. pid = NETLINK_CREDS(skb)->pid;
  192. switch (snlh->msgtype) {
  193. case SCSI_NL_SHOST_VENDOR:
  194. {
  195. struct scsi_nl_host_vendor_msg *msg = NLMSG_DATA(nlh);
  196. /* Locate the driver that corresponds to the message */
  197. spin_lock_irqsave(&scsi_nl_lock, flags);
  198. match = 0;
  199. list_for_each_entry(driver, &scsi_nl_drivers, next) {
  200. if (driver->vendor_id == msg->vendor_id) {
  201. match = 1;
  202. break;
  203. }
  204. }
  205. if ((!match) || (!driver->dmsg_handler)) {
  206. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  207. err = -ESRCH;
  208. goto rcv_exit;
  209. }
  210. if (driver->flags & HANDLER_DELETING) {
  211. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  212. err = -ESHUTDOWN;
  213. goto rcv_exit;
  214. }
  215. driver->refcnt++;
  216. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  217. /* if successful, scsi_host_lookup takes a shost reference */
  218. shost = scsi_host_lookup(msg->host_no);
  219. if (!shost) {
  220. err = -ENODEV;
  221. goto driver_exit;
  222. }
  223. /* is this host owned by the vendor ? */
  224. if (shost->hostt != driver->hostt) {
  225. err = -EINVAL;
  226. goto vendormsg_put;
  227. }
  228. /* pass message on to the driver */
  229. err = driver->dmsg_handler(shost, (void *)&msg[1],
  230. msg->vmsg_datalen, pid);
  231. vendormsg_put:
  232. /* release reference by scsi_host_lookup */
  233. scsi_host_put(shost);
  234. driver_exit:
  235. /* release our own reference on the registration object */
  236. spin_lock_irqsave(&scsi_nl_lock, flags);
  237. driver->refcnt--;
  238. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  239. break;
  240. }
  241. default:
  242. err = -EBADR;
  243. break;
  244. }
  245. rcv_exit:
  246. if (err)
  247. printk(KERN_WARNING "%s: Msgtype %d failed - err %d\n",
  248. __func__, snlh->msgtype, err);
  249. return err;
  250. }
  251. /**
  252. * scsi_nl_add_transport -
  253. * Registers message and event handlers for a transport. Enables
  254. * receipt of netlink messages and events to a transport.
  255. *
  256. * @tport: transport registering handlers
  257. * @msg_handler: receive message handler callback
  258. * @event_handler: receive event handler callback
  259. **/
  260. int
  261. scsi_nl_add_transport(u8 tport,
  262. int (*msg_handler)(struct sk_buff *),
  263. void (*event_handler)(struct notifier_block *, unsigned long, void *))
  264. {
  265. unsigned long flags;
  266. int err = 0;
  267. if (tport >= SCSI_NL_MAX_TRANSPORTS)
  268. return -EINVAL;
  269. spin_lock_irqsave(&scsi_nl_lock, flags);
  270. if (scsi_nl_state & STATE_EHANDLER_BSY) {
  271. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  272. msleep(1);
  273. spin_lock_irqsave(&scsi_nl_lock, flags);
  274. }
  275. if (transports[tport].msg_handler || transports[tport].event_handler) {
  276. err = -EALREADY;
  277. goto register_out;
  278. }
  279. transports[tport].msg_handler = msg_handler;
  280. transports[tport].event_handler = event_handler;
  281. transports[tport].flags = 0;
  282. transports[tport].refcnt = 0;
  283. register_out:
  284. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  285. return err;
  286. }
  287. EXPORT_SYMBOL_GPL(scsi_nl_add_transport);
  288. /**
  289. * scsi_nl_remove_transport -
  290. * Disable transport receiption of messages and events
  291. *
  292. * @tport: transport deregistering handlers
  293. *
  294. **/
  295. void
  296. scsi_nl_remove_transport(u8 tport)
  297. {
  298. unsigned long flags;
  299. spin_lock_irqsave(&scsi_nl_lock, flags);
  300. if (scsi_nl_state & STATE_EHANDLER_BSY) {
  301. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  302. msleep(1);
  303. spin_lock_irqsave(&scsi_nl_lock, flags);
  304. }
  305. if (tport < SCSI_NL_MAX_TRANSPORTS) {
  306. transports[tport].flags |= HANDLER_DELETING;
  307. while (transports[tport].refcnt != 0) {
  308. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  309. schedule_timeout_uninterruptible(HZ/4);
  310. spin_lock_irqsave(&scsi_nl_lock, flags);
  311. }
  312. transports[tport].msg_handler = NULL;
  313. transports[tport].event_handler = NULL;
  314. transports[tport].flags = 0;
  315. }
  316. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  317. return;
  318. }
  319. EXPORT_SYMBOL_GPL(scsi_nl_remove_transport);
  320. /**
  321. * scsi_nl_add_driver -
  322. * A driver is registering its interfaces for SCSI netlink messages
  323. *
  324. * @vendor_id: A unique identification value for the driver.
  325. * @hostt: address of the driver's host template. Used
  326. * to verify an shost is bound to the driver
  327. * @nlmsg_handler: receive message handler callback
  328. * @nlevt_handler: receive event handler callback
  329. *
  330. * Returns:
  331. * 0 on Success
  332. * error result otherwise
  333. **/
  334. int
  335. scsi_nl_add_driver(u64 vendor_id, struct scsi_host_template *hostt,
  336. int (*nlmsg_handler)(struct Scsi_Host *shost, void *payload,
  337. u32 len, u32 pid),
  338. void (*nlevt_handler)(struct notifier_block *nb,
  339. unsigned long event, void *notify_ptr))
  340. {
  341. struct scsi_nl_drvr *driver;
  342. unsigned long flags;
  343. driver = kzalloc(sizeof(*driver), GFP_KERNEL);
  344. if (unlikely(!driver)) {
  345. printk(KERN_ERR "%s: allocation failure\n", __func__);
  346. return -ENOMEM;
  347. }
  348. driver->dmsg_handler = nlmsg_handler;
  349. driver->devt_handler = nlevt_handler;
  350. driver->hostt = hostt;
  351. driver->vendor_id = vendor_id;
  352. spin_lock_irqsave(&scsi_nl_lock, flags);
  353. if (scsi_nl_state & STATE_EHANDLER_BSY) {
  354. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  355. msleep(1);
  356. spin_lock_irqsave(&scsi_nl_lock, flags);
  357. }
  358. list_add_tail(&driver->next, &scsi_nl_drivers);
  359. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  360. return 0;
  361. }
  362. EXPORT_SYMBOL_GPL(scsi_nl_add_driver);
  363. /**
  364. * scsi_nl_remove_driver -
  365. * An driver is unregistering with the SCSI netlink messages
  366. *
  367. * @vendor_id: The unique identification value for the driver.
  368. **/
  369. void
  370. scsi_nl_remove_driver(u64 vendor_id)
  371. {
  372. struct scsi_nl_drvr *driver;
  373. unsigned long flags;
  374. spin_lock_irqsave(&scsi_nl_lock, flags);
  375. if (scsi_nl_state & STATE_EHANDLER_BSY) {
  376. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  377. msleep(1);
  378. spin_lock_irqsave(&scsi_nl_lock, flags);
  379. }
  380. list_for_each_entry(driver, &scsi_nl_drivers, next) {
  381. if (driver->vendor_id == vendor_id) {
  382. driver->flags |= HANDLER_DELETING;
  383. while (driver->refcnt != 0) {
  384. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  385. schedule_timeout_uninterruptible(HZ/4);
  386. spin_lock_irqsave(&scsi_nl_lock, flags);
  387. }
  388. list_del(&driver->next);
  389. kfree(driver);
  390. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  391. return;
  392. }
  393. }
  394. spin_unlock_irqrestore(&scsi_nl_lock, flags);
  395. printk(KERN_ERR "%s: removal of driver failed - vendor_id 0x%llx\n",
  396. __func__, (unsigned long long)vendor_id);
  397. return;
  398. }
  399. EXPORT_SYMBOL_GPL(scsi_nl_remove_driver);
  400. /**
  401. * scsi_netlink_init - Called by SCSI subsystem to initialize
  402. * the SCSI transport netlink interface
  403. *
  404. **/
  405. void
  406. scsi_netlink_init(void)
  407. {
  408. int error;
  409. struct netlink_kernel_cfg cfg = {
  410. .input = scsi_nl_rcv_msg,
  411. .groups = SCSI_NL_GRP_CNT,
  412. };
  413. INIT_LIST_HEAD(&scsi_nl_drivers);
  414. error = netlink_register_notifier(&scsi_netlink_notifier);
  415. if (error) {
  416. printk(KERN_ERR "%s: register of event handler failed - %d\n",
  417. __func__, error);
  418. return;
  419. }
  420. scsi_nl_sock = netlink_kernel_create(&init_net, NETLINK_SCSITRANSPORT,
  421. THIS_MODULE, &cfg);
  422. if (!scsi_nl_sock) {
  423. printk(KERN_ERR "%s: register of receive handler failed\n",
  424. __func__);
  425. netlink_unregister_notifier(&scsi_netlink_notifier);
  426. return;
  427. }
  428. /* Register the entry points for the generic SCSI transport */
  429. error = scsi_nl_add_transport(SCSI_NL_TRANSPORT,
  430. scsi_generic_msg_handler, NULL);
  431. if (error)
  432. printk(KERN_ERR "%s: register of GENERIC transport handler"
  433. " failed - %d\n", __func__, error);
  434. return;
  435. }
  436. /**
  437. * scsi_netlink_exit - Called by SCSI subsystem to disable the SCSI transport netlink interface
  438. *
  439. **/
  440. void
  441. scsi_netlink_exit(void)
  442. {
  443. scsi_nl_remove_transport(SCSI_NL_TRANSPORT);
  444. if (scsi_nl_sock) {
  445. netlink_kernel_release(scsi_nl_sock);
  446. netlink_unregister_notifier(&scsi_netlink_notifier);
  447. }
  448. return;
  449. }
  450. /*
  451. * Exported Interfaces
  452. */
  453. /**
  454. * scsi_nl_send_transport_msg -
  455. * Generic function to send a single message from a SCSI transport to
  456. * a single process
  457. *
  458. * @pid: receiving pid
  459. * @hdr: message payload
  460. *
  461. **/
  462. void
  463. scsi_nl_send_transport_msg(u32 pid, struct scsi_nl_hdr *hdr)
  464. {
  465. struct sk_buff *skb;
  466. struct nlmsghdr *nlh;
  467. const char *fn;
  468. char *datab;
  469. u32 len, skblen;
  470. int err;
  471. if (!scsi_nl_sock) {
  472. err = -ENOENT;
  473. fn = "netlink socket";
  474. goto msg_fail;
  475. }
  476. len = NLMSG_SPACE(hdr->msglen);
  477. skblen = NLMSG_SPACE(len);
  478. skb = alloc_skb(skblen, GFP_KERNEL);
  479. if (!skb) {
  480. err = -ENOBUFS;
  481. fn = "alloc_skb";
  482. goto msg_fail;
  483. }
  484. nlh = nlmsg_put(skb, pid, 0, SCSI_TRANSPORT_MSG, len - sizeof(*nlh), 0);
  485. if (!nlh) {
  486. err = -ENOBUFS;
  487. fn = "nlmsg_put";
  488. goto msg_fail_skb;
  489. }
  490. datab = NLMSG_DATA(nlh);
  491. memcpy(datab, hdr, hdr->msglen);
  492. err = nlmsg_unicast(scsi_nl_sock, skb, pid);
  493. if (err < 0) {
  494. fn = "nlmsg_unicast";
  495. /* nlmsg_unicast already kfree_skb'd */
  496. goto msg_fail;
  497. }
  498. return;
  499. msg_fail_skb:
  500. kfree_skb(skb);
  501. msg_fail:
  502. printk(KERN_WARNING
  503. "%s: Dropped Message : pid %d Transport %d, msgtype x%x, "
  504. "msglen %d: %s : err %d\n",
  505. __func__, pid, hdr->transport, hdr->msgtype, hdr->msglen,
  506. fn, err);
  507. return;
  508. }
  509. EXPORT_SYMBOL_GPL(scsi_nl_send_transport_msg);
  510. /**
  511. * scsi_nl_send_vendor_msg - called to send a shost vendor unique message
  512. * to a specific process id.
  513. *
  514. * @pid: process id of the receiver
  515. * @host_no: host # sending the message
  516. * @vendor_id: unique identifier for the driver's vendor
  517. * @data_len: amount, in bytes, of vendor unique payload data
  518. * @data_buf: pointer to vendor unique data buffer
  519. *
  520. * Returns:
  521. * 0 on successful return
  522. * otherwise, failing error code
  523. *
  524. * Notes:
  525. * This routine assumes no locks are held on entry.
  526. */
  527. int
  528. scsi_nl_send_vendor_msg(u32 pid, unsigned short host_no, u64 vendor_id,
  529. char *data_buf, u32 data_len)
  530. {
  531. struct sk_buff *skb;
  532. struct nlmsghdr *nlh;
  533. struct scsi_nl_host_vendor_msg *msg;
  534. u32 len, skblen;
  535. int err;
  536. if (!scsi_nl_sock) {
  537. err = -ENOENT;
  538. goto send_vendor_fail;
  539. }
  540. len = SCSI_NL_MSGALIGN(sizeof(*msg) + data_len);
  541. skblen = NLMSG_SPACE(len);
  542. skb = alloc_skb(skblen, GFP_KERNEL);
  543. if (!skb) {
  544. err = -ENOBUFS;
  545. goto send_vendor_fail;
  546. }
  547. nlh = nlmsg_put(skb, 0, 0, SCSI_TRANSPORT_MSG,
  548. skblen - sizeof(*nlh), 0);
  549. if (!nlh) {
  550. err = -ENOBUFS;
  551. goto send_vendor_fail_skb;
  552. }
  553. msg = NLMSG_DATA(nlh);
  554. INIT_SCSI_NL_HDR(&msg->snlh, SCSI_NL_TRANSPORT,
  555. SCSI_NL_SHOST_VENDOR, len);
  556. msg->vendor_id = vendor_id;
  557. msg->host_no = host_no;
  558. msg->vmsg_datalen = data_len; /* bytes */
  559. memcpy(&msg[1], data_buf, data_len);
  560. err = nlmsg_unicast(scsi_nl_sock, skb, pid);
  561. if (err)
  562. /* nlmsg_multicast already kfree_skb'd */
  563. goto send_vendor_fail;
  564. return 0;
  565. send_vendor_fail_skb:
  566. kfree_skb(skb);
  567. send_vendor_fail:
  568. printk(KERN_WARNING
  569. "%s: Dropped SCSI Msg : host %d vendor_unique - err %d\n",
  570. __func__, host_no, err);
  571. return err;
  572. }
  573. EXPORT_SYMBOL(scsi_nl_send_vendor_msg);