af_llc.c 31 KB

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