lec.c 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269
  1. /*
  2. * lec.c: Lan Emulation driver
  3. *
  4. * Marko Kiiskila <mkiiskila@yahoo.com>
  5. */
  6. #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
  7. #include <linux/slab.h>
  8. #include <linux/kernel.h>
  9. #include <linux/bitops.h>
  10. #include <linux/capability.h>
  11. /* We are ethernet device */
  12. #include <linux/if_ether.h>
  13. #include <linux/netdevice.h>
  14. #include <linux/etherdevice.h>
  15. #include <net/sock.h>
  16. #include <linux/skbuff.h>
  17. #include <linux/ip.h>
  18. #include <asm/byteorder.h>
  19. #include <linux/uaccess.h>
  20. #include <net/arp.h>
  21. #include <net/dst.h>
  22. #include <linux/proc_fs.h>
  23. #include <linux/spinlock.h>
  24. #include <linux/seq_file.h>
  25. /* And atm device */
  26. #include <linux/atmdev.h>
  27. #include <linux/atmlec.h>
  28. /* Proxy LEC knows about bridging */
  29. #if IS_ENABLED(CONFIG_BRIDGE)
  30. #include "../bridge/br_private.h"
  31. static unsigned char bridge_ula_lec[] = { 0x01, 0x80, 0xc2, 0x00, 0x00 };
  32. #endif
  33. /* Modular too */
  34. #include <linux/module.h>
  35. #include <linux/init.h>
  36. /* Hardening for Spectre-v1 */
  37. #include <linux/nospec.h>
  38. #include "lec.h"
  39. #include "lec_arpc.h"
  40. #include "resources.h"
  41. #define DUMP_PACKETS 0 /*
  42. * 0 = None,
  43. * 1 = 30 first bytes
  44. * 2 = Whole packet
  45. */
  46. #define LEC_UNRES_QUE_LEN 8 /*
  47. * number of tx packets to queue for a
  48. * single destination while waiting for SVC
  49. */
  50. static int lec_open(struct net_device *dev);
  51. static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
  52. struct net_device *dev);
  53. static int lec_close(struct net_device *dev);
  54. static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
  55. const unsigned char *mac_addr);
  56. static int lec_arp_remove(struct lec_priv *priv,
  57. struct lec_arp_table *to_remove);
  58. /* LANE2 functions */
  59. static void lane2_associate_ind(struct net_device *dev, const u8 *mac_address,
  60. const u8 *tlvs, u32 sizeoftlvs);
  61. static int lane2_resolve(struct net_device *dev, const u8 *dst_mac, int force,
  62. u8 **tlvs, u32 *sizeoftlvs);
  63. static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst,
  64. const u8 *tlvs, u32 sizeoftlvs);
  65. static int lec_addr_delete(struct lec_priv *priv, const unsigned char *atm_addr,
  66. unsigned long permanent);
  67. static void lec_arp_check_empties(struct lec_priv *priv,
  68. struct atm_vcc *vcc, struct sk_buff *skb);
  69. static void lec_arp_destroy(struct lec_priv *priv);
  70. static void lec_arp_init(struct lec_priv *priv);
  71. static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
  72. const unsigned char *mac_to_find,
  73. int is_rdesc,
  74. struct lec_arp_table **ret_entry);
  75. static void lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,
  76. const unsigned char *atm_addr,
  77. unsigned long remoteflag,
  78. unsigned int targetless_le_arp);
  79. static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id);
  80. static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc);
  81. static void lec_set_flush_tran_id(struct lec_priv *priv,
  82. const unsigned char *atm_addr,
  83. unsigned long tran_id);
  84. static void lec_vcc_added(struct lec_priv *priv,
  85. const struct atmlec_ioc *ioc_data,
  86. struct atm_vcc *vcc,
  87. void (*old_push)(struct atm_vcc *vcc,
  88. struct sk_buff *skb));
  89. static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc);
  90. /* must be done under lec_arp_lock */
  91. static inline void lec_arp_hold(struct lec_arp_table *entry)
  92. {
  93. refcount_inc(&entry->usage);
  94. }
  95. static inline void lec_arp_put(struct lec_arp_table *entry)
  96. {
  97. if (refcount_dec_and_test(&entry->usage))
  98. kfree(entry);
  99. }
  100. static struct lane2_ops lane2_ops = {
  101. .resolve = lane2_resolve, /* spec 3.1.3 */
  102. .associate_req = lane2_associate_req, /* spec 3.1.4 */
  103. .associate_indicator = NULL /* spec 3.1.5 */
  104. };
  105. static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  106. /* Device structures */
  107. static struct net_device *dev_lec[MAX_LEC_ITF];
  108. #if IS_ENABLED(CONFIG_BRIDGE)
  109. static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
  110. {
  111. char *buff;
  112. struct lec_priv *priv;
  113. /*
  114. * Check if this is a BPDU. If so, ask zeppelin to send
  115. * LE_TOPOLOGY_REQUEST with the same value of Topology Change bit
  116. * as the Config BPDU has
  117. */
  118. buff = skb->data + skb->dev->hard_header_len;
  119. if (*buff++ == 0x42 && *buff++ == 0x42 && *buff++ == 0x03) {
  120. struct sock *sk;
  121. struct sk_buff *skb2;
  122. struct atmlec_msg *mesg;
  123. skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
  124. if (skb2 == NULL)
  125. return;
  126. skb2->len = sizeof(struct atmlec_msg);
  127. mesg = (struct atmlec_msg *)skb2->data;
  128. mesg->type = l_topology_change;
  129. buff += 4;
  130. mesg->content.normal.flag = *buff & 0x01;
  131. /* 0x01 is topology change */
  132. priv = netdev_priv(dev);
  133. atm_force_charge(priv->lecd, skb2->truesize);
  134. sk = sk_atm(priv->lecd);
  135. skb_queue_tail(&sk->sk_receive_queue, skb2);
  136. sk->sk_data_ready(sk);
  137. }
  138. }
  139. #endif /* IS_ENABLED(CONFIG_BRIDGE) */
  140. /*
  141. * Open/initialize the netdevice. This is called (in the current kernel)
  142. * sometime after booting when the 'ifconfig' program is run.
  143. *
  144. * This routine should set everything up anew at each open, even
  145. * registers that "should" only need to be set once at boot, so that
  146. * there is non-reboot way to recover if something goes wrong.
  147. */
  148. static int lec_open(struct net_device *dev)
  149. {
  150. netif_start_queue(dev);
  151. return 0;
  152. }
  153. static void
  154. lec_send(struct atm_vcc *vcc, struct sk_buff *skb)
  155. {
  156. struct net_device *dev = skb->dev;
  157. ATM_SKB(skb)->vcc = vcc;
  158. atm_account_tx(vcc, skb);
  159. if (vcc->send(vcc, skb) < 0) {
  160. dev->stats.tx_dropped++;
  161. return;
  162. }
  163. dev->stats.tx_packets++;
  164. dev->stats.tx_bytes += skb->len;
  165. }
  166. static void lec_tx_timeout(struct net_device *dev)
  167. {
  168. pr_info("%s\n", dev->name);
  169. netif_trans_update(dev);
  170. netif_wake_queue(dev);
  171. }
  172. static netdev_tx_t lec_start_xmit(struct sk_buff *skb,
  173. struct net_device *dev)
  174. {
  175. struct sk_buff *skb2;
  176. struct lec_priv *priv = netdev_priv(dev);
  177. struct lecdatahdr_8023 *lec_h;
  178. struct atm_vcc *vcc;
  179. struct lec_arp_table *entry;
  180. unsigned char *dst;
  181. int min_frame_size;
  182. int is_rdesc;
  183. pr_debug("called\n");
  184. if (!priv->lecd) {
  185. pr_info("%s:No lecd attached\n", dev->name);
  186. dev->stats.tx_errors++;
  187. netif_stop_queue(dev);
  188. kfree_skb(skb);
  189. return NETDEV_TX_OK;
  190. }
  191. pr_debug("skbuff head:%lx data:%lx tail:%lx end:%lx\n",
  192. (long)skb->head, (long)skb->data, (long)skb_tail_pointer(skb),
  193. (long)skb_end_pointer(skb));
  194. #if IS_ENABLED(CONFIG_BRIDGE)
  195. if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0)
  196. lec_handle_bridge(skb, dev);
  197. #endif
  198. /* Make sure we have room for lec_id */
  199. if (skb_headroom(skb) < 2) {
  200. pr_debug("reallocating skb\n");
  201. skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
  202. if (unlikely(!skb2)) {
  203. kfree_skb(skb);
  204. return NETDEV_TX_OK;
  205. }
  206. consume_skb(skb);
  207. skb = skb2;
  208. }
  209. skb_push(skb, 2);
  210. /* Put le header to place */
  211. lec_h = (struct lecdatahdr_8023 *)skb->data;
  212. lec_h->le_header = htons(priv->lecid);
  213. #if DUMP_PACKETS >= 2
  214. #define MAX_DUMP_SKB 99
  215. #elif DUMP_PACKETS >= 1
  216. #define MAX_DUMP_SKB 30
  217. #endif
  218. #if DUMP_PACKETS >= 1
  219. printk(KERN_DEBUG "%s: send datalen:%ld lecid:%4.4x\n",
  220. dev->name, skb->len, priv->lecid);
  221. print_hex_dump(KERN_DEBUG, "", DUMP_OFFSET, 16, 1,
  222. skb->data, min(skb->len, MAX_DUMP_SKB), true);
  223. #endif /* DUMP_PACKETS >= 1 */
  224. /* Minimum ethernet-frame size */
  225. min_frame_size = LEC_MINIMUM_8023_SIZE;
  226. if (skb->len < min_frame_size) {
  227. if ((skb->len + skb_tailroom(skb)) < min_frame_size) {
  228. skb2 = skb_copy_expand(skb, 0,
  229. min_frame_size - skb->truesize,
  230. GFP_ATOMIC);
  231. dev_kfree_skb(skb);
  232. if (skb2 == NULL) {
  233. dev->stats.tx_dropped++;
  234. return NETDEV_TX_OK;
  235. }
  236. skb = skb2;
  237. }
  238. skb_put(skb, min_frame_size - skb->len);
  239. }
  240. /* Send to right vcc */
  241. is_rdesc = 0;
  242. dst = lec_h->h_dest;
  243. entry = NULL;
  244. vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry);
  245. pr_debug("%s:vcc:%p vcc_flags:%lx, entry:%p\n",
  246. dev->name, vcc, vcc ? vcc->flags : 0, entry);
  247. if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) {
  248. if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) {
  249. pr_debug("%s:queuing packet, MAC address %pM\n",
  250. dev->name, lec_h->h_dest);
  251. skb_queue_tail(&entry->tx_wait, skb);
  252. } else {
  253. pr_debug("%s:tx queue full or no arp entry, dropping, MAC address: %pM\n",
  254. dev->name, lec_h->h_dest);
  255. dev->stats.tx_dropped++;
  256. dev_kfree_skb(skb);
  257. }
  258. goto out;
  259. }
  260. #if DUMP_PACKETS > 0
  261. printk(KERN_DEBUG "%s:sending to vpi:%d vci:%d\n",
  262. dev->name, vcc->vpi, vcc->vci);
  263. #endif /* DUMP_PACKETS > 0 */
  264. while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) {
  265. pr_debug("emptying tx queue, MAC address %pM\n", lec_h->h_dest);
  266. lec_send(vcc, skb2);
  267. }
  268. lec_send(vcc, skb);
  269. if (!atm_may_send(vcc, 0)) {
  270. struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc);
  271. vpriv->xoff = 1;
  272. netif_stop_queue(dev);
  273. /*
  274. * vcc->pop() might have occurred in between, making
  275. * the vcc usuable again. Since xmit is serialized,
  276. * this is the only situation we have to re-test.
  277. */
  278. if (atm_may_send(vcc, 0))
  279. netif_wake_queue(dev);
  280. }
  281. out:
  282. if (entry)
  283. lec_arp_put(entry);
  284. netif_trans_update(dev);
  285. return NETDEV_TX_OK;
  286. }
  287. /* The inverse routine to net_open(). */
  288. static int lec_close(struct net_device *dev)
  289. {
  290. netif_stop_queue(dev);
  291. return 0;
  292. }
  293. static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
  294. {
  295. unsigned long flags;
  296. struct net_device *dev = (struct net_device *)vcc->proto_data;
  297. struct lec_priv *priv = netdev_priv(dev);
  298. struct atmlec_msg *mesg;
  299. struct lec_arp_table *entry;
  300. int i;
  301. char *tmp; /* FIXME */
  302. WARN_ON(refcount_sub_and_test(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc));
  303. mesg = (struct atmlec_msg *)skb->data;
  304. tmp = skb->data;
  305. tmp += sizeof(struct atmlec_msg);
  306. pr_debug("%s: msg from zeppelin:%d\n", dev->name, mesg->type);
  307. switch (mesg->type) {
  308. case l_set_mac_addr:
  309. for (i = 0; i < 6; i++)
  310. dev->dev_addr[i] = mesg->content.normal.mac_addr[i];
  311. break;
  312. case l_del_mac_addr:
  313. for (i = 0; i < 6; i++)
  314. dev->dev_addr[i] = 0;
  315. break;
  316. case l_addr_delete:
  317. lec_addr_delete(priv, mesg->content.normal.atm_addr,
  318. mesg->content.normal.flag);
  319. break;
  320. case l_topology_change:
  321. priv->topology_change = mesg->content.normal.flag;
  322. break;
  323. case l_flush_complete:
  324. lec_flush_complete(priv, mesg->content.normal.flag);
  325. break;
  326. case l_narp_req: /* LANE2: see 7.1.35 in the lane2 spec */
  327. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  328. entry = lec_arp_find(priv, mesg->content.normal.mac_addr);
  329. lec_arp_remove(priv, entry);
  330. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  331. if (mesg->content.normal.no_source_le_narp)
  332. break;
  333. /* FALL THROUGH */
  334. case l_arp_update:
  335. lec_arp_update(priv, mesg->content.normal.mac_addr,
  336. mesg->content.normal.atm_addr,
  337. mesg->content.normal.flag,
  338. mesg->content.normal.targetless_le_arp);
  339. pr_debug("in l_arp_update\n");
  340. if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */
  341. pr_debug("LANE2 3.1.5, got tlvs, size %d\n",
  342. mesg->sizeoftlvs);
  343. lane2_associate_ind(dev, mesg->content.normal.mac_addr,
  344. tmp, mesg->sizeoftlvs);
  345. }
  346. break;
  347. case l_config:
  348. priv->maximum_unknown_frame_count =
  349. mesg->content.config.maximum_unknown_frame_count;
  350. priv->max_unknown_frame_time =
  351. (mesg->content.config.max_unknown_frame_time * HZ);
  352. priv->max_retry_count = mesg->content.config.max_retry_count;
  353. priv->aging_time = (mesg->content.config.aging_time * HZ);
  354. priv->forward_delay_time =
  355. (mesg->content.config.forward_delay_time * HZ);
  356. priv->arp_response_time =
  357. (mesg->content.config.arp_response_time * HZ);
  358. priv->flush_timeout = (mesg->content.config.flush_timeout * HZ);
  359. priv->path_switching_delay =
  360. (mesg->content.config.path_switching_delay * HZ);
  361. priv->lane_version = mesg->content.config.lane_version;
  362. /* LANE2 */
  363. priv->lane2_ops = NULL;
  364. if (priv->lane_version > 1)
  365. priv->lane2_ops = &lane2_ops;
  366. rtnl_lock();
  367. if (dev_set_mtu(dev, mesg->content.config.mtu))
  368. pr_info("%s: change_mtu to %d failed\n",
  369. dev->name, mesg->content.config.mtu);
  370. rtnl_unlock();
  371. priv->is_proxy = mesg->content.config.is_proxy;
  372. break;
  373. case l_flush_tran_id:
  374. lec_set_flush_tran_id(priv, mesg->content.normal.atm_addr,
  375. mesg->content.normal.flag);
  376. break;
  377. case l_set_lecid:
  378. priv->lecid =
  379. (unsigned short)(0xffff & mesg->content.normal.flag);
  380. break;
  381. case l_should_bridge:
  382. #if IS_ENABLED(CONFIG_BRIDGE)
  383. {
  384. pr_debug("%s: bridge zeppelin asks about %pM\n",
  385. dev->name, mesg->content.proxy.mac_addr);
  386. if (br_fdb_test_addr_hook == NULL)
  387. break;
  388. if (br_fdb_test_addr_hook(dev, mesg->content.proxy.mac_addr)) {
  389. /* hit from bridge table, send LE_ARP_RESPONSE */
  390. struct sk_buff *skb2;
  391. struct sock *sk;
  392. pr_debug("%s: entry found, responding to zeppelin\n",
  393. dev->name);
  394. skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
  395. if (skb2 == NULL)
  396. break;
  397. skb2->len = sizeof(struct atmlec_msg);
  398. skb_copy_to_linear_data(skb2, mesg, sizeof(*mesg));
  399. atm_force_charge(priv->lecd, skb2->truesize);
  400. sk = sk_atm(priv->lecd);
  401. skb_queue_tail(&sk->sk_receive_queue, skb2);
  402. sk->sk_data_ready(sk);
  403. }
  404. }
  405. #endif /* IS_ENABLED(CONFIG_BRIDGE) */
  406. break;
  407. default:
  408. pr_info("%s: Unknown message type %d\n", dev->name, mesg->type);
  409. dev_kfree_skb(skb);
  410. return -EINVAL;
  411. }
  412. dev_kfree_skb(skb);
  413. return 0;
  414. }
  415. static void lec_atm_close(struct atm_vcc *vcc)
  416. {
  417. struct sk_buff *skb;
  418. struct net_device *dev = (struct net_device *)vcc->proto_data;
  419. struct lec_priv *priv = netdev_priv(dev);
  420. priv->lecd = NULL;
  421. /* Do something needful? */
  422. netif_stop_queue(dev);
  423. lec_arp_destroy(priv);
  424. if (skb_peek(&sk_atm(vcc)->sk_receive_queue))
  425. pr_info("%s closing with messages pending\n", dev->name);
  426. while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue))) {
  427. atm_return(vcc, skb->truesize);
  428. dev_kfree_skb(skb);
  429. }
  430. pr_info("%s: Shut down!\n", dev->name);
  431. module_put(THIS_MODULE);
  432. }
  433. static const struct atmdev_ops lecdev_ops = {
  434. .close = lec_atm_close,
  435. .send = lec_atm_send
  436. };
  437. static struct atm_dev lecatm_dev = {
  438. .ops = &lecdev_ops,
  439. .type = "lec",
  440. .number = 999, /* dummy device number */
  441. .lock = __SPIN_LOCK_UNLOCKED(lecatm_dev.lock)
  442. };
  443. /*
  444. * LANE2: new argument struct sk_buff *data contains
  445. * the LE_ARP based TLVs introduced in the LANE2 spec
  446. */
  447. static int
  448. send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,
  449. const unsigned char *mac_addr, const unsigned char *atm_addr,
  450. struct sk_buff *data)
  451. {
  452. struct sock *sk;
  453. struct sk_buff *skb;
  454. struct atmlec_msg *mesg;
  455. if (!priv || !priv->lecd)
  456. return -1;
  457. skb = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
  458. if (!skb)
  459. return -1;
  460. skb->len = sizeof(struct atmlec_msg);
  461. mesg = (struct atmlec_msg *)skb->data;
  462. memset(mesg, 0, sizeof(struct atmlec_msg));
  463. mesg->type = type;
  464. if (data != NULL)
  465. mesg->sizeoftlvs = data->len;
  466. if (mac_addr)
  467. ether_addr_copy(mesg->content.normal.mac_addr, mac_addr);
  468. else
  469. mesg->content.normal.targetless_le_arp = 1;
  470. if (atm_addr)
  471. memcpy(&mesg->content.normal.atm_addr, atm_addr, ATM_ESA_LEN);
  472. atm_force_charge(priv->lecd, skb->truesize);
  473. sk = sk_atm(priv->lecd);
  474. skb_queue_tail(&sk->sk_receive_queue, skb);
  475. sk->sk_data_ready(sk);
  476. if (data != NULL) {
  477. pr_debug("about to send %d bytes of data\n", data->len);
  478. atm_force_charge(priv->lecd, data->truesize);
  479. skb_queue_tail(&sk->sk_receive_queue, data);
  480. sk->sk_data_ready(sk);
  481. }
  482. return 0;
  483. }
  484. static void lec_set_multicast_list(struct net_device *dev)
  485. {
  486. /*
  487. * by default, all multicast frames arrive over the bus.
  488. * eventually support selective multicast service
  489. */
  490. }
  491. static const struct net_device_ops lec_netdev_ops = {
  492. .ndo_open = lec_open,
  493. .ndo_stop = lec_close,
  494. .ndo_start_xmit = lec_start_xmit,
  495. .ndo_tx_timeout = lec_tx_timeout,
  496. .ndo_set_rx_mode = lec_set_multicast_list,
  497. };
  498. static const unsigned char lec_ctrl_magic[] = {
  499. 0xff,
  500. 0x00,
  501. 0x01,
  502. 0x01
  503. };
  504. #define LEC_DATA_DIRECT_8023 2
  505. #define LEC_DATA_DIRECT_8025 3
  506. static int lec_is_data_direct(struct atm_vcc *vcc)
  507. {
  508. return ((vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8023) ||
  509. (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025));
  510. }
  511. static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
  512. {
  513. unsigned long flags;
  514. struct net_device *dev = (struct net_device *)vcc->proto_data;
  515. struct lec_priv *priv = netdev_priv(dev);
  516. #if DUMP_PACKETS > 0
  517. printk(KERN_DEBUG "%s: vcc vpi:%d vci:%d\n",
  518. dev->name, vcc->vpi, vcc->vci);
  519. #endif
  520. if (!skb) {
  521. pr_debug("%s: null skb\n", dev->name);
  522. lec_vcc_close(priv, vcc);
  523. return;
  524. }
  525. #if DUMP_PACKETS >= 2
  526. #define MAX_SKB_DUMP 99
  527. #elif DUMP_PACKETS >= 1
  528. #define MAX_SKB_DUMP 30
  529. #endif
  530. #if DUMP_PACKETS > 0
  531. printk(KERN_DEBUG "%s: rcv datalen:%ld lecid:%4.4x\n",
  532. dev->name, skb->len, priv->lecid);
  533. print_hex_dump(KERN_DEBUG, "", DUMP_OFFSET, 16, 1,
  534. skb->data, min(MAX_SKB_DUMP, skb->len), true);
  535. #endif /* DUMP_PACKETS > 0 */
  536. if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) {
  537. /* Control frame, to daemon */
  538. struct sock *sk = sk_atm(vcc);
  539. pr_debug("%s: To daemon\n", dev->name);
  540. skb_queue_tail(&sk->sk_receive_queue, skb);
  541. sk->sk_data_ready(sk);
  542. } else { /* Data frame, queue to protocol handlers */
  543. struct lec_arp_table *entry;
  544. unsigned char *src, *dst;
  545. atm_return(vcc, skb->truesize);
  546. if (*(__be16 *) skb->data == htons(priv->lecid) ||
  547. !priv->lecd || !(dev->flags & IFF_UP)) {
  548. /*
  549. * Probably looping back, or if lecd is missing,
  550. * lecd has gone down
  551. */
  552. pr_debug("Ignoring frame...\n");
  553. dev_kfree_skb(skb);
  554. return;
  555. }
  556. dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest;
  557. /*
  558. * If this is a Data Direct VCC, and the VCC does not match
  559. * the LE_ARP cache entry, delete the LE_ARP cache entry.
  560. */
  561. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  562. if (lec_is_data_direct(vcc)) {
  563. src = ((struct lecdatahdr_8023 *)skb->data)->h_source;
  564. entry = lec_arp_find(priv, src);
  565. if (entry && entry->vcc != vcc) {
  566. lec_arp_remove(priv, entry);
  567. lec_arp_put(entry);
  568. }
  569. }
  570. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  571. if (!(dst[0] & 0x01) && /* Never filter Multi/Broadcast */
  572. !priv->is_proxy && /* Proxy wants all the packets */
  573. memcmp(dst, dev->dev_addr, dev->addr_len)) {
  574. dev_kfree_skb(skb);
  575. return;
  576. }
  577. if (!hlist_empty(&priv->lec_arp_empty_ones))
  578. lec_arp_check_empties(priv, vcc, skb);
  579. skb_pull(skb, 2); /* skip lec_id */
  580. skb->protocol = eth_type_trans(skb, dev);
  581. dev->stats.rx_packets++;
  582. dev->stats.rx_bytes += skb->len;
  583. memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
  584. netif_rx(skb);
  585. }
  586. }
  587. static void lec_pop(struct atm_vcc *vcc, struct sk_buff *skb)
  588. {
  589. struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc);
  590. struct net_device *dev = skb->dev;
  591. if (vpriv == NULL) {
  592. pr_info("vpriv = NULL!?!?!?\n");
  593. return;
  594. }
  595. vpriv->old_pop(vcc, skb);
  596. if (vpriv->xoff && atm_may_send(vcc, 0)) {
  597. vpriv->xoff = 0;
  598. if (netif_running(dev) && netif_queue_stopped(dev))
  599. netif_wake_queue(dev);
  600. }
  601. }
  602. static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
  603. {
  604. struct lec_vcc_priv *vpriv;
  605. int bytes_left;
  606. struct atmlec_ioc ioc_data;
  607. /* Lecd must be up in this case */
  608. bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc));
  609. if (bytes_left != 0)
  610. pr_info("copy from user failed for %d bytes\n", bytes_left);
  611. if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF)
  612. return -EINVAL;
  613. ioc_data.dev_num = array_index_nospec(ioc_data.dev_num, MAX_LEC_ITF);
  614. if (!dev_lec[ioc_data.dev_num])
  615. return -EINVAL;
  616. vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL);
  617. if (!vpriv)
  618. return -ENOMEM;
  619. vpriv->xoff = 0;
  620. vpriv->old_pop = vcc->pop;
  621. vcc->user_back = vpriv;
  622. vcc->pop = lec_pop;
  623. lec_vcc_added(netdev_priv(dev_lec[ioc_data.dev_num]),
  624. &ioc_data, vcc, vcc->push);
  625. vcc->proto_data = dev_lec[ioc_data.dev_num];
  626. vcc->push = lec_push;
  627. return 0;
  628. }
  629. static int lec_mcast_attach(struct atm_vcc *vcc, int arg)
  630. {
  631. if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg])
  632. return -EINVAL;
  633. vcc->proto_data = dev_lec[arg];
  634. return lec_mcast_make(netdev_priv(dev_lec[arg]), vcc);
  635. }
  636. /* Initialize device. */
  637. static int lecd_attach(struct atm_vcc *vcc, int arg)
  638. {
  639. int i;
  640. struct lec_priv *priv;
  641. if (arg < 0)
  642. i = 0;
  643. else
  644. i = arg;
  645. if (arg >= MAX_LEC_ITF)
  646. return -EINVAL;
  647. if (!dev_lec[i]) {
  648. int size;
  649. size = sizeof(struct lec_priv);
  650. dev_lec[i] = alloc_etherdev(size);
  651. if (!dev_lec[i])
  652. return -ENOMEM;
  653. dev_lec[i]->netdev_ops = &lec_netdev_ops;
  654. dev_lec[i]->max_mtu = 18190;
  655. snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i);
  656. if (register_netdev(dev_lec[i])) {
  657. free_netdev(dev_lec[i]);
  658. return -EINVAL;
  659. }
  660. priv = netdev_priv(dev_lec[i]);
  661. } else {
  662. priv = netdev_priv(dev_lec[i]);
  663. if (priv->lecd)
  664. return -EADDRINUSE;
  665. }
  666. lec_arp_init(priv);
  667. priv->itfnum = i; /* LANE2 addition */
  668. priv->lecd = vcc;
  669. vcc->dev = &lecatm_dev;
  670. vcc_insert_socket(sk_atm(vcc));
  671. vcc->proto_data = dev_lec[i];
  672. set_bit(ATM_VF_META, &vcc->flags);
  673. set_bit(ATM_VF_READY, &vcc->flags);
  674. /* Set default values to these variables */
  675. priv->maximum_unknown_frame_count = 1;
  676. priv->max_unknown_frame_time = (1 * HZ);
  677. priv->vcc_timeout_period = (1200 * HZ);
  678. priv->max_retry_count = 1;
  679. priv->aging_time = (300 * HZ);
  680. priv->forward_delay_time = (15 * HZ);
  681. priv->topology_change = 0;
  682. priv->arp_response_time = (1 * HZ);
  683. priv->flush_timeout = (4 * HZ);
  684. priv->path_switching_delay = (6 * HZ);
  685. if (dev_lec[i]->flags & IFF_UP)
  686. netif_start_queue(dev_lec[i]);
  687. __module_get(THIS_MODULE);
  688. return i;
  689. }
  690. #ifdef CONFIG_PROC_FS
  691. static const char *lec_arp_get_status_string(unsigned char status)
  692. {
  693. static const char *const lec_arp_status_string[] = {
  694. "ESI_UNKNOWN ",
  695. "ESI_ARP_PENDING ",
  696. "ESI_VC_PENDING ",
  697. "<Undefined> ",
  698. "ESI_FLUSH_PENDING ",
  699. "ESI_FORWARD_DIRECT"
  700. };
  701. if (status > ESI_FORWARD_DIRECT)
  702. status = 3; /* ESI_UNDEFINED */
  703. return lec_arp_status_string[status];
  704. }
  705. static void lec_info(struct seq_file *seq, struct lec_arp_table *entry)
  706. {
  707. int i;
  708. for (i = 0; i < ETH_ALEN; i++)
  709. seq_printf(seq, "%2.2x", entry->mac_addr[i] & 0xff);
  710. seq_printf(seq, " ");
  711. for (i = 0; i < ATM_ESA_LEN; i++)
  712. seq_printf(seq, "%2.2x", entry->atm_addr[i] & 0xff);
  713. seq_printf(seq, " %s %4.4x", lec_arp_get_status_string(entry->status),
  714. entry->flags & 0xffff);
  715. if (entry->vcc)
  716. seq_printf(seq, "%3d %3d ", entry->vcc->vpi, entry->vcc->vci);
  717. else
  718. seq_printf(seq, " ");
  719. if (entry->recv_vcc) {
  720. seq_printf(seq, " %3d %3d", entry->recv_vcc->vpi,
  721. entry->recv_vcc->vci);
  722. }
  723. seq_putc(seq, '\n');
  724. }
  725. struct lec_state {
  726. unsigned long flags;
  727. struct lec_priv *locked;
  728. struct hlist_node *node;
  729. struct net_device *dev;
  730. int itf;
  731. int arp_table;
  732. int misc_table;
  733. };
  734. static void *lec_tbl_walk(struct lec_state *state, struct hlist_head *tbl,
  735. loff_t *l)
  736. {
  737. struct hlist_node *e = state->node;
  738. if (!e)
  739. e = tbl->first;
  740. if (e == SEQ_START_TOKEN) {
  741. e = tbl->first;
  742. --*l;
  743. }
  744. for (; e; e = e->next) {
  745. if (--*l < 0)
  746. break;
  747. }
  748. state->node = e;
  749. return (*l < 0) ? state : NULL;
  750. }
  751. static void *lec_arp_walk(struct lec_state *state, loff_t *l,
  752. struct lec_priv *priv)
  753. {
  754. void *v = NULL;
  755. int p;
  756. for (p = state->arp_table; p < LEC_ARP_TABLE_SIZE; p++) {
  757. v = lec_tbl_walk(state, &priv->lec_arp_tables[p], l);
  758. if (v)
  759. break;
  760. }
  761. state->arp_table = p;
  762. return v;
  763. }
  764. static void *lec_misc_walk(struct lec_state *state, loff_t *l,
  765. struct lec_priv *priv)
  766. {
  767. struct hlist_head *lec_misc_tables[] = {
  768. &priv->lec_arp_empty_ones,
  769. &priv->lec_no_forward,
  770. &priv->mcast_fwds
  771. };
  772. void *v = NULL;
  773. int q;
  774. for (q = state->misc_table; q < ARRAY_SIZE(lec_misc_tables); q++) {
  775. v = lec_tbl_walk(state, lec_misc_tables[q], l);
  776. if (v)
  777. break;
  778. }
  779. state->misc_table = q;
  780. return v;
  781. }
  782. static void *lec_priv_walk(struct lec_state *state, loff_t *l,
  783. struct lec_priv *priv)
  784. {
  785. if (!state->locked) {
  786. state->locked = priv;
  787. spin_lock_irqsave(&priv->lec_arp_lock, state->flags);
  788. }
  789. if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) {
  790. spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags);
  791. state->locked = NULL;
  792. /* Partial state reset for the next time we get called */
  793. state->arp_table = state->misc_table = 0;
  794. }
  795. return state->locked;
  796. }
  797. static void *lec_itf_walk(struct lec_state *state, loff_t *l)
  798. {
  799. struct net_device *dev;
  800. void *v;
  801. dev = state->dev ? state->dev : dev_lec[state->itf];
  802. v = (dev && netdev_priv(dev)) ?
  803. lec_priv_walk(state, l, netdev_priv(dev)) : NULL;
  804. if (!v && dev) {
  805. dev_put(dev);
  806. /* Partial state reset for the next time we get called */
  807. dev = NULL;
  808. }
  809. state->dev = dev;
  810. return v;
  811. }
  812. static void *lec_get_idx(struct lec_state *state, loff_t l)
  813. {
  814. void *v = NULL;
  815. for (; state->itf < MAX_LEC_ITF; state->itf++) {
  816. v = lec_itf_walk(state, &l);
  817. if (v)
  818. break;
  819. }
  820. return v;
  821. }
  822. static void *lec_seq_start(struct seq_file *seq, loff_t *pos)
  823. {
  824. struct lec_state *state = seq->private;
  825. state->itf = 0;
  826. state->dev = NULL;
  827. state->locked = NULL;
  828. state->arp_table = 0;
  829. state->misc_table = 0;
  830. state->node = SEQ_START_TOKEN;
  831. return *pos ? lec_get_idx(state, *pos) : SEQ_START_TOKEN;
  832. }
  833. static void lec_seq_stop(struct seq_file *seq, void *v)
  834. {
  835. struct lec_state *state = seq->private;
  836. if (state->dev) {
  837. spin_unlock_irqrestore(&state->locked->lec_arp_lock,
  838. state->flags);
  839. dev_put(state->dev);
  840. }
  841. }
  842. static void *lec_seq_next(struct seq_file *seq, void *v, loff_t *pos)
  843. {
  844. struct lec_state *state = seq->private;
  845. v = lec_get_idx(state, 1);
  846. *pos += !!PTR_ERR(v);
  847. return v;
  848. }
  849. static int lec_seq_show(struct seq_file *seq, void *v)
  850. {
  851. static const char lec_banner[] =
  852. "Itf MAC ATM destination"
  853. " Status Flags "
  854. "VPI/VCI Recv VPI/VCI\n";
  855. if (v == SEQ_START_TOKEN)
  856. seq_puts(seq, lec_banner);
  857. else {
  858. struct lec_state *state = seq->private;
  859. struct net_device *dev = state->dev;
  860. struct lec_arp_table *entry = hlist_entry(state->node,
  861. struct lec_arp_table,
  862. next);
  863. seq_printf(seq, "%s ", dev->name);
  864. lec_info(seq, entry);
  865. }
  866. return 0;
  867. }
  868. static const struct seq_operations lec_seq_ops = {
  869. .start = lec_seq_start,
  870. .next = lec_seq_next,
  871. .stop = lec_seq_stop,
  872. .show = lec_seq_show,
  873. };
  874. #endif
  875. static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
  876. {
  877. struct atm_vcc *vcc = ATM_SD(sock);
  878. int err = 0;
  879. switch (cmd) {
  880. case ATMLEC_CTRL:
  881. case ATMLEC_MCAST:
  882. case ATMLEC_DATA:
  883. if (!capable(CAP_NET_ADMIN))
  884. return -EPERM;
  885. break;
  886. default:
  887. return -ENOIOCTLCMD;
  888. }
  889. switch (cmd) {
  890. case ATMLEC_CTRL:
  891. err = lecd_attach(vcc, (int)arg);
  892. if (err >= 0)
  893. sock->state = SS_CONNECTED;
  894. break;
  895. case ATMLEC_MCAST:
  896. err = lec_mcast_attach(vcc, (int)arg);
  897. break;
  898. case ATMLEC_DATA:
  899. err = lec_vcc_attach(vcc, (void __user *)arg);
  900. break;
  901. }
  902. return err;
  903. }
  904. static struct atm_ioctl lane_ioctl_ops = {
  905. .owner = THIS_MODULE,
  906. .ioctl = lane_ioctl,
  907. };
  908. static int __init lane_module_init(void)
  909. {
  910. #ifdef CONFIG_PROC_FS
  911. struct proc_dir_entry *p;
  912. p = proc_create_seq_private("lec", 0444, atm_proc_root, &lec_seq_ops,
  913. sizeof(struct lec_state), NULL);
  914. if (!p) {
  915. pr_err("Unable to initialize /proc/net/atm/lec\n");
  916. return -ENOMEM;
  917. }
  918. #endif
  919. register_atm_ioctl(&lane_ioctl_ops);
  920. pr_info("lec.c: initialized\n");
  921. return 0;
  922. }
  923. static void __exit lane_module_cleanup(void)
  924. {
  925. int i;
  926. #ifdef CONFIG_PROC_FS
  927. remove_proc_entry("lec", atm_proc_root);
  928. #endif
  929. deregister_atm_ioctl(&lane_ioctl_ops);
  930. for (i = 0; i < MAX_LEC_ITF; i++) {
  931. if (dev_lec[i] != NULL) {
  932. unregister_netdev(dev_lec[i]);
  933. free_netdev(dev_lec[i]);
  934. dev_lec[i] = NULL;
  935. }
  936. }
  937. }
  938. module_init(lane_module_init);
  939. module_exit(lane_module_cleanup);
  940. /*
  941. * LANE2: 3.1.3, LE_RESOLVE.request
  942. * Non force allocates memory and fills in *tlvs, fills in *sizeoftlvs.
  943. * If sizeoftlvs == NULL the default TLVs associated with with this
  944. * lec will be used.
  945. * If dst_mac == NULL, targetless LE_ARP will be sent
  946. */
  947. static int lane2_resolve(struct net_device *dev, const u8 *dst_mac, int force,
  948. u8 **tlvs, u32 *sizeoftlvs)
  949. {
  950. unsigned long flags;
  951. struct lec_priv *priv = netdev_priv(dev);
  952. struct lec_arp_table *table;
  953. struct sk_buff *skb;
  954. int retval;
  955. if (force == 0) {
  956. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  957. table = lec_arp_find(priv, dst_mac);
  958. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  959. if (table == NULL)
  960. return -1;
  961. *tlvs = kmemdup(table->tlvs, table->sizeoftlvs, GFP_ATOMIC);
  962. if (*tlvs == NULL)
  963. return -1;
  964. *sizeoftlvs = table->sizeoftlvs;
  965. return 0;
  966. }
  967. if (sizeoftlvs == NULL)
  968. retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, NULL);
  969. else {
  970. skb = alloc_skb(*sizeoftlvs, GFP_ATOMIC);
  971. if (skb == NULL)
  972. return -1;
  973. skb->len = *sizeoftlvs;
  974. skb_copy_to_linear_data(skb, *tlvs, *sizeoftlvs);
  975. retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, skb);
  976. }
  977. return retval;
  978. }
  979. /*
  980. * LANE2: 3.1.4, LE_ASSOCIATE.request
  981. * Associate the *tlvs with the *lan_dst address.
  982. * Will overwrite any previous association
  983. * Returns 1 for success, 0 for failure (out of memory)
  984. *
  985. */
  986. static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst,
  987. const u8 *tlvs, u32 sizeoftlvs)
  988. {
  989. int retval;
  990. struct sk_buff *skb;
  991. struct lec_priv *priv = netdev_priv(dev);
  992. if (!ether_addr_equal(lan_dst, dev->dev_addr))
  993. return 0; /* not our mac address */
  994. kfree(priv->tlvs); /* NULL if there was no previous association */
  995. priv->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL);
  996. if (priv->tlvs == NULL)
  997. return 0;
  998. priv->sizeoftlvs = sizeoftlvs;
  999. skb = alloc_skb(sizeoftlvs, GFP_ATOMIC);
  1000. if (skb == NULL)
  1001. return 0;
  1002. skb->len = sizeoftlvs;
  1003. skb_copy_to_linear_data(skb, tlvs, sizeoftlvs);
  1004. retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb);
  1005. if (retval != 0)
  1006. pr_info("lec.c: lane2_associate_req() failed\n");
  1007. /*
  1008. * If the previous association has changed we must
  1009. * somehow notify other LANE entities about the change
  1010. */
  1011. return 1;
  1012. }
  1013. /*
  1014. * LANE2: 3.1.5, LE_ASSOCIATE.indication
  1015. *
  1016. */
  1017. static void lane2_associate_ind(struct net_device *dev, const u8 *mac_addr,
  1018. const u8 *tlvs, u32 sizeoftlvs)
  1019. {
  1020. #if 0
  1021. int i = 0;
  1022. #endif
  1023. struct lec_priv *priv = netdev_priv(dev);
  1024. #if 0 /*
  1025. * Why have the TLVs in LE_ARP entries
  1026. * since we do not use them? When you
  1027. * uncomment this code, make sure the
  1028. * TLVs get freed when entry is killed
  1029. */
  1030. struct lec_arp_table *entry = lec_arp_find(priv, mac_addr);
  1031. if (entry == NULL)
  1032. return; /* should not happen */
  1033. kfree(entry->tlvs);
  1034. entry->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL);
  1035. if (entry->tlvs == NULL)
  1036. return;
  1037. entry->sizeoftlvs = sizeoftlvs;
  1038. #endif
  1039. #if 0
  1040. pr_info("\n");
  1041. pr_info("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs);
  1042. while (i < sizeoftlvs)
  1043. pr_cont("%02x ", tlvs[i++]);
  1044. pr_cont("\n");
  1045. #endif
  1046. /* tell MPOA about the TLVs we saw */
  1047. if (priv->lane2_ops && priv->lane2_ops->associate_indicator) {
  1048. priv->lane2_ops->associate_indicator(dev, mac_addr,
  1049. tlvs, sizeoftlvs);
  1050. }
  1051. }
  1052. /*
  1053. * Here starts what used to lec_arpc.c
  1054. *
  1055. * lec_arpc.c was added here when making
  1056. * lane client modular. October 1997
  1057. */
  1058. #include <linux/types.h>
  1059. #include <linux/timer.h>
  1060. #include <linux/param.h>
  1061. #include <linux/atomic.h>
  1062. #include <linux/inetdevice.h>
  1063. #include <net/route.h>
  1064. #if 0
  1065. #define pr_debug(format, args...)
  1066. /*
  1067. #define pr_debug printk
  1068. */
  1069. #endif
  1070. #define DEBUG_ARP_TABLE 0
  1071. #define LEC_ARP_REFRESH_INTERVAL (3*HZ)
  1072. static void lec_arp_check_expire(struct work_struct *work);
  1073. static void lec_arp_expire_arp(struct timer_list *t);
  1074. /*
  1075. * Arp table funcs
  1076. */
  1077. #define HASH(ch) (ch & (LEC_ARP_TABLE_SIZE - 1))
  1078. /*
  1079. * Initialization of arp-cache
  1080. */
  1081. static void lec_arp_init(struct lec_priv *priv)
  1082. {
  1083. unsigned short i;
  1084. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++)
  1085. INIT_HLIST_HEAD(&priv->lec_arp_tables[i]);
  1086. INIT_HLIST_HEAD(&priv->lec_arp_empty_ones);
  1087. INIT_HLIST_HEAD(&priv->lec_no_forward);
  1088. INIT_HLIST_HEAD(&priv->mcast_fwds);
  1089. spin_lock_init(&priv->lec_arp_lock);
  1090. INIT_DELAYED_WORK(&priv->lec_arp_work, lec_arp_check_expire);
  1091. schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
  1092. }
  1093. static void lec_arp_clear_vccs(struct lec_arp_table *entry)
  1094. {
  1095. if (entry->vcc) {
  1096. struct atm_vcc *vcc = entry->vcc;
  1097. struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc);
  1098. struct net_device *dev = (struct net_device *)vcc->proto_data;
  1099. vcc->pop = vpriv->old_pop;
  1100. if (vpriv->xoff)
  1101. netif_wake_queue(dev);
  1102. kfree(vpriv);
  1103. vcc->user_back = NULL;
  1104. vcc->push = entry->old_push;
  1105. vcc_release_async(vcc, -EPIPE);
  1106. entry->vcc = NULL;
  1107. }
  1108. if (entry->recv_vcc) {
  1109. entry->recv_vcc->push = entry->old_recv_push;
  1110. vcc_release_async(entry->recv_vcc, -EPIPE);
  1111. entry->recv_vcc = NULL;
  1112. }
  1113. }
  1114. /*
  1115. * Insert entry to lec_arp_table
  1116. * LANE2: Add to the end of the list to satisfy 8.1.13
  1117. */
  1118. static inline void
  1119. lec_arp_add(struct lec_priv *priv, struct lec_arp_table *entry)
  1120. {
  1121. struct hlist_head *tmp;
  1122. tmp = &priv->lec_arp_tables[HASH(entry->mac_addr[ETH_ALEN - 1])];
  1123. hlist_add_head(&entry->next, tmp);
  1124. pr_debug("Added entry:%pM\n", entry->mac_addr);
  1125. }
  1126. /*
  1127. * Remove entry from lec_arp_table
  1128. */
  1129. static int
  1130. lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove)
  1131. {
  1132. struct lec_arp_table *entry;
  1133. int i, remove_vcc = 1;
  1134. if (!to_remove)
  1135. return -1;
  1136. hlist_del(&to_remove->next);
  1137. del_timer(&to_remove->timer);
  1138. /*
  1139. * If this is the only MAC connected to this VCC,
  1140. * also tear down the VCC
  1141. */
  1142. if (to_remove->status >= ESI_FLUSH_PENDING) {
  1143. /*
  1144. * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT
  1145. */
  1146. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1147. hlist_for_each_entry(entry,
  1148. &priv->lec_arp_tables[i], next) {
  1149. if (memcmp(to_remove->atm_addr,
  1150. entry->atm_addr, ATM_ESA_LEN) == 0) {
  1151. remove_vcc = 0;
  1152. break;
  1153. }
  1154. }
  1155. }
  1156. if (remove_vcc)
  1157. lec_arp_clear_vccs(to_remove);
  1158. }
  1159. skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */
  1160. pr_debug("Removed entry:%pM\n", to_remove->mac_addr);
  1161. return 0;
  1162. }
  1163. #if DEBUG_ARP_TABLE
  1164. static const char *get_status_string(unsigned char st)
  1165. {
  1166. switch (st) {
  1167. case ESI_UNKNOWN:
  1168. return "ESI_UNKNOWN";
  1169. case ESI_ARP_PENDING:
  1170. return "ESI_ARP_PENDING";
  1171. case ESI_VC_PENDING:
  1172. return "ESI_VC_PENDING";
  1173. case ESI_FLUSH_PENDING:
  1174. return "ESI_FLUSH_PENDING";
  1175. case ESI_FORWARD_DIRECT:
  1176. return "ESI_FORWARD_DIRECT";
  1177. }
  1178. return "<UNKNOWN>";
  1179. }
  1180. static void dump_arp_table(struct lec_priv *priv)
  1181. {
  1182. struct lec_arp_table *rulla;
  1183. char buf[256];
  1184. int i, j, offset;
  1185. pr_info("Dump %p:\n", priv);
  1186. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1187. hlist_for_each_entry(rulla,
  1188. &priv->lec_arp_tables[i], next) {
  1189. offset = 0;
  1190. offset += sprintf(buf, "%d: %p\n", i, rulla);
  1191. offset += sprintf(buf + offset, "Mac: %pM",
  1192. rulla->mac_addr);
  1193. offset += sprintf(buf + offset, " Atm:");
  1194. for (j = 0; j < ATM_ESA_LEN; j++) {
  1195. offset += sprintf(buf + offset,
  1196. "%2.2x ",
  1197. rulla->atm_addr[j] & 0xff);
  1198. }
  1199. offset += sprintf(buf + offset,
  1200. "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
  1201. rulla->vcc ? rulla->vcc->vpi : 0,
  1202. rulla->vcc ? rulla->vcc->vci : 0,
  1203. rulla->recv_vcc ? rulla->recv_vcc->
  1204. vpi : 0,
  1205. rulla->recv_vcc ? rulla->recv_vcc->
  1206. vci : 0, rulla->last_used,
  1207. rulla->timestamp, rulla->no_tries);
  1208. offset +=
  1209. sprintf(buf + offset,
  1210. "Flags:%x, Packets_flooded:%x, Status: %s ",
  1211. rulla->flags, rulla->packets_flooded,
  1212. get_status_string(rulla->status));
  1213. pr_info("%s\n", buf);
  1214. }
  1215. }
  1216. if (!hlist_empty(&priv->lec_no_forward))
  1217. pr_info("No forward\n");
  1218. hlist_for_each_entry(rulla, &priv->lec_no_forward, next) {
  1219. offset = 0;
  1220. offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr);
  1221. offset += sprintf(buf + offset, " Atm:");
  1222. for (j = 0; j < ATM_ESA_LEN; j++) {
  1223. offset += sprintf(buf + offset, "%2.2x ",
  1224. rulla->atm_addr[j] & 0xff);
  1225. }
  1226. offset += sprintf(buf + offset,
  1227. "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
  1228. rulla->vcc ? rulla->vcc->vpi : 0,
  1229. rulla->vcc ? rulla->vcc->vci : 0,
  1230. rulla->recv_vcc ? rulla->recv_vcc->vpi : 0,
  1231. rulla->recv_vcc ? rulla->recv_vcc->vci : 0,
  1232. rulla->last_used,
  1233. rulla->timestamp, rulla->no_tries);
  1234. offset += sprintf(buf + offset,
  1235. "Flags:%x, Packets_flooded:%x, Status: %s ",
  1236. rulla->flags, rulla->packets_flooded,
  1237. get_status_string(rulla->status));
  1238. pr_info("%s\n", buf);
  1239. }
  1240. if (!hlist_empty(&priv->lec_arp_empty_ones))
  1241. pr_info("Empty ones\n");
  1242. hlist_for_each_entry(rulla, &priv->lec_arp_empty_ones, next) {
  1243. offset = 0;
  1244. offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr);
  1245. offset += sprintf(buf + offset, " Atm:");
  1246. for (j = 0; j < ATM_ESA_LEN; j++) {
  1247. offset += sprintf(buf + offset, "%2.2x ",
  1248. rulla->atm_addr[j] & 0xff);
  1249. }
  1250. offset += sprintf(buf + offset,
  1251. "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
  1252. rulla->vcc ? rulla->vcc->vpi : 0,
  1253. rulla->vcc ? rulla->vcc->vci : 0,
  1254. rulla->recv_vcc ? rulla->recv_vcc->vpi : 0,
  1255. rulla->recv_vcc ? rulla->recv_vcc->vci : 0,
  1256. rulla->last_used,
  1257. rulla->timestamp, rulla->no_tries);
  1258. offset += sprintf(buf + offset,
  1259. "Flags:%x, Packets_flooded:%x, Status: %s ",
  1260. rulla->flags, rulla->packets_flooded,
  1261. get_status_string(rulla->status));
  1262. pr_info("%s", buf);
  1263. }
  1264. if (!hlist_empty(&priv->mcast_fwds))
  1265. pr_info("Multicast Forward VCCs\n");
  1266. hlist_for_each_entry(rulla, &priv->mcast_fwds, next) {
  1267. offset = 0;
  1268. offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr);
  1269. offset += sprintf(buf + offset, " Atm:");
  1270. for (j = 0; j < ATM_ESA_LEN; j++) {
  1271. offset += sprintf(buf + offset, "%2.2x ",
  1272. rulla->atm_addr[j] & 0xff);
  1273. }
  1274. offset += sprintf(buf + offset,
  1275. "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
  1276. rulla->vcc ? rulla->vcc->vpi : 0,
  1277. rulla->vcc ? rulla->vcc->vci : 0,
  1278. rulla->recv_vcc ? rulla->recv_vcc->vpi : 0,
  1279. rulla->recv_vcc ? rulla->recv_vcc->vci : 0,
  1280. rulla->last_used,
  1281. rulla->timestamp, rulla->no_tries);
  1282. offset += sprintf(buf + offset,
  1283. "Flags:%x, Packets_flooded:%x, Status: %s ",
  1284. rulla->flags, rulla->packets_flooded,
  1285. get_status_string(rulla->status));
  1286. pr_info("%s\n", buf);
  1287. }
  1288. }
  1289. #else
  1290. #define dump_arp_table(priv) do { } while (0)
  1291. #endif
  1292. /*
  1293. * Destruction of arp-cache
  1294. */
  1295. static void lec_arp_destroy(struct lec_priv *priv)
  1296. {
  1297. unsigned long flags;
  1298. struct hlist_node *next;
  1299. struct lec_arp_table *entry;
  1300. int i;
  1301. cancel_delayed_work_sync(&priv->lec_arp_work);
  1302. /*
  1303. * Remove all entries
  1304. */
  1305. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1306. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1307. hlist_for_each_entry_safe(entry, next,
  1308. &priv->lec_arp_tables[i], next) {
  1309. lec_arp_remove(priv, entry);
  1310. lec_arp_put(entry);
  1311. }
  1312. INIT_HLIST_HEAD(&priv->lec_arp_tables[i]);
  1313. }
  1314. hlist_for_each_entry_safe(entry, next,
  1315. &priv->lec_arp_empty_ones, next) {
  1316. del_timer_sync(&entry->timer);
  1317. lec_arp_clear_vccs(entry);
  1318. hlist_del(&entry->next);
  1319. lec_arp_put(entry);
  1320. }
  1321. INIT_HLIST_HEAD(&priv->lec_arp_empty_ones);
  1322. hlist_for_each_entry_safe(entry, next,
  1323. &priv->lec_no_forward, next) {
  1324. del_timer_sync(&entry->timer);
  1325. lec_arp_clear_vccs(entry);
  1326. hlist_del(&entry->next);
  1327. lec_arp_put(entry);
  1328. }
  1329. INIT_HLIST_HEAD(&priv->lec_no_forward);
  1330. hlist_for_each_entry_safe(entry, next, &priv->mcast_fwds, next) {
  1331. /* No timer, LANEv2 7.1.20 and 2.3.5.3 */
  1332. lec_arp_clear_vccs(entry);
  1333. hlist_del(&entry->next);
  1334. lec_arp_put(entry);
  1335. }
  1336. INIT_HLIST_HEAD(&priv->mcast_fwds);
  1337. priv->mcast_vcc = NULL;
  1338. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1339. }
  1340. /*
  1341. * Find entry by mac_address
  1342. */
  1343. static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
  1344. const unsigned char *mac_addr)
  1345. {
  1346. struct hlist_head *head;
  1347. struct lec_arp_table *entry;
  1348. pr_debug("%pM\n", mac_addr);
  1349. head = &priv->lec_arp_tables[HASH(mac_addr[ETH_ALEN - 1])];
  1350. hlist_for_each_entry(entry, head, next) {
  1351. if (ether_addr_equal(mac_addr, entry->mac_addr))
  1352. return entry;
  1353. }
  1354. return NULL;
  1355. }
  1356. static struct lec_arp_table *make_entry(struct lec_priv *priv,
  1357. const unsigned char *mac_addr)
  1358. {
  1359. struct lec_arp_table *to_return;
  1360. to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC);
  1361. if (!to_return) {
  1362. pr_info("LEC: Arp entry kmalloc failed\n");
  1363. return NULL;
  1364. }
  1365. ether_addr_copy(to_return->mac_addr, mac_addr);
  1366. INIT_HLIST_NODE(&to_return->next);
  1367. timer_setup(&to_return->timer, lec_arp_expire_arp, 0);
  1368. to_return->last_used = jiffies;
  1369. to_return->priv = priv;
  1370. skb_queue_head_init(&to_return->tx_wait);
  1371. refcount_set(&to_return->usage, 1);
  1372. return to_return;
  1373. }
  1374. /* Arp sent timer expired */
  1375. static void lec_arp_expire_arp(struct timer_list *t)
  1376. {
  1377. struct lec_arp_table *entry;
  1378. entry = from_timer(entry, t, timer);
  1379. pr_debug("\n");
  1380. if (entry->status == ESI_ARP_PENDING) {
  1381. if (entry->no_tries <= entry->priv->max_retry_count) {
  1382. if (entry->is_rdesc)
  1383. send_to_lecd(entry->priv, l_rdesc_arp_xmt,
  1384. entry->mac_addr, NULL, NULL);
  1385. else
  1386. send_to_lecd(entry->priv, l_arp_xmt,
  1387. entry->mac_addr, NULL, NULL);
  1388. entry->no_tries++;
  1389. }
  1390. mod_timer(&entry->timer, jiffies + (1 * HZ));
  1391. }
  1392. }
  1393. /* Unknown/unused vcc expire, remove associated entry */
  1394. static void lec_arp_expire_vcc(struct timer_list *t)
  1395. {
  1396. unsigned long flags;
  1397. struct lec_arp_table *to_remove = from_timer(to_remove, t, timer);
  1398. struct lec_priv *priv = to_remove->priv;
  1399. del_timer(&to_remove->timer);
  1400. pr_debug("%p %p: vpi:%d vci:%d\n",
  1401. to_remove, priv,
  1402. to_remove->vcc ? to_remove->recv_vcc->vpi : 0,
  1403. to_remove->vcc ? to_remove->recv_vcc->vci : 0);
  1404. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1405. hlist_del(&to_remove->next);
  1406. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1407. lec_arp_clear_vccs(to_remove);
  1408. lec_arp_put(to_remove);
  1409. }
  1410. static bool __lec_arp_check_expire(struct lec_arp_table *entry,
  1411. unsigned long now,
  1412. struct lec_priv *priv)
  1413. {
  1414. unsigned long time_to_check;
  1415. if ((entry->flags) & LEC_REMOTE_FLAG && priv->topology_change)
  1416. time_to_check = priv->forward_delay_time;
  1417. else
  1418. time_to_check = priv->aging_time;
  1419. pr_debug("About to expire: %lx - %lx > %lx\n",
  1420. now, entry->last_used, time_to_check);
  1421. if (time_after(now, entry->last_used + time_to_check) &&
  1422. !(entry->flags & LEC_PERMANENT_FLAG) &&
  1423. !(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */
  1424. /* Remove entry */
  1425. pr_debug("Entry timed out\n");
  1426. lec_arp_remove(priv, entry);
  1427. lec_arp_put(entry);
  1428. } else {
  1429. /* Something else */
  1430. if ((entry->status == ESI_VC_PENDING ||
  1431. entry->status == ESI_ARP_PENDING) &&
  1432. time_after_eq(now, entry->timestamp +
  1433. priv->max_unknown_frame_time)) {
  1434. entry->timestamp = jiffies;
  1435. entry->packets_flooded = 0;
  1436. if (entry->status == ESI_VC_PENDING)
  1437. send_to_lecd(priv, l_svc_setup,
  1438. entry->mac_addr,
  1439. entry->atm_addr,
  1440. NULL);
  1441. }
  1442. if (entry->status == ESI_FLUSH_PENDING &&
  1443. time_after_eq(now, entry->timestamp +
  1444. priv->path_switching_delay)) {
  1445. lec_arp_hold(entry);
  1446. return true;
  1447. }
  1448. }
  1449. return false;
  1450. }
  1451. /*
  1452. * Expire entries.
  1453. * 1. Re-set timer
  1454. * 2. For each entry, delete entries that have aged past the age limit.
  1455. * 3. For each entry, depending on the status of the entry, perform
  1456. * the following maintenance.
  1457. * a. If status is ESI_VC_PENDING or ESI_ARP_PENDING then if the
  1458. * tick_count is above the max_unknown_frame_time, clear
  1459. * the tick_count to zero and clear the packets_flooded counter
  1460. * to zero. This supports the packet rate limit per address
  1461. * while flooding unknowns.
  1462. * b. If the status is ESI_FLUSH_PENDING and the tick_count is greater
  1463. * than or equal to the path_switching_delay, change the status
  1464. * to ESI_FORWARD_DIRECT. This causes the flush period to end
  1465. * regardless of the progress of the flush protocol.
  1466. */
  1467. static void lec_arp_check_expire(struct work_struct *work)
  1468. {
  1469. unsigned long flags;
  1470. struct lec_priv *priv =
  1471. container_of(work, struct lec_priv, lec_arp_work.work);
  1472. struct hlist_node *next;
  1473. struct lec_arp_table *entry;
  1474. unsigned long now;
  1475. int i;
  1476. pr_debug("%p\n", priv);
  1477. now = jiffies;
  1478. restart:
  1479. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1480. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1481. hlist_for_each_entry_safe(entry, next,
  1482. &priv->lec_arp_tables[i], next) {
  1483. if (__lec_arp_check_expire(entry, now, priv)) {
  1484. struct sk_buff *skb;
  1485. struct atm_vcc *vcc = entry->vcc;
  1486. spin_unlock_irqrestore(&priv->lec_arp_lock,
  1487. flags);
  1488. while ((skb = skb_dequeue(&entry->tx_wait)))
  1489. lec_send(vcc, skb);
  1490. entry->last_used = jiffies;
  1491. entry->status = ESI_FORWARD_DIRECT;
  1492. lec_arp_put(entry);
  1493. goto restart;
  1494. }
  1495. }
  1496. }
  1497. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1498. schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
  1499. }
  1500. /*
  1501. * Try to find vcc where mac_address is attached.
  1502. *
  1503. */
  1504. static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
  1505. const unsigned char *mac_to_find,
  1506. int is_rdesc,
  1507. struct lec_arp_table **ret_entry)
  1508. {
  1509. unsigned long flags;
  1510. struct lec_arp_table *entry;
  1511. struct atm_vcc *found;
  1512. if (mac_to_find[0] & 0x01) {
  1513. switch (priv->lane_version) {
  1514. case 1:
  1515. return priv->mcast_vcc;
  1516. case 2: /* LANE2 wants arp for multicast addresses */
  1517. if (ether_addr_equal(mac_to_find, bus_mac))
  1518. return priv->mcast_vcc;
  1519. break;
  1520. default:
  1521. break;
  1522. }
  1523. }
  1524. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1525. entry = lec_arp_find(priv, mac_to_find);
  1526. if (entry) {
  1527. if (entry->status == ESI_FORWARD_DIRECT) {
  1528. /* Connection Ok */
  1529. entry->last_used = jiffies;
  1530. lec_arp_hold(entry);
  1531. *ret_entry = entry;
  1532. found = entry->vcc;
  1533. goto out;
  1534. }
  1535. /*
  1536. * If the LE_ARP cache entry is still pending, reset count to 0
  1537. * so another LE_ARP request can be made for this frame.
  1538. */
  1539. if (entry->status == ESI_ARP_PENDING)
  1540. entry->no_tries = 0;
  1541. /*
  1542. * Data direct VC not yet set up, check to see if the unknown
  1543. * frame count is greater than the limit. If the limit has
  1544. * not been reached, allow the caller to send packet to
  1545. * BUS.
  1546. */
  1547. if (entry->status != ESI_FLUSH_PENDING &&
  1548. entry->packets_flooded <
  1549. priv->maximum_unknown_frame_count) {
  1550. entry->packets_flooded++;
  1551. pr_debug("Flooding..\n");
  1552. found = priv->mcast_vcc;
  1553. goto out;
  1554. }
  1555. /*
  1556. * We got here because entry->status == ESI_FLUSH_PENDING
  1557. * or BUS flood limit was reached for an entry which is
  1558. * in ESI_ARP_PENDING or ESI_VC_PENDING state.
  1559. */
  1560. lec_arp_hold(entry);
  1561. *ret_entry = entry;
  1562. pr_debug("entry->status %d entry->vcc %p\n", entry->status,
  1563. entry->vcc);
  1564. found = NULL;
  1565. } else {
  1566. /* No matching entry was found */
  1567. entry = make_entry(priv, mac_to_find);
  1568. pr_debug("Making entry\n");
  1569. if (!entry) {
  1570. found = priv->mcast_vcc;
  1571. goto out;
  1572. }
  1573. lec_arp_add(priv, entry);
  1574. /* We want arp-request(s) to be sent */
  1575. entry->packets_flooded = 1;
  1576. entry->status = ESI_ARP_PENDING;
  1577. entry->no_tries = 1;
  1578. entry->last_used = entry->timestamp = jiffies;
  1579. entry->is_rdesc = is_rdesc;
  1580. if (entry->is_rdesc)
  1581. send_to_lecd(priv, l_rdesc_arp_xmt, mac_to_find, NULL,
  1582. NULL);
  1583. else
  1584. send_to_lecd(priv, l_arp_xmt, mac_to_find, NULL, NULL);
  1585. entry->timer.expires = jiffies + (1 * HZ);
  1586. entry->timer.function = lec_arp_expire_arp;
  1587. add_timer(&entry->timer);
  1588. found = priv->mcast_vcc;
  1589. }
  1590. out:
  1591. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1592. return found;
  1593. }
  1594. static int
  1595. lec_addr_delete(struct lec_priv *priv, const unsigned char *atm_addr,
  1596. unsigned long permanent)
  1597. {
  1598. unsigned long flags;
  1599. struct hlist_node *next;
  1600. struct lec_arp_table *entry;
  1601. int i;
  1602. pr_debug("\n");
  1603. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1604. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1605. hlist_for_each_entry_safe(entry, next,
  1606. &priv->lec_arp_tables[i], next) {
  1607. if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) &&
  1608. (permanent ||
  1609. !(entry->flags & LEC_PERMANENT_FLAG))) {
  1610. lec_arp_remove(priv, entry);
  1611. lec_arp_put(entry);
  1612. }
  1613. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1614. return 0;
  1615. }
  1616. }
  1617. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1618. return -1;
  1619. }
  1620. /*
  1621. * Notifies: Response to arp_request (atm_addr != NULL)
  1622. */
  1623. static void
  1624. lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,
  1625. const unsigned char *atm_addr, unsigned long remoteflag,
  1626. unsigned int targetless_le_arp)
  1627. {
  1628. unsigned long flags;
  1629. struct hlist_node *next;
  1630. struct lec_arp_table *entry, *tmp;
  1631. int i;
  1632. pr_debug("%smac:%pM\n",
  1633. (targetless_le_arp) ? "targetless " : "", mac_addr);
  1634. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1635. entry = lec_arp_find(priv, mac_addr);
  1636. if (entry == NULL && targetless_le_arp)
  1637. goto out; /*
  1638. * LANE2: ignore targetless LE_ARPs for which
  1639. * we have no entry in the cache. 7.1.30
  1640. */
  1641. if (!hlist_empty(&priv->lec_arp_empty_ones)) {
  1642. hlist_for_each_entry_safe(entry, next,
  1643. &priv->lec_arp_empty_ones, next) {
  1644. if (memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN) == 0) {
  1645. hlist_del(&entry->next);
  1646. del_timer(&entry->timer);
  1647. tmp = lec_arp_find(priv, mac_addr);
  1648. if (tmp) {
  1649. del_timer(&tmp->timer);
  1650. tmp->status = ESI_FORWARD_DIRECT;
  1651. memcpy(tmp->atm_addr, atm_addr, ATM_ESA_LEN);
  1652. tmp->vcc = entry->vcc;
  1653. tmp->old_push = entry->old_push;
  1654. tmp->last_used = jiffies;
  1655. del_timer(&entry->timer);
  1656. lec_arp_put(entry);
  1657. entry = tmp;
  1658. } else {
  1659. entry->status = ESI_FORWARD_DIRECT;
  1660. ether_addr_copy(entry->mac_addr,
  1661. mac_addr);
  1662. entry->last_used = jiffies;
  1663. lec_arp_add(priv, entry);
  1664. }
  1665. if (remoteflag)
  1666. entry->flags |= LEC_REMOTE_FLAG;
  1667. else
  1668. entry->flags &= ~LEC_REMOTE_FLAG;
  1669. pr_debug("After update\n");
  1670. dump_arp_table(priv);
  1671. goto out;
  1672. }
  1673. }
  1674. }
  1675. entry = lec_arp_find(priv, mac_addr);
  1676. if (!entry) {
  1677. entry = make_entry(priv, mac_addr);
  1678. if (!entry)
  1679. goto out;
  1680. entry->status = ESI_UNKNOWN;
  1681. lec_arp_add(priv, entry);
  1682. /* Temporary, changes before end of function */
  1683. }
  1684. memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN);
  1685. del_timer(&entry->timer);
  1686. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1687. hlist_for_each_entry(tmp,
  1688. &priv->lec_arp_tables[i], next) {
  1689. if (entry != tmp &&
  1690. !memcmp(tmp->atm_addr, atm_addr, ATM_ESA_LEN)) {
  1691. /* Vcc to this host exists */
  1692. if (tmp->status > ESI_VC_PENDING) {
  1693. /*
  1694. * ESI_FLUSH_PENDING,
  1695. * ESI_FORWARD_DIRECT
  1696. */
  1697. entry->vcc = tmp->vcc;
  1698. entry->old_push = tmp->old_push;
  1699. }
  1700. entry->status = tmp->status;
  1701. break;
  1702. }
  1703. }
  1704. }
  1705. if (remoteflag)
  1706. entry->flags |= LEC_REMOTE_FLAG;
  1707. else
  1708. entry->flags &= ~LEC_REMOTE_FLAG;
  1709. if (entry->status == ESI_ARP_PENDING || entry->status == ESI_UNKNOWN) {
  1710. entry->status = ESI_VC_PENDING;
  1711. send_to_lecd(priv, l_svc_setup, entry->mac_addr, atm_addr, NULL);
  1712. }
  1713. pr_debug("After update2\n");
  1714. dump_arp_table(priv);
  1715. out:
  1716. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1717. }
  1718. /*
  1719. * Notifies: Vcc setup ready
  1720. */
  1721. static void
  1722. lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data,
  1723. struct atm_vcc *vcc,
  1724. void (*old_push) (struct atm_vcc *vcc, struct sk_buff *skb))
  1725. {
  1726. unsigned long flags;
  1727. struct lec_arp_table *entry;
  1728. int i, found_entry = 0;
  1729. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1730. /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */
  1731. if (ioc_data->receive == 2) {
  1732. pr_debug("LEC_ARP: Attaching mcast forward\n");
  1733. #if 0
  1734. entry = lec_arp_find(priv, bus_mac);
  1735. if (!entry) {
  1736. pr_info("LEC_ARP: Multicast entry not found!\n");
  1737. goto out;
  1738. }
  1739. memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
  1740. entry->recv_vcc = vcc;
  1741. entry->old_recv_push = old_push;
  1742. #endif
  1743. entry = make_entry(priv, bus_mac);
  1744. if (entry == NULL)
  1745. goto out;
  1746. del_timer(&entry->timer);
  1747. memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
  1748. entry->recv_vcc = vcc;
  1749. entry->old_recv_push = old_push;
  1750. hlist_add_head(&entry->next, &priv->mcast_fwds);
  1751. goto out;
  1752. } else if (ioc_data->receive == 1) {
  1753. /*
  1754. * Vcc which we don't want to make default vcc,
  1755. * attach it anyway.
  1756. */
  1757. pr_debug("LEC_ARP:Attaching data direct, not default: %2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
  1758. ioc_data->atm_addr[0], ioc_data->atm_addr[1],
  1759. ioc_data->atm_addr[2], ioc_data->atm_addr[3],
  1760. ioc_data->atm_addr[4], ioc_data->atm_addr[5],
  1761. ioc_data->atm_addr[6], ioc_data->atm_addr[7],
  1762. ioc_data->atm_addr[8], ioc_data->atm_addr[9],
  1763. ioc_data->atm_addr[10], ioc_data->atm_addr[11],
  1764. ioc_data->atm_addr[12], ioc_data->atm_addr[13],
  1765. ioc_data->atm_addr[14], ioc_data->atm_addr[15],
  1766. ioc_data->atm_addr[16], ioc_data->atm_addr[17],
  1767. ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
  1768. entry = make_entry(priv, bus_mac);
  1769. if (entry == NULL)
  1770. goto out;
  1771. memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
  1772. eth_zero_addr(entry->mac_addr);
  1773. entry->recv_vcc = vcc;
  1774. entry->old_recv_push = old_push;
  1775. entry->status = ESI_UNKNOWN;
  1776. entry->timer.expires = jiffies + priv->vcc_timeout_period;
  1777. entry->timer.function = lec_arp_expire_vcc;
  1778. hlist_add_head(&entry->next, &priv->lec_no_forward);
  1779. add_timer(&entry->timer);
  1780. dump_arp_table(priv);
  1781. goto out;
  1782. }
  1783. pr_debug("LEC_ARP:Attaching data direct, default: %2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
  1784. ioc_data->atm_addr[0], ioc_data->atm_addr[1],
  1785. ioc_data->atm_addr[2], ioc_data->atm_addr[3],
  1786. ioc_data->atm_addr[4], ioc_data->atm_addr[5],
  1787. ioc_data->atm_addr[6], ioc_data->atm_addr[7],
  1788. ioc_data->atm_addr[8], ioc_data->atm_addr[9],
  1789. ioc_data->atm_addr[10], ioc_data->atm_addr[11],
  1790. ioc_data->atm_addr[12], ioc_data->atm_addr[13],
  1791. ioc_data->atm_addr[14], ioc_data->atm_addr[15],
  1792. ioc_data->atm_addr[16], ioc_data->atm_addr[17],
  1793. ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
  1794. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1795. hlist_for_each_entry(entry,
  1796. &priv->lec_arp_tables[i], next) {
  1797. if (memcmp
  1798. (ioc_data->atm_addr, entry->atm_addr,
  1799. ATM_ESA_LEN) == 0) {
  1800. pr_debug("LEC_ARP: Attaching data direct\n");
  1801. pr_debug("Currently -> Vcc: %d, Rvcc:%d\n",
  1802. entry->vcc ? entry->vcc->vci : 0,
  1803. entry->recv_vcc ? entry->recv_vcc->
  1804. vci : 0);
  1805. found_entry = 1;
  1806. del_timer(&entry->timer);
  1807. entry->vcc = vcc;
  1808. entry->old_push = old_push;
  1809. if (entry->status == ESI_VC_PENDING) {
  1810. if (priv->maximum_unknown_frame_count
  1811. == 0)
  1812. entry->status =
  1813. ESI_FORWARD_DIRECT;
  1814. else {
  1815. entry->timestamp = jiffies;
  1816. entry->status =
  1817. ESI_FLUSH_PENDING;
  1818. #if 0
  1819. send_to_lecd(priv, l_flush_xmt,
  1820. NULL,
  1821. entry->atm_addr,
  1822. NULL);
  1823. #endif
  1824. }
  1825. } else {
  1826. /*
  1827. * They were forming a connection
  1828. * to us, and we to them. Our
  1829. * ATM address is numerically lower
  1830. * than theirs, so we make connection
  1831. * we formed into default VCC (8.1.11).
  1832. * Connection they made gets torn
  1833. * down. This might confuse some
  1834. * clients. Can be changed if
  1835. * someone reports trouble...
  1836. */
  1837. ;
  1838. }
  1839. }
  1840. }
  1841. }
  1842. if (found_entry) {
  1843. pr_debug("After vcc was added\n");
  1844. dump_arp_table(priv);
  1845. goto out;
  1846. }
  1847. /*
  1848. * Not found, snatch address from first data packet that arrives
  1849. * from this vcc
  1850. */
  1851. entry = make_entry(priv, bus_mac);
  1852. if (!entry)
  1853. goto out;
  1854. entry->vcc = vcc;
  1855. entry->old_push = old_push;
  1856. memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
  1857. eth_zero_addr(entry->mac_addr);
  1858. entry->status = ESI_UNKNOWN;
  1859. hlist_add_head(&entry->next, &priv->lec_arp_empty_ones);
  1860. entry->timer.expires = jiffies + priv->vcc_timeout_period;
  1861. entry->timer.function = lec_arp_expire_vcc;
  1862. add_timer(&entry->timer);
  1863. pr_debug("After vcc was added\n");
  1864. dump_arp_table(priv);
  1865. out:
  1866. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1867. }
  1868. static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id)
  1869. {
  1870. unsigned long flags;
  1871. struct lec_arp_table *entry;
  1872. int i;
  1873. pr_debug("%lx\n", tran_id);
  1874. restart:
  1875. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1876. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1877. hlist_for_each_entry(entry,
  1878. &priv->lec_arp_tables[i], next) {
  1879. if (entry->flush_tran_id == tran_id &&
  1880. entry->status == ESI_FLUSH_PENDING) {
  1881. struct sk_buff *skb;
  1882. struct atm_vcc *vcc = entry->vcc;
  1883. lec_arp_hold(entry);
  1884. spin_unlock_irqrestore(&priv->lec_arp_lock,
  1885. flags);
  1886. while ((skb = skb_dequeue(&entry->tx_wait)))
  1887. lec_send(vcc, skb);
  1888. entry->last_used = jiffies;
  1889. entry->status = ESI_FORWARD_DIRECT;
  1890. lec_arp_put(entry);
  1891. pr_debug("LEC_ARP: Flushed\n");
  1892. goto restart;
  1893. }
  1894. }
  1895. }
  1896. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1897. dump_arp_table(priv);
  1898. }
  1899. static void
  1900. lec_set_flush_tran_id(struct lec_priv *priv,
  1901. const unsigned char *atm_addr, unsigned long tran_id)
  1902. {
  1903. unsigned long flags;
  1904. struct lec_arp_table *entry;
  1905. int i;
  1906. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1907. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++)
  1908. hlist_for_each_entry(entry,
  1909. &priv->lec_arp_tables[i], next) {
  1910. if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) {
  1911. entry->flush_tran_id = tran_id;
  1912. pr_debug("Set flush transaction id to %lx for %p\n",
  1913. tran_id, entry);
  1914. }
  1915. }
  1916. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1917. }
  1918. static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc)
  1919. {
  1920. unsigned long flags;
  1921. unsigned char mac_addr[] = {
  1922. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  1923. };
  1924. struct lec_arp_table *to_add;
  1925. struct lec_vcc_priv *vpriv;
  1926. int err = 0;
  1927. vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL);
  1928. if (!vpriv)
  1929. return -ENOMEM;
  1930. vpriv->xoff = 0;
  1931. vpriv->old_pop = vcc->pop;
  1932. vcc->user_back = vpriv;
  1933. vcc->pop = lec_pop;
  1934. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1935. to_add = make_entry(priv, mac_addr);
  1936. if (!to_add) {
  1937. vcc->pop = vpriv->old_pop;
  1938. kfree(vpriv);
  1939. err = -ENOMEM;
  1940. goto out;
  1941. }
  1942. memcpy(to_add->atm_addr, vcc->remote.sas_addr.prv, ATM_ESA_LEN);
  1943. to_add->status = ESI_FORWARD_DIRECT;
  1944. to_add->flags |= LEC_PERMANENT_FLAG;
  1945. to_add->vcc = vcc;
  1946. to_add->old_push = vcc->push;
  1947. vcc->push = lec_push;
  1948. priv->mcast_vcc = vcc;
  1949. lec_arp_add(priv, to_add);
  1950. out:
  1951. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1952. return err;
  1953. }
  1954. static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc)
  1955. {
  1956. unsigned long flags;
  1957. struct hlist_node *next;
  1958. struct lec_arp_table *entry;
  1959. int i;
  1960. pr_debug("LEC_ARP: lec_vcc_close vpi:%d vci:%d\n", vcc->vpi, vcc->vci);
  1961. dump_arp_table(priv);
  1962. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1963. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1964. hlist_for_each_entry_safe(entry, next,
  1965. &priv->lec_arp_tables[i], next) {
  1966. if (vcc == entry->vcc) {
  1967. lec_arp_remove(priv, entry);
  1968. lec_arp_put(entry);
  1969. if (priv->mcast_vcc == vcc)
  1970. priv->mcast_vcc = NULL;
  1971. }
  1972. }
  1973. }
  1974. hlist_for_each_entry_safe(entry, next,
  1975. &priv->lec_arp_empty_ones, next) {
  1976. if (entry->vcc == vcc) {
  1977. lec_arp_clear_vccs(entry);
  1978. del_timer(&entry->timer);
  1979. hlist_del(&entry->next);
  1980. lec_arp_put(entry);
  1981. }
  1982. }
  1983. hlist_for_each_entry_safe(entry, next,
  1984. &priv->lec_no_forward, next) {
  1985. if (entry->recv_vcc == vcc) {
  1986. lec_arp_clear_vccs(entry);
  1987. del_timer(&entry->timer);
  1988. hlist_del(&entry->next);
  1989. lec_arp_put(entry);
  1990. }
  1991. }
  1992. hlist_for_each_entry_safe(entry, next, &priv->mcast_fwds, next) {
  1993. if (entry->recv_vcc == vcc) {
  1994. lec_arp_clear_vccs(entry);
  1995. /* No timer, LANEv2 7.1.20 and 2.3.5.3 */
  1996. hlist_del(&entry->next);
  1997. lec_arp_put(entry);
  1998. }
  1999. }
  2000. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  2001. dump_arp_table(priv);
  2002. }
  2003. static void
  2004. lec_arp_check_empties(struct lec_priv *priv,
  2005. struct atm_vcc *vcc, struct sk_buff *skb)
  2006. {
  2007. unsigned long flags;
  2008. struct hlist_node *next;
  2009. struct lec_arp_table *entry, *tmp;
  2010. struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data;
  2011. unsigned char *src = hdr->h_source;
  2012. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  2013. hlist_for_each_entry_safe(entry, next,
  2014. &priv->lec_arp_empty_ones, next) {
  2015. if (vcc == entry->vcc) {
  2016. del_timer(&entry->timer);
  2017. ether_addr_copy(entry->mac_addr, src);
  2018. entry->status = ESI_FORWARD_DIRECT;
  2019. entry->last_used = jiffies;
  2020. /* We might have got an entry */
  2021. tmp = lec_arp_find(priv, src);
  2022. if (tmp) {
  2023. lec_arp_remove(priv, tmp);
  2024. lec_arp_put(tmp);
  2025. }
  2026. hlist_del(&entry->next);
  2027. lec_arp_add(priv, entry);
  2028. goto out;
  2029. }
  2030. }
  2031. pr_debug("LEC_ARP: Arp_check_empties: entry not found!\n");
  2032. out:
  2033. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  2034. }
  2035. MODULE_LICENSE("GPL");