.. | .. |
---|
1 | 1 | /* 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: |
---|
3 | 3 | * |
---|
4 | 4 | * 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/>. |
---|
17 | 5 | */ |
---|
18 | 6 | |
---|
19 | 7 | #ifndef _NET_BATMAN_ADV_TYPES_H_ |
---|
.. | .. |
---|
26 | 14 | #include <linux/average.h> |
---|
27 | 15 | #include <linux/bitops.h> |
---|
28 | 16 | #include <linux/compiler.h> |
---|
| 17 | +#include <linux/if.h> |
---|
29 | 18 | #include <linux/if_ether.h> |
---|
30 | 19 | #include <linux/kref.h> |
---|
31 | 20 | #include <linux/mutex.h> |
---|
32 | 21 | #include <linux/netdevice.h> |
---|
33 | 22 | #include <linux/netlink.h> |
---|
34 | 23 | #include <linux/sched.h> /* for linux/wait.h */ |
---|
| 24 | +#include <linux/seq_file.h> |
---|
| 25 | +#include <linux/skbuff.h> |
---|
35 | 26 | #include <linux/spinlock.h> |
---|
| 27 | +#include <linux/timer.h> |
---|
36 | 28 | #include <linux/types.h> |
---|
37 | 29 | #include <linux/wait.h> |
---|
38 | 30 | #include <linux/workqueue.h> |
---|
39 | 31 | #include <uapi/linux/batadv_packet.h> |
---|
40 | 32 | #include <uapi/linux/batman_adv.h> |
---|
41 | | - |
---|
42 | | -struct seq_file; |
---|
43 | 33 | |
---|
44 | 34 | #ifdef CONFIG_BATMAN_ADV_DAT |
---|
45 | 35 | |
---|
.. | .. |
---|
131 | 121 | /** @elp_wq: workqueue used to schedule ELP transmissions */ |
---|
132 | 122 | struct delayed_work elp_wq; |
---|
133 | 123 | |
---|
| 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 | + |
---|
134 | 133 | /** |
---|
135 | 134 | * @throughput_override: throughput override to disable link |
---|
136 | 135 | * auto-detection |
---|
.. | .. |
---|
171 | 170 | /** @list: list node for batadv_hardif_list */ |
---|
172 | 171 | struct list_head list; |
---|
173 | 172 | |
---|
174 | | - /** @if_num: identificator of the interface */ |
---|
175 | | - unsigned int if_num; |
---|
176 | | - |
---|
177 | 173 | /** @if_status: status of the interface for batman-adv */ |
---|
178 | 174 | char if_status; |
---|
179 | 175 | |
---|
.. | .. |
---|
212 | 208 | /** @rcu: struct used for freeing in an RCU-safe manner */ |
---|
213 | 209 | struct rcu_head rcu; |
---|
214 | 210 | |
---|
| 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 | + |
---|
215 | 217 | /** @bat_iv: per hard-interface B.A.T.M.A.N. IV data */ |
---|
216 | 218 | struct batadv_hard_iface_bat_iv bat_iv; |
---|
217 | 219 | |
---|
.. | .. |
---|
234 | 236 | |
---|
235 | 237 | /** @neigh_list_lock: lock protecting neigh_list */ |
---|
236 | 238 | 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; |
---|
237 | 253 | }; |
---|
238 | 254 | |
---|
239 | 255 | /** |
---|
.. | .. |
---|
260 | 276 | |
---|
261 | 277 | /** @batman_seqno_reset: time when the batman seqno window was reset */ |
---|
262 | 278 | 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; |
---|
263 | 282 | |
---|
264 | 283 | /** @refcount: number of contexts the object is used */ |
---|
265 | 284 | struct kref refcount; |
---|
.. | .. |
---|
343 | 362 | */ |
---|
344 | 363 | struct batadv_orig_bat_iv { |
---|
345 | 364 | /** |
---|
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 |
---|
359 | 369 | */ |
---|
360 | 370 | spinlock_t ogm_cnt_lock; |
---|
361 | 371 | }; |
---|
.. | .. |
---|
413 | 423 | * list |
---|
414 | 424 | */ |
---|
415 | 425 | 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; |
---|
416 | 437 | #endif |
---|
417 | 438 | |
---|
418 | 439 | /** @capabilities: announced capabilities of this originator */ |
---|
.. | .. |
---|
440 | 461 | spinlock_t tt_buff_lock; |
---|
441 | 462 | |
---|
442 | 463 | /** |
---|
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 |
---|
446 | 467 | * atomically in order to avoid another thread to read the |
---|
447 | 468 | * table/metadata between those. |
---|
448 | 469 | */ |
---|
.. | .. |
---|
733 | 754 | * struct batadv_bcast_duplist_entry - structure for LAN broadcast suppression |
---|
734 | 755 | */ |
---|
735 | 756 | 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 */ |
---|
737 | 758 | u8 orig[ETH_ALEN]; |
---|
738 | 759 | |
---|
739 | 760 | /** @crc: crc32 checksum of broadcast payload */ |
---|
.. | .. |
---|
995 | 1016 | |
---|
996 | 1017 | /** |
---|
997 | 1018 | * @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 |
---|
1000 | 1021 | * they have to be executed atomically in order to avoid another thread |
---|
1001 | 1022 | * to read the table/metadata between those. |
---|
1002 | 1023 | */ |
---|
.. | .. |
---|
1009 | 1030 | #ifdef CONFIG_BATMAN_ADV_BLA |
---|
1010 | 1031 | |
---|
1011 | 1032 | /** |
---|
1012 | | - * struct batadv_priv_bla - per mesh interface bridge loope avoidance data |
---|
| 1033 | + * struct batadv_priv_bla - per mesh interface bridge loop avoidance data |
---|
1013 | 1034 | */ |
---|
1014 | 1035 | struct batadv_priv_bla { |
---|
1015 | 1036 | /** @num_requests: number of bla requests in flight */ |
---|
.. | .. |
---|
1071 | 1092 | * struct batadv_priv_debug_log - debug logging data |
---|
1072 | 1093 | */ |
---|
1073 | 1094 | struct batadv_priv_debug_log { |
---|
1074 | | - /** @log_buff: buffer holding the logs (ring bufer) */ |
---|
| 1095 | + /** @log_buff: buffer holding the logs (ring buffer) */ |
---|
1075 | 1096 | char log_buff[BATADV_LOG_BUF_LEN]; |
---|
1076 | 1097 | |
---|
1077 | 1098 | /** @log_start: index of next character to read */ |
---|
.. | .. |
---|
1095 | 1116 | /** @gateway_list: list of available gateway nodes */ |
---|
1096 | 1117 | struct hlist_head gateway_list; |
---|
1097 | 1118 | |
---|
1098 | | - /** @list_lock: lock protecting gateway_list & curr_gw */ |
---|
| 1119 | + /** @list_lock: lock protecting gateway_list, curr_gw, generation */ |
---|
1099 | 1120 | spinlock_t list_lock; |
---|
1100 | 1121 | |
---|
1101 | 1122 | /** @curr_gw: pointer to currently selected gateway node */ |
---|
1102 | 1123 | struct batadv_gw_node __rcu *curr_gw; |
---|
| 1124 | + |
---|
| 1125 | + /** @generation: current (generation) sequence number */ |
---|
| 1126 | + unsigned int generation; |
---|
1103 | 1127 | |
---|
1104 | 1128 | /** |
---|
1105 | 1129 | * @mode: gateway operation: off, client or server (see batadv_gw_modes) |
---|
.. | .. |
---|
1177 | 1201 | }; |
---|
1178 | 1202 | |
---|
1179 | 1203 | /** |
---|
| 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 | +/** |
---|
1180 | 1224 | * struct batadv_priv_mcast - per mesh interface mcast data |
---|
1181 | 1225 | */ |
---|
1182 | 1226 | struct batadv_priv_mcast { |
---|
.. | .. |
---|
1204 | 1248 | */ |
---|
1205 | 1249 | struct hlist_head want_all_ipv6_list; |
---|
1206 | 1250 | |
---|
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; |
---|
1209 | 1256 | |
---|
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; |
---|
1212 | 1262 | |
---|
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; |
---|
1221 | 1267 | |
---|
1222 | 1268 | /** |
---|
1223 | 1269 | * @mla_lock: a lock protecting mla_list and mla_flags |
---|
.. | .. |
---|
1235 | 1281 | |
---|
1236 | 1282 | /** @num_want_all_ipv6: counter for items in want_all_ipv6_list */ |
---|
1237 | 1283 | 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; |
---|
1238 | 1290 | |
---|
1239 | 1291 | /** |
---|
1240 | 1292 | * @want_lists_lock: lock for protecting modifications to mcasts |
---|
.. | .. |
---|
1440 | 1492 | /** @unacked_lock: protect unacked_list */ |
---|
1441 | 1493 | spinlock_t unacked_lock; |
---|
1442 | 1494 | |
---|
1443 | | - /** @last_recv_time: time time (jiffies) a msg was received */ |
---|
| 1495 | + /** @last_recv_time: time (jiffies) a msg was received */ |
---|
1444 | 1496 | unsigned long last_recv_time; |
---|
1445 | 1497 | |
---|
1446 | 1498 | /** @refcount: number of context where the object is used */ |
---|
.. | .. |
---|
1515 | 1567 | struct net_device *soft_iface; |
---|
1516 | 1568 | |
---|
1517 | 1569 | /** |
---|
| 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 | + /** |
---|
1518 | 1576 | * @bat_counters: mesh internal traffic statistic counters (see |
---|
1519 | 1577 | * batadv_counters) |
---|
1520 | 1578 | */ |
---|
.. | .. |
---|
1569 | 1627 | * node's sender/originating side |
---|
1570 | 1628 | */ |
---|
1571 | 1629 | 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; |
---|
1572 | 1636 | #endif |
---|
1573 | 1637 | |
---|
1574 | 1638 | /** @orig_interval: OGM broadcast interval in milliseconds */ |
---|
.. | .. |
---|
1608 | 1672 | |
---|
1609 | 1673 | /** @batman_queue_left: number of remaining OGM packet slots */ |
---|
1610 | 1674 | atomic_t batman_queue_left; |
---|
1611 | | - |
---|
1612 | | - /** @num_ifaces: number of interfaces assigned to this mesh interface */ |
---|
1613 | | - unsigned int num_ifaces; |
---|
1614 | 1675 | |
---|
1615 | 1676 | /** @mesh_obj: kobject for sysfs mesh subdirectory */ |
---|
1616 | 1677 | struct kobject *mesh_obj; |
---|
.. | .. |
---|
1669 | 1730 | spinlock_t softif_vlan_list_lock; |
---|
1670 | 1731 | |
---|
1671 | 1732 | #ifdef CONFIG_BATMAN_ADV_BLA |
---|
1672 | | - /** @bla: bridge loope avoidance data */ |
---|
| 1733 | + /** @bla: bridge loop avoidance data */ |
---|
1673 | 1734 | struct batadv_priv_bla bla; |
---|
1674 | 1735 | #endif |
---|
1675 | 1736 | |
---|
.. | .. |
---|
1941 | 2002 | */ |
---|
1942 | 2003 | struct batadv_tt_req_node { |
---|
1943 | 2004 | /** |
---|
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 |
---|
1945 | 2006 | */ |
---|
1946 | 2007 | u8 addr[ETH_ALEN]; |
---|
1947 | 2008 | |
---|
.. | .. |
---|
2194 | 2255 | * struct batadv_algo_orig_ops - mesh algorithm callbacks (originator specific) |
---|
2195 | 2256 | */ |
---|
2196 | 2257 | 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 | | - |
---|
2219 | 2258 | #ifdef CONFIG_BATMAN_ADV_DEBUGFS |
---|
2220 | 2259 | /** @print: print the originator table (optional) */ |
---|
2221 | 2260 | void (*print)(struct batadv_priv *priv, struct seq_file *seq, |
---|