hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/net/batman-adv/bat_v.c
....@@ -1,19 +1,7 @@
11 // SPDX-License-Identifier: GPL-2.0
2
-/* Copyright (C) 2013-2018 B.A.T.M.A.N. contributors:
2
+/* Copyright (C) 2013-2020 B.A.T.M.A.N. contributors:
33 *
44 * Linus Lüssing, 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 "bat_v.h"
....@@ -27,11 +15,14 @@
2715 #include <linux/jiffies.h>
2816 #include <linux/kernel.h>
2917 #include <linux/kref.h>
18
+#include <linux/list.h>
3019 #include <linux/netdevice.h>
3120 #include <linux/netlink.h>
3221 #include <linux/rculist.h>
3322 #include <linux/rcupdate.h>
3423 #include <linux/seq_file.h>
24
+#include <linux/skbuff.h>
25
+#include <linux/spinlock.h>
3526 #include <linux/stddef.h>
3627 #include <linux/types.h>
3728 #include <linux/workqueue.h>
....@@ -50,8 +41,6 @@
5041 #include "log.h"
5142 #include "netlink.h"
5243 #include "originator.h"
53
-
54
-struct sk_buff;
5544
5645 static void batadv_v_iface_activate(struct batadv_hard_iface *hard_iface)
5746 {
....@@ -90,6 +79,7 @@
9079
9180 static void batadv_v_iface_disable(struct batadv_hard_iface *hard_iface)
9281 {
82
+ batadv_v_ogm_iface_disable(hard_iface);
9383 batadv_v_elp_iface_disable(hard_iface);
9484 }
9585
....@@ -915,13 +905,14 @@
915905 * batadv_v_gw_dump_entry() - Dump a gateway into a message
916906 * @msg: Netlink message to dump into
917907 * @portid: Port making netlink request
918
- * @seq: Sequence number of netlink message
908
+ * @cb: Control block containing additional options
919909 * @bat_priv: The bat priv with all the soft interface information
920910 * @gw_node: Gateway to be dumped
921911 *
922912 * Return: Error code, or 0 on success
923913 */
924
-static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
914
+static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid,
915
+ struct netlink_callback *cb,
925916 struct batadv_priv *bat_priv,
926917 struct batadv_gw_node *gw_node)
927918 {
....@@ -941,12 +932,15 @@
941932
942933 curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
943934
944
- hdr = genlmsg_put(msg, portid, seq, &batadv_netlink_family,
945
- NLM_F_MULTI, BATADV_CMD_GET_GATEWAYS);
935
+ hdr = genlmsg_put(msg, portid, cb->nlh->nlmsg_seq,
936
+ &batadv_netlink_family, NLM_F_MULTI,
937
+ BATADV_CMD_GET_GATEWAYS);
946938 if (!hdr) {
947939 ret = -ENOBUFS;
948940 goto out;
949941 }
942
+
943
+ genl_dump_check_consistent(cb, hdr);
950944
951945 ret = -EMSGSIZE;
952946
....@@ -1018,13 +1012,15 @@
10181012 int idx_skip = cb->args[0];
10191013 int idx = 0;
10201014
1021
- rcu_read_lock();
1022
- hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.gateway_list, list) {
1015
+ spin_lock_bh(&bat_priv->gw.list_lock);
1016
+ cb->seq = bat_priv->gw.generation << 1 | 1;
1017
+
1018
+ hlist_for_each_entry(gw_node, &bat_priv->gw.gateway_list, list) {
10231019 if (idx++ < idx_skip)
10241020 continue;
10251021
1026
- if (batadv_v_gw_dump_entry(msg, portid, cb->nlh->nlmsg_seq,
1027
- bat_priv, gw_node)) {
1022
+ if (batadv_v_gw_dump_entry(msg, portid, cb, bat_priv,
1023
+ gw_node)) {
10281024 idx_skip = idx - 1;
10291025 goto unlock;
10301026 }
....@@ -1032,7 +1028,7 @@
10321028
10331029 idx_skip = idx;
10341030 unlock:
1035
- rcu_read_unlock();
1031
+ spin_unlock_bh(&bat_priv->gw.list_lock);
10361032
10371033 cb->args[0] = idx_skip;
10381034 }
....@@ -1086,6 +1082,11 @@
10861082 */
10871083 atomic_set(&hard_iface->bat_v.throughput_override, 0);
10881084 atomic_set(&hard_iface->bat_v.elp_interval, 500);
1085
+
1086
+ hard_iface->bat_v.aggr_len = 0;
1087
+ skb_queue_head_init(&hard_iface->bat_v.aggr_list);
1088
+ INIT_DELAYED_WORK(&hard_iface->bat_v.aggr_wq,
1089
+ batadv_v_ogm_aggr_work);
10891090 }
10901091
10911092 /**