hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/batman-adv/gateway_client.c
....@@ -1,19 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0
2
-/* Copyright (C) 2009-2018 B.A.T.M.A.N. contributors:
2
+/* Copyright (C) 2009-2020 B.A.T.M.A.N. contributors:
33 *
44 * Marek Lindner
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of version 2 of the GNU General Public
8
- * License as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful, but
11
- * WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- * General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
175 */
186
197 #include "gateway_client.h"
....@@ -47,14 +35,12 @@
4735 #include <uapi/linux/batadv_packet.h>
4836 #include <uapi/linux/batman_adv.h>
4937
50
-#include "gateway_common.h"
5138 #include "hard-interface.h"
5239 #include "log.h"
5340 #include "netlink.h"
5441 #include "originator.h"
5542 #include "routing.h"
5643 #include "soft-interface.h"
57
-#include "sysfs.h"
5844 #include "translation-table.h"
5945
6046 /* These are the offsets of the "hw type" and "hw address length" in the dhcp
....@@ -74,7 +60,7 @@
7460 * after rcu grace period
7561 * @ref: kref pointer of the gw_node
7662 */
77
-static void batadv_gw_node_release(struct kref *ref)
63
+void batadv_gw_node_release(struct kref *ref)
7864 {
7965 struct batadv_gw_node *gw_node;
8066
....@@ -82,16 +68,6 @@
8268
8369 batadv_orig_node_put(gw_node->orig_node);
8470 kfree_rcu(gw_node, rcu);
85
-}
86
-
87
-/**
88
- * batadv_gw_node_put() - decrement the gw_node refcounter and possibly release
89
- * it
90
- * @gw_node: gateway node to free
91
- */
92
-void batadv_gw_node_put(struct batadv_gw_node *gw_node)
93
-{
94
- kref_put(&gw_node->refcount, batadv_gw_node_release);
9571 }
9672
9773 /**
....@@ -160,8 +136,8 @@
160136 if (new_gw_node)
161137 kref_get(&new_gw_node->refcount);
162138
163
- curr_gw_node = rcu_dereference_protected(bat_priv->gw.curr_gw, 1);
164
- rcu_assign_pointer(bat_priv->gw.curr_gw, new_gw_node);
139
+ curr_gw_node = rcu_replace_pointer(bat_priv->gw.curr_gw, new_gw_node,
140
+ true);
165141
166142 if (curr_gw_node)
167143 batadv_gw_node_put(curr_gw_node);
....@@ -377,6 +353,7 @@
377353
378354 kref_get(&gw_node->refcount);
379355 hlist_add_head_rcu(&gw_node->list, &bat_priv->gw.gateway_list);
356
+ bat_priv->gw.generation++;
380357
381358 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
382359 "Found new gateway %pM -> gw bandwidth: %u.%u/%u.%u MBit\n",
....@@ -472,6 +449,7 @@
472449 if (!hlist_unhashed(&gw_node->list)) {
473450 hlist_del_init_rcu(&gw_node->list);
474451 batadv_gw_node_put(gw_node);
452
+ bat_priv->gw.generation++;
475453 }
476454 spin_unlock_bh(&bat_priv->gw.list_lock);
477455
....@@ -518,6 +496,7 @@
518496 &bat_priv->gw.gateway_list, list) {
519497 hlist_del_init_rcu(&gw_node->list);
520498 batadv_gw_node_put(gw_node);
499
+ bat_priv->gw.generation++;
521500 }
522501 spin_unlock_bh(&bat_priv->gw.list_lock);
523502 }