lec.c 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276
  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. lane2_resolve, /* resolve, spec 3.1.3 */
  100. lane2_associate_req, /* associate_req, spec 3.1.4 */
  101. NULL /* associate indicator, 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. remove_proc_entry("lec", atm_proc_root);
  934. deregister_atm_ioctl(&lane_ioctl_ops);
  935. for (i = 0; i < MAX_LEC_ITF; i++) {
  936. if (dev_lec[i] != NULL) {
  937. unregister_netdev(dev_lec[i]);
  938. free_netdev(dev_lec[i]);
  939. dev_lec[i] = NULL;
  940. }
  941. }
  942. }
  943. module_init(lane_module_init);
  944. module_exit(lane_module_cleanup);
  945. /*
  946. * LANE2: 3.1.3, LE_RESOLVE.request
  947. * Non force allocates memory and fills in *tlvs, fills in *sizeoftlvs.
  948. * If sizeoftlvs == NULL the default TLVs associated with with this
  949. * lec will be used.
  950. * If dst_mac == NULL, targetless LE_ARP will be sent
  951. */
  952. static int lane2_resolve(struct net_device *dev, const u8 *dst_mac, int force,
  953. u8 **tlvs, u32 *sizeoftlvs)
  954. {
  955. unsigned long flags;
  956. struct lec_priv *priv = netdev_priv(dev);
  957. struct lec_arp_table *table;
  958. struct sk_buff *skb;
  959. int retval;
  960. if (force == 0) {
  961. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  962. table = lec_arp_find(priv, dst_mac);
  963. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  964. if (table == NULL)
  965. return -1;
  966. *tlvs = kmemdup(table->tlvs, table->sizeoftlvs, GFP_ATOMIC);
  967. if (*tlvs == NULL)
  968. return -1;
  969. *sizeoftlvs = table->sizeoftlvs;
  970. return 0;
  971. }
  972. if (sizeoftlvs == NULL)
  973. retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, NULL);
  974. else {
  975. skb = alloc_skb(*sizeoftlvs, GFP_ATOMIC);
  976. if (skb == NULL)
  977. return -1;
  978. skb->len = *sizeoftlvs;
  979. skb_copy_to_linear_data(skb, *tlvs, *sizeoftlvs);
  980. retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, skb);
  981. }
  982. return retval;
  983. }
  984. /*
  985. * LANE2: 3.1.4, LE_ASSOCIATE.request
  986. * Associate the *tlvs with the *lan_dst address.
  987. * Will overwrite any previous association
  988. * Returns 1 for success, 0 for failure (out of memory)
  989. *
  990. */
  991. static int lane2_associate_req(struct net_device *dev, const u8 *lan_dst,
  992. const u8 *tlvs, u32 sizeoftlvs)
  993. {
  994. int retval;
  995. struct sk_buff *skb;
  996. struct lec_priv *priv = netdev_priv(dev);
  997. if (!ether_addr_equal(lan_dst, dev->dev_addr))
  998. return 0; /* not our mac address */
  999. kfree(priv->tlvs); /* NULL if there was no previous association */
  1000. priv->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL);
  1001. if (priv->tlvs == NULL)
  1002. return 0;
  1003. priv->sizeoftlvs = sizeoftlvs;
  1004. skb = alloc_skb(sizeoftlvs, GFP_ATOMIC);
  1005. if (skb == NULL)
  1006. return 0;
  1007. skb->len = sizeoftlvs;
  1008. skb_copy_to_linear_data(skb, tlvs, sizeoftlvs);
  1009. retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb);
  1010. if (retval != 0)
  1011. pr_info("lec.c: lane2_associate_req() failed\n");
  1012. /*
  1013. * If the previous association has changed we must
  1014. * somehow notify other LANE entities about the change
  1015. */
  1016. return 1;
  1017. }
  1018. /*
  1019. * LANE2: 3.1.5, LE_ASSOCIATE.indication
  1020. *
  1021. */
  1022. static void lane2_associate_ind(struct net_device *dev, const u8 *mac_addr,
  1023. const u8 *tlvs, u32 sizeoftlvs)
  1024. {
  1025. #if 0
  1026. int i = 0;
  1027. #endif
  1028. struct lec_priv *priv = netdev_priv(dev);
  1029. #if 0 /*
  1030. * Why have the TLVs in LE_ARP entries
  1031. * since we do not use them? When you
  1032. * uncomment this code, make sure the
  1033. * TLVs get freed when entry is killed
  1034. */
  1035. struct lec_arp_table *entry = lec_arp_find(priv, mac_addr);
  1036. if (entry == NULL)
  1037. return; /* should not happen */
  1038. kfree(entry->tlvs);
  1039. entry->tlvs = kmemdup(tlvs, sizeoftlvs, GFP_KERNEL);
  1040. if (entry->tlvs == NULL)
  1041. return;
  1042. entry->sizeoftlvs = sizeoftlvs;
  1043. #endif
  1044. #if 0
  1045. pr_info("\n");
  1046. pr_info("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs);
  1047. while (i < sizeoftlvs)
  1048. pr_cont("%02x ", tlvs[i++]);
  1049. pr_cont("\n");
  1050. #endif
  1051. /* tell MPOA about the TLVs we saw */
  1052. if (priv->lane2_ops && priv->lane2_ops->associate_indicator) {
  1053. priv->lane2_ops->associate_indicator(dev, mac_addr,
  1054. tlvs, sizeoftlvs);
  1055. }
  1056. }
  1057. /*
  1058. * Here starts what used to lec_arpc.c
  1059. *
  1060. * lec_arpc.c was added here when making
  1061. * lane client modular. October 1997
  1062. */
  1063. #include <linux/types.h>
  1064. #include <linux/timer.h>
  1065. #include <linux/param.h>
  1066. #include <linux/atomic.h>
  1067. #include <linux/inetdevice.h>
  1068. #include <net/route.h>
  1069. #if 0
  1070. #define pr_debug(format, args...)
  1071. /*
  1072. #define pr_debug printk
  1073. */
  1074. #endif
  1075. #define DEBUG_ARP_TABLE 0
  1076. #define LEC_ARP_REFRESH_INTERVAL (3*HZ)
  1077. static void lec_arp_check_expire(struct work_struct *work);
  1078. static void lec_arp_expire_arp(unsigned long data);
  1079. /*
  1080. * Arp table funcs
  1081. */
  1082. #define HASH(ch) (ch & (LEC_ARP_TABLE_SIZE - 1))
  1083. /*
  1084. * Initialization of arp-cache
  1085. */
  1086. static void lec_arp_init(struct lec_priv *priv)
  1087. {
  1088. unsigned short i;
  1089. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++)
  1090. INIT_HLIST_HEAD(&priv->lec_arp_tables[i]);
  1091. INIT_HLIST_HEAD(&priv->lec_arp_empty_ones);
  1092. INIT_HLIST_HEAD(&priv->lec_no_forward);
  1093. INIT_HLIST_HEAD(&priv->mcast_fwds);
  1094. spin_lock_init(&priv->lec_arp_lock);
  1095. INIT_DELAYED_WORK(&priv->lec_arp_work, lec_arp_check_expire);
  1096. schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
  1097. }
  1098. static void lec_arp_clear_vccs(struct lec_arp_table *entry)
  1099. {
  1100. if (entry->vcc) {
  1101. struct atm_vcc *vcc = entry->vcc;
  1102. struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc);
  1103. struct net_device *dev = (struct net_device *)vcc->proto_data;
  1104. vcc->pop = vpriv->old_pop;
  1105. if (vpriv->xoff)
  1106. netif_wake_queue(dev);
  1107. kfree(vpriv);
  1108. vcc->user_back = NULL;
  1109. vcc->push = entry->old_push;
  1110. vcc_release_async(vcc, -EPIPE);
  1111. entry->vcc = NULL;
  1112. }
  1113. if (entry->recv_vcc) {
  1114. entry->recv_vcc->push = entry->old_recv_push;
  1115. vcc_release_async(entry->recv_vcc, -EPIPE);
  1116. entry->recv_vcc = NULL;
  1117. }
  1118. }
  1119. /*
  1120. * Insert entry to lec_arp_table
  1121. * LANE2: Add to the end of the list to satisfy 8.1.13
  1122. */
  1123. static inline void
  1124. lec_arp_add(struct lec_priv *priv, struct lec_arp_table *entry)
  1125. {
  1126. struct hlist_head *tmp;
  1127. tmp = &priv->lec_arp_tables[HASH(entry->mac_addr[ETH_ALEN - 1])];
  1128. hlist_add_head(&entry->next, tmp);
  1129. pr_debug("Added entry:%pM\n", entry->mac_addr);
  1130. }
  1131. /*
  1132. * Remove entry from lec_arp_table
  1133. */
  1134. static int
  1135. lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove)
  1136. {
  1137. struct lec_arp_table *entry;
  1138. int i, remove_vcc = 1;
  1139. if (!to_remove)
  1140. return -1;
  1141. hlist_del(&to_remove->next);
  1142. del_timer(&to_remove->timer);
  1143. /*
  1144. * If this is the only MAC connected to this VCC,
  1145. * also tear down the VCC
  1146. */
  1147. if (to_remove->status >= ESI_FLUSH_PENDING) {
  1148. /*
  1149. * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT
  1150. */
  1151. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1152. hlist_for_each_entry(entry,
  1153. &priv->lec_arp_tables[i], next) {
  1154. if (memcmp(to_remove->atm_addr,
  1155. entry->atm_addr, ATM_ESA_LEN) == 0) {
  1156. remove_vcc = 0;
  1157. break;
  1158. }
  1159. }
  1160. }
  1161. if (remove_vcc)
  1162. lec_arp_clear_vccs(to_remove);
  1163. }
  1164. skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */
  1165. pr_debug("Removed entry:%pM\n", to_remove->mac_addr);
  1166. return 0;
  1167. }
  1168. #if DEBUG_ARP_TABLE
  1169. static const char *get_status_string(unsigned char st)
  1170. {
  1171. switch (st) {
  1172. case ESI_UNKNOWN:
  1173. return "ESI_UNKNOWN";
  1174. case ESI_ARP_PENDING:
  1175. return "ESI_ARP_PENDING";
  1176. case ESI_VC_PENDING:
  1177. return "ESI_VC_PENDING";
  1178. case ESI_FLUSH_PENDING:
  1179. return "ESI_FLUSH_PENDING";
  1180. case ESI_FORWARD_DIRECT:
  1181. return "ESI_FORWARD_DIRECT";
  1182. }
  1183. return "<UNKNOWN>";
  1184. }
  1185. static void dump_arp_table(struct lec_priv *priv)
  1186. {
  1187. struct lec_arp_table *rulla;
  1188. char buf[256];
  1189. int i, j, offset;
  1190. pr_info("Dump %p:\n", priv);
  1191. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1192. hlist_for_each_entry(rulla,
  1193. &priv->lec_arp_tables[i], next) {
  1194. offset = 0;
  1195. offset += sprintf(buf, "%d: %p\n", i, rulla);
  1196. offset += sprintf(buf + offset, "Mac: %pM",
  1197. rulla->mac_addr);
  1198. offset += sprintf(buf + offset, " Atm:");
  1199. for (j = 0; j < ATM_ESA_LEN; j++) {
  1200. offset += sprintf(buf + offset,
  1201. "%2.2x ",
  1202. rulla->atm_addr[j] & 0xff);
  1203. }
  1204. offset += sprintf(buf + offset,
  1205. "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
  1206. rulla->vcc ? rulla->vcc->vpi : 0,
  1207. rulla->vcc ? rulla->vcc->vci : 0,
  1208. rulla->recv_vcc ? rulla->recv_vcc->
  1209. vpi : 0,
  1210. rulla->recv_vcc ? rulla->recv_vcc->
  1211. vci : 0, rulla->last_used,
  1212. rulla->timestamp, rulla->no_tries);
  1213. offset +=
  1214. sprintf(buf + offset,
  1215. "Flags:%x, Packets_flooded:%x, Status: %s ",
  1216. rulla->flags, rulla->packets_flooded,
  1217. get_status_string(rulla->status));
  1218. pr_info("%s\n", buf);
  1219. }
  1220. }
  1221. if (!hlist_empty(&priv->lec_no_forward))
  1222. pr_info("No forward\n");
  1223. hlist_for_each_entry(rulla, &priv->lec_no_forward, next) {
  1224. offset = 0;
  1225. offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr);
  1226. offset += sprintf(buf + offset, " Atm:");
  1227. for (j = 0; j < ATM_ESA_LEN; j++) {
  1228. offset += sprintf(buf + offset, "%2.2x ",
  1229. rulla->atm_addr[j] & 0xff);
  1230. }
  1231. offset += sprintf(buf + offset,
  1232. "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
  1233. rulla->vcc ? rulla->vcc->vpi : 0,
  1234. rulla->vcc ? rulla->vcc->vci : 0,
  1235. rulla->recv_vcc ? rulla->recv_vcc->vpi : 0,
  1236. rulla->recv_vcc ? rulla->recv_vcc->vci : 0,
  1237. rulla->last_used,
  1238. rulla->timestamp, rulla->no_tries);
  1239. offset += sprintf(buf + offset,
  1240. "Flags:%x, Packets_flooded:%x, Status: %s ",
  1241. rulla->flags, rulla->packets_flooded,
  1242. get_status_string(rulla->status));
  1243. pr_info("%s\n", buf);
  1244. }
  1245. if (!hlist_empty(&priv->lec_arp_empty_ones))
  1246. pr_info("Empty ones\n");
  1247. hlist_for_each_entry(rulla, &priv->lec_arp_empty_ones, next) {
  1248. offset = 0;
  1249. offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr);
  1250. offset += sprintf(buf + offset, " Atm:");
  1251. for (j = 0; j < ATM_ESA_LEN; j++) {
  1252. offset += sprintf(buf + offset, "%2.2x ",
  1253. rulla->atm_addr[j] & 0xff);
  1254. }
  1255. offset += sprintf(buf + offset,
  1256. "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
  1257. rulla->vcc ? rulla->vcc->vpi : 0,
  1258. rulla->vcc ? rulla->vcc->vci : 0,
  1259. rulla->recv_vcc ? rulla->recv_vcc->vpi : 0,
  1260. rulla->recv_vcc ? rulla->recv_vcc->vci : 0,
  1261. rulla->last_used,
  1262. rulla->timestamp, rulla->no_tries);
  1263. offset += sprintf(buf + offset,
  1264. "Flags:%x, Packets_flooded:%x, Status: %s ",
  1265. rulla->flags, rulla->packets_flooded,
  1266. get_status_string(rulla->status));
  1267. pr_info("%s", buf);
  1268. }
  1269. if (!hlist_empty(&priv->mcast_fwds))
  1270. pr_info("Multicast Forward VCCs\n");
  1271. hlist_for_each_entry(rulla, &priv->mcast_fwds, next) {
  1272. offset = 0;
  1273. offset += sprintf(buf + offset, "Mac: %pM", rulla->mac_addr);
  1274. offset += sprintf(buf + offset, " Atm:");
  1275. for (j = 0; j < ATM_ESA_LEN; j++) {
  1276. offset += sprintf(buf + offset, "%2.2x ",
  1277. rulla->atm_addr[j] & 0xff);
  1278. }
  1279. offset += sprintf(buf + offset,
  1280. "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
  1281. rulla->vcc ? rulla->vcc->vpi : 0,
  1282. rulla->vcc ? rulla->vcc->vci : 0,
  1283. rulla->recv_vcc ? rulla->recv_vcc->vpi : 0,
  1284. rulla->recv_vcc ? rulla->recv_vcc->vci : 0,
  1285. rulla->last_used,
  1286. rulla->timestamp, rulla->no_tries);
  1287. offset += sprintf(buf + offset,
  1288. "Flags:%x, Packets_flooded:%x, Status: %s ",
  1289. rulla->flags, rulla->packets_flooded,
  1290. get_status_string(rulla->status));
  1291. pr_info("%s\n", buf);
  1292. }
  1293. }
  1294. #else
  1295. #define dump_arp_table(priv) do { } while (0)
  1296. #endif
  1297. /*
  1298. * Destruction of arp-cache
  1299. */
  1300. static void lec_arp_destroy(struct lec_priv *priv)
  1301. {
  1302. unsigned long flags;
  1303. struct hlist_node *next;
  1304. struct lec_arp_table *entry;
  1305. int i;
  1306. cancel_delayed_work_sync(&priv->lec_arp_work);
  1307. /*
  1308. * Remove all entries
  1309. */
  1310. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1311. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1312. hlist_for_each_entry_safe(entry, next,
  1313. &priv->lec_arp_tables[i], next) {
  1314. lec_arp_remove(priv, entry);
  1315. lec_arp_put(entry);
  1316. }
  1317. INIT_HLIST_HEAD(&priv->lec_arp_tables[i]);
  1318. }
  1319. hlist_for_each_entry_safe(entry, next,
  1320. &priv->lec_arp_empty_ones, next) {
  1321. del_timer_sync(&entry->timer);
  1322. lec_arp_clear_vccs(entry);
  1323. hlist_del(&entry->next);
  1324. lec_arp_put(entry);
  1325. }
  1326. INIT_HLIST_HEAD(&priv->lec_arp_empty_ones);
  1327. hlist_for_each_entry_safe(entry, next,
  1328. &priv->lec_no_forward, next) {
  1329. del_timer_sync(&entry->timer);
  1330. lec_arp_clear_vccs(entry);
  1331. hlist_del(&entry->next);
  1332. lec_arp_put(entry);
  1333. }
  1334. INIT_HLIST_HEAD(&priv->lec_no_forward);
  1335. hlist_for_each_entry_safe(entry, next, &priv->mcast_fwds, next) {
  1336. /* No timer, LANEv2 7.1.20 and 2.3.5.3 */
  1337. lec_arp_clear_vccs(entry);
  1338. hlist_del(&entry->next);
  1339. lec_arp_put(entry);
  1340. }
  1341. INIT_HLIST_HEAD(&priv->mcast_fwds);
  1342. priv->mcast_vcc = NULL;
  1343. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1344. }
  1345. /*
  1346. * Find entry by mac_address
  1347. */
  1348. static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
  1349. const unsigned char *mac_addr)
  1350. {
  1351. struct hlist_head *head;
  1352. struct lec_arp_table *entry;
  1353. pr_debug("%pM\n", mac_addr);
  1354. head = &priv->lec_arp_tables[HASH(mac_addr[ETH_ALEN - 1])];
  1355. hlist_for_each_entry(entry, head, next) {
  1356. if (ether_addr_equal(mac_addr, entry->mac_addr))
  1357. return entry;
  1358. }
  1359. return NULL;
  1360. }
  1361. static struct lec_arp_table *make_entry(struct lec_priv *priv,
  1362. const unsigned char *mac_addr)
  1363. {
  1364. struct lec_arp_table *to_return;
  1365. to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC);
  1366. if (!to_return) {
  1367. pr_info("LEC: Arp entry kmalloc failed\n");
  1368. return NULL;
  1369. }
  1370. ether_addr_copy(to_return->mac_addr, mac_addr);
  1371. INIT_HLIST_NODE(&to_return->next);
  1372. setup_timer(&to_return->timer, lec_arp_expire_arp,
  1373. (unsigned long)to_return);
  1374. to_return->last_used = jiffies;
  1375. to_return->priv = priv;
  1376. skb_queue_head_init(&to_return->tx_wait);
  1377. atomic_set(&to_return->usage, 1);
  1378. return to_return;
  1379. }
  1380. /* Arp sent timer expired */
  1381. static void lec_arp_expire_arp(unsigned long data)
  1382. {
  1383. struct lec_arp_table *entry;
  1384. entry = (struct lec_arp_table *)data;
  1385. pr_debug("\n");
  1386. if (entry->status == ESI_ARP_PENDING) {
  1387. if (entry->no_tries <= entry->priv->max_retry_count) {
  1388. if (entry->is_rdesc)
  1389. send_to_lecd(entry->priv, l_rdesc_arp_xmt,
  1390. entry->mac_addr, NULL, NULL);
  1391. else
  1392. send_to_lecd(entry->priv, l_arp_xmt,
  1393. entry->mac_addr, NULL, NULL);
  1394. entry->no_tries++;
  1395. }
  1396. mod_timer(&entry->timer, jiffies + (1 * HZ));
  1397. }
  1398. }
  1399. /* Unknown/unused vcc expire, remove associated entry */
  1400. static void lec_arp_expire_vcc(unsigned long data)
  1401. {
  1402. unsigned long flags;
  1403. struct lec_arp_table *to_remove = (struct lec_arp_table *)data;
  1404. struct lec_priv *priv = to_remove->priv;
  1405. del_timer(&to_remove->timer);
  1406. pr_debug("%p %p: vpi:%d vci:%d\n",
  1407. to_remove, priv,
  1408. to_remove->vcc ? to_remove->recv_vcc->vpi : 0,
  1409. to_remove->vcc ? to_remove->recv_vcc->vci : 0);
  1410. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1411. hlist_del(&to_remove->next);
  1412. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1413. lec_arp_clear_vccs(to_remove);
  1414. lec_arp_put(to_remove);
  1415. }
  1416. static bool __lec_arp_check_expire(struct lec_arp_table *entry,
  1417. unsigned long now,
  1418. struct lec_priv *priv)
  1419. {
  1420. unsigned long time_to_check;
  1421. if ((entry->flags) & LEC_REMOTE_FLAG && priv->topology_change)
  1422. time_to_check = priv->forward_delay_time;
  1423. else
  1424. time_to_check = priv->aging_time;
  1425. pr_debug("About to expire: %lx - %lx > %lx\n",
  1426. now, entry->last_used, time_to_check);
  1427. if (time_after(now, entry->last_used + time_to_check) &&
  1428. !(entry->flags & LEC_PERMANENT_FLAG) &&
  1429. !(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */
  1430. /* Remove entry */
  1431. pr_debug("Entry timed out\n");
  1432. lec_arp_remove(priv, entry);
  1433. lec_arp_put(entry);
  1434. } else {
  1435. /* Something else */
  1436. if ((entry->status == ESI_VC_PENDING ||
  1437. entry->status == ESI_ARP_PENDING) &&
  1438. time_after_eq(now, entry->timestamp +
  1439. priv->max_unknown_frame_time)) {
  1440. entry->timestamp = jiffies;
  1441. entry->packets_flooded = 0;
  1442. if (entry->status == ESI_VC_PENDING)
  1443. send_to_lecd(priv, l_svc_setup,
  1444. entry->mac_addr,
  1445. entry->atm_addr,
  1446. NULL);
  1447. }
  1448. if (entry->status == ESI_FLUSH_PENDING &&
  1449. time_after_eq(now, entry->timestamp +
  1450. priv->path_switching_delay)) {
  1451. lec_arp_hold(entry);
  1452. return true;
  1453. }
  1454. }
  1455. return false;
  1456. }
  1457. /*
  1458. * Expire entries.
  1459. * 1. Re-set timer
  1460. * 2. For each entry, delete entries that have aged past the age limit.
  1461. * 3. For each entry, depending on the status of the entry, perform
  1462. * the following maintenance.
  1463. * a. If status is ESI_VC_PENDING or ESI_ARP_PENDING then if the
  1464. * tick_count is above the max_unknown_frame_time, clear
  1465. * the tick_count to zero and clear the packets_flooded counter
  1466. * to zero. This supports the packet rate limit per address
  1467. * while flooding unknowns.
  1468. * b. If the status is ESI_FLUSH_PENDING and the tick_count is greater
  1469. * than or equal to the path_switching_delay, change the status
  1470. * to ESI_FORWARD_DIRECT. This causes the flush period to end
  1471. * regardless of the progress of the flush protocol.
  1472. */
  1473. static void lec_arp_check_expire(struct work_struct *work)
  1474. {
  1475. unsigned long flags;
  1476. struct lec_priv *priv =
  1477. container_of(work, struct lec_priv, lec_arp_work.work);
  1478. struct hlist_node *next;
  1479. struct lec_arp_table *entry;
  1480. unsigned long now;
  1481. int i;
  1482. pr_debug("%p\n", priv);
  1483. now = jiffies;
  1484. restart:
  1485. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1486. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1487. hlist_for_each_entry_safe(entry, next,
  1488. &priv->lec_arp_tables[i], next) {
  1489. if (__lec_arp_check_expire(entry, now, priv)) {
  1490. struct sk_buff *skb;
  1491. struct atm_vcc *vcc = entry->vcc;
  1492. spin_unlock_irqrestore(&priv->lec_arp_lock,
  1493. flags);
  1494. while ((skb = skb_dequeue(&entry->tx_wait)))
  1495. lec_send(vcc, skb);
  1496. entry->last_used = jiffies;
  1497. entry->status = ESI_FORWARD_DIRECT;
  1498. lec_arp_put(entry);
  1499. goto restart;
  1500. }
  1501. }
  1502. }
  1503. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1504. schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
  1505. }
  1506. /*
  1507. * Try to find vcc where mac_address is attached.
  1508. *
  1509. */
  1510. static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
  1511. const unsigned char *mac_to_find,
  1512. int is_rdesc,
  1513. struct lec_arp_table **ret_entry)
  1514. {
  1515. unsigned long flags;
  1516. struct lec_arp_table *entry;
  1517. struct atm_vcc *found;
  1518. if (mac_to_find[0] & 0x01) {
  1519. switch (priv->lane_version) {
  1520. case 1:
  1521. return priv->mcast_vcc;
  1522. case 2: /* LANE2 wants arp for multicast addresses */
  1523. if (ether_addr_equal(mac_to_find, bus_mac))
  1524. return priv->mcast_vcc;
  1525. break;
  1526. default:
  1527. break;
  1528. }
  1529. }
  1530. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1531. entry = lec_arp_find(priv, mac_to_find);
  1532. if (entry) {
  1533. if (entry->status == ESI_FORWARD_DIRECT) {
  1534. /* Connection Ok */
  1535. entry->last_used = jiffies;
  1536. lec_arp_hold(entry);
  1537. *ret_entry = entry;
  1538. found = entry->vcc;
  1539. goto out;
  1540. }
  1541. /*
  1542. * If the LE_ARP cache entry is still pending, reset count to 0
  1543. * so another LE_ARP request can be made for this frame.
  1544. */
  1545. if (entry->status == ESI_ARP_PENDING)
  1546. entry->no_tries = 0;
  1547. /*
  1548. * Data direct VC not yet set up, check to see if the unknown
  1549. * frame count is greater than the limit. If the limit has
  1550. * not been reached, allow the caller to send packet to
  1551. * BUS.
  1552. */
  1553. if (entry->status != ESI_FLUSH_PENDING &&
  1554. entry->packets_flooded <
  1555. priv->maximum_unknown_frame_count) {
  1556. entry->packets_flooded++;
  1557. pr_debug("Flooding..\n");
  1558. found = priv->mcast_vcc;
  1559. goto out;
  1560. }
  1561. /*
  1562. * We got here because entry->status == ESI_FLUSH_PENDING
  1563. * or BUS flood limit was reached for an entry which is
  1564. * in ESI_ARP_PENDING or ESI_VC_PENDING state.
  1565. */
  1566. lec_arp_hold(entry);
  1567. *ret_entry = entry;
  1568. pr_debug("entry->status %d entry->vcc %p\n", entry->status,
  1569. entry->vcc);
  1570. found = NULL;
  1571. } else {
  1572. /* No matching entry was found */
  1573. entry = make_entry(priv, mac_to_find);
  1574. pr_debug("Making entry\n");
  1575. if (!entry) {
  1576. found = priv->mcast_vcc;
  1577. goto out;
  1578. }
  1579. lec_arp_add(priv, entry);
  1580. /* We want arp-request(s) to be sent */
  1581. entry->packets_flooded = 1;
  1582. entry->status = ESI_ARP_PENDING;
  1583. entry->no_tries = 1;
  1584. entry->last_used = entry->timestamp = jiffies;
  1585. entry->is_rdesc = is_rdesc;
  1586. if (entry->is_rdesc)
  1587. send_to_lecd(priv, l_rdesc_arp_xmt, mac_to_find, NULL,
  1588. NULL);
  1589. else
  1590. send_to_lecd(priv, l_arp_xmt, mac_to_find, NULL, NULL);
  1591. entry->timer.expires = jiffies + (1 * HZ);
  1592. entry->timer.function = lec_arp_expire_arp;
  1593. add_timer(&entry->timer);
  1594. found = priv->mcast_vcc;
  1595. }
  1596. out:
  1597. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1598. return found;
  1599. }
  1600. static int
  1601. lec_addr_delete(struct lec_priv *priv, const unsigned char *atm_addr,
  1602. unsigned long permanent)
  1603. {
  1604. unsigned long flags;
  1605. struct hlist_node *next;
  1606. struct lec_arp_table *entry;
  1607. int i;
  1608. pr_debug("\n");
  1609. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1610. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1611. hlist_for_each_entry_safe(entry, next,
  1612. &priv->lec_arp_tables[i], next) {
  1613. if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) &&
  1614. (permanent ||
  1615. !(entry->flags & LEC_PERMANENT_FLAG))) {
  1616. lec_arp_remove(priv, entry);
  1617. lec_arp_put(entry);
  1618. }
  1619. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1620. return 0;
  1621. }
  1622. }
  1623. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1624. return -1;
  1625. }
  1626. /*
  1627. * Notifies: Response to arp_request (atm_addr != NULL)
  1628. */
  1629. static void
  1630. lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,
  1631. const unsigned char *atm_addr, unsigned long remoteflag,
  1632. unsigned int targetless_le_arp)
  1633. {
  1634. unsigned long flags;
  1635. struct hlist_node *next;
  1636. struct lec_arp_table *entry, *tmp;
  1637. int i;
  1638. pr_debug("%smac:%pM\n",
  1639. (targetless_le_arp) ? "targetless " : "", mac_addr);
  1640. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1641. entry = lec_arp_find(priv, mac_addr);
  1642. if (entry == NULL && targetless_le_arp)
  1643. goto out; /*
  1644. * LANE2: ignore targetless LE_ARPs for which
  1645. * we have no entry in the cache. 7.1.30
  1646. */
  1647. if (!hlist_empty(&priv->lec_arp_empty_ones)) {
  1648. hlist_for_each_entry_safe(entry, next,
  1649. &priv->lec_arp_empty_ones, next) {
  1650. if (memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN) == 0) {
  1651. hlist_del(&entry->next);
  1652. del_timer(&entry->timer);
  1653. tmp = lec_arp_find(priv, mac_addr);
  1654. if (tmp) {
  1655. del_timer(&tmp->timer);
  1656. tmp->status = ESI_FORWARD_DIRECT;
  1657. memcpy(tmp->atm_addr, atm_addr, ATM_ESA_LEN);
  1658. tmp->vcc = entry->vcc;
  1659. tmp->old_push = entry->old_push;
  1660. tmp->last_used = jiffies;
  1661. del_timer(&entry->timer);
  1662. lec_arp_put(entry);
  1663. entry = tmp;
  1664. } else {
  1665. entry->status = ESI_FORWARD_DIRECT;
  1666. ether_addr_copy(entry->mac_addr,
  1667. mac_addr);
  1668. entry->last_used = jiffies;
  1669. lec_arp_add(priv, entry);
  1670. }
  1671. if (remoteflag)
  1672. entry->flags |= LEC_REMOTE_FLAG;
  1673. else
  1674. entry->flags &= ~LEC_REMOTE_FLAG;
  1675. pr_debug("After update\n");
  1676. dump_arp_table(priv);
  1677. goto out;
  1678. }
  1679. }
  1680. }
  1681. entry = lec_arp_find(priv, mac_addr);
  1682. if (!entry) {
  1683. entry = make_entry(priv, mac_addr);
  1684. if (!entry)
  1685. goto out;
  1686. entry->status = ESI_UNKNOWN;
  1687. lec_arp_add(priv, entry);
  1688. /* Temporary, changes before end of function */
  1689. }
  1690. memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN);
  1691. del_timer(&entry->timer);
  1692. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1693. hlist_for_each_entry(tmp,
  1694. &priv->lec_arp_tables[i], next) {
  1695. if (entry != tmp &&
  1696. !memcmp(tmp->atm_addr, atm_addr, ATM_ESA_LEN)) {
  1697. /* Vcc to this host exists */
  1698. if (tmp->status > ESI_VC_PENDING) {
  1699. /*
  1700. * ESI_FLUSH_PENDING,
  1701. * ESI_FORWARD_DIRECT
  1702. */
  1703. entry->vcc = tmp->vcc;
  1704. entry->old_push = tmp->old_push;
  1705. }
  1706. entry->status = tmp->status;
  1707. break;
  1708. }
  1709. }
  1710. }
  1711. if (remoteflag)
  1712. entry->flags |= LEC_REMOTE_FLAG;
  1713. else
  1714. entry->flags &= ~LEC_REMOTE_FLAG;
  1715. if (entry->status == ESI_ARP_PENDING || entry->status == ESI_UNKNOWN) {
  1716. entry->status = ESI_VC_PENDING;
  1717. send_to_lecd(priv, l_svc_setup, entry->mac_addr, atm_addr, NULL);
  1718. }
  1719. pr_debug("After update2\n");
  1720. dump_arp_table(priv);
  1721. out:
  1722. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1723. }
  1724. /*
  1725. * Notifies: Vcc setup ready
  1726. */
  1727. static void
  1728. lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data,
  1729. struct atm_vcc *vcc,
  1730. void (*old_push) (struct atm_vcc *vcc, struct sk_buff *skb))
  1731. {
  1732. unsigned long flags;
  1733. struct lec_arp_table *entry;
  1734. int i, found_entry = 0;
  1735. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1736. /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */
  1737. if (ioc_data->receive == 2) {
  1738. pr_debug("LEC_ARP: Attaching mcast forward\n");
  1739. #if 0
  1740. entry = lec_arp_find(priv, bus_mac);
  1741. if (!entry) {
  1742. pr_info("LEC_ARP: Multicast entry not found!\n");
  1743. goto out;
  1744. }
  1745. memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
  1746. entry->recv_vcc = vcc;
  1747. entry->old_recv_push = old_push;
  1748. #endif
  1749. entry = make_entry(priv, bus_mac);
  1750. if (entry == NULL)
  1751. goto out;
  1752. del_timer(&entry->timer);
  1753. memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
  1754. entry->recv_vcc = vcc;
  1755. entry->old_recv_push = old_push;
  1756. hlist_add_head(&entry->next, &priv->mcast_fwds);
  1757. goto out;
  1758. } else if (ioc_data->receive == 1) {
  1759. /*
  1760. * Vcc which we don't want to make default vcc,
  1761. * attach it anyway.
  1762. */
  1763. 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",
  1764. ioc_data->atm_addr[0], ioc_data->atm_addr[1],
  1765. ioc_data->atm_addr[2], ioc_data->atm_addr[3],
  1766. ioc_data->atm_addr[4], ioc_data->atm_addr[5],
  1767. ioc_data->atm_addr[6], ioc_data->atm_addr[7],
  1768. ioc_data->atm_addr[8], ioc_data->atm_addr[9],
  1769. ioc_data->atm_addr[10], ioc_data->atm_addr[11],
  1770. ioc_data->atm_addr[12], ioc_data->atm_addr[13],
  1771. ioc_data->atm_addr[14], ioc_data->atm_addr[15],
  1772. ioc_data->atm_addr[16], ioc_data->atm_addr[17],
  1773. ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
  1774. entry = make_entry(priv, bus_mac);
  1775. if (entry == NULL)
  1776. goto out;
  1777. memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
  1778. eth_zero_addr(entry->mac_addr);
  1779. entry->recv_vcc = vcc;
  1780. entry->old_recv_push = old_push;
  1781. entry->status = ESI_UNKNOWN;
  1782. entry->timer.expires = jiffies + priv->vcc_timeout_period;
  1783. entry->timer.function = lec_arp_expire_vcc;
  1784. hlist_add_head(&entry->next, &priv->lec_no_forward);
  1785. add_timer(&entry->timer);
  1786. dump_arp_table(priv);
  1787. goto out;
  1788. }
  1789. 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",
  1790. ioc_data->atm_addr[0], ioc_data->atm_addr[1],
  1791. ioc_data->atm_addr[2], ioc_data->atm_addr[3],
  1792. ioc_data->atm_addr[4], ioc_data->atm_addr[5],
  1793. ioc_data->atm_addr[6], ioc_data->atm_addr[7],
  1794. ioc_data->atm_addr[8], ioc_data->atm_addr[9],
  1795. ioc_data->atm_addr[10], ioc_data->atm_addr[11],
  1796. ioc_data->atm_addr[12], ioc_data->atm_addr[13],
  1797. ioc_data->atm_addr[14], ioc_data->atm_addr[15],
  1798. ioc_data->atm_addr[16], ioc_data->atm_addr[17],
  1799. ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
  1800. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1801. hlist_for_each_entry(entry,
  1802. &priv->lec_arp_tables[i], next) {
  1803. if (memcmp
  1804. (ioc_data->atm_addr, entry->atm_addr,
  1805. ATM_ESA_LEN) == 0) {
  1806. pr_debug("LEC_ARP: Attaching data direct\n");
  1807. pr_debug("Currently -> Vcc: %d, Rvcc:%d\n",
  1808. entry->vcc ? entry->vcc->vci : 0,
  1809. entry->recv_vcc ? entry->recv_vcc->
  1810. vci : 0);
  1811. found_entry = 1;
  1812. del_timer(&entry->timer);
  1813. entry->vcc = vcc;
  1814. entry->old_push = old_push;
  1815. if (entry->status == ESI_VC_PENDING) {
  1816. if (priv->maximum_unknown_frame_count
  1817. == 0)
  1818. entry->status =
  1819. ESI_FORWARD_DIRECT;
  1820. else {
  1821. entry->timestamp = jiffies;
  1822. entry->status =
  1823. ESI_FLUSH_PENDING;
  1824. #if 0
  1825. send_to_lecd(priv, l_flush_xmt,
  1826. NULL,
  1827. entry->atm_addr,
  1828. NULL);
  1829. #endif
  1830. }
  1831. } else {
  1832. /*
  1833. * They were forming a connection
  1834. * to us, and we to them. Our
  1835. * ATM address is numerically lower
  1836. * than theirs, so we make connection
  1837. * we formed into default VCC (8.1.11).
  1838. * Connection they made gets torn
  1839. * down. This might confuse some
  1840. * clients. Can be changed if
  1841. * someone reports trouble...
  1842. */
  1843. ;
  1844. }
  1845. }
  1846. }
  1847. }
  1848. if (found_entry) {
  1849. pr_debug("After vcc was added\n");
  1850. dump_arp_table(priv);
  1851. goto out;
  1852. }
  1853. /*
  1854. * Not found, snatch address from first data packet that arrives
  1855. * from this vcc
  1856. */
  1857. entry = make_entry(priv, bus_mac);
  1858. if (!entry)
  1859. goto out;
  1860. entry->vcc = vcc;
  1861. entry->old_push = old_push;
  1862. memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
  1863. eth_zero_addr(entry->mac_addr);
  1864. entry->status = ESI_UNKNOWN;
  1865. hlist_add_head(&entry->next, &priv->lec_arp_empty_ones);
  1866. entry->timer.expires = jiffies + priv->vcc_timeout_period;
  1867. entry->timer.function = lec_arp_expire_vcc;
  1868. add_timer(&entry->timer);
  1869. pr_debug("After vcc was added\n");
  1870. dump_arp_table(priv);
  1871. out:
  1872. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1873. }
  1874. static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id)
  1875. {
  1876. unsigned long flags;
  1877. struct lec_arp_table *entry;
  1878. int i;
  1879. pr_debug("%lx\n", tran_id);
  1880. restart:
  1881. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1882. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1883. hlist_for_each_entry(entry,
  1884. &priv->lec_arp_tables[i], next) {
  1885. if (entry->flush_tran_id == tran_id &&
  1886. entry->status == ESI_FLUSH_PENDING) {
  1887. struct sk_buff *skb;
  1888. struct atm_vcc *vcc = entry->vcc;
  1889. lec_arp_hold(entry);
  1890. spin_unlock_irqrestore(&priv->lec_arp_lock,
  1891. flags);
  1892. while ((skb = skb_dequeue(&entry->tx_wait)))
  1893. lec_send(vcc, skb);
  1894. entry->last_used = jiffies;
  1895. entry->status = ESI_FORWARD_DIRECT;
  1896. lec_arp_put(entry);
  1897. pr_debug("LEC_ARP: Flushed\n");
  1898. goto restart;
  1899. }
  1900. }
  1901. }
  1902. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1903. dump_arp_table(priv);
  1904. }
  1905. static void
  1906. lec_set_flush_tran_id(struct lec_priv *priv,
  1907. const unsigned char *atm_addr, unsigned long tran_id)
  1908. {
  1909. unsigned long flags;
  1910. struct lec_arp_table *entry;
  1911. int i;
  1912. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1913. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++)
  1914. hlist_for_each_entry(entry,
  1915. &priv->lec_arp_tables[i], next) {
  1916. if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) {
  1917. entry->flush_tran_id = tran_id;
  1918. pr_debug("Set flush transaction id to %lx for %p\n",
  1919. tran_id, entry);
  1920. }
  1921. }
  1922. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1923. }
  1924. static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc)
  1925. {
  1926. unsigned long flags;
  1927. unsigned char mac_addr[] = {
  1928. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  1929. };
  1930. struct lec_arp_table *to_add;
  1931. struct lec_vcc_priv *vpriv;
  1932. int err = 0;
  1933. vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL);
  1934. if (!vpriv)
  1935. return -ENOMEM;
  1936. vpriv->xoff = 0;
  1937. vpriv->old_pop = vcc->pop;
  1938. vcc->user_back = vpriv;
  1939. vcc->pop = lec_pop;
  1940. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1941. to_add = make_entry(priv, mac_addr);
  1942. if (!to_add) {
  1943. vcc->pop = vpriv->old_pop;
  1944. kfree(vpriv);
  1945. err = -ENOMEM;
  1946. goto out;
  1947. }
  1948. memcpy(to_add->atm_addr, vcc->remote.sas_addr.prv, ATM_ESA_LEN);
  1949. to_add->status = ESI_FORWARD_DIRECT;
  1950. to_add->flags |= LEC_PERMANENT_FLAG;
  1951. to_add->vcc = vcc;
  1952. to_add->old_push = vcc->push;
  1953. vcc->push = lec_push;
  1954. priv->mcast_vcc = vcc;
  1955. lec_arp_add(priv, to_add);
  1956. out:
  1957. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1958. return err;
  1959. }
  1960. static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc)
  1961. {
  1962. unsigned long flags;
  1963. struct hlist_node *next;
  1964. struct lec_arp_table *entry;
  1965. int i;
  1966. pr_debug("LEC_ARP: lec_vcc_close vpi:%d vci:%d\n", vcc->vpi, vcc->vci);
  1967. dump_arp_table(priv);
  1968. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1969. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1970. hlist_for_each_entry_safe(entry, next,
  1971. &priv->lec_arp_tables[i], next) {
  1972. if (vcc == entry->vcc) {
  1973. lec_arp_remove(priv, entry);
  1974. lec_arp_put(entry);
  1975. if (priv->mcast_vcc == vcc)
  1976. priv->mcast_vcc = NULL;
  1977. }
  1978. }
  1979. }
  1980. hlist_for_each_entry_safe(entry, next,
  1981. &priv->lec_arp_empty_ones, next) {
  1982. if (entry->vcc == vcc) {
  1983. lec_arp_clear_vccs(entry);
  1984. del_timer(&entry->timer);
  1985. hlist_del(&entry->next);
  1986. lec_arp_put(entry);
  1987. }
  1988. }
  1989. hlist_for_each_entry_safe(entry, next,
  1990. &priv->lec_no_forward, next) {
  1991. if (entry->recv_vcc == vcc) {
  1992. lec_arp_clear_vccs(entry);
  1993. del_timer(&entry->timer);
  1994. hlist_del(&entry->next);
  1995. lec_arp_put(entry);
  1996. }
  1997. }
  1998. hlist_for_each_entry_safe(entry, next, &priv->mcast_fwds, next) {
  1999. if (entry->recv_vcc == vcc) {
  2000. lec_arp_clear_vccs(entry);
  2001. /* No timer, LANEv2 7.1.20 and 2.3.5.3 */
  2002. hlist_del(&entry->next);
  2003. lec_arp_put(entry);
  2004. }
  2005. }
  2006. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  2007. dump_arp_table(priv);
  2008. }
  2009. static void
  2010. lec_arp_check_empties(struct lec_priv *priv,
  2011. struct atm_vcc *vcc, struct sk_buff *skb)
  2012. {
  2013. unsigned long flags;
  2014. struct hlist_node *next;
  2015. struct lec_arp_table *entry, *tmp;
  2016. struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data;
  2017. unsigned char *src = hdr->h_source;
  2018. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  2019. hlist_for_each_entry_safe(entry, next,
  2020. &priv->lec_arp_empty_ones, next) {
  2021. if (vcc == entry->vcc) {
  2022. del_timer(&entry->timer);
  2023. ether_addr_copy(entry->mac_addr, src);
  2024. entry->status = ESI_FORWARD_DIRECT;
  2025. entry->last_used = jiffies;
  2026. /* We might have got an entry */
  2027. tmp = lec_arp_find(priv, src);
  2028. if (tmp) {
  2029. lec_arp_remove(priv, tmp);
  2030. lec_arp_put(tmp);
  2031. }
  2032. hlist_del(&entry->next);
  2033. lec_arp_add(priv, entry);
  2034. goto out;
  2035. }
  2036. }
  2037. pr_debug("LEC_ARP: Arp_check_empties: entry not found!\n");
  2038. out:
  2039. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  2040. }
  2041. MODULE_LICENSE("GPL");