hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/batman-adv/types.h
....@@ -1,19 +1,7 @@
11 /* SPDX-License-Identifier: GPL-2.0 */
2
-/* Copyright (C) 2007-2018 B.A.T.M.A.N. contributors:
2
+/* Copyright (C) 2007-2020 B.A.T.M.A.N. contributors:
33 *
44 * Marek Lindner, Simon Wunderlich
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 #ifndef _NET_BATMAN_ADV_TYPES_H_
....@@ -26,20 +14,22 @@
2614 #include <linux/average.h>
2715 #include <linux/bitops.h>
2816 #include <linux/compiler.h>
17
+#include <linux/if.h>
2918 #include <linux/if_ether.h>
3019 #include <linux/kref.h>
3120 #include <linux/mutex.h>
3221 #include <linux/netdevice.h>
3322 #include <linux/netlink.h>
3423 #include <linux/sched.h> /* for linux/wait.h */
24
+#include <linux/seq_file.h>
25
+#include <linux/skbuff.h>
3526 #include <linux/spinlock.h>
27
+#include <linux/timer.h>
3628 #include <linux/types.h>
3729 #include <linux/wait.h>
3830 #include <linux/workqueue.h>
3931 #include <uapi/linux/batadv_packet.h>
4032 #include <uapi/linux/batman_adv.h>
41
-
42
-struct seq_file;
4333
4434 #ifdef CONFIG_BATMAN_ADV_DAT
4535
....@@ -131,6 +121,15 @@
131121 /** @elp_wq: workqueue used to schedule ELP transmissions */
132122 struct delayed_work elp_wq;
133123
124
+ /** @aggr_wq: workqueue used to transmit queued OGM packets */
125
+ struct delayed_work aggr_wq;
126
+
127
+ /** @aggr_list: queue for to be aggregated OGM packets */
128
+ struct sk_buff_head aggr_list;
129
+
130
+ /** @aggr_len: size of the OGM aggregate (excluding ethernet header) */
131
+ unsigned int aggr_len;
132
+
134133 /**
135134 * @throughput_override: throughput override to disable link
136135 * auto-detection
....@@ -171,9 +170,6 @@
171170 /** @list: list node for batadv_hardif_list */
172171 struct list_head list;
173172
174
- /** @if_num: identificator of the interface */
175
- unsigned int if_num;
176
-
177173 /** @if_status: status of the interface for batman-adv */
178174 char if_status;
179175
....@@ -212,6 +208,12 @@
212208 /** @rcu: struct used for freeing in an RCU-safe manner */
213209 struct rcu_head rcu;
214210
211
+ /**
212
+ * @hop_penalty: penalty which will be applied to the tq-field
213
+ * of an OGM received via this interface
214
+ */
215
+ atomic_t hop_penalty;
216
+
215217 /** @bat_iv: per hard-interface B.A.T.M.A.N. IV data */
216218 struct batadv_hard_iface_bat_iv bat_iv;
217219
....@@ -234,6 +236,20 @@
234236
235237 /** @neigh_list_lock: lock protecting neigh_list */
236238 spinlock_t neigh_list_lock;
239
+};
240
+
241
+/**
242
+ * struct batadv_orig_ifinfo - B.A.T.M.A.N. IV private orig_ifinfo members
243
+ */
244
+struct batadv_orig_ifinfo_bat_iv {
245
+ /**
246
+ * @bcast_own: bitfield which counts the number of our OGMs this
247
+ * orig_node rebroadcasted "back" to us (relative to last_real_seqno)
248
+ */
249
+ DECLARE_BITMAP(bcast_own, BATADV_TQ_LOCAL_WINDOW_SIZE);
250
+
251
+ /** @bcast_own_sum: sum of bcast_own */
252
+ u8 bcast_own_sum;
237253 };
238254
239255 /**
....@@ -260,6 +276,9 @@
260276
261277 /** @batman_seqno_reset: time when the batman seqno window was reset */
262278 unsigned long batman_seqno_reset;
279
+
280
+ /** @bat_iv: B.A.T.M.A.N. IV private structure */
281
+ struct batadv_orig_ifinfo_bat_iv bat_iv;
263282
264283 /** @refcount: number of contexts the object is used */
265284 struct kref refcount;
....@@ -343,19 +362,10 @@
343362 */
344363 struct batadv_orig_bat_iv {
345364 /**
346
- * @bcast_own: set of bitfields (one per hard-interface) where each one
347
- * counts the number of our OGMs this orig_node rebroadcasted "back" to
348
- * us (relative to last_real_seqno). Every bitfield is
349
- * BATADV_TQ_LOCAL_WINDOW_SIZE bits long.
350
- */
351
- unsigned long *bcast_own;
352
-
353
- /** @bcast_own_sum: sum of bcast_own */
354
- u8 *bcast_own_sum;
355
-
356
- /**
357
- * @ogm_cnt_lock: lock protecting bcast_own, bcast_own_sum,
358
- * neigh_node->bat_iv.real_bits & neigh_node->bat_iv.real_packet_count
365
+ * @ogm_cnt_lock: lock protecting &batadv_orig_ifinfo_bat_iv.bcast_own,
366
+ * &batadv_orig_ifinfo_bat_iv.bcast_own_sum,
367
+ * &batadv_neigh_ifinfo_bat_iv.bat_iv.real_bits and
368
+ * &batadv_neigh_ifinfo_bat_iv.real_packet_count
359369 */
360370 spinlock_t ogm_cnt_lock;
361371 };
....@@ -413,6 +423,17 @@
413423 * list
414424 */
415425 struct hlist_node mcast_want_all_ipv6_node;
426
+
427
+ /**
428
+ * @mcast_want_all_rtr4_node: a list node for the mcast.want_all_rtr4
429
+ * list
430
+ */
431
+ struct hlist_node mcast_want_all_rtr4_node;
432
+ /**
433
+ * @mcast_want_all_rtr6_node: a list node for the mcast.want_all_rtr6
434
+ * list
435
+ */
436
+ struct hlist_node mcast_want_all_rtr6_node;
416437 #endif
417438
418439 /** @capabilities: announced capabilities of this originator */
....@@ -440,9 +461,9 @@
440461 spinlock_t tt_buff_lock;
441462
442463 /**
443
- * @tt_lock: prevents from updating the table while reading it. Table
444
- * update is made up by two operations (data structure update and
445
- * metdata -CRC/TTVN-recalculation) and they have to be executed
464
+ * @tt_lock: avoids concurrent read from and write to the table. Table
465
+ * update is made up of two operations (data structure update and
466
+ * metadata -CRC/TTVN-recalculation) and they have to be executed
446467 * atomically in order to avoid another thread to read the
447468 * table/metadata between those.
448469 */
....@@ -733,7 +754,7 @@
733754 * struct batadv_bcast_duplist_entry - structure for LAN broadcast suppression
734755 */
735756 struct batadv_bcast_duplist_entry {
736
- /** @orig: mac address of orig node orginating the broadcast */
757
+ /** @orig: mac address of orig node originating the broadcast */
737758 u8 orig[ETH_ALEN];
738759
739760 /** @crc: crc32 checksum of broadcast payload */
....@@ -995,8 +1016,8 @@
9951016
9961017 /**
9971018 * @commit_lock: prevents from executing a local TT commit while reading
998
- * the local table. The local TT commit is made up by two operations
999
- * (data structure update and metdata -CRC/TTVN- recalculation) and
1019
+ * the local table. The local TT commit is made up of two operations
1020
+ * (data structure update and metadata -CRC/TTVN- recalculation) and
10001021 * they have to be executed atomically in order to avoid another thread
10011022 * to read the table/metadata between those.
10021023 */
....@@ -1009,7 +1030,7 @@
10091030 #ifdef CONFIG_BATMAN_ADV_BLA
10101031
10111032 /**
1012
- * struct batadv_priv_bla - per mesh interface bridge loope avoidance data
1033
+ * struct batadv_priv_bla - per mesh interface bridge loop avoidance data
10131034 */
10141035 struct batadv_priv_bla {
10151036 /** @num_requests: number of bla requests in flight */
....@@ -1071,7 +1092,7 @@
10711092 * struct batadv_priv_debug_log - debug logging data
10721093 */
10731094 struct batadv_priv_debug_log {
1074
- /** @log_buff: buffer holding the logs (ring bufer) */
1095
+ /** @log_buff: buffer holding the logs (ring buffer) */
10751096 char log_buff[BATADV_LOG_BUF_LEN];
10761097
10771098 /** @log_start: index of next character to read */
....@@ -1095,11 +1116,14 @@
10951116 /** @gateway_list: list of available gateway nodes */
10961117 struct hlist_head gateway_list;
10971118
1098
- /** @list_lock: lock protecting gateway_list & curr_gw */
1119
+ /** @list_lock: lock protecting gateway_list, curr_gw, generation */
10991120 spinlock_t list_lock;
11001121
11011122 /** @curr_gw: pointer to currently selected gateway node */
11021123 struct batadv_gw_node __rcu *curr_gw;
1124
+
1125
+ /** @generation: current (generation) sequence number */
1126
+ unsigned int generation;
11031127
11041128 /**
11051129 * @mode: gateway operation: off, client or server (see batadv_gw_modes)
....@@ -1177,6 +1201,26 @@
11771201 };
11781202
11791203 /**
1204
+ * struct batadv_mcast_mla_flags - flags for the querier, bridge and tvlv state
1205
+ */
1206
+struct batadv_mcast_mla_flags {
1207
+ /** @querier_ipv4: the current state of an IGMP querier in the mesh */
1208
+ struct batadv_mcast_querier_state querier_ipv4;
1209
+
1210
+ /** @querier_ipv6: the current state of an MLD querier in the mesh */
1211
+ struct batadv_mcast_querier_state querier_ipv6;
1212
+
1213
+ /** @enabled: whether the multicast tvlv is currently enabled */
1214
+ unsigned char enabled:1;
1215
+
1216
+ /** @bridged: whether the soft interface has a bridge on top */
1217
+ unsigned char bridged:1;
1218
+
1219
+ /** @tvlv_flags: the flags we have last sent in our mcast tvlv */
1220
+ u8 tvlv_flags;
1221
+};
1222
+
1223
+/**
11801224 * struct batadv_priv_mcast - per mesh interface mcast data
11811225 */
11821226 struct batadv_priv_mcast {
....@@ -1204,20 +1248,22 @@
12041248 */
12051249 struct hlist_head want_all_ipv6_list;
12061250
1207
- /** @querier_ipv4: the current state of an IGMP querier in the mesh */
1208
- struct batadv_mcast_querier_state querier_ipv4;
1251
+ /**
1252
+ * @want_all_rtr4_list: a list of orig_nodes wanting all routable IPv4
1253
+ * multicast traffic
1254
+ */
1255
+ struct hlist_head want_all_rtr4_list;
12091256
1210
- /** @querier_ipv6: the current state of an MLD querier in the mesh */
1211
- struct batadv_mcast_querier_state querier_ipv6;
1257
+ /**
1258
+ * @want_all_rtr6_list: a list of orig_nodes wanting all routable IPv6
1259
+ * multicast traffic
1260
+ */
1261
+ struct hlist_head want_all_rtr6_list;
12121262
1213
- /** @flags: the flags we have last sent in our mcast tvlv */
1214
- u8 flags;
1215
-
1216
- /** @enabled: whether the multicast tvlv is currently enabled */
1217
- unsigned char enabled:1;
1218
-
1219
- /** @bridged: whether the soft interface has a bridge on top */
1220
- unsigned char bridged:1;
1263
+ /**
1264
+ * @mla_flags: flags for the querier, bridge and tvlv state
1265
+ */
1266
+ struct batadv_mcast_mla_flags mla_flags;
12211267
12221268 /**
12231269 * @mla_lock: a lock protecting mla_list and mla_flags
....@@ -1235,6 +1281,12 @@
12351281
12361282 /** @num_want_all_ipv6: counter for items in want_all_ipv6_list */
12371283 atomic_t num_want_all_ipv6;
1284
+
1285
+ /** @num_want_all_rtr4: counter for items in want_all_rtr4_list */
1286
+ atomic_t num_want_all_rtr4;
1287
+
1288
+ /** @num_want_all_rtr6: counter for items in want_all_rtr6_list */
1289
+ atomic_t num_want_all_rtr6;
12381290
12391291 /**
12401292 * @want_lists_lock: lock for protecting modifications to mcasts
....@@ -1440,7 +1492,7 @@
14401492 /** @unacked_lock: protect unacked_list */
14411493 spinlock_t unacked_lock;
14421494
1443
- /** @last_recv_time: time time (jiffies) a msg was received */
1495
+ /** @last_recv_time: time (jiffies) a msg was received */
14441496 unsigned long last_recv_time;
14451497
14461498 /** @refcount: number of context where the object is used */
....@@ -1515,6 +1567,12 @@
15151567 struct net_device *soft_iface;
15161568
15171569 /**
1570
+ * @mtu_set_by_user: MTU was set once by user
1571
+ * protected by rtnl_lock
1572
+ */
1573
+ int mtu_set_by_user;
1574
+
1575
+ /**
15181576 * @bat_counters: mesh internal traffic statistic counters (see
15191577 * batadv_counters)
15201578 */
....@@ -1569,6 +1627,12 @@
15691627 * node's sender/originating side
15701628 */
15711629 atomic_t multicast_mode;
1630
+
1631
+ /**
1632
+ * @multicast_fanout: Maximum number of packet copies to generate for a
1633
+ * multicast-to-unicast conversion
1634
+ */
1635
+ atomic_t multicast_fanout;
15721636 #endif
15731637
15741638 /** @orig_interval: OGM broadcast interval in milliseconds */
....@@ -1608,9 +1672,6 @@
16081672
16091673 /** @batman_queue_left: number of remaining OGM packet slots */
16101674 atomic_t batman_queue_left;
1611
-
1612
- /** @num_ifaces: number of interfaces assigned to this mesh interface */
1613
- unsigned int num_ifaces;
16141675
16151676 /** @mesh_obj: kobject for sysfs mesh subdirectory */
16161677 struct kobject *mesh_obj;
....@@ -1669,7 +1730,7 @@
16691730 spinlock_t softif_vlan_list_lock;
16701731
16711732 #ifdef CONFIG_BATMAN_ADV_BLA
1672
- /** @bla: bridge loope avoidance data */
1733
+ /** @bla: bridge loop avoidance data */
16731734 struct batadv_priv_bla bla;
16741735 #endif
16751736
....@@ -1941,7 +2002,7 @@
19412002 */
19422003 struct batadv_tt_req_node {
19432004 /**
1944
- * @addr: mac address address of the originator this request was sent to
2005
+ * @addr: mac address of the originator this request was sent to
19452006 */
19462007 u8 addr[ETH_ALEN];
19472008
....@@ -2194,28 +2255,6 @@
21942255 * struct batadv_algo_orig_ops - mesh algorithm callbacks (originator specific)
21952256 */
21962257 struct batadv_algo_orig_ops {
2197
- /**
2198
- * @free: free the resources allocated by the routing algorithm for an
2199
- * orig_node object (optional)
2200
- */
2201
- void (*free)(struct batadv_orig_node *orig_node);
2202
-
2203
- /**
2204
- * @add_if: ask the routing algorithm to apply the needed changes to the
2205
- * orig_node due to a new hard-interface being added into the mesh
2206
- * (optional)
2207
- */
2208
- int (*add_if)(struct batadv_orig_node *orig_node,
2209
- unsigned int max_if_num);
2210
-
2211
- /**
2212
- * @del_if: ask the routing algorithm to apply the needed changes to the
2213
- * orig_node due to an hard-interface being removed from the mesh
2214
- * (optional)
2215
- */
2216
- int (*del_if)(struct batadv_orig_node *orig_node,
2217
- unsigned int max_if_num, unsigned int del_if_num);
2218
-
22192258 #ifdef CONFIG_BATMAN_ADV_DEBUGFS
22202259 /** @print: print the originator table (optional) */
22212260 void (*print)(struct batadv_priv *priv, struct seq_file *seq,