1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2009-2019 B.A.T.M.A.N. contributors:
7 #include "gateway_client.h"
10 #include <linux/atomic.h>
11 #include <linux/byteorder/generic.h>
12 #include <linux/errno.h>
13 #include <linux/etherdevice.h>
14 #include <linux/gfp.h>
15 #include <linux/if_ether.h>
16 #include <linux/if_vlan.h>
19 #include <linux/ipv6.h>
20 #include <linux/kernel.h>
21 #include <linux/kref.h>
22 #include <linux/list.h>
23 #include <linux/lockdep.h>
24 #include <linux/netdevice.h>
25 #include <linux/netlink.h>
26 #include <linux/rculist.h>
27 #include <linux/rcupdate.h>
28 #include <linux/seq_file.h>
29 #include <linux/skbuff.h>
30 #include <linux/slab.h>
31 #include <linux/spinlock.h>
32 #include <linux/stddef.h>
33 #include <linux/udp.h>
35 #include <uapi/linux/batadv_packet.h>
36 #include <uapi/linux/batman_adv.h>
38 #include "hard-interface.h"
41 #include "originator.h"
43 #include "soft-interface.h"
45 #include "translation-table.h"
47 /* These are the offsets of the "hw type" and "hw address length" in the dhcp
48 * packet starting at the beginning of the dhcp header
50 #define BATADV_DHCP_HTYPE_OFFSET 1
51 #define BATADV_DHCP_HLEN_OFFSET 2
52 /* Value of htype representing Ethernet */
53 #define BATADV_DHCP_HTYPE_ETHERNET 0x01
54 /* This is the offset of the "chaddr" field in the dhcp packet starting at the
55 * beginning of the dhcp header
57 #define BATADV_DHCP_CHADDR_OFFSET 28
60 * batadv_gw_node_release() - release gw_node from lists and queue for free
61 * after rcu grace period
62 * @ref: kref pointer of the gw_node
64 static void batadv_gw_node_release(struct kref *ref)
66 struct batadv_gw_node *gw_node;
68 gw_node = container_of(ref, struct batadv_gw_node, refcount);
70 batadv_orig_node_put(gw_node->orig_node);
71 kfree_rcu(gw_node, rcu);
75 * batadv_gw_node_put() - decrement the gw_node refcounter and possibly release
77 * @gw_node: gateway node to free
79 void batadv_gw_node_put(struct batadv_gw_node *gw_node)
81 kref_put(&gw_node->refcount, batadv_gw_node_release);
85 * batadv_gw_get_selected_gw_node() - Get currently selected gateway
86 * @bat_priv: the bat priv with all the soft interface information
88 * Return: selected gateway (with increased refcnt), NULL on errors
90 struct batadv_gw_node *
91 batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv)
93 struct batadv_gw_node *gw_node;
96 gw_node = rcu_dereference(bat_priv->gw.curr_gw);
100 if (!kref_get_unless_zero(&gw_node->refcount))
109 * batadv_gw_get_selected_orig() - Get originator of currently selected gateway
110 * @bat_priv: the bat priv with all the soft interface information
112 * Return: orig_node of selected gateway (with increased refcnt), NULL on errors
114 struct batadv_orig_node *
115 batadv_gw_get_selected_orig(struct batadv_priv *bat_priv)
117 struct batadv_gw_node *gw_node;
118 struct batadv_orig_node *orig_node = NULL;
120 gw_node = batadv_gw_get_selected_gw_node(bat_priv);
125 orig_node = gw_node->orig_node;
129 if (!kref_get_unless_zero(&orig_node->refcount))
136 batadv_gw_node_put(gw_node);
140 static void batadv_gw_select(struct batadv_priv *bat_priv,
141 struct batadv_gw_node *new_gw_node)
143 struct batadv_gw_node *curr_gw_node;
145 spin_lock_bh(&bat_priv->gw.list_lock);
148 kref_get(&new_gw_node->refcount);
150 curr_gw_node = rcu_dereference_protected(bat_priv->gw.curr_gw, 1);
151 rcu_assign_pointer(bat_priv->gw.curr_gw, new_gw_node);
154 batadv_gw_node_put(curr_gw_node);
156 spin_unlock_bh(&bat_priv->gw.list_lock);
160 * batadv_gw_reselect() - force a gateway reselection
161 * @bat_priv: the bat priv with all the soft interface information
163 * Set a flag to remind the GW component to perform a new gateway reselection.
164 * However this function does not ensure that the current gateway is going to be
165 * deselected. The reselection mechanism may elect the same gateway once again.
167 * This means that invoking batadv_gw_reselect() does not guarantee a gateway
168 * change and therefore a uevent is not necessarily expected.
170 void batadv_gw_reselect(struct batadv_priv *bat_priv)
172 atomic_set(&bat_priv->gw.reselect, 1);
176 * batadv_gw_check_client_stop() - check if client mode has been switched off
177 * @bat_priv: the bat priv with all the soft interface information
179 * This function assumes the caller has checked that the gw state *is actually
180 * changing*. This function is not supposed to be called when there is no state
183 void batadv_gw_check_client_stop(struct batadv_priv *bat_priv)
185 struct batadv_gw_node *curr_gw;
187 if (atomic_read(&bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT)
190 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
194 /* deselect the current gateway so that next time that client mode is
195 * enabled a proper GW_ADD event can be sent
197 batadv_gw_select(bat_priv, NULL);
199 /* if batman-adv is switching the gw client mode off and a gateway was
200 * already selected, send a DEL uevent
202 batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, NULL);
204 batadv_gw_node_put(curr_gw);
208 * batadv_gw_election() - Elect the best gateway
209 * @bat_priv: the bat priv with all the soft interface information
211 void batadv_gw_election(struct batadv_priv *bat_priv)
213 struct batadv_gw_node *curr_gw = NULL;
214 struct batadv_gw_node *next_gw = NULL;
215 struct batadv_neigh_node *router = NULL;
216 struct batadv_neigh_ifinfo *router_ifinfo = NULL;
217 char gw_addr[18] = { '\0' };
219 if (atomic_read(&bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT)
222 if (!bat_priv->algo_ops->gw.get_best_gw_node)
225 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
227 if (!batadv_atomic_dec_not_zero(&bat_priv->gw.reselect) && curr_gw)
230 /* if gw.reselect is set to 1 it means that a previous call to
231 * gw.is_eligible() said that we have a new best GW, therefore it can
232 * now be picked from the list and selected
234 next_gw = bat_priv->algo_ops->gw.get_best_gw_node(bat_priv);
236 if (curr_gw == next_gw)
240 sprintf(gw_addr, "%pM", next_gw->orig_node->orig);
242 router = batadv_orig_router_get(next_gw->orig_node,
245 batadv_gw_reselect(bat_priv);
249 router_ifinfo = batadv_neigh_ifinfo_get(router,
251 if (!router_ifinfo) {
252 batadv_gw_reselect(bat_priv);
257 if (curr_gw && !next_gw) {
258 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
259 "Removing selected gateway - no gateway in range\n");
260 batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL,
262 } else if (!curr_gw && next_gw) {
263 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
264 "Adding route to gateway %pM (bandwidth: %u.%u/%u.%u MBit, tq: %i)\n",
265 next_gw->orig_node->orig,
266 next_gw->bandwidth_down / 10,
267 next_gw->bandwidth_down % 10,
268 next_gw->bandwidth_up / 10,
269 next_gw->bandwidth_up % 10,
270 router_ifinfo->bat_iv.tq_avg);
271 batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_ADD,
274 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
275 "Changing route to gateway %pM (bandwidth: %u.%u/%u.%u MBit, tq: %i)\n",
276 next_gw->orig_node->orig,
277 next_gw->bandwidth_down / 10,
278 next_gw->bandwidth_down % 10,
279 next_gw->bandwidth_up / 10,
280 next_gw->bandwidth_up % 10,
281 router_ifinfo->bat_iv.tq_avg);
282 batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_CHANGE,
286 batadv_gw_select(bat_priv, next_gw);
290 batadv_gw_node_put(curr_gw);
292 batadv_gw_node_put(next_gw);
294 batadv_neigh_node_put(router);
296 batadv_neigh_ifinfo_put(router_ifinfo);
300 * batadv_gw_check_election() - Elect orig node as best gateway when eligible
301 * @bat_priv: the bat priv with all the soft interface information
302 * @orig_node: orig node which is to be checked
304 void batadv_gw_check_election(struct batadv_priv *bat_priv,
305 struct batadv_orig_node *orig_node)
307 struct batadv_orig_node *curr_gw_orig;
309 /* abort immediately if the routing algorithm does not support gateway
312 if (!bat_priv->algo_ops->gw.is_eligible)
315 curr_gw_orig = batadv_gw_get_selected_orig(bat_priv);
319 /* this node already is the gateway */
320 if (curr_gw_orig == orig_node)
323 if (!bat_priv->algo_ops->gw.is_eligible(bat_priv, curr_gw_orig,
328 batadv_gw_reselect(bat_priv);
331 batadv_orig_node_put(curr_gw_orig);
335 * batadv_gw_node_add() - add gateway node to list of available gateways
336 * @bat_priv: the bat priv with all the soft interface information
337 * @orig_node: originator announcing gateway capabilities
338 * @gateway: announced bandwidth information
340 * Has to be called with the appropriate locks being acquired
343 static void batadv_gw_node_add(struct batadv_priv *bat_priv,
344 struct batadv_orig_node *orig_node,
345 struct batadv_tvlv_gateway_data *gateway)
347 struct batadv_gw_node *gw_node;
349 lockdep_assert_held(&bat_priv->gw.list_lock);
351 if (gateway->bandwidth_down == 0)
354 gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC);
358 kref_init(&gw_node->refcount);
359 INIT_HLIST_NODE(&gw_node->list);
360 kref_get(&orig_node->refcount);
361 gw_node->orig_node = orig_node;
362 gw_node->bandwidth_down = ntohl(gateway->bandwidth_down);
363 gw_node->bandwidth_up = ntohl(gateway->bandwidth_up);
365 kref_get(&gw_node->refcount);
366 hlist_add_head_rcu(&gw_node->list, &bat_priv->gw.gateway_list);
367 bat_priv->gw.generation++;
369 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
370 "Found new gateway %pM -> gw bandwidth: %u.%u/%u.%u MBit\n",
372 ntohl(gateway->bandwidth_down) / 10,
373 ntohl(gateway->bandwidth_down) % 10,
374 ntohl(gateway->bandwidth_up) / 10,
375 ntohl(gateway->bandwidth_up) % 10);
377 /* don't return reference to new gw_node */
378 batadv_gw_node_put(gw_node);
382 * batadv_gw_node_get() - retrieve gateway node from list of available gateways
383 * @bat_priv: the bat priv with all the soft interface information
384 * @orig_node: originator announcing gateway capabilities
386 * Return: gateway node if found or NULL otherwise.
388 struct batadv_gw_node *batadv_gw_node_get(struct batadv_priv *bat_priv,
389 struct batadv_orig_node *orig_node)
391 struct batadv_gw_node *gw_node_tmp, *gw_node = NULL;
394 hlist_for_each_entry_rcu(gw_node_tmp, &bat_priv->gw.gateway_list,
396 if (gw_node_tmp->orig_node != orig_node)
399 if (!kref_get_unless_zero(&gw_node_tmp->refcount))
402 gw_node = gw_node_tmp;
411 * batadv_gw_node_update() - update list of available gateways with changed
412 * bandwidth information
413 * @bat_priv: the bat priv with all the soft interface information
414 * @orig_node: originator announcing gateway capabilities
415 * @gateway: announced bandwidth information
417 void batadv_gw_node_update(struct batadv_priv *bat_priv,
418 struct batadv_orig_node *orig_node,
419 struct batadv_tvlv_gateway_data *gateway)
421 struct batadv_gw_node *gw_node, *curr_gw = NULL;
423 spin_lock_bh(&bat_priv->gw.list_lock);
424 gw_node = batadv_gw_node_get(bat_priv, orig_node);
426 batadv_gw_node_add(bat_priv, orig_node, gateway);
427 spin_unlock_bh(&bat_priv->gw.list_lock);
430 spin_unlock_bh(&bat_priv->gw.list_lock);
432 if (gw_node->bandwidth_down == ntohl(gateway->bandwidth_down) &&
433 gw_node->bandwidth_up == ntohl(gateway->bandwidth_up))
436 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
437 "Gateway bandwidth of originator %pM changed from %u.%u/%u.%u MBit to %u.%u/%u.%u MBit\n",
439 gw_node->bandwidth_down / 10,
440 gw_node->bandwidth_down % 10,
441 gw_node->bandwidth_up / 10,
442 gw_node->bandwidth_up % 10,
443 ntohl(gateway->bandwidth_down) / 10,
444 ntohl(gateway->bandwidth_down) % 10,
445 ntohl(gateway->bandwidth_up) / 10,
446 ntohl(gateway->bandwidth_up) % 10);
448 gw_node->bandwidth_down = ntohl(gateway->bandwidth_down);
449 gw_node->bandwidth_up = ntohl(gateway->bandwidth_up);
451 if (ntohl(gateway->bandwidth_down) == 0) {
452 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
453 "Gateway %pM removed from gateway list\n",
456 /* Note: We don't need a NULL check here, since curr_gw never
459 spin_lock_bh(&bat_priv->gw.list_lock);
460 if (!hlist_unhashed(&gw_node->list)) {
461 hlist_del_init_rcu(&gw_node->list);
462 batadv_gw_node_put(gw_node);
463 bat_priv->gw.generation++;
465 spin_unlock_bh(&bat_priv->gw.list_lock);
467 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
468 if (gw_node == curr_gw)
469 batadv_gw_reselect(bat_priv);
472 batadv_gw_node_put(curr_gw);
477 batadv_gw_node_put(gw_node);
481 * batadv_gw_node_delete() - Remove orig_node from gateway list
482 * @bat_priv: the bat priv with all the soft interface information
483 * @orig_node: orig node which is currently in process of being removed
485 void batadv_gw_node_delete(struct batadv_priv *bat_priv,
486 struct batadv_orig_node *orig_node)
488 struct batadv_tvlv_gateway_data gateway;
490 gateway.bandwidth_down = 0;
491 gateway.bandwidth_up = 0;
493 batadv_gw_node_update(bat_priv, orig_node, &gateway);
497 * batadv_gw_node_free() - Free gateway information from soft interface
498 * @bat_priv: the bat priv with all the soft interface information
500 void batadv_gw_node_free(struct batadv_priv *bat_priv)
502 struct batadv_gw_node *gw_node;
503 struct hlist_node *node_tmp;
505 spin_lock_bh(&bat_priv->gw.list_lock);
506 hlist_for_each_entry_safe(gw_node, node_tmp,
507 &bat_priv->gw.gateway_list, list) {
508 hlist_del_init_rcu(&gw_node->list);
509 batadv_gw_node_put(gw_node);
510 bat_priv->gw.generation++;
512 spin_unlock_bh(&bat_priv->gw.list_lock);
515 #ifdef CONFIG_BATMAN_ADV_DEBUGFS
518 * batadv_gw_client_seq_print_text() - Print the gateway table in a seq file
519 * @seq: seq file to print on
524 int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
526 struct net_device *net_dev = (struct net_device *)seq->private;
527 struct batadv_priv *bat_priv = netdev_priv(net_dev);
528 struct batadv_hard_iface *primary_if;
530 primary_if = batadv_seq_print_text_primary_if_get(seq);
534 seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s %s)]\n",
535 BATADV_SOURCE_VERSION, primary_if->net_dev->name,
536 primary_if->net_dev->dev_addr, net_dev->name,
537 bat_priv->algo_ops->name);
539 batadv_hardif_put(primary_if);
541 if (!bat_priv->algo_ops->gw.print) {
543 "No printing function for this routing protocol\n");
547 bat_priv->algo_ops->gw.print(bat_priv, seq);
554 * batadv_gw_dump() - Dump gateways into a message
555 * @msg: Netlink message to dump into
556 * @cb: Control block containing additional options
558 * Return: Error code, or length of message
560 int batadv_gw_dump(struct sk_buff *msg, struct netlink_callback *cb)
562 struct batadv_hard_iface *primary_if = NULL;
563 struct net *net = sock_net(cb->skb->sk);
564 struct net_device *soft_iface;
565 struct batadv_priv *bat_priv;
569 ifindex = batadv_netlink_get_ifindex(cb->nlh,
570 BATADV_ATTR_MESH_IFINDEX);
574 soft_iface = dev_get_by_index(net, ifindex);
575 if (!soft_iface || !batadv_softif_is_valid(soft_iface)) {
580 bat_priv = netdev_priv(soft_iface);
582 primary_if = batadv_primary_if_get_selected(bat_priv);
583 if (!primary_if || primary_if->if_status != BATADV_IF_ACTIVE) {
588 if (!bat_priv->algo_ops->gw.dump) {
593 bat_priv->algo_ops->gw.dump(msg, cb, bat_priv);
599 batadv_hardif_put(primary_if);
607 * batadv_gw_dhcp_recipient_get() - check if a packet is a DHCP message
608 * @skb: the packet to check
609 * @header_len: a pointer to the batman-adv header size
610 * @chaddr: buffer where the client address will be stored. Valid
611 * only if the function returns BATADV_DHCP_TO_CLIENT
613 * This function may re-allocate the data buffer of the skb passed as argument.
616 * - BATADV_DHCP_NO if the packet is not a dhcp message or if there was an error
618 * - BATADV_DHCP_TO_SERVER if this is a message going to the DHCP server
619 * - BATADV_DHCP_TO_CLIENT if this is a message going to a DHCP client
621 enum batadv_dhcp_recipient
622 batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
625 enum batadv_dhcp_recipient ret = BATADV_DHCP_NO;
626 struct ethhdr *ethhdr;
628 struct ipv6hdr *ipv6hdr;
629 struct udphdr *udphdr;
630 struct vlan_ethhdr *vhdr;
635 /* check for ethernet header */
636 if (!pskb_may_pull(skb, *header_len + ETH_HLEN))
637 return BATADV_DHCP_NO;
639 ethhdr = eth_hdr(skb);
640 proto = ethhdr->h_proto;
641 *header_len += ETH_HLEN;
643 /* check for initial vlan header */
644 if (proto == htons(ETH_P_8021Q)) {
645 if (!pskb_may_pull(skb, *header_len + VLAN_HLEN))
646 return BATADV_DHCP_NO;
648 vhdr = vlan_eth_hdr(skb);
649 proto = vhdr->h_vlan_encapsulated_proto;
650 *header_len += VLAN_HLEN;
653 /* check for ip header */
655 case htons(ETH_P_IP):
656 if (!pskb_may_pull(skb, *header_len + sizeof(*iphdr)))
657 return BATADV_DHCP_NO;
659 iphdr = (struct iphdr *)(skb->data + *header_len);
660 *header_len += iphdr->ihl * 4;
662 /* check for udp header */
663 if (iphdr->protocol != IPPROTO_UDP)
664 return BATADV_DHCP_NO;
667 case htons(ETH_P_IPV6):
668 if (!pskb_may_pull(skb, *header_len + sizeof(*ipv6hdr)))
669 return BATADV_DHCP_NO;
671 ipv6hdr = (struct ipv6hdr *)(skb->data + *header_len);
672 *header_len += sizeof(*ipv6hdr);
674 /* check for udp header */
675 if (ipv6hdr->nexthdr != IPPROTO_UDP)
676 return BATADV_DHCP_NO;
680 return BATADV_DHCP_NO;
683 if (!pskb_may_pull(skb, *header_len + sizeof(*udphdr)))
684 return BATADV_DHCP_NO;
686 udphdr = (struct udphdr *)(skb->data + *header_len);
687 *header_len += sizeof(*udphdr);
689 /* check for bootp port */
691 case htons(ETH_P_IP):
692 if (udphdr->dest == htons(67))
693 ret = BATADV_DHCP_TO_SERVER;
694 else if (udphdr->source == htons(67))
695 ret = BATADV_DHCP_TO_CLIENT;
697 case htons(ETH_P_IPV6):
698 if (udphdr->dest == htons(547))
699 ret = BATADV_DHCP_TO_SERVER;
700 else if (udphdr->source == htons(547))
701 ret = BATADV_DHCP_TO_CLIENT;
705 chaddr_offset = *header_len + BATADV_DHCP_CHADDR_OFFSET;
706 /* store the client address if the message is going to a client */
707 if (ret == BATADV_DHCP_TO_CLIENT &&
708 pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) {
709 /* check if the DHCP packet carries an Ethernet DHCP */
710 p = skb->data + *header_len + BATADV_DHCP_HTYPE_OFFSET;
711 if (*p != BATADV_DHCP_HTYPE_ETHERNET)
712 return BATADV_DHCP_NO;
714 /* check if the DHCP packet carries a valid Ethernet address */
715 p = skb->data + *header_len + BATADV_DHCP_HLEN_OFFSET;
717 return BATADV_DHCP_NO;
719 ether_addr_copy(chaddr, skb->data + chaddr_offset);
726 * batadv_gw_out_of_range() - check if the dhcp request destination is the best
728 * @bat_priv: the bat priv with all the soft interface information
729 * @skb: the outgoing packet
731 * Check if the skb is a DHCP request and if it is sent to the current best GW
732 * server. Due to topology changes it may be the case that the GW server
733 * previously selected is not the best one anymore.
735 * This call might reallocate skb data.
736 * Must be invoked only when the DHCP packet is going TO a DHCP SERVER.
738 * Return: true if the packet destination is unicast and it is not the best gw,
741 bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
744 struct batadv_neigh_node *neigh_curr = NULL;
745 struct batadv_neigh_node *neigh_old = NULL;
746 struct batadv_orig_node *orig_dst_node = NULL;
747 struct batadv_gw_node *gw_node = NULL;
748 struct batadv_gw_node *curr_gw = NULL;
749 struct batadv_neigh_ifinfo *curr_ifinfo, *old_ifinfo;
750 struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
751 bool out_of_range = false;
755 vid = batadv_get_vid(skb, 0);
757 if (is_multicast_ether_addr(ethhdr->h_dest))
760 orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
761 ethhdr->h_dest, vid);
765 gw_node = batadv_gw_node_get(bat_priv, orig_dst_node);
769 switch (atomic_read(&bat_priv->gw.mode)) {
770 case BATADV_GW_MODE_SERVER:
771 /* If we are a GW then we are our best GW. We can artificially
772 * set the tq towards ourself as the maximum value
774 curr_tq_avg = BATADV_TQ_MAX_VALUE;
776 case BATADV_GW_MODE_CLIENT:
777 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
781 /* packet is going to our gateway */
782 if (curr_gw->orig_node == orig_dst_node)
785 /* If the dhcp packet has been sent to a different gw,
786 * we have to evaluate whether the old gw is still
789 neigh_curr = batadv_find_router(bat_priv, curr_gw->orig_node,
794 curr_ifinfo = batadv_neigh_ifinfo_get(neigh_curr,
799 curr_tq_avg = curr_ifinfo->bat_iv.tq_avg;
800 batadv_neigh_ifinfo_put(curr_ifinfo);
803 case BATADV_GW_MODE_OFF:
808 neigh_old = batadv_find_router(bat_priv, orig_dst_node, NULL);
812 old_ifinfo = batadv_neigh_ifinfo_get(neigh_old, BATADV_IF_DEFAULT);
816 if ((curr_tq_avg - old_ifinfo->bat_iv.tq_avg) > BATADV_GW_THRESHOLD)
818 batadv_neigh_ifinfo_put(old_ifinfo);
822 batadv_orig_node_put(orig_dst_node);
824 batadv_gw_node_put(curr_gw);
826 batadv_gw_node_put(gw_node);
828 batadv_neigh_node_put(neigh_old);
830 batadv_neigh_node_put(neigh_curr);