scsi_netlink.c 16 KB

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