af_llc.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249
  1. /*
  2. * af_llc.c - LLC User Interface SAPs
  3. * Description:
  4. * Functions in this module are implementation of socket based llc
  5. * communications for the Linux operating system. Support of llc class
  6. * one and class two is provided via SOCK_DGRAM and SOCK_STREAM
  7. * respectively.
  8. *
  9. * An llc2 connection is (mac + sap), only one llc2 sap connection
  10. * is allowed per mac. Though one sap may have multiple mac + sap
  11. * connections.
  12. *
  13. * Copyright (c) 2001 by Jay Schulist <jschlst@samba.org>
  14. * 2002-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  15. *
  16. * This program can be redistributed or modified under the terms of the
  17. * GNU General Public License as published by the Free Software Foundation.
  18. * This program is distributed without any warranty or implied warranty
  19. * of merchantability or fitness for a particular purpose.
  20. *
  21. * See the GNU General Public License for more details.
  22. */
  23. #include <linux/compiler.h>
  24. #include <linux/kernel.h>
  25. #include <linux/module.h>
  26. #include <linux/rtnetlink.h>
  27. #include <linux/init.h>
  28. #include <linux/slab.h>
  29. #include <net/llc.h>
  30. #include <net/llc_sap.h>
  31. #include <net/llc_pdu.h>
  32. #include <net/llc_conn.h>
  33. #include <net/tcp_states.h>
  34. /* remember: uninitialized global data is zeroed because its in .bss */
  35. static u16 llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
  36. static u16 llc_ui_sap_link_no_max[256];
  37. static struct sockaddr_llc llc_ui_addrnull;
  38. static const struct proto_ops llc_ui_ops;
  39. static int llc_ui_wait_for_conn(struct sock *sk, long timeout);
  40. static int llc_ui_wait_for_disc(struct sock *sk, long timeout);
  41. static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout);
  42. #if 0
  43. #define dprintk(args...) printk(KERN_DEBUG args)
  44. #else
  45. #define dprintk(args...)
  46. #endif
  47. /* Maybe we'll add some more in the future. */
  48. #define LLC_CMSG_PKTINFO 1
  49. /**
  50. * llc_ui_next_link_no - return the next unused link number for a sap
  51. * @sap: Address of sap to get link number from.
  52. *
  53. * Return the next unused link number for a given sap.
  54. */
  55. static inline u16 llc_ui_next_link_no(int sap)
  56. {
  57. return llc_ui_sap_link_no_max[sap]++;
  58. }
  59. /**
  60. * llc_proto_type - return eth protocol for ARP header type
  61. * @arphrd: ARP header type.
  62. *
  63. * Given an ARP header type return the corresponding ethernet protocol.
  64. */
  65. static inline __be16 llc_proto_type(u16 arphrd)
  66. {
  67. return arphrd == ARPHRD_IEEE802_TR ?
  68. htons(ETH_P_TR_802_2) : htons(ETH_P_802_2);
  69. }
  70. /**
  71. * llc_ui_addr_null - determines if a address structure is null
  72. * @addr: Address to test if null.
  73. */
  74. static inline u8 llc_ui_addr_null(struct sockaddr_llc *addr)
  75. {
  76. return !memcmp(addr, &llc_ui_addrnull, sizeof(*addr));
  77. }
  78. /**
  79. * llc_ui_header_len - return length of llc header based on operation
  80. * @sk: Socket which contains a valid llc socket type.
  81. * @addr: Complete sockaddr_llc structure received from the user.
  82. *
  83. * Provide the length of the llc header depending on what kind of
  84. * operation the user would like to perform and the type of socket.
  85. * Returns the correct llc header length.
  86. */
  87. static inline u8 llc_ui_header_len(struct sock *sk, struct sockaddr_llc *addr)
  88. {
  89. u8 rc = LLC_PDU_LEN_U;
  90. if (addr->sllc_test || addr->sllc_xid)
  91. rc = LLC_PDU_LEN_U;
  92. else if (sk->sk_type == SOCK_STREAM)
  93. rc = LLC_PDU_LEN_I;
  94. return rc;
  95. }
  96. /**
  97. * llc_ui_send_data - send data via reliable llc2 connection
  98. * @sk: Connection the socket is using.
  99. * @skb: Data the user wishes to send.
  100. * @noblock: can we block waiting for data?
  101. *
  102. * Send data via reliable llc2 connection.
  103. * Returns 0 upon success, non-zero if action did not succeed.
  104. */
  105. static int llc_ui_send_data(struct sock* sk, struct sk_buff *skb, int noblock)
  106. {
  107. struct llc_sock* llc = llc_sk(sk);
  108. int rc = 0;
  109. if (unlikely(llc_data_accept_state(llc->state) ||
  110. llc->remote_busy_flag ||
  111. llc->p_flag)) {
  112. long timeout = sock_sndtimeo(sk, noblock);
  113. rc = llc_ui_wait_for_busy_core(sk, timeout);
  114. }
  115. if (unlikely(!rc))
  116. rc = llc_build_and_send_pkt(sk, skb);
  117. return rc;
  118. }
  119. static void llc_ui_sk_init(struct socket *sock, struct sock *sk)
  120. {
  121. sock_graft(sk, sock);
  122. sk->sk_type = sock->type;
  123. sock->ops = &llc_ui_ops;
  124. }
  125. static struct proto llc_proto = {
  126. .name = "LLC",
  127. .owner = THIS_MODULE,
  128. .obj_size = sizeof(struct llc_sock),
  129. .slab_flags = SLAB_DESTROY_BY_RCU,
  130. };
  131. /**
  132. * llc_ui_create - alloc and init a new llc_ui socket
  133. * @net: network namespace (must be default network)
  134. * @sock: Socket to initialize and attach allocated sk to.
  135. * @protocol: Unused.
  136. * @kern: on behalf of kernel or userspace
  137. *
  138. * Allocate and initialize a new llc_ui socket, validate the user wants a
  139. * socket type we have available.
  140. * Returns 0 upon success, negative upon failure.
  141. */
  142. static int llc_ui_create(struct net *net, struct socket *sock, int protocol,
  143. int kern)
  144. {
  145. struct sock *sk;
  146. int rc = -ESOCKTNOSUPPORT;
  147. if (!capable(CAP_NET_RAW))
  148. return -EPERM;
  149. if (!net_eq(net, &init_net))
  150. return -EAFNOSUPPORT;
  151. if (likely(sock->type == SOCK_DGRAM || sock->type == SOCK_STREAM)) {
  152. rc = -ENOMEM;
  153. sk = llc_sk_alloc(net, PF_LLC, GFP_KERNEL, &llc_proto);
  154. if (sk) {
  155. rc = 0;
  156. llc_ui_sk_init(sock, sk);
  157. }
  158. }
  159. return rc;
  160. }
  161. /**
  162. * llc_ui_release - shutdown socket
  163. * @sock: Socket to release.
  164. *
  165. * Shutdown and deallocate an existing socket.
  166. */
  167. static int llc_ui_release(struct socket *sock)
  168. {
  169. struct sock *sk = sock->sk;
  170. struct llc_sock *llc;
  171. if (unlikely(sk == NULL))
  172. goto out;
  173. sock_hold(sk);
  174. lock_sock(sk);
  175. llc = llc_sk(sk);
  176. dprintk("%s: closing local(%02X) remote(%02X)\n", __func__,
  177. llc->laddr.lsap, llc->daddr.lsap);
  178. if (!llc_send_disc(sk))
  179. llc_ui_wait_for_disc(sk, sk->sk_rcvtimeo);
  180. if (!sock_flag(sk, SOCK_ZAPPED))
  181. llc_sap_remove_socket(llc->sap, sk);
  182. release_sock(sk);
  183. if (llc->dev)
  184. dev_put(llc->dev);
  185. sock_put(sk);
  186. llc_sk_free(sk);
  187. out:
  188. return 0;
  189. }
  190. /**
  191. * llc_ui_autoport - provide dynamically allocate SAP number
  192. *
  193. * Provide the caller with a dynamically allocated SAP number according
  194. * to the rules that are set in this function. Returns: 0, upon failure,
  195. * SAP number otherwise.
  196. */
  197. static int llc_ui_autoport(void)
  198. {
  199. struct llc_sap *sap;
  200. int i, tries = 0;
  201. while (tries < LLC_SAP_DYN_TRIES) {
  202. for (i = llc_ui_sap_last_autoport;
  203. i < LLC_SAP_DYN_STOP; i += 2) {
  204. sap = llc_sap_find(i);
  205. if (!sap) {
  206. llc_ui_sap_last_autoport = i + 2;
  207. goto out;
  208. }
  209. llc_sap_put(sap);
  210. }
  211. llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
  212. tries++;
  213. }
  214. i = 0;
  215. out:
  216. return i;
  217. }
  218. /**
  219. * llc_ui_autobind - automatically bind a socket to a sap
  220. * @sock: socket to bind
  221. * @addr: address to connect to
  222. *
  223. * Used by llc_ui_connect and llc_ui_sendmsg when the user hasn't
  224. * specifically used llc_ui_bind to bind to an specific address/sap
  225. *
  226. * Returns: 0 upon success, negative otherwise.
  227. */
  228. static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
  229. {
  230. struct sock *sk = sock->sk;
  231. struct llc_sock *llc = llc_sk(sk);
  232. struct llc_sap *sap;
  233. int rc = -EINVAL;
  234. if (!sock_flag(sk, SOCK_ZAPPED))
  235. goto out;
  236. rc = -ENODEV;
  237. if (sk->sk_bound_dev_if) {
  238. llc->dev = dev_get_by_index(&init_net, sk->sk_bound_dev_if);
  239. if (llc->dev && addr->sllc_arphrd != llc->dev->type) {
  240. dev_put(llc->dev);
  241. llc->dev = NULL;
  242. }
  243. } else
  244. llc->dev = dev_getfirstbyhwtype(&init_net, addr->sllc_arphrd);
  245. if (!llc->dev)
  246. goto out;
  247. rc = -EUSERS;
  248. llc->laddr.lsap = llc_ui_autoport();
  249. if (!llc->laddr.lsap)
  250. goto out;
  251. rc = -EBUSY; /* some other network layer is using the sap */
  252. sap = llc_sap_open(llc->laddr.lsap, NULL);
  253. if (!sap)
  254. goto out;
  255. memcpy(llc->laddr.mac, llc->dev->dev_addr, IFHWADDRLEN);
  256. memcpy(&llc->addr, addr, sizeof(llc->addr));
  257. /* assign new connection to its SAP */
  258. llc_sap_add_socket(sap, sk);
  259. sock_reset_flag(sk, SOCK_ZAPPED);
  260. rc = 0;
  261. out:
  262. return rc;
  263. }
  264. /**
  265. * llc_ui_bind - bind a socket to a specific address.
  266. * @sock: Socket to bind an address to.
  267. * @uaddr: Address the user wants the socket bound to.
  268. * @addrlen: Length of the uaddr structure.
  269. *
  270. * Bind a socket to a specific address. For llc a user is able to bind to
  271. * a specific sap only or mac + sap.
  272. * If the user desires to bind to a specific mac + sap, it is possible to
  273. * have multiple sap connections via multiple macs.
  274. * Bind and autobind for that matter must enforce the correct sap usage
  275. * otherwise all hell will break loose.
  276. * Returns: 0 upon success, negative otherwise.
  277. */
  278. static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
  279. {
  280. struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr;
  281. struct sock *sk = sock->sk;
  282. struct llc_sock *llc = llc_sk(sk);
  283. struct llc_sap *sap;
  284. int rc = -EINVAL;
  285. dprintk("%s: binding %02X\n", __func__, addr->sllc_sap);
  286. if (unlikely(!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr)))
  287. goto out;
  288. rc = -EAFNOSUPPORT;
  289. if (unlikely(addr->sllc_family != AF_LLC))
  290. goto out;
  291. rc = -ENODEV;
  292. rcu_read_lock();
  293. if (sk->sk_bound_dev_if) {
  294. llc->dev = dev_get_by_index_rcu(&init_net, sk->sk_bound_dev_if);
  295. if (llc->dev) {
  296. if (!addr->sllc_arphrd)
  297. addr->sllc_arphrd = llc->dev->type;
  298. if (llc_mac_null(addr->sllc_mac))
  299. memcpy(addr->sllc_mac, llc->dev->dev_addr,
  300. IFHWADDRLEN);
  301. if (addr->sllc_arphrd != llc->dev->type ||
  302. !llc_mac_match(addr->sllc_mac,
  303. llc->dev->dev_addr)) {
  304. rc = -EINVAL;
  305. llc->dev = NULL;
  306. }
  307. }
  308. } else
  309. llc->dev = dev_getbyhwaddr_rcu(&init_net, addr->sllc_arphrd,
  310. addr->sllc_mac);
  311. if (llc->dev)
  312. dev_hold(llc->dev);
  313. rcu_read_unlock();
  314. if (!llc->dev)
  315. goto out;
  316. if (!addr->sllc_sap) {
  317. rc = -EUSERS;
  318. addr->sllc_sap = llc_ui_autoport();
  319. if (!addr->sllc_sap)
  320. goto out;
  321. }
  322. sap = llc_sap_find(addr->sllc_sap);
  323. if (!sap) {
  324. sap = llc_sap_open(addr->sllc_sap, NULL);
  325. rc = -EBUSY; /* some other network layer is using the sap */
  326. if (!sap)
  327. goto out;
  328. } else {
  329. struct llc_addr laddr, daddr;
  330. struct sock *ask;
  331. memset(&laddr, 0, sizeof(laddr));
  332. memset(&daddr, 0, sizeof(daddr));
  333. /*
  334. * FIXME: check if the address is multicast,
  335. * only SOCK_DGRAM can do this.
  336. */
  337. memcpy(laddr.mac, addr->sllc_mac, IFHWADDRLEN);
  338. laddr.lsap = addr->sllc_sap;
  339. rc = -EADDRINUSE; /* mac + sap clash. */
  340. ask = llc_lookup_established(sap, &daddr, &laddr);
  341. if (ask) {
  342. sock_put(ask);
  343. goto out_put;
  344. }
  345. }
  346. llc->laddr.lsap = addr->sllc_sap;
  347. memcpy(llc->laddr.mac, addr->sllc_mac, IFHWADDRLEN);
  348. memcpy(&llc->addr, addr, sizeof(llc->addr));
  349. /* assign new connection to its SAP */
  350. llc_sap_add_socket(sap, sk);
  351. sock_reset_flag(sk, SOCK_ZAPPED);
  352. rc = 0;
  353. out_put:
  354. llc_sap_put(sap);
  355. out:
  356. return rc;
  357. }
  358. /**
  359. * llc_ui_shutdown - shutdown a connect llc2 socket.
  360. * @sock: Socket to shutdown.
  361. * @how: What part of the socket to shutdown.
  362. *
  363. * Shutdown a connected llc2 socket. Currently this function only supports
  364. * shutting down both sends and receives (2), we could probably make this
  365. * function such that a user can shutdown only half the connection but not
  366. * right now.
  367. * Returns: 0 upon success, negative otherwise.
  368. */
  369. static int llc_ui_shutdown(struct socket *sock, int how)
  370. {
  371. struct sock *sk = sock->sk;
  372. int rc = -ENOTCONN;
  373. lock_sock(sk);
  374. if (unlikely(sk->sk_state != TCP_ESTABLISHED))
  375. goto out;
  376. rc = -EINVAL;
  377. if (how != 2)
  378. goto out;
  379. rc = llc_send_disc(sk);
  380. if (!rc)
  381. rc = llc_ui_wait_for_disc(sk, sk->sk_rcvtimeo);
  382. /* Wake up anyone sleeping in poll */
  383. sk->sk_state_change(sk);
  384. out:
  385. release_sock(sk);
  386. return rc;
  387. }
  388. /**
  389. * llc_ui_connect - Connect to a remote llc2 mac + sap.
  390. * @sock: Socket which will be connected to the remote destination.
  391. * @uaddr: Remote and possibly the local address of the new connection.
  392. * @addrlen: Size of uaddr structure.
  393. * @flags: Operational flags specified by the user.
  394. *
  395. * Connect to a remote llc2 mac + sap. The caller must specify the
  396. * destination mac and address to connect to. If the user hasn't previously
  397. * called bind(2) with a smac the address of the first interface of the
  398. * specified arp type will be used.
  399. * This function will autobind if user did not previously call bind.
  400. * Returns: 0 upon success, negative otherwise.
  401. */
  402. static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr,
  403. int addrlen, int flags)
  404. {
  405. struct sock *sk = sock->sk;
  406. struct llc_sock *llc = llc_sk(sk);
  407. struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr;
  408. int rc = -EINVAL;
  409. lock_sock(sk);
  410. if (unlikely(addrlen != sizeof(*addr)))
  411. goto out;
  412. rc = -EAFNOSUPPORT;
  413. if (unlikely(addr->sllc_family != AF_LLC))
  414. goto out;
  415. if (unlikely(sk->sk_type != SOCK_STREAM))
  416. goto out;
  417. rc = -EALREADY;
  418. if (unlikely(sock->state == SS_CONNECTING))
  419. goto out;
  420. /* bind connection to sap if user hasn't done it. */
  421. if (sock_flag(sk, SOCK_ZAPPED)) {
  422. /* bind to sap with null dev, exclusive */
  423. rc = llc_ui_autobind(sock, addr);
  424. if (rc)
  425. goto out;
  426. }
  427. llc->daddr.lsap = addr->sllc_sap;
  428. memcpy(llc->daddr.mac, addr->sllc_mac, IFHWADDRLEN);
  429. sock->state = SS_CONNECTING;
  430. sk->sk_state = TCP_SYN_SENT;
  431. llc->link = llc_ui_next_link_no(llc->sap->laddr.lsap);
  432. rc = llc_establish_connection(sk, llc->dev->dev_addr,
  433. addr->sllc_mac, addr->sllc_sap);
  434. if (rc) {
  435. dprintk("%s: llc_ui_send_conn failed :-(\n", __func__);
  436. sock->state = SS_UNCONNECTED;
  437. sk->sk_state = TCP_CLOSE;
  438. goto out;
  439. }
  440. if (sk->sk_state == TCP_SYN_SENT) {
  441. const long timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
  442. if (!timeo || !llc_ui_wait_for_conn(sk, timeo))
  443. goto out;
  444. rc = sock_intr_errno(timeo);
  445. if (signal_pending(current))
  446. goto out;
  447. }
  448. if (sk->sk_state == TCP_CLOSE)
  449. goto sock_error;
  450. sock->state = SS_CONNECTED;
  451. rc = 0;
  452. out:
  453. release_sock(sk);
  454. return rc;
  455. sock_error:
  456. rc = sock_error(sk) ? : -ECONNABORTED;
  457. sock->state = SS_UNCONNECTED;
  458. goto out;
  459. }
  460. /**
  461. * llc_ui_listen - allow a normal socket to accept incoming connections
  462. * @sock: Socket to allow incoming connections on.
  463. * @backlog: Number of connections to queue.
  464. *
  465. * Allow a normal socket to accept incoming connections.
  466. * Returns 0 upon success, negative otherwise.
  467. */
  468. static int llc_ui_listen(struct socket *sock, int backlog)
  469. {
  470. struct sock *sk = sock->sk;
  471. int rc = -EINVAL;
  472. lock_sock(sk);
  473. if (unlikely(sock->state != SS_UNCONNECTED))
  474. goto out;
  475. rc = -EOPNOTSUPP;
  476. if (unlikely(sk->sk_type != SOCK_STREAM))
  477. goto out;
  478. rc = -EAGAIN;
  479. if (sock_flag(sk, SOCK_ZAPPED))
  480. goto out;
  481. rc = 0;
  482. if (!(unsigned)backlog) /* BSDism */
  483. backlog = 1;
  484. sk->sk_max_ack_backlog = backlog;
  485. if (sk->sk_state != TCP_LISTEN) {
  486. sk->sk_ack_backlog = 0;
  487. sk->sk_state = TCP_LISTEN;
  488. }
  489. sk->sk_socket->flags |= __SO_ACCEPTCON;
  490. out:
  491. release_sock(sk);
  492. return rc;
  493. }
  494. static int llc_ui_wait_for_disc(struct sock *sk, long timeout)
  495. {
  496. DEFINE_WAIT(wait);
  497. int rc = 0;
  498. while (1) {
  499. prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
  500. if (sk_wait_event(sk, &timeout, sk->sk_state == TCP_CLOSE))
  501. break;
  502. rc = -ERESTARTSYS;
  503. if (signal_pending(current))
  504. break;
  505. rc = -EAGAIN;
  506. if (!timeout)
  507. break;
  508. rc = 0;
  509. }
  510. finish_wait(sk_sleep(sk), &wait);
  511. return rc;
  512. }
  513. static int llc_ui_wait_for_conn(struct sock *sk, long timeout)
  514. {
  515. DEFINE_WAIT(wait);
  516. while (1) {
  517. prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
  518. if (sk_wait_event(sk, &timeout, sk->sk_state != TCP_SYN_SENT))
  519. break;
  520. if (signal_pending(current) || !timeout)
  521. break;
  522. }
  523. finish_wait(sk_sleep(sk), &wait);
  524. return timeout;
  525. }
  526. static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout)
  527. {
  528. DEFINE_WAIT(wait);
  529. struct llc_sock *llc = llc_sk(sk);
  530. int rc;
  531. while (1) {
  532. prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
  533. rc = 0;
  534. if (sk_wait_event(sk, &timeout,
  535. (sk->sk_shutdown & RCV_SHUTDOWN) ||
  536. (!llc_data_accept_state(llc->state) &&
  537. !llc->remote_busy_flag &&
  538. !llc->p_flag)))
  539. break;
  540. rc = -ERESTARTSYS;
  541. if (signal_pending(current))
  542. break;
  543. rc = -EAGAIN;
  544. if (!timeout)
  545. break;
  546. }
  547. finish_wait(sk_sleep(sk), &wait);
  548. return rc;
  549. }
  550. static int llc_wait_data(struct sock *sk, long timeo)
  551. {
  552. int rc;
  553. while (1) {
  554. /*
  555. * POSIX 1003.1g mandates this order.
  556. */
  557. rc = sock_error(sk);
  558. if (rc)
  559. break;
  560. rc = 0;
  561. if (sk->sk_shutdown & RCV_SHUTDOWN)
  562. break;
  563. rc = -EAGAIN;
  564. if (!timeo)
  565. break;
  566. rc = sock_intr_errno(timeo);
  567. if (signal_pending(current))
  568. break;
  569. rc = 0;
  570. if (sk_wait_data(sk, &timeo))
  571. break;
  572. }
  573. return rc;
  574. }
  575. static void llc_cmsg_rcv(struct msghdr *msg, struct sk_buff *skb)
  576. {
  577. struct llc_sock *llc = llc_sk(skb->sk);
  578. if (llc->cmsg_flags & LLC_CMSG_PKTINFO) {
  579. struct llc_pktinfo info;
  580. info.lpi_ifindex = llc_sk(skb->sk)->dev->ifindex;
  581. llc_pdu_decode_dsap(skb, &info.lpi_sap);
  582. llc_pdu_decode_da(skb, info.lpi_mac);
  583. put_cmsg(msg, SOL_LLC, LLC_OPT_PKTINFO, sizeof(info), &info);
  584. }
  585. }
  586. /**
  587. * llc_ui_accept - accept a new incoming connection.
  588. * @sock: Socket which connections arrive on.
  589. * @newsock: Socket to move incoming connection to.
  590. * @flags: User specified operational flags.
  591. *
  592. * Accept a new incoming connection.
  593. * Returns 0 upon success, negative otherwise.
  594. */
  595. static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags)
  596. {
  597. struct sock *sk = sock->sk, *newsk;
  598. struct llc_sock *llc, *newllc;
  599. struct sk_buff *skb;
  600. int rc = -EOPNOTSUPP;
  601. dprintk("%s: accepting on %02X\n", __func__,
  602. llc_sk(sk)->laddr.lsap);
  603. lock_sock(sk);
  604. if (unlikely(sk->sk_type != SOCK_STREAM))
  605. goto out;
  606. rc = -EINVAL;
  607. if (unlikely(sock->state != SS_UNCONNECTED ||
  608. sk->sk_state != TCP_LISTEN))
  609. goto out;
  610. /* wait for a connection to arrive. */
  611. if (skb_queue_empty(&sk->sk_receive_queue)) {
  612. rc = llc_wait_data(sk, sk->sk_rcvtimeo);
  613. if (rc)
  614. goto out;
  615. }
  616. dprintk("%s: got a new connection on %02X\n", __func__,
  617. llc_sk(sk)->laddr.lsap);
  618. skb = skb_dequeue(&sk->sk_receive_queue);
  619. rc = -EINVAL;
  620. if (!skb->sk)
  621. goto frees;
  622. rc = 0;
  623. newsk = skb->sk;
  624. /* attach connection to a new socket. */
  625. llc_ui_sk_init(newsock, newsk);
  626. sock_reset_flag(newsk, SOCK_ZAPPED);
  627. newsk->sk_state = TCP_ESTABLISHED;
  628. newsock->state = SS_CONNECTED;
  629. llc = llc_sk(sk);
  630. newllc = llc_sk(newsk);
  631. memcpy(&newllc->addr, &llc->addr, sizeof(newllc->addr));
  632. newllc->link = llc_ui_next_link_no(newllc->laddr.lsap);
  633. /* put original socket back into a clean listen state. */
  634. sk->sk_state = TCP_LISTEN;
  635. sk->sk_ack_backlog--;
  636. dprintk("%s: ok success on %02X, client on %02X\n", __func__,
  637. llc_sk(sk)->addr.sllc_sap, newllc->daddr.lsap);
  638. frees:
  639. kfree_skb(skb);
  640. out:
  641. release_sock(sk);
  642. return rc;
  643. }
  644. /**
  645. * llc_ui_recvmsg - copy received data to the socket user.
  646. * @sock: Socket to copy data from.
  647. * @msg: Various user space related information.
  648. * @len: Size of user buffer.
  649. * @flags: User specified flags.
  650. *
  651. * Copy received data to the socket user.
  652. * Returns non-negative upon success, negative otherwise.
  653. */
  654. static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
  655. struct msghdr *msg, size_t len, int flags)
  656. {
  657. struct sockaddr_llc *uaddr = (struct sockaddr_llc *)msg->msg_name;
  658. const int nonblock = flags & MSG_DONTWAIT;
  659. struct sk_buff *skb = NULL;
  660. struct sock *sk = sock->sk;
  661. struct llc_sock *llc = llc_sk(sk);
  662. size_t copied = 0;
  663. u32 peek_seq = 0;
  664. u32 *seq;
  665. unsigned long used;
  666. int target; /* Read at least this many bytes */
  667. long timeo;
  668. lock_sock(sk);
  669. copied = -ENOTCONN;
  670. if (unlikely(sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_LISTEN))
  671. goto out;
  672. timeo = sock_rcvtimeo(sk, nonblock);
  673. seq = &llc->copied_seq;
  674. if (flags & MSG_PEEK) {
  675. peek_seq = llc->copied_seq;
  676. seq = &peek_seq;
  677. }
  678. target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
  679. copied = 0;
  680. do {
  681. u32 offset;
  682. /*
  683. * We need to check signals first, to get correct SIGURG
  684. * handling. FIXME: Need to check this doesn't impact 1003.1g
  685. * and move it down to the bottom of the loop
  686. */
  687. if (signal_pending(current)) {
  688. if (copied)
  689. break;
  690. copied = timeo ? sock_intr_errno(timeo) : -EAGAIN;
  691. break;
  692. }
  693. /* Next get a buffer. */
  694. skb = skb_peek(&sk->sk_receive_queue);
  695. if (skb) {
  696. offset = *seq;
  697. goto found_ok_skb;
  698. }
  699. /* Well, if we have backlog, try to process it now yet. */
  700. if (copied >= target && !sk->sk_backlog.tail)
  701. break;
  702. if (copied) {
  703. if (sk->sk_err ||
  704. sk->sk_state == TCP_CLOSE ||
  705. (sk->sk_shutdown & RCV_SHUTDOWN) ||
  706. !timeo ||
  707. (flags & MSG_PEEK))
  708. break;
  709. } else {
  710. if (sock_flag(sk, SOCK_DONE))
  711. break;
  712. if (sk->sk_err) {
  713. copied = sock_error(sk);
  714. break;
  715. }
  716. if (sk->sk_shutdown & RCV_SHUTDOWN)
  717. break;
  718. if (sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_CLOSE) {
  719. if (!sock_flag(sk, SOCK_DONE)) {
  720. /*
  721. * This occurs when user tries to read
  722. * from never connected socket.
  723. */
  724. copied = -ENOTCONN;
  725. break;
  726. }
  727. break;
  728. }
  729. if (!timeo) {
  730. copied = -EAGAIN;
  731. break;
  732. }
  733. }
  734. if (copied >= target) { /* Do not sleep, just process backlog. */
  735. release_sock(sk);
  736. lock_sock(sk);
  737. } else
  738. sk_wait_data(sk, &timeo);
  739. if ((flags & MSG_PEEK) && peek_seq != llc->copied_seq) {
  740. if (net_ratelimit())
  741. printk(KERN_DEBUG "LLC(%s:%d): Application "
  742. "bug, race in MSG_PEEK.\n",
  743. current->comm, task_pid_nr(current));
  744. peek_seq = llc->copied_seq;
  745. }
  746. continue;
  747. found_ok_skb:
  748. /* Ok so how much can we use? */
  749. used = skb->len - offset;
  750. if (len < used)
  751. used = len;
  752. if (!(flags & MSG_TRUNC)) {
  753. int rc = skb_copy_datagram_iovec(skb, offset,
  754. msg->msg_iov, used);
  755. if (rc) {
  756. /* Exception. Bailout! */
  757. if (!copied)
  758. copied = -EFAULT;
  759. break;
  760. }
  761. }
  762. *seq += used;
  763. copied += used;
  764. len -= used;
  765. /* For non stream protcols we get one packet per recvmsg call */
  766. if (sk->sk_type != SOCK_STREAM)
  767. goto copy_uaddr;
  768. if (!(flags & MSG_PEEK)) {
  769. sk_eat_skb(sk, skb, 0);
  770. *seq = 0;
  771. }
  772. /* Partial read */
  773. if (used + offset < skb->len)
  774. continue;
  775. } while (len > 0);
  776. out:
  777. release_sock(sk);
  778. return copied;
  779. copy_uaddr:
  780. if (uaddr != NULL && skb != NULL) {
  781. memcpy(uaddr, llc_ui_skb_cb(skb), sizeof(*uaddr));
  782. msg->msg_namelen = sizeof(*uaddr);
  783. }
  784. if (llc_sk(sk)->cmsg_flags)
  785. llc_cmsg_rcv(msg, skb);
  786. if (!(flags & MSG_PEEK)) {
  787. sk_eat_skb(sk, skb, 0);
  788. *seq = 0;
  789. }
  790. goto out;
  791. }
  792. /**
  793. * llc_ui_sendmsg - Transmit data provided by the socket user.
  794. * @sock: Socket to transmit data from.
  795. * @msg: Various user related information.
  796. * @len: Length of data to transmit.
  797. *
  798. * Transmit data provided by the socket user.
  799. * Returns non-negative upon success, negative otherwise.
  800. */
  801. static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock,
  802. struct msghdr *msg, size_t len)
  803. {
  804. struct sock *sk = sock->sk;
  805. struct llc_sock *llc = llc_sk(sk);
  806. struct sockaddr_llc *addr = (struct sockaddr_llc *)msg->msg_name;
  807. int flags = msg->msg_flags;
  808. int noblock = flags & MSG_DONTWAIT;
  809. struct sk_buff *skb;
  810. size_t size = 0;
  811. int rc = -EINVAL, copied = 0, hdrlen;
  812. dprintk("%s: sending from %02X to %02X\n", __func__,
  813. llc->laddr.lsap, llc->daddr.lsap);
  814. lock_sock(sk);
  815. if (addr) {
  816. if (msg->msg_namelen < sizeof(*addr))
  817. goto release;
  818. } else {
  819. if (llc_ui_addr_null(&llc->addr))
  820. goto release;
  821. addr = &llc->addr;
  822. }
  823. /* must bind connection to sap if user hasn't done it. */
  824. if (sock_flag(sk, SOCK_ZAPPED)) {
  825. /* bind to sap with null dev, exclusive. */
  826. rc = llc_ui_autobind(sock, addr);
  827. if (rc)
  828. goto release;
  829. }
  830. hdrlen = llc->dev->hard_header_len + llc_ui_header_len(sk, addr);
  831. size = hdrlen + len;
  832. if (size > llc->dev->mtu)
  833. size = llc->dev->mtu;
  834. copied = size - hdrlen;
  835. release_sock(sk);
  836. skb = sock_alloc_send_skb(sk, size, noblock, &rc);
  837. lock_sock(sk);
  838. if (!skb)
  839. goto release;
  840. skb->dev = llc->dev;
  841. skb->protocol = llc_proto_type(addr->sllc_arphrd);
  842. skb_reserve(skb, hdrlen);
  843. rc = memcpy_fromiovec(skb_put(skb, copied), msg->msg_iov, copied);
  844. if (rc)
  845. goto out;
  846. if (sk->sk_type == SOCK_DGRAM || addr->sllc_ua) {
  847. llc_build_and_send_ui_pkt(llc->sap, skb, addr->sllc_mac,
  848. addr->sllc_sap);
  849. goto out;
  850. }
  851. if (addr->sllc_test) {
  852. llc_build_and_send_test_pkt(llc->sap, skb, addr->sllc_mac,
  853. addr->sllc_sap);
  854. goto out;
  855. }
  856. if (addr->sllc_xid) {
  857. llc_build_and_send_xid_pkt(llc->sap, skb, addr->sllc_mac,
  858. addr->sllc_sap);
  859. goto out;
  860. }
  861. rc = -ENOPROTOOPT;
  862. if (!(sk->sk_type == SOCK_STREAM && !addr->sllc_ua))
  863. goto out;
  864. rc = llc_ui_send_data(sk, skb, noblock);
  865. out:
  866. if (rc) {
  867. kfree_skb(skb);
  868. release:
  869. dprintk("%s: failed sending from %02X to %02X: %d\n",
  870. __func__, llc->laddr.lsap, llc->daddr.lsap, rc);
  871. }
  872. release_sock(sk);
  873. return rc ? : copied;
  874. }
  875. /**
  876. * llc_ui_getname - return the address info of a socket
  877. * @sock: Socket to get address of.
  878. * @uaddr: Address structure to return information.
  879. * @uaddrlen: Length of address structure.
  880. * @peer: Does user want local or remote address information.
  881. *
  882. * Return the address information of a socket.
  883. */
  884. static int llc_ui_getname(struct socket *sock, struct sockaddr *uaddr,
  885. int *uaddrlen, int peer)
  886. {
  887. struct sockaddr_llc sllc;
  888. struct sock *sk = sock->sk;
  889. struct llc_sock *llc = llc_sk(sk);
  890. int rc = 0;
  891. memset(&sllc, 0, sizeof(sllc));
  892. lock_sock(sk);
  893. if (sock_flag(sk, SOCK_ZAPPED))
  894. goto out;
  895. *uaddrlen = sizeof(sllc);
  896. memset(uaddr, 0, *uaddrlen);
  897. if (peer) {
  898. rc = -ENOTCONN;
  899. if (sk->sk_state != TCP_ESTABLISHED)
  900. goto out;
  901. if(llc->dev)
  902. sllc.sllc_arphrd = llc->dev->type;
  903. sllc.sllc_sap = llc->daddr.lsap;
  904. memcpy(&sllc.sllc_mac, &llc->daddr.mac, IFHWADDRLEN);
  905. } else {
  906. rc = -EINVAL;
  907. if (!llc->sap)
  908. goto out;
  909. sllc.sllc_sap = llc->sap->laddr.lsap;
  910. if (llc->dev) {
  911. sllc.sllc_arphrd = llc->dev->type;
  912. memcpy(&sllc.sllc_mac, llc->dev->dev_addr,
  913. IFHWADDRLEN);
  914. }
  915. }
  916. rc = 0;
  917. sllc.sllc_family = AF_LLC;
  918. memcpy(uaddr, &sllc, sizeof(sllc));
  919. out:
  920. release_sock(sk);
  921. return rc;
  922. }
  923. /**
  924. * llc_ui_ioctl - io controls for PF_LLC
  925. * @sock: Socket to get/set info
  926. * @cmd: command
  927. * @arg: optional argument for cmd
  928. *
  929. * get/set info on llc sockets
  930. */
  931. static int llc_ui_ioctl(struct socket *sock, unsigned int cmd,
  932. unsigned long arg)
  933. {
  934. return -ENOIOCTLCMD;
  935. }
  936. /**
  937. * llc_ui_setsockopt - set various connection specific parameters.
  938. * @sock: Socket to set options on.
  939. * @level: Socket level user is requesting operations on.
  940. * @optname: Operation name.
  941. * @optval User provided operation data.
  942. * @optlen: Length of optval.
  943. *
  944. * Set various connection specific parameters.
  945. */
  946. static int llc_ui_setsockopt(struct socket *sock, int level, int optname,
  947. char __user *optval, unsigned int optlen)
  948. {
  949. struct sock *sk = sock->sk;
  950. struct llc_sock *llc = llc_sk(sk);
  951. unsigned int opt;
  952. int rc = -EINVAL;
  953. lock_sock(sk);
  954. if (unlikely(level != SOL_LLC || optlen != sizeof(int)))
  955. goto out;
  956. rc = get_user(opt, (int __user *)optval);
  957. if (rc)
  958. goto out;
  959. rc = -EINVAL;
  960. switch (optname) {
  961. case LLC_OPT_RETRY:
  962. if (opt > LLC_OPT_MAX_RETRY)
  963. goto out;
  964. llc->n2 = opt;
  965. break;
  966. case LLC_OPT_SIZE:
  967. if (opt > LLC_OPT_MAX_SIZE)
  968. goto out;
  969. llc->n1 = opt;
  970. break;
  971. case LLC_OPT_ACK_TMR_EXP:
  972. if (opt > LLC_OPT_MAX_ACK_TMR_EXP)
  973. goto out;
  974. llc->ack_timer.expire = opt * HZ;
  975. break;
  976. case LLC_OPT_P_TMR_EXP:
  977. if (opt > LLC_OPT_MAX_P_TMR_EXP)
  978. goto out;
  979. llc->pf_cycle_timer.expire = opt * HZ;
  980. break;
  981. case LLC_OPT_REJ_TMR_EXP:
  982. if (opt > LLC_OPT_MAX_REJ_TMR_EXP)
  983. goto out;
  984. llc->rej_sent_timer.expire = opt * HZ;
  985. break;
  986. case LLC_OPT_BUSY_TMR_EXP:
  987. if (opt > LLC_OPT_MAX_BUSY_TMR_EXP)
  988. goto out;
  989. llc->busy_state_timer.expire = opt * HZ;
  990. break;
  991. case LLC_OPT_TX_WIN:
  992. if (opt > LLC_OPT_MAX_WIN)
  993. goto out;
  994. llc->k = opt;
  995. break;
  996. case LLC_OPT_RX_WIN:
  997. if (opt > LLC_OPT_MAX_WIN)
  998. goto out;
  999. llc->rw = opt;
  1000. break;
  1001. case LLC_OPT_PKTINFO:
  1002. if (opt)
  1003. llc->cmsg_flags |= LLC_CMSG_PKTINFO;
  1004. else
  1005. llc->cmsg_flags &= ~LLC_CMSG_PKTINFO;
  1006. break;
  1007. default:
  1008. rc = -ENOPROTOOPT;
  1009. goto out;
  1010. }
  1011. rc = 0;
  1012. out:
  1013. release_sock(sk);
  1014. return rc;
  1015. }
  1016. /**
  1017. * llc_ui_getsockopt - get connection specific socket info
  1018. * @sock: Socket to get information from.
  1019. * @level: Socket level user is requesting operations on.
  1020. * @optname: Operation name.
  1021. * @optval: Variable to return operation data in.
  1022. * @optlen: Length of optval.
  1023. *
  1024. * Get connection specific socket information.
  1025. */
  1026. static int llc_ui_getsockopt(struct socket *sock, int level, int optname,
  1027. char __user *optval, int __user *optlen)
  1028. {
  1029. struct sock *sk = sock->sk;
  1030. struct llc_sock *llc = llc_sk(sk);
  1031. int val = 0, len = 0, rc = -EINVAL;
  1032. lock_sock(sk);
  1033. if (unlikely(level != SOL_LLC))
  1034. goto out;
  1035. rc = get_user(len, optlen);
  1036. if (rc)
  1037. goto out;
  1038. rc = -EINVAL;
  1039. if (len != sizeof(int))
  1040. goto out;
  1041. switch (optname) {
  1042. case LLC_OPT_RETRY:
  1043. val = llc->n2; break;
  1044. case LLC_OPT_SIZE:
  1045. val = llc->n1; break;
  1046. case LLC_OPT_ACK_TMR_EXP:
  1047. val = llc->ack_timer.expire / HZ; break;
  1048. case LLC_OPT_P_TMR_EXP:
  1049. val = llc->pf_cycle_timer.expire / HZ; break;
  1050. case LLC_OPT_REJ_TMR_EXP:
  1051. val = llc->rej_sent_timer.expire / HZ; break;
  1052. case LLC_OPT_BUSY_TMR_EXP:
  1053. val = llc->busy_state_timer.expire / HZ; break;
  1054. case LLC_OPT_TX_WIN:
  1055. val = llc->k; break;
  1056. case LLC_OPT_RX_WIN:
  1057. val = llc->rw; break;
  1058. case LLC_OPT_PKTINFO:
  1059. val = (llc->cmsg_flags & LLC_CMSG_PKTINFO) != 0;
  1060. break;
  1061. default:
  1062. rc = -ENOPROTOOPT;
  1063. goto out;
  1064. }
  1065. rc = 0;
  1066. if (put_user(len, optlen) || copy_to_user(optval, &val, len))
  1067. rc = -EFAULT;
  1068. out:
  1069. release_sock(sk);
  1070. return rc;
  1071. }
  1072. static const struct net_proto_family llc_ui_family_ops = {
  1073. .family = PF_LLC,
  1074. .create = llc_ui_create,
  1075. .owner = THIS_MODULE,
  1076. };
  1077. static const struct proto_ops llc_ui_ops = {
  1078. .family = PF_LLC,
  1079. .owner = THIS_MODULE,
  1080. .release = llc_ui_release,
  1081. .bind = llc_ui_bind,
  1082. .connect = llc_ui_connect,
  1083. .socketpair = sock_no_socketpair,
  1084. .accept = llc_ui_accept,
  1085. .getname = llc_ui_getname,
  1086. .poll = datagram_poll,
  1087. .ioctl = llc_ui_ioctl,
  1088. .listen = llc_ui_listen,
  1089. .shutdown = llc_ui_shutdown,
  1090. .setsockopt = llc_ui_setsockopt,
  1091. .getsockopt = llc_ui_getsockopt,
  1092. .sendmsg = llc_ui_sendmsg,
  1093. .recvmsg = llc_ui_recvmsg,
  1094. .mmap = sock_no_mmap,
  1095. .sendpage = sock_no_sendpage,
  1096. };
  1097. static const char llc_proc_err_msg[] __initconst =
  1098. KERN_CRIT "LLC: Unable to register the proc_fs entries\n";
  1099. static const char llc_sysctl_err_msg[] __initconst =
  1100. KERN_CRIT "LLC: Unable to register the sysctl entries\n";
  1101. static const char llc_sock_err_msg[] __initconst =
  1102. KERN_CRIT "LLC: Unable to register the network family\n";
  1103. static int __init llc2_init(void)
  1104. {
  1105. int rc = proto_register(&llc_proto, 0);
  1106. if (rc != 0)
  1107. goto out;
  1108. llc_build_offset_table();
  1109. llc_station_init();
  1110. llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
  1111. rc = llc_proc_init();
  1112. if (rc != 0) {
  1113. printk(llc_proc_err_msg);
  1114. goto out_unregister_llc_proto;
  1115. }
  1116. rc = llc_sysctl_init();
  1117. if (rc) {
  1118. printk(llc_sysctl_err_msg);
  1119. goto out_proc;
  1120. }
  1121. rc = sock_register(&llc_ui_family_ops);
  1122. if (rc) {
  1123. printk(llc_sock_err_msg);
  1124. goto out_sysctl;
  1125. }
  1126. llc_add_pack(LLC_DEST_SAP, llc_sap_handler);
  1127. llc_add_pack(LLC_DEST_CONN, llc_conn_handler);
  1128. out:
  1129. return rc;
  1130. out_sysctl:
  1131. llc_sysctl_exit();
  1132. out_proc:
  1133. llc_proc_exit();
  1134. out_unregister_llc_proto:
  1135. proto_unregister(&llc_proto);
  1136. goto out;
  1137. }
  1138. static void __exit llc2_exit(void)
  1139. {
  1140. llc_station_exit();
  1141. llc_remove_pack(LLC_DEST_SAP);
  1142. llc_remove_pack(LLC_DEST_CONN);
  1143. sock_unregister(PF_LLC);
  1144. llc_proc_exit();
  1145. llc_sysctl_exit();
  1146. proto_unregister(&llc_proto);
  1147. }
  1148. module_init(llc2_init);
  1149. module_exit(llc2_exit);
  1150. MODULE_LICENSE("GPL");
  1151. MODULE_AUTHOR("Procom 1997, Jay Schullist 2001, Arnaldo C. Melo 2001-2003");
  1152. MODULE_DESCRIPTION("IEEE 802.2 PF_LLC support");
  1153. MODULE_ALIAS_NETPROTO(PF_LLC);