bat_v_elp.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. // SPDX-License-Identifier: GPL-2.0
  2. /* Copyright (C) B.A.T.M.A.N. contributors:
  3. *
  4. * Linus Lüssing, Marek Lindner
  5. */
  6. #include "bat_v_elp.h"
  7. #include "main.h"
  8. #include <linux/atomic.h>
  9. #include <linux/bitops.h>
  10. #include <linux/byteorder/generic.h>
  11. #include <linux/container_of.h>
  12. #include <linux/errno.h>
  13. #include <linux/etherdevice.h>
  14. #include <linux/ethtool.h>
  15. #include <linux/gfp.h>
  16. #include <linux/if_ether.h>
  17. #include <linux/jiffies.h>
  18. #include <linux/kref.h>
  19. #include <linux/list.h>
  20. #include <linux/minmax.h>
  21. #include <linux/netdevice.h>
  22. #include <linux/nl80211.h>
  23. #include <linux/random.h>
  24. #include <linux/rculist.h>
  25. #include <linux/rcupdate.h>
  26. #include <linux/rtnetlink.h>
  27. #include <linux/skbuff.h>
  28. #include <linux/slab.h>
  29. #include <linux/stddef.h>
  30. #include <linux/string.h>
  31. #include <linux/types.h>
  32. #include <linux/workqueue.h>
  33. #include <net/cfg80211.h>
  34. #include <uapi/linux/batadv_packet.h>
  35. #include "bat_v_ogm.h"
  36. #include "hard-interface.h"
  37. #include "log.h"
  38. #include "originator.h"
  39. #include "routing.h"
  40. #include "send.h"
  41. /**
  42. * struct batadv_v_metric_queue_entry - list of hardif neighbors which require
  43. * and metric update
  44. */
  45. struct batadv_v_metric_queue_entry {
  46. /** @hardif_neigh: hardif neighbor scheduled for metric update */
  47. struct batadv_hardif_neigh_node *hardif_neigh;
  48. /** @list: list node for metric_queue */
  49. struct list_head list;
  50. };
  51. /**
  52. * batadv_v_elp_start_timer() - restart timer for ELP periodic work
  53. * @hard_iface: the interface for which the timer has to be reset
  54. */
  55. static void batadv_v_elp_start_timer(struct batadv_hard_iface *hard_iface)
  56. {
  57. unsigned int msecs;
  58. msecs = atomic_read(&hard_iface->bat_v.elp_interval) - BATADV_JITTER;
  59. msecs += get_random_u32_below(2 * BATADV_JITTER);
  60. queue_delayed_work(batadv_event_workqueue, &hard_iface->bat_v.elp_wq,
  61. msecs_to_jiffies(msecs));
  62. }
  63. /**
  64. * batadv_v_elp_get_throughput() - get the throughput towards a neighbour
  65. * @neigh: the neighbour for which the throughput has to be obtained
  66. * @pthroughput: calculated throughput towards the given neighbour in multiples
  67. * of 100kpbs (a value of '1' equals 0.1Mbps, '10' equals 1Mbps, etc).
  68. *
  69. * Return: true when value behind @pthroughput was set
  70. */
  71. static bool batadv_v_elp_get_throughput(struct batadv_hardif_neigh_node *neigh,
  72. u32 *pthroughput)
  73. {
  74. struct batadv_hard_iface *hard_iface = neigh->if_incoming;
  75. struct net_device *mesh_iface = hard_iface->mesh_iface;
  76. struct ethtool_link_ksettings link_settings;
  77. struct net_device *real_netdev;
  78. struct station_info sinfo;
  79. u32 throughput;
  80. int ret;
  81. /* don't query throughput when no longer associated with any
  82. * batman-adv interface
  83. */
  84. if (!mesh_iface)
  85. return false;
  86. /* if the user specified a customised value for this interface, then
  87. * return it directly
  88. */
  89. throughput = atomic_read(&hard_iface->bat_v.throughput_override);
  90. if (throughput != 0) {
  91. *pthroughput = throughput;
  92. return true;
  93. }
  94. /* if this is a wireless device, then ask its throughput through
  95. * cfg80211 API
  96. */
  97. if (batadv_is_wifi_hardif(hard_iface)) {
  98. if (!batadv_is_cfg80211_hardif(hard_iface))
  99. /* unsupported WiFi driver version */
  100. goto default_throughput;
  101. /* only use rtnl_trylock because the elp worker will be cancelled while
  102. * the rntl_lock is held. the cancel_delayed_work_sync() would otherwise
  103. * wait forever when the elp work_item was started and it is then also
  104. * trying to rtnl_lock
  105. */
  106. if (!rtnl_trylock())
  107. return false;
  108. real_netdev = __batadv_get_real_netdev(hard_iface->net_dev);
  109. rtnl_unlock();
  110. if (!real_netdev)
  111. goto default_throughput;
  112. ret = cfg80211_get_station(real_netdev, neigh->addr, &sinfo);
  113. if (!ret) {
  114. /* free the TID stats immediately */
  115. cfg80211_sinfo_release_content(&sinfo);
  116. }
  117. dev_put(real_netdev);
  118. if (ret == -ENOENT) {
  119. /* Node is not associated anymore! It would be
  120. * possible to delete this neighbor. For now set
  121. * the throughput metric to 0.
  122. */
  123. *pthroughput = 0;
  124. return true;
  125. }
  126. if (ret)
  127. goto default_throughput;
  128. if (sinfo.filled & BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT)) {
  129. *pthroughput = sinfo.expected_throughput / 100;
  130. return true;
  131. }
  132. /* try to estimate the expected throughput based on reported tx
  133. * rates
  134. */
  135. if (sinfo.filled & BIT(NL80211_STA_INFO_TX_BITRATE)) {
  136. *pthroughput = cfg80211_calculate_bitrate(&sinfo.txrate) / 3;
  137. return true;
  138. }
  139. goto default_throughput;
  140. }
  141. /* only use rtnl_trylock because the elp worker will be cancelled while
  142. * the rntl_lock is held. the cancel_delayed_work_sync() would otherwise
  143. * wait forever when the elp work_item was started and it is then also
  144. * trying to rtnl_lock
  145. */
  146. if (!rtnl_trylock())
  147. return false;
  148. /* if not a wifi interface, check if this device provides data via
  149. * ethtool (e.g. an Ethernet adapter)
  150. */
  151. ret = __ethtool_get_link_ksettings(hard_iface->net_dev, &link_settings);
  152. rtnl_unlock();
  153. if (ret == 0) {
  154. /* link characteristics might change over time */
  155. if (link_settings.base.duplex == DUPLEX_FULL)
  156. hard_iface->bat_v.flags |= BATADV_FULL_DUPLEX;
  157. else
  158. hard_iface->bat_v.flags &= ~BATADV_FULL_DUPLEX;
  159. throughput = link_settings.base.speed;
  160. if (throughput && throughput != SPEED_UNKNOWN) {
  161. *pthroughput = throughput * 10;
  162. return true;
  163. }
  164. }
  165. default_throughput:
  166. if (!(hard_iface->bat_v.flags & BATADV_WARNING_DEFAULT)) {
  167. batadv_info(mesh_iface,
  168. "WiFi driver or ethtool info does not provide information about link speeds on interface %s, therefore defaulting to hardcoded throughput values of %u.%1u Mbps. Consider overriding the throughput manually or checking your driver.\n",
  169. hard_iface->net_dev->name,
  170. BATADV_THROUGHPUT_DEFAULT_VALUE / 10,
  171. BATADV_THROUGHPUT_DEFAULT_VALUE % 10);
  172. hard_iface->bat_v.flags |= BATADV_WARNING_DEFAULT;
  173. }
  174. /* if none of the above cases apply, return the base_throughput */
  175. *pthroughput = BATADV_THROUGHPUT_DEFAULT_VALUE;
  176. return true;
  177. }
  178. /**
  179. * batadv_v_elp_throughput_metric_update() - worker updating the throughput
  180. * metric of a single hop neighbour
  181. * @neigh: the neighbour to probe
  182. */
  183. static void
  184. batadv_v_elp_throughput_metric_update(struct batadv_hardif_neigh_node *neigh)
  185. {
  186. u32 throughput;
  187. bool valid;
  188. valid = batadv_v_elp_get_throughput(neigh, &throughput);
  189. if (!valid)
  190. return;
  191. ewma_throughput_add(&neigh->bat_v.throughput, throughput);
  192. }
  193. /**
  194. * batadv_v_elp_wifi_neigh_probe() - send link probing packets to a neighbour
  195. * @neigh: the neighbour to probe
  196. *
  197. * Sends a predefined number of unicast wifi packets to a given neighbour in
  198. * order to trigger the throughput estimation on this link by the RC algorithm.
  199. * Packets are sent only if there is not enough payload unicast traffic towards
  200. * this neighbour..
  201. *
  202. * Return: True on success and false in case of error during skb preparation.
  203. */
  204. static bool
  205. batadv_v_elp_wifi_neigh_probe(struct batadv_hardif_neigh_node *neigh)
  206. {
  207. struct batadv_hard_iface *hard_iface = neigh->if_incoming;
  208. struct batadv_priv *bat_priv = netdev_priv(hard_iface->mesh_iface);
  209. unsigned long last_tx_diff;
  210. struct sk_buff *skb;
  211. int probe_len, i;
  212. int elp_skb_len;
  213. /* this probing routine is for Wifi neighbours only */
  214. if (!batadv_is_wifi_hardif(hard_iface))
  215. return true;
  216. /* probe the neighbor only if no unicast packets have been sent
  217. * to it in the last 100 milliseconds: this is the rate control
  218. * algorithm sampling interval (minstrel). In this way, if not
  219. * enough traffic has been sent to the neighbor, batman-adv can
  220. * generate 2 probe packets and push the RC algorithm to perform
  221. * the sampling
  222. */
  223. last_tx_diff = jiffies_to_msecs(jiffies - neigh->bat_v.last_unicast_tx);
  224. if (last_tx_diff <= BATADV_ELP_PROBE_MAX_TX_DIFF)
  225. return true;
  226. probe_len = max_t(int, sizeof(struct batadv_elp_packet),
  227. BATADV_ELP_MIN_PROBE_SIZE);
  228. for (i = 0; i < BATADV_ELP_PROBES_PER_NODE; i++) {
  229. elp_skb_len = hard_iface->bat_v.elp_skb->len;
  230. skb = skb_copy_expand(hard_iface->bat_v.elp_skb, 0,
  231. probe_len - elp_skb_len,
  232. GFP_ATOMIC);
  233. if (!skb)
  234. return false;
  235. /* Tell the skb to get as big as the allocated space (we want
  236. * the packet to be exactly of that size to make the link
  237. * throughput estimation effective.
  238. */
  239. skb_put_zero(skb, probe_len - hard_iface->bat_v.elp_skb->len);
  240. batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
  241. "Sending unicast (probe) ELP packet on interface %s to %pM\n",
  242. hard_iface->net_dev->name, neigh->addr);
  243. batadv_send_skb_packet(skb, hard_iface, neigh->addr);
  244. }
  245. return true;
  246. }
  247. /**
  248. * batadv_v_elp_periodic_work() - ELP periodic task per interface
  249. * @work: work queue item
  250. *
  251. * Emits broadcast ELP messages in regular intervals.
  252. */
  253. static void batadv_v_elp_periodic_work(struct work_struct *work)
  254. {
  255. struct batadv_v_metric_queue_entry *metric_entry;
  256. struct batadv_v_metric_queue_entry *metric_safe;
  257. struct batadv_hardif_neigh_node *hardif_neigh;
  258. struct batadv_hard_iface *hard_iface;
  259. struct batadv_hard_iface_bat_v *bat_v;
  260. struct batadv_elp_packet *elp_packet;
  261. struct list_head metric_queue;
  262. struct batadv_priv *bat_priv;
  263. struct sk_buff *skb;
  264. u32 elp_interval;
  265. bat_v = container_of(work, struct batadv_hard_iface_bat_v, elp_wq.work);
  266. hard_iface = container_of(bat_v, struct batadv_hard_iface, bat_v);
  267. bat_priv = netdev_priv(hard_iface->mesh_iface);
  268. if (atomic_read(&bat_priv->mesh_state) == BATADV_MESH_DEACTIVATING)
  269. goto out;
  270. /* we are in the process of shutting this interface down */
  271. if (hard_iface->if_status == BATADV_IF_NOT_IN_USE ||
  272. hard_iface->if_status == BATADV_IF_TO_BE_REMOVED)
  273. goto out;
  274. /* the interface was enabled but may not be ready yet */
  275. if (hard_iface->if_status != BATADV_IF_ACTIVE)
  276. goto restart_timer;
  277. skb = skb_copy(hard_iface->bat_v.elp_skb, GFP_ATOMIC);
  278. if (!skb)
  279. goto restart_timer;
  280. elp_packet = (struct batadv_elp_packet *)skb->data;
  281. elp_packet->seqno = htonl(atomic_read(&hard_iface->bat_v.elp_seqno));
  282. elp_interval = atomic_read(&hard_iface->bat_v.elp_interval);
  283. elp_packet->elp_interval = htonl(elp_interval);
  284. batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
  285. "Sending broadcast ELP packet on interface %s, seqno %u\n",
  286. hard_iface->net_dev->name,
  287. atomic_read(&hard_iface->bat_v.elp_seqno));
  288. batadv_send_broadcast_skb(skb, hard_iface);
  289. atomic_inc(&hard_iface->bat_v.elp_seqno);
  290. INIT_LIST_HEAD(&metric_queue);
  291. /* The throughput metric is updated on each sent packet. This way, if a
  292. * node is dead and no longer sends packets, batman-adv is still able to
  293. * react timely to its death.
  294. *
  295. * The throughput metric is updated by following these steps:
  296. * 1) if the hard_iface is wifi => send a number of unicast ELPs for
  297. * probing/sampling to each neighbor
  298. * 2) update the throughput metric value of each neighbor (note that the
  299. * value retrieved in this step might be 100ms old because the
  300. * probing packets at point 1) could still be in the HW queue)
  301. */
  302. rcu_read_lock();
  303. hlist_for_each_entry_rcu(hardif_neigh, &hard_iface->neigh_list, list) {
  304. if (!batadv_v_elp_wifi_neigh_probe(hardif_neigh))
  305. /* if something goes wrong while probing, better to stop
  306. * sending packets immediately and reschedule the task
  307. */
  308. break;
  309. if (!kref_get_unless_zero(&hardif_neigh->refcount))
  310. continue;
  311. /* Reading the estimated throughput from cfg80211 is a task that
  312. * may sleep and that is not allowed in an rcu protected
  313. * context. Therefore add it to metric_queue and process it
  314. * outside rcu protected context.
  315. */
  316. metric_entry = kzalloc_obj(*metric_entry, GFP_ATOMIC);
  317. if (!metric_entry) {
  318. batadv_hardif_neigh_put(hardif_neigh);
  319. continue;
  320. }
  321. metric_entry->hardif_neigh = hardif_neigh;
  322. list_add(&metric_entry->list, &metric_queue);
  323. }
  324. rcu_read_unlock();
  325. list_for_each_entry_safe(metric_entry, metric_safe, &metric_queue, list) {
  326. batadv_v_elp_throughput_metric_update(metric_entry->hardif_neigh);
  327. batadv_hardif_neigh_put(metric_entry->hardif_neigh);
  328. list_del(&metric_entry->list);
  329. kfree(metric_entry);
  330. }
  331. restart_timer:
  332. batadv_v_elp_start_timer(hard_iface);
  333. out:
  334. return;
  335. }
  336. /**
  337. * batadv_v_elp_iface_enable() - setup the ELP interface private resources
  338. * @hard_iface: interface for which the data has to be prepared
  339. *
  340. * Return: 0 on success or a -ENOMEM in case of failure.
  341. */
  342. int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)
  343. {
  344. static const size_t tvlv_padding = sizeof(__be32);
  345. struct batadv_elp_packet *elp_packet;
  346. unsigned char *elp_buff;
  347. u32 random_seqno;
  348. size_t size;
  349. int res = -ENOMEM;
  350. size = ETH_HLEN + NET_IP_ALIGN + BATADV_ELP_HLEN + tvlv_padding;
  351. hard_iface->bat_v.elp_skb = dev_alloc_skb(size);
  352. if (!hard_iface->bat_v.elp_skb)
  353. goto out;
  354. skb_reserve(hard_iface->bat_v.elp_skb, ETH_HLEN + NET_IP_ALIGN);
  355. elp_buff = skb_put_zero(hard_iface->bat_v.elp_skb,
  356. BATADV_ELP_HLEN + tvlv_padding);
  357. elp_packet = (struct batadv_elp_packet *)elp_buff;
  358. elp_packet->packet_type = BATADV_ELP;
  359. elp_packet->version = BATADV_COMPAT_VERSION;
  360. /* randomize initial seqno to avoid collision */
  361. get_random_bytes(&random_seqno, sizeof(random_seqno));
  362. atomic_set(&hard_iface->bat_v.elp_seqno, random_seqno);
  363. /* assume full-duplex by default */
  364. hard_iface->bat_v.flags |= BATADV_FULL_DUPLEX;
  365. /* warn the user (again) if there is no throughput data is available */
  366. hard_iface->bat_v.flags &= ~BATADV_WARNING_DEFAULT;
  367. if (batadv_is_wifi_hardif(hard_iface))
  368. hard_iface->bat_v.flags &= ~BATADV_FULL_DUPLEX;
  369. INIT_DELAYED_WORK(&hard_iface->bat_v.elp_wq,
  370. batadv_v_elp_periodic_work);
  371. batadv_v_elp_start_timer(hard_iface);
  372. res = 0;
  373. out:
  374. return res;
  375. }
  376. /**
  377. * batadv_v_elp_iface_disable() - release ELP interface private resources
  378. * @hard_iface: interface for which the resources have to be released
  379. */
  380. void batadv_v_elp_iface_disable(struct batadv_hard_iface *hard_iface)
  381. {
  382. cancel_delayed_work_sync(&hard_iface->bat_v.elp_wq);
  383. dev_kfree_skb(hard_iface->bat_v.elp_skb);
  384. hard_iface->bat_v.elp_skb = NULL;
  385. }
  386. /**
  387. * batadv_v_elp_iface_activate() - update the ELP buffer belonging to the given
  388. * hard-interface
  389. * @primary_iface: the new primary interface
  390. * @hard_iface: interface holding the to-be-updated buffer
  391. */
  392. void batadv_v_elp_iface_activate(struct batadv_hard_iface *primary_iface,
  393. struct batadv_hard_iface *hard_iface)
  394. {
  395. struct batadv_elp_packet *elp_packet;
  396. struct sk_buff *skb;
  397. if (!hard_iface->bat_v.elp_skb)
  398. return;
  399. skb = hard_iface->bat_v.elp_skb;
  400. elp_packet = (struct batadv_elp_packet *)skb->data;
  401. ether_addr_copy(elp_packet->orig,
  402. primary_iface->net_dev->dev_addr);
  403. }
  404. /**
  405. * batadv_v_elp_primary_iface_set() - change internal data to reflect the new
  406. * primary interface
  407. * @primary_iface: the new primary interface
  408. */
  409. void batadv_v_elp_primary_iface_set(struct batadv_hard_iface *primary_iface)
  410. {
  411. struct batadv_hard_iface *hard_iface;
  412. struct list_head *iter;
  413. /* update orig field of every elp iface belonging to this mesh */
  414. rcu_read_lock();
  415. netdev_for_each_lower_private_rcu(primary_iface->mesh_iface, hard_iface, iter)
  416. batadv_v_elp_iface_activate(primary_iface, hard_iface);
  417. rcu_read_unlock();
  418. }
  419. /**
  420. * batadv_v_elp_neigh_update() - update an ELP neighbour node
  421. * @bat_priv: the bat priv with all the mesh interface information
  422. * @neigh_addr: the neighbour interface address
  423. * @if_incoming: the interface the packet was received through
  424. * @elp_packet: the received ELP packet
  425. *
  426. * Updates the ELP neighbour node state with the data received within the new
  427. * ELP packet.
  428. */
  429. static void batadv_v_elp_neigh_update(struct batadv_priv *bat_priv,
  430. u8 *neigh_addr,
  431. struct batadv_hard_iface *if_incoming,
  432. struct batadv_elp_packet *elp_packet)
  433. {
  434. struct batadv_neigh_node *neigh;
  435. struct batadv_orig_node *orig_neigh;
  436. struct batadv_hardif_neigh_node *hardif_neigh;
  437. s32 seqno_diff;
  438. s32 elp_latest_seqno;
  439. orig_neigh = batadv_v_ogm_orig_get(bat_priv, elp_packet->orig);
  440. if (!orig_neigh)
  441. return;
  442. neigh = batadv_neigh_node_get_or_create(orig_neigh,
  443. if_incoming, neigh_addr);
  444. if (!neigh)
  445. goto orig_free;
  446. hardif_neigh = batadv_hardif_neigh_get(if_incoming, neigh_addr);
  447. if (!hardif_neigh)
  448. goto neigh_free;
  449. elp_latest_seqno = hardif_neigh->bat_v.elp_latest_seqno;
  450. seqno_diff = ntohl(elp_packet->seqno) - elp_latest_seqno;
  451. /* known or older sequence numbers are ignored. However always adopt
  452. * if the router seems to have been restarted.
  453. */
  454. if (seqno_diff < 1 && seqno_diff > -BATADV_ELP_MAX_AGE)
  455. goto hardif_free;
  456. neigh->last_seen = jiffies;
  457. hardif_neigh->last_seen = jiffies;
  458. hardif_neigh->bat_v.elp_latest_seqno = ntohl(elp_packet->seqno);
  459. hardif_neigh->bat_v.elp_interval = ntohl(elp_packet->elp_interval);
  460. hardif_free:
  461. batadv_hardif_neigh_put(hardif_neigh);
  462. neigh_free:
  463. batadv_neigh_node_put(neigh);
  464. orig_free:
  465. batadv_orig_node_put(orig_neigh);
  466. }
  467. /**
  468. * batadv_v_elp_packet_recv() - main ELP packet handler
  469. * @skb: the received packet
  470. * @if_incoming: the interface this packet was received through
  471. *
  472. * Return: NET_RX_SUCCESS and consumes the skb if the packet was properly
  473. * processed or NET_RX_DROP in case of failure.
  474. */
  475. int batadv_v_elp_packet_recv(struct sk_buff *skb,
  476. struct batadv_hard_iface *if_incoming)
  477. {
  478. struct batadv_priv *bat_priv = netdev_priv(if_incoming->mesh_iface);
  479. struct batadv_elp_packet *elp_packet;
  480. struct batadv_hard_iface *primary_if;
  481. struct ethhdr *ethhdr;
  482. bool res;
  483. int ret = NET_RX_DROP;
  484. res = batadv_check_management_packet(skb, if_incoming, BATADV_ELP_HLEN);
  485. if (!res)
  486. goto free_skb;
  487. ethhdr = eth_hdr(skb);
  488. if (batadv_is_my_mac(bat_priv, ethhdr->h_source))
  489. goto free_skb;
  490. /* did we receive a B.A.T.M.A.N. V ELP packet on an interface
  491. * that does not have B.A.T.M.A.N. V ELP enabled ?
  492. */
  493. if (strcmp(bat_priv->algo_ops->name, "BATMAN_V") != 0)
  494. goto free_skb;
  495. elp_packet = (struct batadv_elp_packet *)skb->data;
  496. batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
  497. "Received ELP packet from %pM seqno %u ORIG: %pM\n",
  498. ethhdr->h_source, ntohl(elp_packet->seqno),
  499. elp_packet->orig);
  500. primary_if = batadv_primary_if_get_selected(bat_priv);
  501. if (!primary_if)
  502. goto free_skb;
  503. batadv_v_elp_neigh_update(bat_priv, ethhdr->h_source, if_incoming,
  504. elp_packet);
  505. ret = NET_RX_SUCCESS;
  506. batadv_hardif_put(primary_if);
  507. free_skb:
  508. if (ret == NET_RX_SUCCESS)
  509. consume_skb(skb);
  510. else
  511. kfree_skb(skb);
  512. return ret;
  513. }