1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2007-2020 B.A.T.M.A.N. contributors:
4 * Marek Lindner, Simon Wunderlich
7 #ifndef _NET_BATMAN_ADV_TYPES_H_
8 #define _NET_BATMAN_ADV_TYPES_H_
10 #ifndef _NET_BATMAN_ADV_MAIN_H_
11 #error only "main.h" can be included directly
14 #include <linux/average.h>
15 #include <linux/bitops.h>
16 #include <linux/compiler.h>
18 #include <linux/if_ether.h>
19 #include <linux/kref.h>
20 #include <linux/mutex.h>
21 #include <linux/netdevice.h>
22 #include <linux/netlink.h>
23 #include <linux/sched.h> /* for linux/wait.h */
24 #include <linux/skbuff.h>
25 #include <linux/spinlock.h>
26 #include <linux/timer.h>
27 #include <linux/types.h>
28 #include <linux/wait.h>
29 #include <linux/workqueue.h>
30 #include <uapi/linux/batadv_packet.h>
31 #include <uapi/linux/batman_adv.h>
33 #ifdef CONFIG_BATMAN_ADV_DAT
36 * typedef batadv_dat_addr_t - type used for all DHT addresses
38 * If it is changed, BATADV_DAT_ADDR_MAX is changed as well.
40 * *Please be careful: batadv_dat_addr_t must be UNSIGNED*
42 typedef u16 batadv_dat_addr_t
;
44 #endif /* CONFIG_BATMAN_ADV_DAT */
47 * enum batadv_dhcp_recipient - dhcp destination
49 enum batadv_dhcp_recipient
{
50 /** @BATADV_DHCP_NO: packet is not a dhcp message */
53 /** @BATADV_DHCP_TO_SERVER: dhcp message is directed to a server */
54 BATADV_DHCP_TO_SERVER
,
56 /** @BATADV_DHCP_TO_CLIENT: dhcp message is directed to a client */
57 BATADV_DHCP_TO_CLIENT
,
61 * BATADV_TT_REMOTE_MASK - bitmask selecting the flags that are sent over the
64 #define BATADV_TT_REMOTE_MASK 0x00FF
67 * BATADV_TT_SYNC_MASK - bitmask of the flags that need to be kept in sync
68 * among the nodes. These flags are used to compute the global/local CRC
70 #define BATADV_TT_SYNC_MASK 0x00F0
73 * struct batadv_hard_iface_bat_iv - per hard-interface B.A.T.M.A.N. IV data
75 struct batadv_hard_iface_bat_iv
{
76 /** @ogm_buff: buffer holding the OGM packet */
77 unsigned char *ogm_buff
;
79 /** @ogm_buff_len: length of the OGM packet buffer */
82 /** @ogm_seqno: OGM sequence number - used to identify each OGM */
85 /** @ogm_buff_mutex: lock protecting ogm_buff and ogm_buff_len */
86 struct mutex ogm_buff_mutex
;
90 * enum batadv_v_hard_iface_flags - interface flags useful to B.A.T.M.A.N. V
92 enum batadv_v_hard_iface_flags
{
94 * @BATADV_FULL_DUPLEX: tells if the connection over this link is
97 BATADV_FULL_DUPLEX
= BIT(0),
100 * @BATADV_WARNING_DEFAULT: tells whether we have warned the user that
101 * no throughput data is available for this interface and that default
102 * values are assumed.
104 BATADV_WARNING_DEFAULT
= BIT(1),
108 * struct batadv_hard_iface_bat_v - per hard-interface B.A.T.M.A.N. V data
110 struct batadv_hard_iface_bat_v
{
111 /** @elp_interval: time interval between two ELP transmissions */
112 atomic_t elp_interval
;
114 /** @elp_seqno: current ELP sequence number */
117 /** @elp_skb: base skb containing the ELP message to send */
118 struct sk_buff
*elp_skb
;
120 /** @elp_wq: workqueue used to schedule ELP transmissions */
121 struct delayed_work elp_wq
;
123 /** @aggr_wq: workqueue used to transmit queued OGM packets */
124 struct delayed_work aggr_wq
;
126 /** @aggr_list: queue for to be aggregated OGM packets */
127 struct sk_buff_head aggr_list
;
129 /** @aggr_len: size of the OGM aggregate (excluding ethernet header) */
130 unsigned int aggr_len
;
133 * @throughput_override: throughput override to disable link
136 atomic_t throughput_override
;
138 /** @flags: interface specific flags */
143 * enum batadv_hard_iface_wifi_flags - Flags describing the wifi configuration
144 * of a batadv_hard_iface
146 enum batadv_hard_iface_wifi_flags
{
147 /** @BATADV_HARDIF_WIFI_WEXT_DIRECT: it is a wext wifi device */
148 BATADV_HARDIF_WIFI_WEXT_DIRECT
= BIT(0),
150 /** @BATADV_HARDIF_WIFI_CFG80211_DIRECT: it is a cfg80211 wifi device */
151 BATADV_HARDIF_WIFI_CFG80211_DIRECT
= BIT(1),
154 * @BATADV_HARDIF_WIFI_WEXT_INDIRECT: link device is a wext wifi device
156 BATADV_HARDIF_WIFI_WEXT_INDIRECT
= BIT(2),
159 * @BATADV_HARDIF_WIFI_CFG80211_INDIRECT: link device is a cfg80211 wifi
162 BATADV_HARDIF_WIFI_CFG80211_INDIRECT
= BIT(3),
166 * struct batadv_hard_iface - network device known to batman-adv
168 struct batadv_hard_iface
{
169 /** @list: list node for batadv_hardif_list */
170 struct list_head list
;
172 /** @if_status: status of the interface for batman-adv */
176 * @num_bcasts: number of payload re-broadcasts on this interface (ARQ)
181 * @wifi_flags: flags whether this is (directly or indirectly) a wifi
186 /** @net_dev: pointer to the net_device */
187 struct net_device
*net_dev
;
189 /** @refcount: number of contexts the object is used */
190 struct kref refcount
;
193 * @batman_adv_ptype: packet type describing packets that should be
194 * processed by batman-adv for this interface
196 struct packet_type batman_adv_ptype
;
199 * @soft_iface: the batman-adv interface which uses this network
202 struct net_device
*soft_iface
;
204 /** @rcu: struct used for freeing in an RCU-safe manner */
208 * @hop_penalty: penalty which will be applied to the tq-field
209 * of an OGM received via this interface
211 atomic_t hop_penalty
;
213 /** @bat_iv: per hard-interface B.A.T.M.A.N. IV data */
214 struct batadv_hard_iface_bat_iv bat_iv
;
216 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
217 /** @bat_v: per hard-interface B.A.T.M.A.N. V data */
218 struct batadv_hard_iface_bat_v bat_v
;
222 * @neigh_list: list of unique single hop neighbors via this interface
224 struct hlist_head neigh_list
;
226 /** @neigh_list_lock: lock protecting neigh_list */
227 spinlock_t neigh_list_lock
;
231 * struct batadv_orig_ifinfo - B.A.T.M.A.N. IV private orig_ifinfo members
233 struct batadv_orig_ifinfo_bat_iv
{
235 * @bcast_own: bitfield which counts the number of our OGMs this
236 * orig_node rebroadcasted "back" to us (relative to last_real_seqno)
238 DECLARE_BITMAP(bcast_own
, BATADV_TQ_LOCAL_WINDOW_SIZE
);
240 /** @bcast_own_sum: sum of bcast_own */
245 * struct batadv_orig_ifinfo - originator info per outgoing interface
247 struct batadv_orig_ifinfo
{
248 /** @list: list node for &batadv_orig_node.ifinfo_list */
249 struct hlist_node list
;
251 /** @if_outgoing: pointer to outgoing hard-interface */
252 struct batadv_hard_iface
*if_outgoing
;
254 /** @router: router that should be used to reach this originator */
255 struct batadv_neigh_node __rcu
*router
;
257 /** @last_real_seqno: last and best known sequence number */
260 /** @last_ttl: ttl of last received packet */
263 /** @last_seqno_forwarded: seqno of the OGM which was forwarded last */
264 u32 last_seqno_forwarded
;
266 /** @batman_seqno_reset: time when the batman seqno window was reset */
267 unsigned long batman_seqno_reset
;
269 /** @bat_iv: B.A.T.M.A.N. IV private structure */
270 struct batadv_orig_ifinfo_bat_iv bat_iv
;
272 /** @refcount: number of contexts the object is used */
273 struct kref refcount
;
275 /** @rcu: struct used for freeing in an RCU-safe manner */
280 * struct batadv_frag_table_entry - head in the fragment buffer table
282 struct batadv_frag_table_entry
{
283 /** @fragment_list: head of list with fragments */
284 struct hlist_head fragment_list
;
286 /** @lock: lock to protect the list of fragments */
289 /** @timestamp: time (jiffie) of last received fragment */
290 unsigned long timestamp
;
292 /** @seqno: sequence number of the fragments in the list */
295 /** @size: accumulated size of packets in list */
298 /** @total_size: expected size of the assembled packet */
303 * struct batadv_frag_list_entry - entry in a list of fragments
305 struct batadv_frag_list_entry
{
306 /** @list: list node information */
307 struct hlist_node list
;
309 /** @skb: fragment */
312 /** @no: fragment number in the set */
317 * struct batadv_vlan_tt - VLAN specific TT attributes
319 struct batadv_vlan_tt
{
320 /** @crc: CRC32 checksum of the entries belonging to this vlan */
323 /** @num_entries: number of TT entries for this VLAN */
324 atomic_t num_entries
;
328 * struct batadv_orig_node_vlan - VLAN specific data per orig_node
330 struct batadv_orig_node_vlan
{
331 /** @vid: the VLAN identifier */
334 /** @tt: VLAN specific TT attributes */
335 struct batadv_vlan_tt tt
;
337 /** @list: list node for &batadv_orig_node.vlan_list */
338 struct hlist_node list
;
341 * @refcount: number of context where this object is currently in use
343 struct kref refcount
;
345 /** @rcu: struct used for freeing in a RCU-safe manner */
350 * struct batadv_orig_bat_iv - B.A.T.M.A.N. IV private orig_node members
352 struct batadv_orig_bat_iv
{
354 * @ogm_cnt_lock: lock protecting &batadv_orig_ifinfo_bat_iv.bcast_own,
355 * &batadv_orig_ifinfo_bat_iv.bcast_own_sum,
356 * &batadv_neigh_ifinfo_bat_iv.bat_iv.real_bits and
357 * &batadv_neigh_ifinfo_bat_iv.real_packet_count
359 spinlock_t ogm_cnt_lock
;
363 * struct batadv_orig_node - structure for orig_list maintaining nodes of mesh
365 struct batadv_orig_node
{
366 /** @orig: originator ethernet address */
369 /** @ifinfo_list: list for routers per outgoing interface */
370 struct hlist_head ifinfo_list
;
373 * @last_bonding_candidate: pointer to last ifinfo of last used router
375 struct batadv_orig_ifinfo
*last_bonding_candidate
;
377 #ifdef CONFIG_BATMAN_ADV_DAT
378 /** @dat_addr: address of the orig node in the distributed hash */
379 batadv_dat_addr_t dat_addr
;
382 /** @last_seen: time when last packet from this node was received */
383 unsigned long last_seen
;
386 * @bcast_seqno_reset: time when the broadcast seqno window was reset
388 unsigned long bcast_seqno_reset
;
390 #ifdef CONFIG_BATMAN_ADV_MCAST
392 * @mcast_handler_lock: synchronizes mcast-capability and -flag changes
394 spinlock_t mcast_handler_lock
;
396 /** @mcast_flags: multicast flags announced by the orig node */
400 * @mcast_want_all_unsnoopables_node: a list node for the
401 * mcast.want_all_unsnoopables list
403 struct hlist_node mcast_want_all_unsnoopables_node
;
406 * @mcast_want_all_ipv4_node: a list node for the mcast.want_all_ipv4
409 struct hlist_node mcast_want_all_ipv4_node
;
411 * @mcast_want_all_ipv6_node: a list node for the mcast.want_all_ipv6
414 struct hlist_node mcast_want_all_ipv6_node
;
417 * @mcast_want_all_rtr4_node: a list node for the mcast.want_all_rtr4
420 struct hlist_node mcast_want_all_rtr4_node
;
422 * @mcast_want_all_rtr6_node: a list node for the mcast.want_all_rtr6
425 struct hlist_node mcast_want_all_rtr6_node
;
428 /** @capabilities: announced capabilities of this originator */
429 unsigned long capabilities
;
432 * @capa_initialized: bitfield to remember whether a capability was
435 unsigned long capa_initialized
;
437 /** @last_ttvn: last seen translation table version number */
440 /** @tt_buff: last tt changeset this node received from the orig node */
441 unsigned char *tt_buff
;
444 * @tt_buff_len: length of the last tt changeset this node received
449 /** @tt_buff_lock: lock that protects tt_buff and tt_buff_len */
450 spinlock_t tt_buff_lock
;
453 * @tt_lock: avoids concurrent read from and write to the table. Table
454 * update is made up of two operations (data structure update and
455 * metadata -CRC/TTVN-recalculation) and they have to be executed
456 * atomically in order to avoid another thread to read the
457 * table/metadata between those.
462 * @bcast_bits: bitfield containing the info which payload broadcast
463 * originated from this orig node this host already has seen (relative
464 * to last_bcast_seqno)
466 DECLARE_BITMAP(bcast_bits
, BATADV_TQ_LOCAL_WINDOW_SIZE
);
469 * @last_bcast_seqno: last broadcast sequence number received by this
472 u32 last_bcast_seqno
;
475 * @neigh_list: list of potential next hop neighbor towards this orig
478 struct hlist_head neigh_list
;
481 * @neigh_list_lock: lock protecting neigh_list, ifinfo_list,
482 * last_bonding_candidate and router
484 spinlock_t neigh_list_lock
;
486 /** @hash_entry: hlist node for &batadv_priv.orig_hash */
487 struct hlist_node hash_entry
;
489 /** @bat_priv: pointer to soft_iface this orig node belongs to */
490 struct batadv_priv
*bat_priv
;
492 /** @bcast_seqno_lock: lock protecting bcast_bits & last_bcast_seqno */
493 spinlock_t bcast_seqno_lock
;
495 /** @refcount: number of contexts the object is used */
496 struct kref refcount
;
498 /** @rcu: struct used for freeing in an RCU-safe manner */
501 #ifdef CONFIG_BATMAN_ADV_NC
502 /** @in_coding_list: list of nodes this orig can hear */
503 struct list_head in_coding_list
;
505 /** @out_coding_list: list of nodes that can hear this orig */
506 struct list_head out_coding_list
;
508 /** @in_coding_list_lock: protects in_coding_list */
509 spinlock_t in_coding_list_lock
;
511 /** @out_coding_list_lock: protects out_coding_list */
512 spinlock_t out_coding_list_lock
;
515 /** @fragments: array with heads for fragment chains */
516 struct batadv_frag_table_entry fragments
[BATADV_FRAG_BUFFER_COUNT
];
519 * @vlan_list: a list of orig_node_vlan structs, one per VLAN served by
520 * the originator represented by this object
522 struct hlist_head vlan_list
;
524 /** @vlan_list_lock: lock protecting vlan_list */
525 spinlock_t vlan_list_lock
;
527 /** @bat_iv: B.A.T.M.A.N. IV private structure */
528 struct batadv_orig_bat_iv bat_iv
;
532 * enum batadv_orig_capabilities - orig node capabilities
534 enum batadv_orig_capabilities
{
536 * @BATADV_ORIG_CAPA_HAS_DAT: orig node has distributed arp table
539 BATADV_ORIG_CAPA_HAS_DAT
,
541 /** @BATADV_ORIG_CAPA_HAS_NC: orig node has network coding enabled */
542 BATADV_ORIG_CAPA_HAS_NC
,
544 /** @BATADV_ORIG_CAPA_HAS_TT: orig node has tt capability */
545 BATADV_ORIG_CAPA_HAS_TT
,
548 * @BATADV_ORIG_CAPA_HAS_MCAST: orig node has some multicast capability
549 * (= orig node announces a tvlv of type BATADV_TVLV_MCAST)
551 BATADV_ORIG_CAPA_HAS_MCAST
,
555 * struct batadv_gw_node - structure for orig nodes announcing gw capabilities
557 struct batadv_gw_node
{
558 /** @list: list node for &batadv_priv_gw.list */
559 struct hlist_node list
;
561 /** @orig_node: pointer to corresponding orig node */
562 struct batadv_orig_node
*orig_node
;
564 /** @bandwidth_down: advertised uplink download bandwidth */
567 /** @bandwidth_up: advertised uplink upload bandwidth */
570 /** @refcount: number of contexts the object is used */
571 struct kref refcount
;
573 /** @rcu: struct used for freeing in an RCU-safe manner */
577 DECLARE_EWMA(throughput
, 10, 8)
580 * struct batadv_hardif_neigh_node_bat_v - B.A.T.M.A.N. V private neighbor
583 struct batadv_hardif_neigh_node_bat_v
{
584 /** @throughput: ewma link throughput towards this neighbor */
585 struct ewma_throughput throughput
;
587 /** @elp_interval: time interval between two ELP transmissions */
590 /** @elp_latest_seqno: latest and best known ELP sequence number */
591 u32 elp_latest_seqno
;
594 * @last_unicast_tx: when the last unicast packet has been sent to this
597 unsigned long last_unicast_tx
;
599 /** @metric_work: work queue callback item for metric update */
600 struct work_struct metric_work
;
604 * struct batadv_hardif_neigh_node - unique neighbor per hard-interface
606 struct batadv_hardif_neigh_node
{
607 /** @list: list node for &batadv_hard_iface.neigh_list */
608 struct hlist_node list
;
610 /** @addr: the MAC address of the neighboring interface */
614 * @orig: the address of the originator this neighbor node belongs to
618 /** @if_incoming: pointer to incoming hard-interface */
619 struct batadv_hard_iface
*if_incoming
;
621 /** @last_seen: when last packet via this neighbor was received */
622 unsigned long last_seen
;
624 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
625 /** @bat_v: B.A.T.M.A.N. V private data */
626 struct batadv_hardif_neigh_node_bat_v bat_v
;
629 /** @refcount: number of contexts the object is used */
630 struct kref refcount
;
632 /** @rcu: struct used for freeing in a RCU-safe manner */
637 * struct batadv_neigh_node - structure for single hops neighbors
639 struct batadv_neigh_node
{
640 /** @list: list node for &batadv_orig_node.neigh_list */
641 struct hlist_node list
;
643 /** @orig_node: pointer to corresponding orig_node */
644 struct batadv_orig_node
*orig_node
;
646 /** @addr: the MAC address of the neighboring interface */
649 /** @ifinfo_list: list for routing metrics per outgoing interface */
650 struct hlist_head ifinfo_list
;
652 /** @ifinfo_lock: lock protecting ifinfo_list and its members */
653 spinlock_t ifinfo_lock
;
655 /** @if_incoming: pointer to incoming hard-interface */
656 struct batadv_hard_iface
*if_incoming
;
658 /** @last_seen: when last packet via this neighbor was received */
659 unsigned long last_seen
;
661 /** @hardif_neigh: hardif_neigh of this neighbor */
662 struct batadv_hardif_neigh_node
*hardif_neigh
;
664 /** @refcount: number of contexts the object is used */
665 struct kref refcount
;
667 /** @rcu: struct used for freeing in an RCU-safe manner */
672 * struct batadv_neigh_ifinfo_bat_iv - neighbor information per outgoing
673 * interface for B.A.T.M.A.N. IV
675 struct batadv_neigh_ifinfo_bat_iv
{
676 /** @tq_recv: ring buffer of received TQ values from this neigh node */
677 u8 tq_recv
[BATADV_TQ_GLOBAL_WINDOW_SIZE
];
679 /** @tq_index: ring buffer index */
683 * @tq_avg: averaged tq of all tq values in the ring buffer (tq_recv)
688 * @real_bits: bitfield containing the number of OGMs received from this
689 * neigh node (relative to orig_node->last_real_seqno)
691 DECLARE_BITMAP(real_bits
, BATADV_TQ_LOCAL_WINDOW_SIZE
);
693 /** @real_packet_count: counted result of real_bits */
694 u8 real_packet_count
;
698 * struct batadv_neigh_ifinfo_bat_v - neighbor information per outgoing
699 * interface for B.A.T.M.A.N. V
701 struct batadv_neigh_ifinfo_bat_v
{
703 * @throughput: last throughput metric received from originator via this
708 /** @last_seqno: last sequence number known for this neighbor */
713 * struct batadv_neigh_ifinfo - neighbor information per outgoing interface
715 struct batadv_neigh_ifinfo
{
716 /** @list: list node for &batadv_neigh_node.ifinfo_list */
717 struct hlist_node list
;
719 /** @if_outgoing: pointer to outgoing hard-interface */
720 struct batadv_hard_iface
*if_outgoing
;
722 /** @bat_iv: B.A.T.M.A.N. IV private structure */
723 struct batadv_neigh_ifinfo_bat_iv bat_iv
;
725 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
726 /** @bat_v: B.A.T.M.A.N. V private data */
727 struct batadv_neigh_ifinfo_bat_v bat_v
;
730 /** @last_ttl: last received ttl from this neigh node */
733 /** @refcount: number of contexts the object is used */
734 struct kref refcount
;
736 /** @rcu: struct used for freeing in a RCU-safe manner */
740 #ifdef CONFIG_BATMAN_ADV_BLA
743 * struct batadv_bcast_duplist_entry - structure for LAN broadcast suppression
745 struct batadv_bcast_duplist_entry
{
746 /** @orig: mac address of orig node originating the broadcast */
749 /** @crc: crc32 checksum of broadcast payload */
752 /** @entrytime: time when the broadcast packet was received */
753 unsigned long entrytime
;
758 * enum batadv_counters - indices for traffic counters
760 enum batadv_counters
{
761 /** @BATADV_CNT_TX: transmitted payload traffic packet counter */
764 /** @BATADV_CNT_TX_BYTES: transmitted payload traffic bytes counter */
768 * @BATADV_CNT_TX_DROPPED: dropped transmission payload traffic packet
771 BATADV_CNT_TX_DROPPED
,
773 /** @BATADV_CNT_RX: received payload traffic packet counter */
776 /** @BATADV_CNT_RX_BYTES: received payload traffic bytes counter */
779 /** @BATADV_CNT_FORWARD: forwarded payload traffic packet counter */
783 * @BATADV_CNT_FORWARD_BYTES: forwarded payload traffic bytes counter
785 BATADV_CNT_FORWARD_BYTES
,
788 * @BATADV_CNT_MGMT_TX: transmitted routing protocol traffic packet
794 * @BATADV_CNT_MGMT_TX_BYTES: transmitted routing protocol traffic bytes
797 BATADV_CNT_MGMT_TX_BYTES
,
800 * @BATADV_CNT_MGMT_RX: received routing protocol traffic packet counter
805 * @BATADV_CNT_MGMT_RX_BYTES: received routing protocol traffic bytes
808 BATADV_CNT_MGMT_RX_BYTES
,
810 /** @BATADV_CNT_FRAG_TX: transmitted fragment traffic packet counter */
814 * @BATADV_CNT_FRAG_TX_BYTES: transmitted fragment traffic bytes counter
816 BATADV_CNT_FRAG_TX_BYTES
,
818 /** @BATADV_CNT_FRAG_RX: received fragment traffic packet counter */
822 * @BATADV_CNT_FRAG_RX_BYTES: received fragment traffic bytes counter
824 BATADV_CNT_FRAG_RX_BYTES
,
826 /** @BATADV_CNT_FRAG_FWD: forwarded fragment traffic packet counter */
830 * @BATADV_CNT_FRAG_FWD_BYTES: forwarded fragment traffic bytes counter
832 BATADV_CNT_FRAG_FWD_BYTES
,
835 * @BATADV_CNT_TT_REQUEST_TX: transmitted tt req traffic packet counter
837 BATADV_CNT_TT_REQUEST_TX
,
839 /** @BATADV_CNT_TT_REQUEST_RX: received tt req traffic packet counter */
840 BATADV_CNT_TT_REQUEST_RX
,
843 * @BATADV_CNT_TT_RESPONSE_TX: transmitted tt resp traffic packet
846 BATADV_CNT_TT_RESPONSE_TX
,
849 * @BATADV_CNT_TT_RESPONSE_RX: received tt resp traffic packet counter
851 BATADV_CNT_TT_RESPONSE_RX
,
854 * @BATADV_CNT_TT_ROAM_ADV_TX: transmitted tt roam traffic packet
857 BATADV_CNT_TT_ROAM_ADV_TX
,
860 * @BATADV_CNT_TT_ROAM_ADV_RX: received tt roam traffic packet counter
862 BATADV_CNT_TT_ROAM_ADV_RX
,
864 #ifdef CONFIG_BATMAN_ADV_DAT
866 * @BATADV_CNT_DAT_GET_TX: transmitted dht GET traffic packet counter
868 BATADV_CNT_DAT_GET_TX
,
870 /** @BATADV_CNT_DAT_GET_RX: received dht GET traffic packet counter */
871 BATADV_CNT_DAT_GET_RX
,
874 * @BATADV_CNT_DAT_PUT_TX: transmitted dht PUT traffic packet counter
876 BATADV_CNT_DAT_PUT_TX
,
878 /** @BATADV_CNT_DAT_PUT_RX: received dht PUT traffic packet counter */
879 BATADV_CNT_DAT_PUT_RX
,
882 * @BATADV_CNT_DAT_CACHED_REPLY_TX: transmitted dat cache reply traffic
885 BATADV_CNT_DAT_CACHED_REPLY_TX
,
888 #ifdef CONFIG_BATMAN_ADV_NC
890 * @BATADV_CNT_NC_CODE: transmitted nc-combined traffic packet counter
895 * @BATADV_CNT_NC_CODE_BYTES: transmitted nc-combined traffic bytes
898 BATADV_CNT_NC_CODE_BYTES
,
901 * @BATADV_CNT_NC_RECODE: transmitted nc-recombined traffic packet
904 BATADV_CNT_NC_RECODE
,
907 * @BATADV_CNT_NC_RECODE_BYTES: transmitted nc-recombined traffic bytes
910 BATADV_CNT_NC_RECODE_BYTES
,
913 * @BATADV_CNT_NC_BUFFER: counter for packets buffered for later nc
916 BATADV_CNT_NC_BUFFER
,
919 * @BATADV_CNT_NC_DECODE: received and nc-decoded traffic packet counter
921 BATADV_CNT_NC_DECODE
,
924 * @BATADV_CNT_NC_DECODE_BYTES: received and nc-decoded traffic bytes
927 BATADV_CNT_NC_DECODE_BYTES
,
930 * @BATADV_CNT_NC_DECODE_FAILED: received and decode-failed traffic
933 BATADV_CNT_NC_DECODE_FAILED
,
936 * @BATADV_CNT_NC_SNIFFED: counter for nc-decoded packets received in
939 BATADV_CNT_NC_SNIFFED
,
942 /** @BATADV_CNT_NUM: number of traffic counters */
947 * struct batadv_priv_tt - per mesh interface translation table data
949 struct batadv_priv_tt
{
950 /** @vn: translation table version number */
954 * @ogm_append_cnt: counter of number of OGMs containing the local tt
957 atomic_t ogm_append_cnt
;
959 /** @local_changes: changes registered in an originator interval */
960 atomic_t local_changes
;
963 * @changes_list: tracks tt local changes within an originator interval
965 struct list_head changes_list
;
967 /** @local_hash: local translation table hash table */
968 struct batadv_hashtable
*local_hash
;
970 /** @global_hash: global translation table hash table */
971 struct batadv_hashtable
*global_hash
;
973 /** @req_list: list of pending & unanswered tt_requests */
974 struct hlist_head req_list
;
977 * @roam_list: list of the last roaming events of each client limiting
978 * the number of roaming events to avoid route flapping
980 struct list_head roam_list
;
982 /** @changes_list_lock: lock protecting changes_list */
983 spinlock_t changes_list_lock
;
985 /** @req_list_lock: lock protecting req_list */
986 spinlock_t req_list_lock
;
988 /** @roam_list_lock: lock protecting roam_list */
989 spinlock_t roam_list_lock
;
991 /** @last_changeset: last tt changeset this host has generated */
992 unsigned char *last_changeset
;
995 * @last_changeset_len: length of last tt changeset this host has
998 s16 last_changeset_len
;
1001 * @last_changeset_lock: lock protecting last_changeset &
1002 * last_changeset_len
1004 spinlock_t last_changeset_lock
;
1007 * @commit_lock: prevents from executing a local TT commit while reading
1008 * the local table. The local TT commit is made up of two operations
1009 * (data structure update and metadata -CRC/TTVN- recalculation) and
1010 * they have to be executed atomically in order to avoid another thread
1011 * to read the table/metadata between those.
1013 spinlock_t commit_lock
;
1015 /** @work: work queue callback item for translation table purging */
1016 struct delayed_work work
;
1019 #ifdef CONFIG_BATMAN_ADV_BLA
1022 * struct batadv_priv_bla - per mesh interface bridge loop avoidance data
1024 struct batadv_priv_bla
{
1025 /** @num_requests: number of bla requests in flight */
1026 atomic_t num_requests
;
1029 * @claim_hash: hash table containing mesh nodes this host has claimed
1031 struct batadv_hashtable
*claim_hash
;
1034 * @backbone_hash: hash table containing all detected backbone gateways
1036 struct batadv_hashtable
*backbone_hash
;
1038 /** @loopdetect_addr: MAC address used for own loopdetection frames */
1039 u8 loopdetect_addr
[ETH_ALEN
];
1042 * @loopdetect_lasttime: time when the loopdetection frames were sent
1044 unsigned long loopdetect_lasttime
;
1047 * @loopdetect_next: how many periods to wait for the next loopdetect
1050 atomic_t loopdetect_next
;
1053 * @bcast_duplist: recently received broadcast packets array (for
1054 * broadcast duplicate suppression)
1056 struct batadv_bcast_duplist_entry bcast_duplist
[BATADV_DUPLIST_SIZE
];
1059 * @bcast_duplist_curr: index of last broadcast packet added to
1062 int bcast_duplist_curr
;
1065 * @bcast_duplist_lock: lock protecting bcast_duplist &
1066 * bcast_duplist_curr
1068 spinlock_t bcast_duplist_lock
;
1070 /** @claim_dest: local claim data (e.g. claim group) */
1071 struct batadv_bla_claim_dst claim_dest
;
1073 /** @work: work queue callback item for cleanups & bla announcements */
1074 struct delayed_work work
;
1078 #ifdef CONFIG_BATMAN_ADV_DEBUG
1081 * struct batadv_priv_debug_log - debug logging data
1083 struct batadv_priv_debug_log
{
1084 /** @log_buff: buffer holding the logs (ring buffer) */
1085 char log_buff
[BATADV_LOG_BUF_LEN
];
1087 /** @log_start: index of next character to read */
1088 unsigned long log_start
;
1090 /** @log_end: index of next character to write */
1091 unsigned long log_end
;
1093 /** @lock: lock protecting log_buff, log_start & log_end */
1096 /** @queue_wait: log reader's wait queue */
1097 wait_queue_head_t queue_wait
;
1102 * struct batadv_priv_gw - per mesh interface gateway data
1104 struct batadv_priv_gw
{
1105 /** @gateway_list: list of available gateway nodes */
1106 struct hlist_head gateway_list
;
1108 /** @list_lock: lock protecting gateway_list, curr_gw, generation */
1109 spinlock_t list_lock
;
1111 /** @curr_gw: pointer to currently selected gateway node */
1112 struct batadv_gw_node __rcu
*curr_gw
;
1114 /** @generation: current (generation) sequence number */
1115 unsigned int generation
;
1118 * @mode: gateway operation: off, client or server (see batadv_gw_modes)
1122 /** @sel_class: gateway selection class (applies if gw_mode client) */
1126 * @bandwidth_down: advertised uplink download bandwidth (if gw_mode
1129 atomic_t bandwidth_down
;
1132 * @bandwidth_up: advertised uplink upload bandwidth (if gw_mode server)
1134 atomic_t bandwidth_up
;
1136 /** @reselect: bool indicating a gateway re-selection is in progress */
1141 * struct batadv_priv_tvlv - per mesh interface tvlv data
1143 struct batadv_priv_tvlv
{
1145 * @container_list: list of registered tvlv containers to be sent with
1148 struct hlist_head container_list
;
1150 /** @handler_list: list of the various tvlv content handlers */
1151 struct hlist_head handler_list
;
1153 /** @container_list_lock: protects tvlv container list access */
1154 spinlock_t container_list_lock
;
1156 /** @handler_list_lock: protects handler list access */
1157 spinlock_t handler_list_lock
;
1160 #ifdef CONFIG_BATMAN_ADV_DAT
1163 * struct batadv_priv_dat - per mesh interface DAT private data
1165 struct batadv_priv_dat
{
1166 /** @addr: node DAT address */
1167 batadv_dat_addr_t addr
;
1169 /** @hash: hashtable representing the local ARP cache */
1170 struct batadv_hashtable
*hash
;
1172 /** @work: work queue callback item for cache purging */
1173 struct delayed_work work
;
1177 #ifdef CONFIG_BATMAN_ADV_MCAST
1179 * struct batadv_mcast_querier_state - IGMP/MLD querier state when bridged
1181 struct batadv_mcast_querier_state
{
1182 /** @exists: whether a querier exists in the mesh */
1183 unsigned char exists
:1;
1186 * @shadowing: if a querier exists, whether it is potentially shadowing
1187 * multicast listeners (i.e. querier is behind our own bridge segment)
1189 unsigned char shadowing
:1;
1193 * struct batadv_mcast_mla_flags - flags for the querier, bridge and tvlv state
1195 struct batadv_mcast_mla_flags
{
1196 /** @querier_ipv4: the current state of an IGMP querier in the mesh */
1197 struct batadv_mcast_querier_state querier_ipv4
;
1199 /** @querier_ipv6: the current state of an MLD querier in the mesh */
1200 struct batadv_mcast_querier_state querier_ipv6
;
1202 /** @enabled: whether the multicast tvlv is currently enabled */
1203 unsigned char enabled
:1;
1205 /** @bridged: whether the soft interface has a bridge on top */
1206 unsigned char bridged
:1;
1208 /** @tvlv_flags: the flags we have last sent in our mcast tvlv */
1213 * struct batadv_priv_mcast - per mesh interface mcast data
1215 struct batadv_priv_mcast
{
1217 * @mla_list: list of multicast addresses we are currently announcing
1220 struct hlist_head mla_list
; /* see __batadv_mcast_mla_update() */
1223 * @want_all_unsnoopables_list: a list of orig_nodes wanting all
1224 * unsnoopable multicast traffic
1226 struct hlist_head want_all_unsnoopables_list
;
1229 * @want_all_ipv4_list: a list of orig_nodes wanting all IPv4 multicast
1232 struct hlist_head want_all_ipv4_list
;
1235 * @want_all_ipv6_list: a list of orig_nodes wanting all IPv6 multicast
1238 struct hlist_head want_all_ipv6_list
;
1241 * @want_all_rtr4_list: a list of orig_nodes wanting all routable IPv4
1244 struct hlist_head want_all_rtr4_list
;
1247 * @want_all_rtr6_list: a list of orig_nodes wanting all routable IPv6
1250 struct hlist_head want_all_rtr6_list
;
1253 * @mla_flags: flags for the querier, bridge and tvlv state
1255 struct batadv_mcast_mla_flags mla_flags
;
1258 * @mla_lock: a lock protecting mla_list and mla_flags
1260 spinlock_t mla_lock
;
1263 * @num_want_all_unsnoopables: number of nodes wanting unsnoopable IP
1266 atomic_t num_want_all_unsnoopables
;
1268 /** @num_want_all_ipv4: counter for items in want_all_ipv4_list */
1269 atomic_t num_want_all_ipv4
;
1271 /** @num_want_all_ipv6: counter for items in want_all_ipv6_list */
1272 atomic_t num_want_all_ipv6
;
1274 /** @num_want_all_rtr4: counter for items in want_all_rtr4_list */
1275 atomic_t num_want_all_rtr4
;
1277 /** @num_want_all_rtr6: counter for items in want_all_rtr6_list */
1278 atomic_t num_want_all_rtr6
;
1281 * @want_lists_lock: lock for protecting modifications to mcasts
1282 * want_all_{unsnoopables,ipv4,ipv6}_list (traversals are rcu-locked)
1284 spinlock_t want_lists_lock
;
1286 /** @work: work queue callback item for multicast TT and TVLV updates */
1287 struct delayed_work work
;
1292 * struct batadv_priv_nc - per mesh interface network coding private data
1294 struct batadv_priv_nc
{
1295 /** @work: work queue callback item for cleanup */
1296 struct delayed_work work
;
1299 * @min_tq: only consider neighbors for encoding if neigh_tq > min_tq
1304 * @max_fwd_delay: maximum packet forward delay to allow coding of
1310 * @max_buffer_time: buffer time for sniffed packets used to decoding
1312 u32 max_buffer_time
;
1315 * @timestamp_fwd_flush: timestamp of last forward packet queue flush
1317 unsigned long timestamp_fwd_flush
;
1320 * @timestamp_sniffed_purge: timestamp of last sniffed packet queue
1323 unsigned long timestamp_sniffed_purge
;
1326 * @coding_hash: Hash table used to buffer skbs while waiting for
1327 * another incoming skb to code it with. Skbs are added to the buffer
1328 * just before being forwarded in routing.c
1330 struct batadv_hashtable
*coding_hash
;
1333 * @decoding_hash: Hash table used to buffer skbs that might be needed
1334 * to decode a received coded skb. The buffer is used for 1) skbs
1335 * arriving on the soft-interface; 2) skbs overheard on the
1336 * hard-interface; and 3) skbs forwarded by batman-adv.
1338 struct batadv_hashtable
*decoding_hash
;
1342 * struct batadv_tp_unacked - unacked packet meta-information
1344 * This struct is supposed to represent a buffer unacked packet. However, since
1345 * the purpose of the TP meter is to count the traffic only, there is no need to
1346 * store the entire sk_buff, the starting offset and the length are enough
1348 struct batadv_tp_unacked
{
1349 /** @seqno: seqno of the unacked packet */
1352 /** @len: length of the packet */
1355 /** @list: list node for &batadv_tp_vars.unacked_list */
1356 struct list_head list
;
1360 * enum batadv_tp_meter_role - Modus in tp meter session
1362 enum batadv_tp_meter_role
{
1363 /** @BATADV_TP_RECEIVER: Initialized as receiver */
1366 /** @BATADV_TP_SENDER: Initialized as sender */
1371 * struct batadv_tp_vars - tp meter private variables per session
1373 struct batadv_tp_vars
{
1374 /** @list: list node for &bat_priv.tp_list */
1375 struct hlist_node list
;
1377 /** @timer: timer for ack (receiver) and retry (sender) */
1378 struct timer_list timer
;
1380 /** @bat_priv: pointer to the mesh object */
1381 struct batadv_priv
*bat_priv
;
1383 /** @start_time: start time in jiffies */
1384 unsigned long start_time
;
1386 /** @other_end: mac address of remote */
1387 u8 other_end
[ETH_ALEN
];
1389 /** @role: receiver/sender modi */
1390 enum batadv_tp_meter_role role
;
1392 /** @sending: sending binary semaphore: 1 if sending, 0 is not */
1395 /** @reason: reason for a stopped session */
1396 enum batadv_tp_meter_reason reason
;
1398 /** @finish_work: work item for the finishing procedure */
1399 struct delayed_work finish_work
;
1401 /** @test_length: test length in milliseconds */
1404 /** @session: TP session identifier */
1407 /** @icmp_uid: local ICMP "socket" index */
1410 /* sender variables */
1412 /** @dec_cwnd: decimal part of the cwnd used during linear growth */
1415 /** @cwnd: current size of the congestion window */
1418 /** @cwnd_lock: lock do protect @cwnd & @dec_cwnd */
1419 spinlock_t cwnd_lock
;
1422 * @ss_threshold: Slow Start threshold. Once cwnd exceeds this value the
1423 * connection switches to the Congestion Avoidance state
1427 /** @last_acked: last acked byte */
1428 atomic_t last_acked
;
1430 /** @last_sent: last sent byte, not yet acked */
1433 /** @tot_sent: amount of data sent/ACKed so far */
1434 atomic64_t tot_sent
;
1436 /** @dup_acks: duplicate ACKs counter */
1439 /** @fast_recovery: true if in Fast Recovery mode */
1440 unsigned char fast_recovery
:1;
1442 /** @recover: last sent seqno when entering Fast Recovery */
1445 /** @rto: sender timeout */
1448 /** @srtt: smoothed RTT scaled by 2^3 */
1451 /** @rttvar: RTT variation scaled by 2^2 */
1455 * @more_bytes: waiting queue anchor when waiting for more ack/retry
1458 wait_queue_head_t more_bytes
;
1460 /** @prerandom_offset: offset inside the prerandom buffer */
1461 u32 prerandom_offset
;
1463 /** @prerandom_lock: spinlock protecting access to prerandom_offset */
1464 spinlock_t prerandom_lock
;
1466 /* receiver variables */
1468 /** @last_recv: last in-order received packet */
1471 /** @unacked_list: list of unacked packets (meta-info only) */
1472 struct list_head unacked_list
;
1474 /** @unacked_lock: protect unacked_list */
1475 spinlock_t unacked_lock
;
1477 /** @last_recv_time: time (jiffies) a msg was received */
1478 unsigned long last_recv_time
;
1480 /** @refcount: number of context where the object is used */
1481 struct kref refcount
;
1483 /** @rcu: struct used for freeing in an RCU-safe manner */
1484 struct rcu_head rcu
;
1488 * struct batadv_softif_vlan - per VLAN attributes set
1490 struct batadv_softif_vlan
{
1491 /** @bat_priv: pointer to the mesh object */
1492 struct batadv_priv
*bat_priv
;
1494 /** @vid: VLAN identifier */
1497 /** @ap_isolation: AP isolation state */
1498 atomic_t ap_isolation
; /* boolean */
1500 /** @tt: TT private attributes (VLAN specific) */
1501 struct batadv_vlan_tt tt
;
1503 /** @list: list node for &bat_priv.softif_vlan_list */
1504 struct hlist_node list
;
1507 * @refcount: number of context where this object is currently in use
1509 struct kref refcount
;
1511 /** @rcu: struct used for freeing in a RCU-safe manner */
1512 struct rcu_head rcu
;
1516 * struct batadv_priv_bat_v - B.A.T.M.A.N. V per soft-interface private data
1518 struct batadv_priv_bat_v
{
1519 /** @ogm_buff: buffer holding the OGM packet */
1520 unsigned char *ogm_buff
;
1522 /** @ogm_buff_len: length of the OGM packet buffer */
1525 /** @ogm_seqno: OGM sequence number - used to identify each OGM */
1528 /** @ogm_buff_mutex: lock protecting ogm_buff and ogm_buff_len */
1529 struct mutex ogm_buff_mutex
;
1531 /** @ogm_wq: workqueue used to schedule OGM transmissions */
1532 struct delayed_work ogm_wq
;
1536 * struct batadv_priv - per mesh interface data
1538 struct batadv_priv
{
1540 * @mesh_state: current status of the mesh
1541 * (inactive/active/deactivating)
1543 atomic_t mesh_state
;
1545 /** @soft_iface: net device which holds this struct as private data */
1546 struct net_device
*soft_iface
;
1549 * @bat_counters: mesh internal traffic statistic counters (see
1552 u64 __percpu
*bat_counters
; /* Per cpu counters */
1555 * @aggregated_ogms: bool indicating whether OGM aggregation is enabled
1557 atomic_t aggregated_ogms
;
1559 /** @bonding: bool indicating whether traffic bonding is enabled */
1563 * @fragmentation: bool indicating whether traffic fragmentation is
1566 atomic_t fragmentation
;
1569 * @packet_size_max: max packet size that can be transmitted via
1570 * multiple fragmented skbs or a single frame if fragmentation is
1573 atomic_t packet_size_max
;
1576 * @frag_seqno: incremental counter to identify chains of egress
1579 atomic_t frag_seqno
;
1581 #ifdef CONFIG_BATMAN_ADV_BLA
1583 * @bridge_loop_avoidance: bool indicating whether bridge loop
1584 * avoidance is enabled
1586 atomic_t bridge_loop_avoidance
;
1589 #ifdef CONFIG_BATMAN_ADV_DAT
1591 * @distributed_arp_table: bool indicating whether distributed ARP table
1594 atomic_t distributed_arp_table
;
1597 #ifdef CONFIG_BATMAN_ADV_MCAST
1599 * @multicast_mode: Enable or disable multicast optimizations on this
1600 * node's sender/originating side
1602 atomic_t multicast_mode
;
1605 * @multicast_fanout: Maximum number of packet copies to generate for a
1606 * multicast-to-unicast conversion
1608 atomic_t multicast_fanout
;
1611 /** @orig_interval: OGM broadcast interval in milliseconds */
1612 atomic_t orig_interval
;
1615 * @hop_penalty: penalty which will be applied to an OGM's tq-field on
1618 atomic_t hop_penalty
;
1620 #ifdef CONFIG_BATMAN_ADV_DEBUG
1621 /** @log_level: configured log level (see batadv_dbg_level) */
1626 * @isolation_mark: the skb->mark value used to match packets for AP
1632 * @isolation_mark_mask: bitmask identifying the bits in skb->mark to be
1633 * used for the isolation mark
1635 u32 isolation_mark_mask
;
1637 /** @bcast_seqno: last sent broadcast packet sequence number */
1638 atomic_t bcast_seqno
;
1641 * @bcast_queue_left: number of remaining buffered broadcast packet
1644 atomic_t bcast_queue_left
;
1646 /** @batman_queue_left: number of remaining OGM packet slots */
1647 atomic_t batman_queue_left
;
1649 /** @forw_bat_list: list of aggregated OGMs that will be forwarded */
1650 struct hlist_head forw_bat_list
;
1653 * @forw_bcast_list: list of broadcast packets that will be
1656 struct hlist_head forw_bcast_list
;
1658 /** @tp_list: list of tp sessions */
1659 struct hlist_head tp_list
;
1661 /** @tp_num: number of currently active tp sessions */
1662 struct batadv_hashtable
*orig_hash
;
1664 /** @orig_hash: hash table containing mesh participants (orig nodes) */
1665 spinlock_t forw_bat_list_lock
;
1667 /** @forw_bat_list_lock: lock protecting forw_bat_list */
1668 spinlock_t forw_bcast_list_lock
;
1670 /** @forw_bcast_list_lock: lock protecting forw_bcast_list */
1671 spinlock_t tp_list_lock
;
1673 /** @tp_list_lock: spinlock protecting @tp_list */
1676 /** @orig_work: work queue callback item for orig node purging */
1677 struct delayed_work orig_work
;
1680 * @primary_if: one of the hard-interfaces assigned to this mesh
1681 * interface becomes the primary interface
1683 struct batadv_hard_iface __rcu
*primary_if
; /* rcu protected pointer */
1685 /** @algo_ops: routing algorithm used by this mesh interface */
1686 struct batadv_algo_ops
*algo_ops
;
1689 * @softif_vlan_list: a list of softif_vlan structs, one per VLAN
1690 * created on top of the mesh interface represented by this object
1692 struct hlist_head softif_vlan_list
;
1694 /** @softif_vlan_list_lock: lock protecting softif_vlan_list */
1695 spinlock_t softif_vlan_list_lock
;
1697 #ifdef CONFIG_BATMAN_ADV_BLA
1698 /** @bla: bridge loop avoidance data */
1699 struct batadv_priv_bla bla
;
1702 #ifdef CONFIG_BATMAN_ADV_DEBUG
1703 /** @debug_log: holding debug logging relevant data */
1704 struct batadv_priv_debug_log
*debug_log
;
1707 /** @gw: gateway data */
1708 struct batadv_priv_gw gw
;
1710 /** @tt: translation table data */
1711 struct batadv_priv_tt tt
;
1713 /** @tvlv: type-version-length-value data */
1714 struct batadv_priv_tvlv tvlv
;
1716 #ifdef CONFIG_BATMAN_ADV_DAT
1717 /** @dat: distributed arp table data */
1718 struct batadv_priv_dat dat
;
1721 #ifdef CONFIG_BATMAN_ADV_MCAST
1722 /** @mcast: multicast data */
1723 struct batadv_priv_mcast mcast
;
1726 #ifdef CONFIG_BATMAN_ADV_NC
1728 * @network_coding: bool indicating whether network coding is enabled
1730 atomic_t network_coding
;
1732 /** @nc: network coding data */
1733 struct batadv_priv_nc nc
;
1734 #endif /* CONFIG_BATMAN_ADV_NC */
1736 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
1737 /** @bat_v: B.A.T.M.A.N. V per soft-interface private data */
1738 struct batadv_priv_bat_v bat_v
;
1743 * struct batadv_socket_client - layer2 icmp socket client data
1745 struct batadv_socket_client
{
1747 * @queue_list: packet queue for packets destined for this socket client
1749 struct list_head queue_list
;
1751 /** @queue_len: number of packets in the packet queue (queue_list) */
1752 unsigned int queue_len
;
1754 /** @index: socket client's index in the batadv_socket_client_hash */
1755 unsigned char index
;
1757 /** @lock: lock protecting queue_list, queue_len & index */
1760 /** @queue_wait: socket client's wait queue */
1761 wait_queue_head_t queue_wait
;
1763 /** @bat_priv: pointer to soft_iface this client belongs to */
1764 struct batadv_priv
*bat_priv
;
1768 * struct batadv_socket_packet - layer2 icmp packet for socket client
1770 struct batadv_socket_packet
{
1771 /** @list: list node for &batadv_socket_client.queue_list */
1772 struct list_head list
;
1774 /** @icmp_len: size of the layer2 icmp packet */
1777 /** @icmp_packet: layer2 icmp packet */
1778 u8 icmp_packet
[BATADV_ICMP_MAX_PACKET_SIZE
];
1781 #ifdef CONFIG_BATMAN_ADV_BLA
1784 * struct batadv_bla_backbone_gw - batman-adv gateway bridged into the LAN
1786 struct batadv_bla_backbone_gw
{
1788 * @orig: originator address of backbone node (mac address of primary
1793 /** @vid: vlan id this gateway was detected on */
1796 /** @hash_entry: hlist node for &batadv_priv_bla.backbone_hash */
1797 struct hlist_node hash_entry
;
1799 /** @bat_priv: pointer to soft_iface this backbone gateway belongs to */
1800 struct batadv_priv
*bat_priv
;
1802 /** @lasttime: last time we heard of this backbone gw */
1803 unsigned long lasttime
;
1806 * @wait_periods: grace time for bridge forward delays and bla group
1807 * forming at bootup phase - no bcast traffic is formwared until it has
1810 atomic_t wait_periods
;
1813 * @request_sent: if this bool is set to true we are out of sync with
1814 * this backbone gateway - no bcast traffic is formwared until the
1815 * situation was resolved
1817 atomic_t request_sent
;
1819 /** @crc: crc16 checksum over all claims */
1822 /** @crc_lock: lock protecting crc */
1823 spinlock_t crc_lock
;
1825 /** @report_work: work struct for reporting detected loops */
1826 struct work_struct report_work
;
1828 /** @refcount: number of contexts the object is used */
1829 struct kref refcount
;
1831 /** @rcu: struct used for freeing in an RCU-safe manner */
1832 struct rcu_head rcu
;
1836 * struct batadv_bla_claim - claimed non-mesh client structure
1838 struct batadv_bla_claim
{
1839 /** @addr: mac address of claimed non-mesh client */
1842 /** @vid: vlan id this client was detected on */
1845 /** @backbone_gw: pointer to backbone gw claiming this client */
1846 struct batadv_bla_backbone_gw
*backbone_gw
;
1848 /** @backbone_lock: lock protecting backbone_gw pointer */
1849 spinlock_t backbone_lock
;
1851 /** @lasttime: last time we heard of claim (locals only) */
1852 unsigned long lasttime
;
1854 /** @hash_entry: hlist node for &batadv_priv_bla.claim_hash */
1855 struct hlist_node hash_entry
;
1857 /** @refcount: number of contexts the object is used */
1858 struct rcu_head rcu
;
1860 /** @rcu: struct used for freeing in an RCU-safe manner */
1861 struct kref refcount
;
1866 * struct batadv_tt_common_entry - tt local & tt global common data
1868 struct batadv_tt_common_entry
{
1869 /** @addr: mac address of non-mesh client */
1872 /** @vid: VLAN identifier */
1876 * @hash_entry: hlist node for &batadv_priv_tt.local_hash or for
1877 * &batadv_priv_tt.global_hash
1879 struct hlist_node hash_entry
;
1881 /** @flags: various state handling flags (see batadv_tt_client_flags) */
1884 /** @added_at: timestamp used for purging stale tt common entries */
1885 unsigned long added_at
;
1887 /** @refcount: number of contexts the object is used */
1888 struct kref refcount
;
1890 /** @rcu: struct used for freeing in an RCU-safe manner */
1891 struct rcu_head rcu
;
1895 * struct batadv_tt_local_entry - translation table local entry data
1897 struct batadv_tt_local_entry
{
1898 /** @common: general translation table data */
1899 struct batadv_tt_common_entry common
;
1901 /** @last_seen: timestamp used for purging stale tt local entries */
1902 unsigned long last_seen
;
1904 /** @vlan: soft-interface vlan of the entry */
1905 struct batadv_softif_vlan
*vlan
;
1909 * struct batadv_tt_global_entry - translation table global entry data
1911 struct batadv_tt_global_entry
{
1912 /** @common: general translation table data */
1913 struct batadv_tt_common_entry common
;
1915 /** @orig_list: list of orig nodes announcing this non-mesh client */
1916 struct hlist_head orig_list
;
1918 /** @orig_list_count: number of items in the orig_list */
1919 atomic_t orig_list_count
;
1921 /** @list_lock: lock protecting orig_list */
1922 spinlock_t list_lock
;
1924 /** @roam_at: time at which TT_GLOBAL_ROAM was set */
1925 unsigned long roam_at
;
1929 * struct batadv_tt_orig_list_entry - orig node announcing a non-mesh client
1931 struct batadv_tt_orig_list_entry
{
1932 /** @orig_node: pointer to orig node announcing this non-mesh client */
1933 struct batadv_orig_node
*orig_node
;
1936 * @ttvn: translation table version number which added the non-mesh
1941 /** @flags: per orig entry TT sync flags */
1944 /** @list: list node for &batadv_tt_global_entry.orig_list */
1945 struct hlist_node list
;
1947 /** @refcount: number of contexts the object is used */
1948 struct kref refcount
;
1950 /** @rcu: struct used for freeing in an RCU-safe manner */
1951 struct rcu_head rcu
;
1955 * struct batadv_tt_change_node - structure for tt changes occurred
1957 struct batadv_tt_change_node
{
1958 /** @list: list node for &batadv_priv_tt.changes_list */
1959 struct list_head list
;
1961 /** @change: holds the actual translation table diff data */
1962 struct batadv_tvlv_tt_change change
;
1966 * struct batadv_tt_req_node - data to keep track of the tt requests in flight
1968 struct batadv_tt_req_node
{
1970 * @addr: mac address of the originator this request was sent to
1974 /** @issued_at: timestamp used for purging stale tt requests */
1975 unsigned long issued_at
;
1977 /** @refcount: number of contexts the object is used by */
1978 struct kref refcount
;
1980 /** @list: list node for &batadv_priv_tt.req_list */
1981 struct hlist_node list
;
1985 * struct batadv_tt_roam_node - roaming client data
1987 struct batadv_tt_roam_node
{
1988 /** @addr: mac address of the client in the roaming phase */
1992 * @counter: number of allowed roaming events per client within a single
1993 * OGM interval (changes are committed with each OGM)
1998 * @first_time: timestamp used for purging stale roaming node entries
2000 unsigned long first_time
;
2002 /** @list: list node for &batadv_priv_tt.roam_list */
2003 struct list_head list
;
2007 * struct batadv_nc_node - network coding node
2009 struct batadv_nc_node
{
2010 /** @list: next and prev pointer for the list handling */
2011 struct list_head list
;
2013 /** @addr: the node's mac address */
2016 /** @refcount: number of contexts the object is used by */
2017 struct kref refcount
;
2019 /** @rcu: struct used for freeing in an RCU-safe manner */
2020 struct rcu_head rcu
;
2022 /** @orig_node: pointer to corresponding orig node struct */
2023 struct batadv_orig_node
*orig_node
;
2025 /** @last_seen: timestamp of last ogm received from this node */
2026 unsigned long last_seen
;
2030 * struct batadv_nc_path - network coding path
2032 struct batadv_nc_path
{
2033 /** @hash_entry: next and prev pointer for the list handling */
2034 struct hlist_node hash_entry
;
2036 /** @rcu: struct used for freeing in an RCU-safe manner */
2037 struct rcu_head rcu
;
2039 /** @refcount: number of contexts the object is used by */
2040 struct kref refcount
;
2042 /** @packet_list: list of buffered packets for this path */
2043 struct list_head packet_list
;
2045 /** @packet_list_lock: access lock for packet list */
2046 spinlock_t packet_list_lock
;
2048 /** @next_hop: next hop (destination) of path */
2049 u8 next_hop
[ETH_ALEN
];
2051 /** @prev_hop: previous hop (source) of path */
2052 u8 prev_hop
[ETH_ALEN
];
2054 /** @last_valid: timestamp for last validation of path */
2055 unsigned long last_valid
;
2059 * struct batadv_nc_packet - network coding packet used when coding and
2062 struct batadv_nc_packet
{
2063 /** @list: next and prev pointer for the list handling */
2064 struct list_head list
;
2066 /** @packet_id: crc32 checksum of skb data */
2070 * @timestamp: field containing the info when the packet was added to
2073 unsigned long timestamp
;
2075 /** @neigh_node: pointer to original next hop neighbor of skb */
2076 struct batadv_neigh_node
*neigh_node
;
2078 /** @skb: skb which can be encoded or used for decoding */
2079 struct sk_buff
*skb
;
2081 /** @nc_path: pointer to path this nc packet is attached to */
2082 struct batadv_nc_path
*nc_path
;
2086 * struct batadv_skb_cb - control buffer structure used to store private data
2087 * relevant to batman-adv in the skb->cb buffer in skbs.
2089 struct batadv_skb_cb
{
2091 * @decoded: Marks a skb as decoded, which is checked when searching for
2092 * coding opportunities in network-coding.c
2094 unsigned char decoded
:1;
2096 /** @num_bcasts: Counter for broadcast packet retransmissions */
2097 unsigned char num_bcasts
;
2101 * struct batadv_forw_packet - structure for bcast packets to be sent/forwarded
2103 struct batadv_forw_packet
{
2105 * @list: list node for &batadv_priv.forw.bcast_list and
2106 * &batadv_priv.forw.bat_list
2108 struct hlist_node list
;
2110 /** @cleanup_list: list node for purging functions */
2111 struct hlist_node cleanup_list
;
2113 /** @send_time: execution time for delayed_work (packet sending) */
2114 unsigned long send_time
;
2117 * @own: bool for locally generated packets (local OGMs are re-scheduled
2122 /** @skb: bcast packet's skb buffer */
2123 struct sk_buff
*skb
;
2125 /** @packet_len: size of aggregated OGM packet inside the skb buffer */
2128 /** @direct_link_flags: direct link flags for aggregated OGM packets */
2129 u32 direct_link_flags
;
2131 /** @num_packets: counter for aggregated OGMv1 packets */
2134 /** @delayed_work: work queue callback item for packet sending */
2135 struct delayed_work delayed_work
;
2138 * @if_incoming: pointer to incoming hard-iface or primary iface if
2139 * locally generated packet
2141 struct batadv_hard_iface
*if_incoming
;
2144 * @if_outgoing: packet where the packet should be sent to, or NULL if
2147 struct batadv_hard_iface
*if_outgoing
;
2149 /** @queue_left: The queue (counter) this packet was applied to */
2150 atomic_t
*queue_left
;
2154 * struct batadv_algo_iface_ops - mesh algorithm callbacks (interface specific)
2156 struct batadv_algo_iface_ops
{
2158 * @activate: start routing mechanisms when hard-interface is brought up
2161 void (*activate
)(struct batadv_hard_iface
*hard_iface
);
2163 /** @enable: init routing info when hard-interface is enabled */
2164 int (*enable
)(struct batadv_hard_iface
*hard_iface
);
2166 /** @enabled: notification when hard-interface was enabled (optional) */
2167 void (*enabled
)(struct batadv_hard_iface
*hard_iface
);
2169 /** @disable: de-init routing info when hard-interface is disabled */
2170 void (*disable
)(struct batadv_hard_iface
*hard_iface
);
2173 * @update_mac: (re-)init mac addresses of the protocol information
2174 * belonging to this hard-interface
2176 void (*update_mac
)(struct batadv_hard_iface
*hard_iface
);
2178 /** @primary_set: called when primary interface is selected / changed */
2179 void (*primary_set
)(struct batadv_hard_iface
*hard_iface
);
2183 * struct batadv_algo_neigh_ops - mesh algorithm callbacks (neighbour specific)
2185 struct batadv_algo_neigh_ops
{
2186 /** @hardif_init: called on creation of single hop entry (optional) */
2187 void (*hardif_init
)(struct batadv_hardif_neigh_node
*neigh
);
2190 * @cmp: compare the metrics of two neighbors for their respective
2191 * outgoing interfaces
2193 int (*cmp
)(struct batadv_neigh_node
*neigh1
,
2194 struct batadv_hard_iface
*if_outgoing1
,
2195 struct batadv_neigh_node
*neigh2
,
2196 struct batadv_hard_iface
*if_outgoing2
);
2199 * @is_similar_or_better: check if neigh1 is equally similar or better
2200 * than neigh2 for their respective outgoing interface from the metric
2203 bool (*is_similar_or_better
)(struct batadv_neigh_node
*neigh1
,
2204 struct batadv_hard_iface
*if_outgoing1
,
2205 struct batadv_neigh_node
*neigh2
,
2206 struct batadv_hard_iface
*if_outgoing2
);
2208 /** @dump: dump neighbors to a netlink socket (optional) */
2209 void (*dump
)(struct sk_buff
*msg
, struct netlink_callback
*cb
,
2210 struct batadv_priv
*priv
,
2211 struct batadv_hard_iface
*hard_iface
);
2215 * struct batadv_algo_orig_ops - mesh algorithm callbacks (originator specific)
2217 struct batadv_algo_orig_ops
{
2218 /** @dump: dump originators to a netlink socket (optional) */
2219 void (*dump
)(struct sk_buff
*msg
, struct netlink_callback
*cb
,
2220 struct batadv_priv
*priv
,
2221 struct batadv_hard_iface
*hard_iface
);
2225 * struct batadv_algo_gw_ops - mesh algorithm callbacks (GW specific)
2227 struct batadv_algo_gw_ops
{
2228 /** @init_sel_class: initialize GW selection class (optional) */
2229 void (*init_sel_class
)(struct batadv_priv
*bat_priv
);
2232 * @store_sel_class: parse and stores a new GW selection class
2235 ssize_t (*store_sel_class
)(struct batadv_priv
*bat_priv
, char *buff
,
2238 * @get_best_gw_node: select the best GW from the list of available
2241 struct batadv_gw_node
*(*get_best_gw_node
)
2242 (struct batadv_priv
*bat_priv
);
2245 * @is_eligible: check if a newly discovered GW is a potential candidate
2246 * for the election as best GW (optional)
2248 bool (*is_eligible
)(struct batadv_priv
*bat_priv
,
2249 struct batadv_orig_node
*curr_gw_orig
,
2250 struct batadv_orig_node
*orig_node
);
2252 /** @dump: dump gateways to a netlink socket (optional) */
2253 void (*dump
)(struct sk_buff
*msg
, struct netlink_callback
*cb
,
2254 struct batadv_priv
*priv
);
2258 * struct batadv_algo_ops - mesh algorithm callbacks
2260 struct batadv_algo_ops
{
2261 /** @list: list node for the batadv_algo_list */
2262 struct hlist_node list
;
2264 /** @name: name of the algorithm */
2267 /** @iface: callbacks related to interface handling */
2268 struct batadv_algo_iface_ops iface
;
2270 /** @neigh: callbacks related to neighbors handling */
2271 struct batadv_algo_neigh_ops neigh
;
2273 /** @orig: callbacks related to originators handling */
2274 struct batadv_algo_orig_ops orig
;
2276 /** @gw: callbacks related to GW mode */
2277 struct batadv_algo_gw_ops gw
;
2281 * struct batadv_dat_entry - it is a single entry of batman-adv ARP backend. It
2282 * is used to stored ARP entries needed for the global DAT cache
2284 struct batadv_dat_entry
{
2285 /** @ip: the IPv4 corresponding to this DAT/ARP entry */
2288 /** @mac_addr: the MAC address associated to the stored IPv4 */
2289 u8 mac_addr
[ETH_ALEN
];
2291 /** @vid: the vlan ID associated to this entry */
2295 * @last_update: time in jiffies when this entry was refreshed last time
2297 unsigned long last_update
;
2299 /** @hash_entry: hlist node for &batadv_priv_dat.hash */
2300 struct hlist_node hash_entry
;
2302 /** @refcount: number of contexts the object is used */
2303 struct kref refcount
;
2305 /** @rcu: struct used for freeing in an RCU-safe manner */
2306 struct rcu_head rcu
;
2310 * struct batadv_hw_addr - a list entry for a MAC address
2312 struct batadv_hw_addr
{
2313 /** @list: list node for the linking of entries */
2314 struct hlist_node list
;
2316 /** @addr: the MAC address of this list entry */
2317 unsigned char addr
[ETH_ALEN
];
2321 * struct batadv_dat_candidate - candidate destination for DAT operations
2323 struct batadv_dat_candidate
{
2325 * @type: the type of the selected candidate. It can one of the
2327 * - BATADV_DAT_CANDIDATE_NOT_FOUND
2328 * - BATADV_DAT_CANDIDATE_ORIG
2333 * @orig_node: if type is BATADV_DAT_CANDIDATE_ORIG this field points to
2334 * the corresponding originator node structure
2336 struct batadv_orig_node
*orig_node
;
2340 * struct batadv_tvlv_container - container for tvlv appended to OGMs
2342 struct batadv_tvlv_container
{
2343 /** @list: hlist node for &batadv_priv_tvlv.container_list */
2344 struct hlist_node list
;
2346 /** @tvlv_hdr: tvlv header information needed to construct the tvlv */
2347 struct batadv_tvlv_hdr tvlv_hdr
;
2349 /** @refcount: number of contexts the object is used */
2350 struct kref refcount
;
2354 * struct batadv_tvlv_handler - handler for specific tvlv type and version
2356 struct batadv_tvlv_handler
{
2357 /** @list: hlist node for &batadv_priv_tvlv.handler_list */
2358 struct hlist_node list
;
2361 * @ogm_handler: handler callback which is given the tvlv payload to
2362 * process on incoming OGM packets
2364 void (*ogm_handler
)(struct batadv_priv
*bat_priv
,
2365 struct batadv_orig_node
*orig
,
2366 u8 flags
, void *tvlv_value
, u16 tvlv_value_len
);
2369 * @unicast_handler: handler callback which is given the tvlv payload to
2370 * process on incoming unicast tvlv packets
2372 int (*unicast_handler
)(struct batadv_priv
*bat_priv
,
2374 void *tvlv_value
, u16 tvlv_value_len
);
2376 /** @type: tvlv type this handler feels responsible for */
2379 /** @version: tvlv version this handler feels responsible for */
2382 /** @flags: tvlv handler flags */
2385 /** @refcount: number of contexts the object is used */
2386 struct kref refcount
;
2388 /** @rcu: struct used for freeing in an RCU-safe manner */
2389 struct rcu_head rcu
;
2393 * enum batadv_tvlv_handler_flags - tvlv handler flags definitions
2395 enum batadv_tvlv_handler_flags
{
2397 * @BATADV_TVLV_HANDLER_OGM_CIFNOTFND: tvlv ogm processing function
2398 * will call this handler even if its type was not found (with no data)
2400 BATADV_TVLV_HANDLER_OGM_CIFNOTFND
= BIT(1),
2403 * @BATADV_TVLV_HANDLER_OGM_CALLED: interval tvlv handling flag - the
2404 * API marks a handler as being called, so it won't be called if the
2405 * BATADV_TVLV_HANDLER_OGM_CIFNOTFND flag was set
2407 BATADV_TVLV_HANDLER_OGM_CALLED
= BIT(2),
2410 #endif /* _NET_BATMAN_ADV_TYPES_H_ */