bat_v_elp.c 18 KB

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