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 <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. INIT_LIST_HEAD(&scsi_nl_drivers);
  410. error = netlink_register_notifier(&scsi_netlink_notifier);
  411. if (error) {
  412. printk(KERN_ERR "%s: register of event handler failed - %d\n",
  413. __func__, error);
  414. return;
  415. }
  416. scsi_nl_sock = netlink_kernel_create(&init_net, NETLINK_SCSITRANSPORT,
  417. SCSI_NL_GRP_CNT, scsi_nl_rcv_msg, NULL,
  418. THIS_MODULE);
  419. if (!scsi_nl_sock) {
  420. printk(KERN_ERR "%s: register of receive handler failed\n",
  421. __func__);
  422. netlink_unregister_notifier(&scsi_netlink_notifier);
  423. return;
  424. }
  425. /* Register the entry points for the generic SCSI transport */
  426. error = scsi_nl_add_transport(SCSI_NL_TRANSPORT,
  427. scsi_generic_msg_handler, NULL);
  428. if (error)
  429. printk(KERN_ERR "%s: register of GENERIC transport handler"
  430. " failed - %d\n", __func__, error);
  431. return;
  432. }
  433. /**
  434. * scsi_netlink_exit - Called by SCSI subsystem to disable the SCSI transport netlink interface
  435. *
  436. **/
  437. void
  438. scsi_netlink_exit(void)
  439. {
  440. scsi_nl_remove_transport(SCSI_NL_TRANSPORT);
  441. if (scsi_nl_sock) {
  442. netlink_kernel_release(scsi_nl_sock);
  443. netlink_unregister_notifier(&scsi_netlink_notifier);
  444. }
  445. return;
  446. }
  447. /*
  448. * Exported Interfaces
  449. */
  450. /**
  451. * scsi_nl_send_transport_msg -
  452. * Generic function to send a single message from a SCSI transport to
  453. * a single process
  454. *
  455. * @pid: receiving pid
  456. * @hdr: message payload
  457. *
  458. **/
  459. void
  460. scsi_nl_send_transport_msg(u32 pid, struct scsi_nl_hdr *hdr)
  461. {
  462. struct sk_buff *skb;
  463. struct nlmsghdr *nlh;
  464. const char *fn;
  465. char *datab;
  466. u32 len, skblen;
  467. int err;
  468. if (!scsi_nl_sock) {
  469. err = -ENOENT;
  470. fn = "netlink socket";
  471. goto msg_fail;
  472. }
  473. len = NLMSG_SPACE(hdr->msglen);
  474. skblen = NLMSG_SPACE(len);
  475. skb = alloc_skb(skblen, GFP_KERNEL);
  476. if (!skb) {
  477. err = -ENOBUFS;
  478. fn = "alloc_skb";
  479. goto msg_fail;
  480. }
  481. nlh = nlmsg_put(skb, pid, 0, SCSI_TRANSPORT_MSG, len - sizeof(*nlh), 0);
  482. if (!nlh) {
  483. err = -ENOBUFS;
  484. fn = "nlmsg_put";
  485. goto msg_fail_skb;
  486. }
  487. datab = NLMSG_DATA(nlh);
  488. memcpy(datab, hdr, hdr->msglen);
  489. err = nlmsg_unicast(scsi_nl_sock, skb, pid);
  490. if (err < 0) {
  491. fn = "nlmsg_unicast";
  492. /* nlmsg_unicast already kfree_skb'd */
  493. goto msg_fail;
  494. }
  495. return;
  496. msg_fail_skb:
  497. kfree_skb(skb);
  498. msg_fail:
  499. printk(KERN_WARNING
  500. "%s: Dropped Message : pid %d Transport %d, msgtype x%x, "
  501. "msglen %d: %s : err %d\n",
  502. __func__, pid, hdr->transport, hdr->msgtype, hdr->msglen,
  503. fn, err);
  504. return;
  505. }
  506. EXPORT_SYMBOL_GPL(scsi_nl_send_transport_msg);
  507. /**
  508. * scsi_nl_send_vendor_msg - called to send a shost vendor unique message
  509. * to a specific process id.
  510. *
  511. * @pid: process id of the receiver
  512. * @host_no: host # sending the message
  513. * @vendor_id: unique identifier for the driver's vendor
  514. * @data_len: amount, in bytes, of vendor unique payload data
  515. * @data_buf: pointer to vendor unique data buffer
  516. *
  517. * Returns:
  518. * 0 on successful return
  519. * otherwise, failing error code
  520. *
  521. * Notes:
  522. * This routine assumes no locks are held on entry.
  523. */
  524. int
  525. scsi_nl_send_vendor_msg(u32 pid, unsigned short host_no, u64 vendor_id,
  526. char *data_buf, u32 data_len)
  527. {
  528. struct sk_buff *skb;
  529. struct nlmsghdr *nlh;
  530. struct scsi_nl_host_vendor_msg *msg;
  531. u32 len, skblen;
  532. int err;
  533. if (!scsi_nl_sock) {
  534. err = -ENOENT;
  535. goto send_vendor_fail;
  536. }
  537. len = SCSI_NL_MSGALIGN(sizeof(*msg) + data_len);
  538. skblen = NLMSG_SPACE(len);
  539. skb = alloc_skb(skblen, GFP_KERNEL);
  540. if (!skb) {
  541. err = -ENOBUFS;
  542. goto send_vendor_fail;
  543. }
  544. nlh = nlmsg_put(skb, 0, 0, SCSI_TRANSPORT_MSG,
  545. skblen - sizeof(*nlh), 0);
  546. if (!nlh) {
  547. err = -ENOBUFS;
  548. goto send_vendor_fail_skb;
  549. }
  550. msg = NLMSG_DATA(nlh);
  551. INIT_SCSI_NL_HDR(&msg->snlh, SCSI_NL_TRANSPORT,
  552. SCSI_NL_SHOST_VENDOR, len);
  553. msg->vendor_id = vendor_id;
  554. msg->host_no = host_no;
  555. msg->vmsg_datalen = data_len; /* bytes */
  556. memcpy(&msg[1], data_buf, data_len);
  557. err = nlmsg_unicast(scsi_nl_sock, skb, pid);
  558. if (err)
  559. /* nlmsg_multicast already kfree_skb'd */
  560. goto send_vendor_fail;
  561. return 0;
  562. send_vendor_fail_skb:
  563. kfree_skb(skb);
  564. send_vendor_fail:
  565. printk(KERN_WARNING
  566. "%s: Dropped SCSI Msg : host %d vendor_unique - err %d\n",
  567. __func__, host_no, err);
  568. return err;
  569. }
  570. EXPORT_SYMBOL(scsi_nl_send_vendor_msg);