.. | .. |
---|
1 | 1 | // 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: |
---|
3 | 3 | * |
---|
4 | 4 | * 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/>. |
---|
17 | 5 | */ |
---|
18 | 6 | |
---|
19 | 7 | #include "bat_v.h" |
---|
.. | .. |
---|
27 | 15 | #include <linux/jiffies.h> |
---|
28 | 16 | #include <linux/kernel.h> |
---|
29 | 17 | #include <linux/kref.h> |
---|
| 18 | +#include <linux/list.h> |
---|
30 | 19 | #include <linux/netdevice.h> |
---|
31 | 20 | #include <linux/netlink.h> |
---|
32 | 21 | #include <linux/rculist.h> |
---|
33 | 22 | #include <linux/rcupdate.h> |
---|
34 | 23 | #include <linux/seq_file.h> |
---|
| 24 | +#include <linux/skbuff.h> |
---|
| 25 | +#include <linux/spinlock.h> |
---|
35 | 26 | #include <linux/stddef.h> |
---|
36 | 27 | #include <linux/types.h> |
---|
37 | 28 | #include <linux/workqueue.h> |
---|
.. | .. |
---|
50 | 41 | #include "log.h" |
---|
51 | 42 | #include "netlink.h" |
---|
52 | 43 | #include "originator.h" |
---|
53 | | - |
---|
54 | | -struct sk_buff; |
---|
55 | 44 | |
---|
56 | 45 | static void batadv_v_iface_activate(struct batadv_hard_iface *hard_iface) |
---|
57 | 46 | { |
---|
.. | .. |
---|
90 | 79 | |
---|
91 | 80 | static void batadv_v_iface_disable(struct batadv_hard_iface *hard_iface) |
---|
92 | 81 | { |
---|
| 82 | + batadv_v_ogm_iface_disable(hard_iface); |
---|
93 | 83 | batadv_v_elp_iface_disable(hard_iface); |
---|
94 | 84 | } |
---|
95 | 85 | |
---|
.. | .. |
---|
915 | 905 | * batadv_v_gw_dump_entry() - Dump a gateway into a message |
---|
916 | 906 | * @msg: Netlink message to dump into |
---|
917 | 907 | * @portid: Port making netlink request |
---|
918 | | - * @seq: Sequence number of netlink message |
---|
| 908 | + * @cb: Control block containing additional options |
---|
919 | 909 | * @bat_priv: The bat priv with all the soft interface information |
---|
920 | 910 | * @gw_node: Gateway to be dumped |
---|
921 | 911 | * |
---|
922 | 912 | * Return: Error code, or 0 on success |
---|
923 | 913 | */ |
---|
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, |
---|
925 | 916 | struct batadv_priv *bat_priv, |
---|
926 | 917 | struct batadv_gw_node *gw_node) |
---|
927 | 918 | { |
---|
.. | .. |
---|
941 | 932 | |
---|
942 | 933 | curr_gw = batadv_gw_get_selected_gw_node(bat_priv); |
---|
943 | 934 | |
---|
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); |
---|
946 | 938 | if (!hdr) { |
---|
947 | 939 | ret = -ENOBUFS; |
---|
948 | 940 | goto out; |
---|
949 | 941 | } |
---|
| 942 | + |
---|
| 943 | + genl_dump_check_consistent(cb, hdr); |
---|
950 | 944 | |
---|
951 | 945 | ret = -EMSGSIZE; |
---|
952 | 946 | |
---|
.. | .. |
---|
1018 | 1012 | int idx_skip = cb->args[0]; |
---|
1019 | 1013 | int idx = 0; |
---|
1020 | 1014 | |
---|
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) { |
---|
1023 | 1019 | if (idx++ < idx_skip) |
---|
1024 | 1020 | continue; |
---|
1025 | 1021 | |
---|
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)) { |
---|
1028 | 1024 | idx_skip = idx - 1; |
---|
1029 | 1025 | goto unlock; |
---|
1030 | 1026 | } |
---|
.. | .. |
---|
1032 | 1028 | |
---|
1033 | 1029 | idx_skip = idx; |
---|
1034 | 1030 | unlock: |
---|
1035 | | - rcu_read_unlock(); |
---|
| 1031 | + spin_unlock_bh(&bat_priv->gw.list_lock); |
---|
1036 | 1032 | |
---|
1037 | 1033 | cb->args[0] = idx_skip; |
---|
1038 | 1034 | } |
---|
.. | .. |
---|
1086 | 1082 | */ |
---|
1087 | 1083 | atomic_set(&hard_iface->bat_v.throughput_override, 0); |
---|
1088 | 1084 | 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); |
---|
1089 | 1090 | } |
---|
1090 | 1091 | |
---|
1091 | 1092 | /** |
---|