lec.c 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277
  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. refcount_inc(&entry->usage);
  92. }
  93. static inline void lec_arp_put(struct lec_arp_table *entry)
  94. {
  95. if (refcount_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. refcount_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. WARN_ON(refcount_sub_and_test(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 const 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(struct timer_list *t);
  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. timer_setup(&to_return->timer, lec_arp_expire_arp, 0);
  1375. to_return->last_used = jiffies;
  1376. to_return->priv = priv;
  1377. skb_queue_head_init(&to_return->tx_wait);
  1378. refcount_set(&to_return->usage, 1);
  1379. return to_return;
  1380. }
  1381. /* Arp sent timer expired */
  1382. static void lec_arp_expire_arp(struct timer_list *t)
  1383. {
  1384. struct lec_arp_table *entry;
  1385. entry = from_timer(entry, t, timer);
  1386. pr_debug("\n");
  1387. if (entry->status == ESI_ARP_PENDING) {
  1388. if (entry->no_tries <= entry->priv->max_retry_count) {
  1389. if (entry->is_rdesc)
  1390. send_to_lecd(entry->priv, l_rdesc_arp_xmt,
  1391. entry->mac_addr, NULL, NULL);
  1392. else
  1393. send_to_lecd(entry->priv, l_arp_xmt,
  1394. entry->mac_addr, NULL, NULL);
  1395. entry->no_tries++;
  1396. }
  1397. mod_timer(&entry->timer, jiffies + (1 * HZ));
  1398. }
  1399. }
  1400. /* Unknown/unused vcc expire, remove associated entry */
  1401. static void lec_arp_expire_vcc(struct timer_list *t)
  1402. {
  1403. unsigned long flags;
  1404. struct lec_arp_table *to_remove = from_timer(to_remove, t, timer);
  1405. struct lec_priv *priv = to_remove->priv;
  1406. del_timer(&to_remove->timer);
  1407. pr_debug("%p %p: vpi:%d vci:%d\n",
  1408. to_remove, priv,
  1409. to_remove->vcc ? to_remove->recv_vcc->vpi : 0,
  1410. to_remove->vcc ? to_remove->recv_vcc->vci : 0);
  1411. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1412. hlist_del(&to_remove->next);
  1413. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1414. lec_arp_clear_vccs(to_remove);
  1415. lec_arp_put(to_remove);
  1416. }
  1417. static bool __lec_arp_check_expire(struct lec_arp_table *entry,
  1418. unsigned long now,
  1419. struct lec_priv *priv)
  1420. {
  1421. unsigned long time_to_check;
  1422. if ((entry->flags) & LEC_REMOTE_FLAG && priv->topology_change)
  1423. time_to_check = priv->forward_delay_time;
  1424. else
  1425. time_to_check = priv->aging_time;
  1426. pr_debug("About to expire: %lx - %lx > %lx\n",
  1427. now, entry->last_used, time_to_check);
  1428. if (time_after(now, entry->last_used + time_to_check) &&
  1429. !(entry->flags & LEC_PERMANENT_FLAG) &&
  1430. !(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */
  1431. /* Remove entry */
  1432. pr_debug("Entry timed out\n");
  1433. lec_arp_remove(priv, entry);
  1434. lec_arp_put(entry);
  1435. } else {
  1436. /* Something else */
  1437. if ((entry->status == ESI_VC_PENDING ||
  1438. entry->status == ESI_ARP_PENDING) &&
  1439. time_after_eq(now, entry->timestamp +
  1440. priv->max_unknown_frame_time)) {
  1441. entry->timestamp = jiffies;
  1442. entry->packets_flooded = 0;
  1443. if (entry->status == ESI_VC_PENDING)
  1444. send_to_lecd(priv, l_svc_setup,
  1445. entry->mac_addr,
  1446. entry->atm_addr,
  1447. NULL);
  1448. }
  1449. if (entry->status == ESI_FLUSH_PENDING &&
  1450. time_after_eq(now, entry->timestamp +
  1451. priv->path_switching_delay)) {
  1452. lec_arp_hold(entry);
  1453. return true;
  1454. }
  1455. }
  1456. return false;
  1457. }
  1458. /*
  1459. * Expire entries.
  1460. * 1. Re-set timer
  1461. * 2. For each entry, delete entries that have aged past the age limit.
  1462. * 3. For each entry, depending on the status of the entry, perform
  1463. * the following maintenance.
  1464. * a. If status is ESI_VC_PENDING or ESI_ARP_PENDING then if the
  1465. * tick_count is above the max_unknown_frame_time, clear
  1466. * the tick_count to zero and clear the packets_flooded counter
  1467. * to zero. This supports the packet rate limit per address
  1468. * while flooding unknowns.
  1469. * b. If the status is ESI_FLUSH_PENDING and the tick_count is greater
  1470. * than or equal to the path_switching_delay, change the status
  1471. * to ESI_FORWARD_DIRECT. This causes the flush period to end
  1472. * regardless of the progress of the flush protocol.
  1473. */
  1474. static void lec_arp_check_expire(struct work_struct *work)
  1475. {
  1476. unsigned long flags;
  1477. struct lec_priv *priv =
  1478. container_of(work, struct lec_priv, lec_arp_work.work);
  1479. struct hlist_node *next;
  1480. struct lec_arp_table *entry;
  1481. unsigned long now;
  1482. int i;
  1483. pr_debug("%p\n", priv);
  1484. now = jiffies;
  1485. restart:
  1486. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1487. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1488. hlist_for_each_entry_safe(entry, next,
  1489. &priv->lec_arp_tables[i], next) {
  1490. if (__lec_arp_check_expire(entry, now, priv)) {
  1491. struct sk_buff *skb;
  1492. struct atm_vcc *vcc = entry->vcc;
  1493. spin_unlock_irqrestore(&priv->lec_arp_lock,
  1494. flags);
  1495. while ((skb = skb_dequeue(&entry->tx_wait)))
  1496. lec_send(vcc, skb);
  1497. entry->last_used = jiffies;
  1498. entry->status = ESI_FORWARD_DIRECT;
  1499. lec_arp_put(entry);
  1500. goto restart;
  1501. }
  1502. }
  1503. }
  1504. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1505. schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
  1506. }
  1507. /*
  1508. * Try to find vcc where mac_address is attached.
  1509. *
  1510. */
  1511. static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
  1512. const unsigned char *mac_to_find,
  1513. int is_rdesc,
  1514. struct lec_arp_table **ret_entry)
  1515. {
  1516. unsigned long flags;
  1517. struct lec_arp_table *entry;
  1518. struct atm_vcc *found;
  1519. if (mac_to_find[0] & 0x01) {
  1520. switch (priv->lane_version) {
  1521. case 1:
  1522. return priv->mcast_vcc;
  1523. case 2: /* LANE2 wants arp for multicast addresses */
  1524. if (ether_addr_equal(mac_to_find, bus_mac))
  1525. return priv->mcast_vcc;
  1526. break;
  1527. default:
  1528. break;
  1529. }
  1530. }
  1531. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1532. entry = lec_arp_find(priv, mac_to_find);
  1533. if (entry) {
  1534. if (entry->status == ESI_FORWARD_DIRECT) {
  1535. /* Connection Ok */
  1536. entry->last_used = jiffies;
  1537. lec_arp_hold(entry);
  1538. *ret_entry = entry;
  1539. found = entry->vcc;
  1540. goto out;
  1541. }
  1542. /*
  1543. * If the LE_ARP cache entry is still pending, reset count to 0
  1544. * so another LE_ARP request can be made for this frame.
  1545. */
  1546. if (entry->status == ESI_ARP_PENDING)
  1547. entry->no_tries = 0;
  1548. /*
  1549. * Data direct VC not yet set up, check to see if the unknown
  1550. * frame count is greater than the limit. If the limit has
  1551. * not been reached, allow the caller to send packet to
  1552. * BUS.
  1553. */
  1554. if (entry->status != ESI_FLUSH_PENDING &&
  1555. entry->packets_flooded <
  1556. priv->maximum_unknown_frame_count) {
  1557. entry->packets_flooded++;
  1558. pr_debug("Flooding..\n");
  1559. found = priv->mcast_vcc;
  1560. goto out;
  1561. }
  1562. /*
  1563. * We got here because entry->status == ESI_FLUSH_PENDING
  1564. * or BUS flood limit was reached for an entry which is
  1565. * in ESI_ARP_PENDING or ESI_VC_PENDING state.
  1566. */
  1567. lec_arp_hold(entry);
  1568. *ret_entry = entry;
  1569. pr_debug("entry->status %d entry->vcc %p\n", entry->status,
  1570. entry->vcc);
  1571. found = NULL;
  1572. } else {
  1573. /* No matching entry was found */
  1574. entry = make_entry(priv, mac_to_find);
  1575. pr_debug("Making entry\n");
  1576. if (!entry) {
  1577. found = priv->mcast_vcc;
  1578. goto out;
  1579. }
  1580. lec_arp_add(priv, entry);
  1581. /* We want arp-request(s) to be sent */
  1582. entry->packets_flooded = 1;
  1583. entry->status = ESI_ARP_PENDING;
  1584. entry->no_tries = 1;
  1585. entry->last_used = entry->timestamp = jiffies;
  1586. entry->is_rdesc = is_rdesc;
  1587. if (entry->is_rdesc)
  1588. send_to_lecd(priv, l_rdesc_arp_xmt, mac_to_find, NULL,
  1589. NULL);
  1590. else
  1591. send_to_lecd(priv, l_arp_xmt, mac_to_find, NULL, NULL);
  1592. entry->timer.expires = jiffies + (1 * HZ);
  1593. entry->timer.function = lec_arp_expire_arp;
  1594. add_timer(&entry->timer);
  1595. found = priv->mcast_vcc;
  1596. }
  1597. out:
  1598. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1599. return found;
  1600. }
  1601. static int
  1602. lec_addr_delete(struct lec_priv *priv, const unsigned char *atm_addr,
  1603. unsigned long permanent)
  1604. {
  1605. unsigned long flags;
  1606. struct hlist_node *next;
  1607. struct lec_arp_table *entry;
  1608. int i;
  1609. pr_debug("\n");
  1610. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1611. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1612. hlist_for_each_entry_safe(entry, next,
  1613. &priv->lec_arp_tables[i], next) {
  1614. if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) &&
  1615. (permanent ||
  1616. !(entry->flags & LEC_PERMANENT_FLAG))) {
  1617. lec_arp_remove(priv, entry);
  1618. lec_arp_put(entry);
  1619. }
  1620. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1621. return 0;
  1622. }
  1623. }
  1624. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1625. return -1;
  1626. }
  1627. /*
  1628. * Notifies: Response to arp_request (atm_addr != NULL)
  1629. */
  1630. static void
  1631. lec_arp_update(struct lec_priv *priv, const unsigned char *mac_addr,
  1632. const unsigned char *atm_addr, unsigned long remoteflag,
  1633. unsigned int targetless_le_arp)
  1634. {
  1635. unsigned long flags;
  1636. struct hlist_node *next;
  1637. struct lec_arp_table *entry, *tmp;
  1638. int i;
  1639. pr_debug("%smac:%pM\n",
  1640. (targetless_le_arp) ? "targetless " : "", mac_addr);
  1641. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1642. entry = lec_arp_find(priv, mac_addr);
  1643. if (entry == NULL && targetless_le_arp)
  1644. goto out; /*
  1645. * LANE2: ignore targetless LE_ARPs for which
  1646. * we have no entry in the cache. 7.1.30
  1647. */
  1648. if (!hlist_empty(&priv->lec_arp_empty_ones)) {
  1649. hlist_for_each_entry_safe(entry, next,
  1650. &priv->lec_arp_empty_ones, next) {
  1651. if (memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN) == 0) {
  1652. hlist_del(&entry->next);
  1653. del_timer(&entry->timer);
  1654. tmp = lec_arp_find(priv, mac_addr);
  1655. if (tmp) {
  1656. del_timer(&tmp->timer);
  1657. tmp->status = ESI_FORWARD_DIRECT;
  1658. memcpy(tmp->atm_addr, atm_addr, ATM_ESA_LEN);
  1659. tmp->vcc = entry->vcc;
  1660. tmp->old_push = entry->old_push;
  1661. tmp->last_used = jiffies;
  1662. del_timer(&entry->timer);
  1663. lec_arp_put(entry);
  1664. entry = tmp;
  1665. } else {
  1666. entry->status = ESI_FORWARD_DIRECT;
  1667. ether_addr_copy(entry->mac_addr,
  1668. mac_addr);
  1669. entry->last_used = jiffies;
  1670. lec_arp_add(priv, entry);
  1671. }
  1672. if (remoteflag)
  1673. entry->flags |= LEC_REMOTE_FLAG;
  1674. else
  1675. entry->flags &= ~LEC_REMOTE_FLAG;
  1676. pr_debug("After update\n");
  1677. dump_arp_table(priv);
  1678. goto out;
  1679. }
  1680. }
  1681. }
  1682. entry = lec_arp_find(priv, mac_addr);
  1683. if (!entry) {
  1684. entry = make_entry(priv, mac_addr);
  1685. if (!entry)
  1686. goto out;
  1687. entry->status = ESI_UNKNOWN;
  1688. lec_arp_add(priv, entry);
  1689. /* Temporary, changes before end of function */
  1690. }
  1691. memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN);
  1692. del_timer(&entry->timer);
  1693. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1694. hlist_for_each_entry(tmp,
  1695. &priv->lec_arp_tables[i], next) {
  1696. if (entry != tmp &&
  1697. !memcmp(tmp->atm_addr, atm_addr, ATM_ESA_LEN)) {
  1698. /* Vcc to this host exists */
  1699. if (tmp->status > ESI_VC_PENDING) {
  1700. /*
  1701. * ESI_FLUSH_PENDING,
  1702. * ESI_FORWARD_DIRECT
  1703. */
  1704. entry->vcc = tmp->vcc;
  1705. entry->old_push = tmp->old_push;
  1706. }
  1707. entry->status = tmp->status;
  1708. break;
  1709. }
  1710. }
  1711. }
  1712. if (remoteflag)
  1713. entry->flags |= LEC_REMOTE_FLAG;
  1714. else
  1715. entry->flags &= ~LEC_REMOTE_FLAG;
  1716. if (entry->status == ESI_ARP_PENDING || entry->status == ESI_UNKNOWN) {
  1717. entry->status = ESI_VC_PENDING;
  1718. send_to_lecd(priv, l_svc_setup, entry->mac_addr, atm_addr, NULL);
  1719. }
  1720. pr_debug("After update2\n");
  1721. dump_arp_table(priv);
  1722. out:
  1723. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1724. }
  1725. /*
  1726. * Notifies: Vcc setup ready
  1727. */
  1728. static void
  1729. lec_vcc_added(struct lec_priv *priv, const struct atmlec_ioc *ioc_data,
  1730. struct atm_vcc *vcc,
  1731. void (*old_push) (struct atm_vcc *vcc, struct sk_buff *skb))
  1732. {
  1733. unsigned long flags;
  1734. struct lec_arp_table *entry;
  1735. int i, found_entry = 0;
  1736. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1737. /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */
  1738. if (ioc_data->receive == 2) {
  1739. pr_debug("LEC_ARP: Attaching mcast forward\n");
  1740. #if 0
  1741. entry = lec_arp_find(priv, bus_mac);
  1742. if (!entry) {
  1743. pr_info("LEC_ARP: Multicast entry not found!\n");
  1744. goto out;
  1745. }
  1746. memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
  1747. entry->recv_vcc = vcc;
  1748. entry->old_recv_push = old_push;
  1749. #endif
  1750. entry = make_entry(priv, bus_mac);
  1751. if (entry == NULL)
  1752. goto out;
  1753. del_timer(&entry->timer);
  1754. memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
  1755. entry->recv_vcc = vcc;
  1756. entry->old_recv_push = old_push;
  1757. hlist_add_head(&entry->next, &priv->mcast_fwds);
  1758. goto out;
  1759. } else if (ioc_data->receive == 1) {
  1760. /*
  1761. * Vcc which we don't want to make default vcc,
  1762. * attach it anyway.
  1763. */
  1764. 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",
  1765. ioc_data->atm_addr[0], ioc_data->atm_addr[1],
  1766. ioc_data->atm_addr[2], ioc_data->atm_addr[3],
  1767. ioc_data->atm_addr[4], ioc_data->atm_addr[5],
  1768. ioc_data->atm_addr[6], ioc_data->atm_addr[7],
  1769. ioc_data->atm_addr[8], ioc_data->atm_addr[9],
  1770. ioc_data->atm_addr[10], ioc_data->atm_addr[11],
  1771. ioc_data->atm_addr[12], ioc_data->atm_addr[13],
  1772. ioc_data->atm_addr[14], ioc_data->atm_addr[15],
  1773. ioc_data->atm_addr[16], ioc_data->atm_addr[17],
  1774. ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
  1775. entry = make_entry(priv, bus_mac);
  1776. if (entry == NULL)
  1777. goto out;
  1778. memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
  1779. eth_zero_addr(entry->mac_addr);
  1780. entry->recv_vcc = vcc;
  1781. entry->old_recv_push = old_push;
  1782. entry->status = ESI_UNKNOWN;
  1783. entry->timer.expires = jiffies + priv->vcc_timeout_period;
  1784. entry->timer.function = lec_arp_expire_vcc;
  1785. hlist_add_head(&entry->next, &priv->lec_no_forward);
  1786. add_timer(&entry->timer);
  1787. dump_arp_table(priv);
  1788. goto out;
  1789. }
  1790. 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",
  1791. ioc_data->atm_addr[0], ioc_data->atm_addr[1],
  1792. ioc_data->atm_addr[2], ioc_data->atm_addr[3],
  1793. ioc_data->atm_addr[4], ioc_data->atm_addr[5],
  1794. ioc_data->atm_addr[6], ioc_data->atm_addr[7],
  1795. ioc_data->atm_addr[8], ioc_data->atm_addr[9],
  1796. ioc_data->atm_addr[10], ioc_data->atm_addr[11],
  1797. ioc_data->atm_addr[12], ioc_data->atm_addr[13],
  1798. ioc_data->atm_addr[14], ioc_data->atm_addr[15],
  1799. ioc_data->atm_addr[16], ioc_data->atm_addr[17],
  1800. ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
  1801. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1802. hlist_for_each_entry(entry,
  1803. &priv->lec_arp_tables[i], next) {
  1804. if (memcmp
  1805. (ioc_data->atm_addr, entry->atm_addr,
  1806. ATM_ESA_LEN) == 0) {
  1807. pr_debug("LEC_ARP: Attaching data direct\n");
  1808. pr_debug("Currently -> Vcc: %d, Rvcc:%d\n",
  1809. entry->vcc ? entry->vcc->vci : 0,
  1810. entry->recv_vcc ? entry->recv_vcc->
  1811. vci : 0);
  1812. found_entry = 1;
  1813. del_timer(&entry->timer);
  1814. entry->vcc = vcc;
  1815. entry->old_push = old_push;
  1816. if (entry->status == ESI_VC_PENDING) {
  1817. if (priv->maximum_unknown_frame_count
  1818. == 0)
  1819. entry->status =
  1820. ESI_FORWARD_DIRECT;
  1821. else {
  1822. entry->timestamp = jiffies;
  1823. entry->status =
  1824. ESI_FLUSH_PENDING;
  1825. #if 0
  1826. send_to_lecd(priv, l_flush_xmt,
  1827. NULL,
  1828. entry->atm_addr,
  1829. NULL);
  1830. #endif
  1831. }
  1832. } else {
  1833. /*
  1834. * They were forming a connection
  1835. * to us, and we to them. Our
  1836. * ATM address is numerically lower
  1837. * than theirs, so we make connection
  1838. * we formed into default VCC (8.1.11).
  1839. * Connection they made gets torn
  1840. * down. This might confuse some
  1841. * clients. Can be changed if
  1842. * someone reports trouble...
  1843. */
  1844. ;
  1845. }
  1846. }
  1847. }
  1848. }
  1849. if (found_entry) {
  1850. pr_debug("After vcc was added\n");
  1851. dump_arp_table(priv);
  1852. goto out;
  1853. }
  1854. /*
  1855. * Not found, snatch address from first data packet that arrives
  1856. * from this vcc
  1857. */
  1858. entry = make_entry(priv, bus_mac);
  1859. if (!entry)
  1860. goto out;
  1861. entry->vcc = vcc;
  1862. entry->old_push = old_push;
  1863. memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
  1864. eth_zero_addr(entry->mac_addr);
  1865. entry->status = ESI_UNKNOWN;
  1866. hlist_add_head(&entry->next, &priv->lec_arp_empty_ones);
  1867. entry->timer.expires = jiffies + priv->vcc_timeout_period;
  1868. entry->timer.function = lec_arp_expire_vcc;
  1869. add_timer(&entry->timer);
  1870. pr_debug("After vcc was added\n");
  1871. dump_arp_table(priv);
  1872. out:
  1873. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1874. }
  1875. static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id)
  1876. {
  1877. unsigned long flags;
  1878. struct lec_arp_table *entry;
  1879. int i;
  1880. pr_debug("%lx\n", tran_id);
  1881. restart:
  1882. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1883. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1884. hlist_for_each_entry(entry,
  1885. &priv->lec_arp_tables[i], next) {
  1886. if (entry->flush_tran_id == tran_id &&
  1887. entry->status == ESI_FLUSH_PENDING) {
  1888. struct sk_buff *skb;
  1889. struct atm_vcc *vcc = entry->vcc;
  1890. lec_arp_hold(entry);
  1891. spin_unlock_irqrestore(&priv->lec_arp_lock,
  1892. flags);
  1893. while ((skb = skb_dequeue(&entry->tx_wait)))
  1894. lec_send(vcc, skb);
  1895. entry->last_used = jiffies;
  1896. entry->status = ESI_FORWARD_DIRECT;
  1897. lec_arp_put(entry);
  1898. pr_debug("LEC_ARP: Flushed\n");
  1899. goto restart;
  1900. }
  1901. }
  1902. }
  1903. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1904. dump_arp_table(priv);
  1905. }
  1906. static void
  1907. lec_set_flush_tran_id(struct lec_priv *priv,
  1908. const unsigned char *atm_addr, unsigned long tran_id)
  1909. {
  1910. unsigned long flags;
  1911. struct lec_arp_table *entry;
  1912. int i;
  1913. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1914. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++)
  1915. hlist_for_each_entry(entry,
  1916. &priv->lec_arp_tables[i], next) {
  1917. if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) {
  1918. entry->flush_tran_id = tran_id;
  1919. pr_debug("Set flush transaction id to %lx for %p\n",
  1920. tran_id, entry);
  1921. }
  1922. }
  1923. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1924. }
  1925. static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc)
  1926. {
  1927. unsigned long flags;
  1928. unsigned char mac_addr[] = {
  1929. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  1930. };
  1931. struct lec_arp_table *to_add;
  1932. struct lec_vcc_priv *vpriv;
  1933. int err = 0;
  1934. vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL);
  1935. if (!vpriv)
  1936. return -ENOMEM;
  1937. vpriv->xoff = 0;
  1938. vpriv->old_pop = vcc->pop;
  1939. vcc->user_back = vpriv;
  1940. vcc->pop = lec_pop;
  1941. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1942. to_add = make_entry(priv, mac_addr);
  1943. if (!to_add) {
  1944. vcc->pop = vpriv->old_pop;
  1945. kfree(vpriv);
  1946. err = -ENOMEM;
  1947. goto out;
  1948. }
  1949. memcpy(to_add->atm_addr, vcc->remote.sas_addr.prv, ATM_ESA_LEN);
  1950. to_add->status = ESI_FORWARD_DIRECT;
  1951. to_add->flags |= LEC_PERMANENT_FLAG;
  1952. to_add->vcc = vcc;
  1953. to_add->old_push = vcc->push;
  1954. vcc->push = lec_push;
  1955. priv->mcast_vcc = vcc;
  1956. lec_arp_add(priv, to_add);
  1957. out:
  1958. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  1959. return err;
  1960. }
  1961. static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc)
  1962. {
  1963. unsigned long flags;
  1964. struct hlist_node *next;
  1965. struct lec_arp_table *entry;
  1966. int i;
  1967. pr_debug("LEC_ARP: lec_vcc_close vpi:%d vci:%d\n", vcc->vpi, vcc->vci);
  1968. dump_arp_table(priv);
  1969. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  1970. for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
  1971. hlist_for_each_entry_safe(entry, next,
  1972. &priv->lec_arp_tables[i], next) {
  1973. if (vcc == entry->vcc) {
  1974. lec_arp_remove(priv, entry);
  1975. lec_arp_put(entry);
  1976. if (priv->mcast_vcc == vcc)
  1977. priv->mcast_vcc = NULL;
  1978. }
  1979. }
  1980. }
  1981. hlist_for_each_entry_safe(entry, next,
  1982. &priv->lec_arp_empty_ones, next) {
  1983. if (entry->vcc == vcc) {
  1984. lec_arp_clear_vccs(entry);
  1985. del_timer(&entry->timer);
  1986. hlist_del(&entry->next);
  1987. lec_arp_put(entry);
  1988. }
  1989. }
  1990. hlist_for_each_entry_safe(entry, next,
  1991. &priv->lec_no_forward, next) {
  1992. if (entry->recv_vcc == vcc) {
  1993. lec_arp_clear_vccs(entry);
  1994. del_timer(&entry->timer);
  1995. hlist_del(&entry->next);
  1996. lec_arp_put(entry);
  1997. }
  1998. }
  1999. hlist_for_each_entry_safe(entry, next, &priv->mcast_fwds, next) {
  2000. if (entry->recv_vcc == vcc) {
  2001. lec_arp_clear_vccs(entry);
  2002. /* No timer, LANEv2 7.1.20 and 2.3.5.3 */
  2003. hlist_del(&entry->next);
  2004. lec_arp_put(entry);
  2005. }
  2006. }
  2007. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  2008. dump_arp_table(priv);
  2009. }
  2010. static void
  2011. lec_arp_check_empties(struct lec_priv *priv,
  2012. struct atm_vcc *vcc, struct sk_buff *skb)
  2013. {
  2014. unsigned long flags;
  2015. struct hlist_node *next;
  2016. struct lec_arp_table *entry, *tmp;
  2017. struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data;
  2018. unsigned char *src = hdr->h_source;
  2019. spin_lock_irqsave(&priv->lec_arp_lock, flags);
  2020. hlist_for_each_entry_safe(entry, next,
  2021. &priv->lec_arp_empty_ones, next) {
  2022. if (vcc == entry->vcc) {
  2023. del_timer(&entry->timer);
  2024. ether_addr_copy(entry->mac_addr, src);
  2025. entry->status = ESI_FORWARD_DIRECT;
  2026. entry->last_used = jiffies;
  2027. /* We might have got an entry */
  2028. tmp = lec_arp_find(priv, src);
  2029. if (tmp) {
  2030. lec_arp_remove(priv, tmp);
  2031. lec_arp_put(tmp);
  2032. }
  2033. hlist_del(&entry->next);
  2034. lec_arp_add(priv, entry);
  2035. goto out;
  2036. }
  2037. }
  2038. pr_debug("LEC_ARP: Arp_check_empties: entry not found!\n");
  2039. out:
  2040. spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
  2041. }
  2042. MODULE_LICENSE("GPL");