scsi_netlink.c 16 KB

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