lec.c 60 KB

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