1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2009-2020 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"
44 #include "translation-table.h"
46 /* These are the offsets of the "hw type" and "hw address length" in the dhcp
47 * packet starting at the beginning of the dhcp header
49 #define BATADV_DHCP_HTYPE_OFFSET 1
50 #define BATADV_DHCP_HLEN_OFFSET 2
51 /* Value of htype representing Ethernet */
52 #define BATADV_DHCP_HTYPE_ETHERNET 0x01
53 /* This is the offset of the "chaddr" field in the dhcp packet starting at the
54 * beginning of the dhcp header
56 #define BATADV_DHCP_CHADDR_OFFSET 28
59 * batadv_gw_node_release() - release gw_node from lists and queue for free
60 * after rcu grace period
61 * @ref: kref pointer of the gw_node
63 void batadv_gw_node_release(struct kref *ref)
65 struct batadv_gw_node *gw_node;
67 gw_node = container_of(ref, struct batadv_gw_node, refcount);
69 batadv_orig_node_put(gw_node->orig_node);
70 kfree_rcu(gw_node, rcu);
74 * batadv_gw_get_selected_gw_node() - Get currently selected gateway
75 * @bat_priv: the bat priv with all the soft interface information
77 * Return: selected gateway (with increased refcnt), NULL on errors
79 struct batadv_gw_node *
80 batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv)
82 struct batadv_gw_node *gw_node;
85 gw_node = rcu_dereference(bat_priv->gw.curr_gw);
89 if (!kref_get_unless_zero(&gw_node->refcount))
98 * batadv_gw_get_selected_orig() - Get originator of currently selected gateway
99 * @bat_priv: the bat priv with all the soft interface information
101 * Return: orig_node of selected gateway (with increased refcnt), NULL on errors
103 struct batadv_orig_node *
104 batadv_gw_get_selected_orig(struct batadv_priv *bat_priv)
106 struct batadv_gw_node *gw_node;
107 struct batadv_orig_node *orig_node = NULL;
109 gw_node = batadv_gw_get_selected_gw_node(bat_priv);
114 orig_node = gw_node->orig_node;
118 if (!kref_get_unless_zero(&orig_node->refcount))
125 batadv_gw_node_put(gw_node);
129 static void batadv_gw_select(struct batadv_priv *bat_priv,
130 struct batadv_gw_node *new_gw_node)
132 struct batadv_gw_node *curr_gw_node;
134 spin_lock_bh(&bat_priv->gw.list_lock);
137 kref_get(&new_gw_node->refcount);
139 curr_gw_node = rcu_replace_pointer(bat_priv->gw.curr_gw, new_gw_node,
143 batadv_gw_node_put(curr_gw_node);
145 spin_unlock_bh(&bat_priv->gw.list_lock);
149 * batadv_gw_reselect() - force a gateway reselection
150 * @bat_priv: the bat priv with all the soft interface information
152 * Set a flag to remind the GW component to perform a new gateway reselection.
153 * However this function does not ensure that the current gateway is going to be
154 * deselected. The reselection mechanism may elect the same gateway once again.
156 * This means that invoking batadv_gw_reselect() does not guarantee a gateway
157 * change and therefore a uevent is not necessarily expected.
159 void batadv_gw_reselect(struct batadv_priv *bat_priv)
161 atomic_set(&bat_priv->gw.reselect, 1);
165 * batadv_gw_check_client_stop() - check if client mode has been switched off
166 * @bat_priv: the bat priv with all the soft interface information
168 * This function assumes the caller has checked that the gw state *is actually
169 * changing*. This function is not supposed to be called when there is no state
172 void batadv_gw_check_client_stop(struct batadv_priv *bat_priv)
174 struct batadv_gw_node *curr_gw;
176 if (atomic_read(&bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT)
179 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
183 /* deselect the current gateway so that next time that client mode is
184 * enabled a proper GW_ADD event can be sent
186 batadv_gw_select(bat_priv, NULL);
188 /* if batman-adv is switching the gw client mode off and a gateway was
189 * already selected, send a DEL uevent
191 batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL, NULL);
193 batadv_gw_node_put(curr_gw);
197 * batadv_gw_election() - Elect the best gateway
198 * @bat_priv: the bat priv with all the soft interface information
200 void batadv_gw_election(struct batadv_priv *bat_priv)
202 struct batadv_gw_node *curr_gw = NULL;
203 struct batadv_gw_node *next_gw = NULL;
204 struct batadv_neigh_node *router = NULL;
205 struct batadv_neigh_ifinfo *router_ifinfo = NULL;
206 char gw_addr[18] = { '\0' };
208 if (atomic_read(&bat_priv->gw.mode) != BATADV_GW_MODE_CLIENT)
211 if (!bat_priv->algo_ops->gw.get_best_gw_node)
214 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
216 if (!batadv_atomic_dec_not_zero(&bat_priv->gw.reselect) && curr_gw)
219 /* if gw.reselect is set to 1 it means that a previous call to
220 * gw.is_eligible() said that we have a new best GW, therefore it can
221 * now be picked from the list and selected
223 next_gw = bat_priv->algo_ops->gw.get_best_gw_node(bat_priv);
225 if (curr_gw == next_gw)
229 sprintf(gw_addr, "%pM", next_gw->orig_node->orig);
231 router = batadv_orig_router_get(next_gw->orig_node,
234 batadv_gw_reselect(bat_priv);
238 router_ifinfo = batadv_neigh_ifinfo_get(router,
240 if (!router_ifinfo) {
241 batadv_gw_reselect(bat_priv);
246 if (curr_gw && !next_gw) {
247 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
248 "Removing selected gateway - no gateway in range\n");
249 batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL,
251 } else if (!curr_gw && next_gw) {
252 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
253 "Adding route to gateway %pM (bandwidth: %u.%u/%u.%u MBit, tq: %i)\n",
254 next_gw->orig_node->orig,
255 next_gw->bandwidth_down / 10,
256 next_gw->bandwidth_down % 10,
257 next_gw->bandwidth_up / 10,
258 next_gw->bandwidth_up % 10,
259 router_ifinfo->bat_iv.tq_avg);
260 batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_ADD,
263 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
264 "Changing 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_CHANGE,
275 batadv_gw_select(bat_priv, next_gw);
279 batadv_gw_node_put(curr_gw);
281 batadv_gw_node_put(next_gw);
283 batadv_neigh_node_put(router);
285 batadv_neigh_ifinfo_put(router_ifinfo);
289 * batadv_gw_check_election() - Elect orig node as best gateway when eligible
290 * @bat_priv: the bat priv with all the soft interface information
291 * @orig_node: orig node which is to be checked
293 void batadv_gw_check_election(struct batadv_priv *bat_priv,
294 struct batadv_orig_node *orig_node)
296 struct batadv_orig_node *curr_gw_orig;
298 /* abort immediately if the routing algorithm does not support gateway
301 if (!bat_priv->algo_ops->gw.is_eligible)
304 curr_gw_orig = batadv_gw_get_selected_orig(bat_priv);
308 /* this node already is the gateway */
309 if (curr_gw_orig == orig_node)
312 if (!bat_priv->algo_ops->gw.is_eligible(bat_priv, curr_gw_orig,
317 batadv_gw_reselect(bat_priv);
320 batadv_orig_node_put(curr_gw_orig);
324 * batadv_gw_node_add() - add gateway node to list of available gateways
325 * @bat_priv: the bat priv with all the soft interface information
326 * @orig_node: originator announcing gateway capabilities
327 * @gateway: announced bandwidth information
329 * Has to be called with the appropriate locks being acquired
332 static void batadv_gw_node_add(struct batadv_priv *bat_priv,
333 struct batadv_orig_node *orig_node,
334 struct batadv_tvlv_gateway_data *gateway)
336 struct batadv_gw_node *gw_node;
338 lockdep_assert_held(&bat_priv->gw.list_lock);
340 if (gateway->bandwidth_down == 0)
343 gw_node = kzalloc(sizeof(*gw_node), GFP_ATOMIC);
347 kref_init(&gw_node->refcount);
348 INIT_HLIST_NODE(&gw_node->list);
349 kref_get(&orig_node->refcount);
350 gw_node->orig_node = orig_node;
351 gw_node->bandwidth_down = ntohl(gateway->bandwidth_down);
352 gw_node->bandwidth_up = ntohl(gateway->bandwidth_up);
354 kref_get(&gw_node->refcount);
355 hlist_add_head_rcu(&gw_node->list, &bat_priv->gw.gateway_list);
356 bat_priv->gw.generation++;
358 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
359 "Found new gateway %pM -> gw bandwidth: %u.%u/%u.%u MBit\n",
361 ntohl(gateway->bandwidth_down) / 10,
362 ntohl(gateway->bandwidth_down) % 10,
363 ntohl(gateway->bandwidth_up) / 10,
364 ntohl(gateway->bandwidth_up) % 10);
366 /* don't return reference to new gw_node */
367 batadv_gw_node_put(gw_node);
371 * batadv_gw_node_get() - retrieve gateway node from list of available gateways
372 * @bat_priv: the bat priv with all the soft interface information
373 * @orig_node: originator announcing gateway capabilities
375 * Return: gateway node if found or NULL otherwise.
377 struct batadv_gw_node *batadv_gw_node_get(struct batadv_priv *bat_priv,
378 struct batadv_orig_node *orig_node)
380 struct batadv_gw_node *gw_node_tmp, *gw_node = NULL;
383 hlist_for_each_entry_rcu(gw_node_tmp, &bat_priv->gw.gateway_list,
385 if (gw_node_tmp->orig_node != orig_node)
388 if (!kref_get_unless_zero(&gw_node_tmp->refcount))
391 gw_node = gw_node_tmp;
400 * batadv_gw_node_update() - update list of available gateways with changed
401 * bandwidth information
402 * @bat_priv: the bat priv with all the soft interface information
403 * @orig_node: originator announcing gateway capabilities
404 * @gateway: announced bandwidth information
406 void batadv_gw_node_update(struct batadv_priv *bat_priv,
407 struct batadv_orig_node *orig_node,
408 struct batadv_tvlv_gateway_data *gateway)
410 struct batadv_gw_node *gw_node, *curr_gw = NULL;
412 spin_lock_bh(&bat_priv->gw.list_lock);
413 gw_node = batadv_gw_node_get(bat_priv, orig_node);
415 batadv_gw_node_add(bat_priv, orig_node, gateway);
416 spin_unlock_bh(&bat_priv->gw.list_lock);
419 spin_unlock_bh(&bat_priv->gw.list_lock);
421 if (gw_node->bandwidth_down == ntohl(gateway->bandwidth_down) &&
422 gw_node->bandwidth_up == ntohl(gateway->bandwidth_up))
425 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
426 "Gateway bandwidth of originator %pM changed from %u.%u/%u.%u MBit to %u.%u/%u.%u MBit\n",
428 gw_node->bandwidth_down / 10,
429 gw_node->bandwidth_down % 10,
430 gw_node->bandwidth_up / 10,
431 gw_node->bandwidth_up % 10,
432 ntohl(gateway->bandwidth_down) / 10,
433 ntohl(gateway->bandwidth_down) % 10,
434 ntohl(gateway->bandwidth_up) / 10,
435 ntohl(gateway->bandwidth_up) % 10);
437 gw_node->bandwidth_down = ntohl(gateway->bandwidth_down);
438 gw_node->bandwidth_up = ntohl(gateway->bandwidth_up);
440 if (ntohl(gateway->bandwidth_down) == 0) {
441 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
442 "Gateway %pM removed from gateway list\n",
445 /* Note: We don't need a NULL check here, since curr_gw never
448 spin_lock_bh(&bat_priv->gw.list_lock);
449 if (!hlist_unhashed(&gw_node->list)) {
450 hlist_del_init_rcu(&gw_node->list);
451 batadv_gw_node_put(gw_node);
452 bat_priv->gw.generation++;
454 spin_unlock_bh(&bat_priv->gw.list_lock);
456 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
457 if (gw_node == curr_gw)
458 batadv_gw_reselect(bat_priv);
461 batadv_gw_node_put(curr_gw);
466 batadv_gw_node_put(gw_node);
470 * batadv_gw_node_delete() - Remove orig_node from gateway list
471 * @bat_priv: the bat priv with all the soft interface information
472 * @orig_node: orig node which is currently in process of being removed
474 void batadv_gw_node_delete(struct batadv_priv *bat_priv,
475 struct batadv_orig_node *orig_node)
477 struct batadv_tvlv_gateway_data gateway;
479 gateway.bandwidth_down = 0;
480 gateway.bandwidth_up = 0;
482 batadv_gw_node_update(bat_priv, orig_node, &gateway);
486 * batadv_gw_node_free() - Free gateway information from soft interface
487 * @bat_priv: the bat priv with all the soft interface information
489 void batadv_gw_node_free(struct batadv_priv *bat_priv)
491 struct batadv_gw_node *gw_node;
492 struct hlist_node *node_tmp;
494 spin_lock_bh(&bat_priv->gw.list_lock);
495 hlist_for_each_entry_safe(gw_node, node_tmp,
496 &bat_priv->gw.gateway_list, list) {
497 hlist_del_init_rcu(&gw_node->list);
498 batadv_gw_node_put(gw_node);
499 bat_priv->gw.generation++;
501 spin_unlock_bh(&bat_priv->gw.list_lock);
504 #ifdef CONFIG_BATMAN_ADV_DEBUGFS
507 * batadv_gw_client_seq_print_text() - Print the gateway table in a seq file
508 * @seq: seq file to print on
513 int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset)
515 struct net_device *net_dev = (struct net_device *)seq->private;
516 struct batadv_priv *bat_priv = netdev_priv(net_dev);
517 struct batadv_hard_iface *primary_if;
519 primary_if = batadv_seq_print_text_primary_if_get(seq);
523 seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s %s)]\n",
524 BATADV_SOURCE_VERSION, primary_if->net_dev->name,
525 primary_if->net_dev->dev_addr, net_dev->name,
526 bat_priv->algo_ops->name);
528 batadv_hardif_put(primary_if);
530 if (!bat_priv->algo_ops->gw.print) {
532 "No printing function for this routing protocol\n");
536 bat_priv->algo_ops->gw.print(bat_priv, seq);
543 * batadv_gw_dump() - Dump gateways into a message
544 * @msg: Netlink message to dump into
545 * @cb: Control block containing additional options
547 * Return: Error code, or length of message
549 int batadv_gw_dump(struct sk_buff *msg, struct netlink_callback *cb)
551 struct batadv_hard_iface *primary_if = NULL;
552 struct net *net = sock_net(cb->skb->sk);
553 struct net_device *soft_iface;
554 struct batadv_priv *bat_priv;
558 ifindex = batadv_netlink_get_ifindex(cb->nlh,
559 BATADV_ATTR_MESH_IFINDEX);
563 soft_iface = dev_get_by_index(net, ifindex);
564 if (!soft_iface || !batadv_softif_is_valid(soft_iface)) {
569 bat_priv = netdev_priv(soft_iface);
571 primary_if = batadv_primary_if_get_selected(bat_priv);
572 if (!primary_if || primary_if->if_status != BATADV_IF_ACTIVE) {
577 if (!bat_priv->algo_ops->gw.dump) {
582 bat_priv->algo_ops->gw.dump(msg, cb, bat_priv);
588 batadv_hardif_put(primary_if);
596 * batadv_gw_dhcp_recipient_get() - check if a packet is a DHCP message
597 * @skb: the packet to check
598 * @header_len: a pointer to the batman-adv header size
599 * @chaddr: buffer where the client address will be stored. Valid
600 * only if the function returns BATADV_DHCP_TO_CLIENT
602 * This function may re-allocate the data buffer of the skb passed as argument.
605 * - BATADV_DHCP_NO if the packet is not a dhcp message or if there was an error
607 * - BATADV_DHCP_TO_SERVER if this is a message going to the DHCP server
608 * - BATADV_DHCP_TO_CLIENT if this is a message going to a DHCP client
610 enum batadv_dhcp_recipient
611 batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
614 enum batadv_dhcp_recipient ret = BATADV_DHCP_NO;
615 struct ethhdr *ethhdr;
617 struct ipv6hdr *ipv6hdr;
618 struct udphdr *udphdr;
619 struct vlan_ethhdr *vhdr;
624 /* check for ethernet header */
625 if (!pskb_may_pull(skb, *header_len + ETH_HLEN))
626 return BATADV_DHCP_NO;
628 ethhdr = eth_hdr(skb);
629 proto = ethhdr->h_proto;
630 *header_len += ETH_HLEN;
632 /* check for initial vlan header */
633 if (proto == htons(ETH_P_8021Q)) {
634 if (!pskb_may_pull(skb, *header_len + VLAN_HLEN))
635 return BATADV_DHCP_NO;
637 vhdr = vlan_eth_hdr(skb);
638 proto = vhdr->h_vlan_encapsulated_proto;
639 *header_len += VLAN_HLEN;
642 /* check for ip header */
644 case htons(ETH_P_IP):
645 if (!pskb_may_pull(skb, *header_len + sizeof(*iphdr)))
646 return BATADV_DHCP_NO;
648 iphdr = (struct iphdr *)(skb->data + *header_len);
649 *header_len += iphdr->ihl * 4;
651 /* check for udp header */
652 if (iphdr->protocol != IPPROTO_UDP)
653 return BATADV_DHCP_NO;
656 case htons(ETH_P_IPV6):
657 if (!pskb_may_pull(skb, *header_len + sizeof(*ipv6hdr)))
658 return BATADV_DHCP_NO;
660 ipv6hdr = (struct ipv6hdr *)(skb->data + *header_len);
661 *header_len += sizeof(*ipv6hdr);
663 /* check for udp header */
664 if (ipv6hdr->nexthdr != IPPROTO_UDP)
665 return BATADV_DHCP_NO;
669 return BATADV_DHCP_NO;
672 if (!pskb_may_pull(skb, *header_len + sizeof(*udphdr)))
673 return BATADV_DHCP_NO;
675 udphdr = (struct udphdr *)(skb->data + *header_len);
676 *header_len += sizeof(*udphdr);
678 /* check for bootp port */
680 case htons(ETH_P_IP):
681 if (udphdr->dest == htons(67))
682 ret = BATADV_DHCP_TO_SERVER;
683 else if (udphdr->source == htons(67))
684 ret = BATADV_DHCP_TO_CLIENT;
686 case htons(ETH_P_IPV6):
687 if (udphdr->dest == htons(547))
688 ret = BATADV_DHCP_TO_SERVER;
689 else if (udphdr->source == htons(547))
690 ret = BATADV_DHCP_TO_CLIENT;
694 chaddr_offset = *header_len + BATADV_DHCP_CHADDR_OFFSET;
695 /* store the client address if the message is going to a client */
696 if (ret == BATADV_DHCP_TO_CLIENT) {
697 if (!pskb_may_pull(skb, chaddr_offset + ETH_ALEN))
698 return BATADV_DHCP_NO;
700 /* check if the DHCP packet carries an Ethernet DHCP */
701 p = skb->data + *header_len + BATADV_DHCP_HTYPE_OFFSET;
702 if (*p != BATADV_DHCP_HTYPE_ETHERNET)
703 return BATADV_DHCP_NO;
705 /* check if the DHCP packet carries a valid Ethernet address */
706 p = skb->data + *header_len + BATADV_DHCP_HLEN_OFFSET;
708 return BATADV_DHCP_NO;
710 ether_addr_copy(chaddr, skb->data + chaddr_offset);
717 * batadv_gw_out_of_range() - check if the dhcp request destination is the best
719 * @bat_priv: the bat priv with all the soft interface information
720 * @skb: the outgoing packet
722 * Check if the skb is a DHCP request and if it is sent to the current best GW
723 * server. Due to topology changes it may be the case that the GW server
724 * previously selected is not the best one anymore.
726 * This call might reallocate skb data.
727 * Must be invoked only when the DHCP packet is going TO a DHCP SERVER.
729 * Return: true if the packet destination is unicast and it is not the best gw,
732 bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
735 struct batadv_neigh_node *neigh_curr = NULL;
736 struct batadv_neigh_node *neigh_old = NULL;
737 struct batadv_orig_node *orig_dst_node = NULL;
738 struct batadv_gw_node *gw_node = NULL;
739 struct batadv_gw_node *curr_gw = NULL;
740 struct batadv_neigh_ifinfo *curr_ifinfo, *old_ifinfo;
741 struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
742 bool out_of_range = false;
746 vid = batadv_get_vid(skb, 0);
748 if (is_multicast_ether_addr(ethhdr->h_dest))
751 orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
752 ethhdr->h_dest, vid);
756 gw_node = batadv_gw_node_get(bat_priv, orig_dst_node);
760 switch (atomic_read(&bat_priv->gw.mode)) {
761 case BATADV_GW_MODE_SERVER:
762 /* If we are a GW then we are our best GW. We can artificially
763 * set the tq towards ourself as the maximum value
765 curr_tq_avg = BATADV_TQ_MAX_VALUE;
767 case BATADV_GW_MODE_CLIENT:
768 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
772 /* packet is going to our gateway */
773 if (curr_gw->orig_node == orig_dst_node)
776 /* If the dhcp packet has been sent to a different gw,
777 * we have to evaluate whether the old gw is still
780 neigh_curr = batadv_find_router(bat_priv, curr_gw->orig_node,
785 curr_ifinfo = batadv_neigh_ifinfo_get(neigh_curr,
790 curr_tq_avg = curr_ifinfo->bat_iv.tq_avg;
791 batadv_neigh_ifinfo_put(curr_ifinfo);
794 case BATADV_GW_MODE_OFF:
799 neigh_old = batadv_find_router(bat_priv, orig_dst_node, NULL);
803 old_ifinfo = batadv_neigh_ifinfo_get(neigh_old, BATADV_IF_DEFAULT);
807 if ((curr_tq_avg - old_ifinfo->bat_iv.tq_avg) > BATADV_GW_THRESHOLD)
809 batadv_neigh_ifinfo_put(old_ifinfo);
813 batadv_orig_node_put(orig_dst_node);
815 batadv_gw_node_put(curr_gw);
817 batadv_gw_node_put(gw_node);
819 batadv_neigh_node_put(neigh_old);
821 batadv_neigh_node_put(neigh_curr);