1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (C) B.A.T.M.A.N. contributors: 3 * 4 * Marek Lindner, Simon Wunderlich 5 */ 6 7 #ifndef _NET_BATMAN_ADV_TYPES_H_ 8 #define _NET_BATMAN_ADV_TYPES_H_ 9 10 #ifndef _NET_BATMAN_ADV_MAIN_H_ 11 #error only "main.h" can be included directly 12 #endif 13 14 #include <linux/average.h> 15 #include <linux/bitops.h> 16 #include <linux/compiler.h> 17 #include <linux/completion.h> 18 #include <linux/if.h> 19 #include <linux/if_ether.h> 20 #include <linux/kref.h> 21 #include <linux/mutex.h> 22 #include <linux/netdevice.h> 23 #include <linux/netlink.h> 24 #include <linux/rhashtable-types.h> 25 #include <linux/sched.h> /* for linux/wait.h */ 26 #include <linux/skbuff.h> 27 #include <linux/spinlock.h> 28 #include <linux/timer.h> 29 #include <linux/types.h> 30 #include <linux/wait.h> 31 #include <linux/workqueue.h> 32 #include <uapi/linux/batadv_packet.h> 33 #include <uapi/linux/batman_adv.h> 34 35 #ifdef CONFIG_BATMAN_ADV_DAT 36 37 /** 38 * typedef batadv_dat_addr_t - type used for all DHT addresses 39 * 40 * If it is changed, BATADV_DAT_ADDR_MAX is changed as well. 41 * 42 * *Please be careful: batadv_dat_addr_t must be UNSIGNED* 43 */ 44 typedef u16 batadv_dat_addr_t; 45 46 #endif /* CONFIG_BATMAN_ADV_DAT */ 47 48 /** 49 * enum batadv_dhcp_recipient - dhcp destination 50 */ 51 enum batadv_dhcp_recipient { 52 /** @BATADV_DHCP_NO: packet is not a dhcp message */ 53 BATADV_DHCP_NO = 0, 54 55 /** @BATADV_DHCP_TO_SERVER: dhcp message is directed to a server */ 56 BATADV_DHCP_TO_SERVER, 57 58 /** @BATADV_DHCP_TO_CLIENT: dhcp message is directed to a client */ 59 BATADV_DHCP_TO_CLIENT, 60 }; 61 62 /** 63 * BATADV_TT_REMOTE_MASK - bitmask selecting the flags that are sent over the 64 * wire only 65 */ 66 #define BATADV_TT_REMOTE_MASK 0x00FF 67 68 /** 69 * BATADV_TT_SYNC_MASK - bitmask of the flags that need to be kept in sync 70 * among the nodes. These flags are used to compute the global/local CRC 71 */ 72 #define BATADV_TT_SYNC_MASK 0x00F0 73 74 /** 75 * struct batadv_ogm_buf - Buffer to construct an OGM with TVLV 76 */ 77 struct batadv_ogm_buf { 78 /** @buf: buffer holding the OGM packet */ 79 void *buf; 80 81 /** @len: length of the OGM packet buffer data */ 82 size_t len; 83 84 /** @capacity: size of allocated buf */ 85 size_t capacity; 86 87 /** @header_length: fixed size header length (must be <= len) */ 88 size_t header_length; 89 }; 90 91 /** 92 * struct batadv_hard_iface_bat_iv - per hard-interface B.A.T.M.A.N. IV data 93 */ 94 struct batadv_hard_iface_bat_iv { 95 /** @ogm_buff: buffer holding the OGM packet */ 96 struct batadv_ogm_buf ogm_buff; 97 98 /** @ogm_seqno: OGM sequence number - used to identify each OGM */ 99 atomic_t ogm_seqno; 100 101 /** @reschedule_work: recover OGM schedule after schedule error */ 102 struct delayed_work reschedule_work; 103 104 /** @ogm_buff_mutex: lock protecting ogm_buff */ 105 struct mutex ogm_buff_mutex; 106 }; 107 108 /** 109 * enum batadv_v_hard_iface_flags - interface flags useful to B.A.T.M.A.N. V 110 */ 111 enum batadv_v_hard_iface_flags { 112 /** 113 * @BATADV_FULL_DUPLEX: tells if the connection over this link is 114 * full-duplex 115 */ 116 BATADV_FULL_DUPLEX = BIT(0), 117 118 /** 119 * @BATADV_WARNING_DEFAULT: tells whether we have warned the user that 120 * no throughput data is available for this interface and that default 121 * values are assumed. 122 */ 123 BATADV_WARNING_DEFAULT = BIT(1), 124 }; 125 126 /** 127 * struct batadv_hard_iface_bat_v - per hard-interface B.A.T.M.A.N. V data 128 */ 129 struct batadv_hard_iface_bat_v { 130 /** @elp_interval: time interval between two ELP transmissions */ 131 u32 elp_interval; 132 133 /** @elp_seqno: current ELP sequence number */ 134 atomic_t elp_seqno; 135 136 /** @elp_skb: base skb containing the ELP message to send */ 137 struct sk_buff *elp_skb; 138 139 /** @elp_wq: workqueue used to schedule ELP transmissions */ 140 struct delayed_work elp_wq; 141 142 /** @aggr_wq: workqueue used to transmit queued OGM packets */ 143 struct delayed_work aggr_wq; 144 145 /** @aggr_list: queue for to be aggregated OGM packets */ 146 struct sk_buff_head aggr_list; 147 148 /** 149 * @aggr_list_enabled: aggr_list is active and new skbs can be 150 * enqueued. Protected by aggr_list.lock after initialization 151 */ 152 bool aggr_list_enabled:1; 153 154 /** @aggr_len: size of the OGM aggregate (excluding ethernet header) */ 155 unsigned int aggr_len; 156 157 /** 158 * @throughput_override: throughput override to disable link 159 * auto-detection 160 */ 161 u32 throughput_override; 162 163 /** @flags: interface specific flags */ 164 u8 flags; 165 }; 166 167 /** 168 * enum batadv_hard_iface_wifi_flags - Flags describing the wifi configuration 169 * of a batadv_hard_iface 170 */ 171 enum batadv_hard_iface_wifi_flags { 172 /** @BATADV_HARDIF_WIFI_WEXT_DIRECT: it is a wext wifi device */ 173 BATADV_HARDIF_WIFI_WEXT_DIRECT = BIT(0), 174 175 /** @BATADV_HARDIF_WIFI_CFG80211_DIRECT: it is a cfg80211 wifi device */ 176 BATADV_HARDIF_WIFI_CFG80211_DIRECT = BIT(1), 177 178 /** 179 * @BATADV_HARDIF_WIFI_WEXT_INDIRECT: link device is a wext wifi device 180 */ 181 BATADV_HARDIF_WIFI_WEXT_INDIRECT = BIT(2), 182 183 /** 184 * @BATADV_HARDIF_WIFI_CFG80211_INDIRECT: link device is a cfg80211 wifi 185 * device 186 */ 187 BATADV_HARDIF_WIFI_CFG80211_INDIRECT = BIT(3), 188 }; 189 190 /** 191 * struct batadv_wifi_net_device_state - cache of wifi information of net_devices 192 */ 193 struct batadv_wifi_net_device_state { 194 /** @l: anchor in rhashtable */ 195 struct rhash_head l; 196 197 /** @netdev: pointer to the net_device */ 198 struct net_device *netdev; 199 200 /** @dev_tracker: device tracker for @netdev */ 201 netdevice_tracker dev_tracker; 202 203 /** 204 * @wifi_flags: flags whether this is (directly or indirectly) a wifi 205 * interface 206 */ 207 u32 wifi_flags; 208 209 /** @rcu: struct used for freeing in an RCU-safe manner */ 210 struct rcu_head rcu; 211 }; 212 213 /** 214 * struct batadv_hard_iface - network device known to batman-adv 215 */ 216 struct batadv_hard_iface { 217 /** @list: list node for batadv_hardif_list */ 218 struct list_head list; 219 220 /** @if_status: status of the interface for batman-adv */ 221 char if_status; 222 223 /** 224 * @num_bcasts: number of payload re-broadcasts on this interface (ARQ) 225 */ 226 u8 num_bcasts; 227 228 /** @net_dev: pointer to the net_device */ 229 struct net_device *net_dev; 230 231 /** @dev_tracker: device tracker for @net_dev */ 232 netdevice_tracker dev_tracker; 233 234 /** @refcount: number of contexts the object is used */ 235 struct kref refcount; 236 237 /** 238 * @batman_adv_ptype: packet type describing packets that should be 239 * processed by batman-adv for this interface 240 */ 241 struct packet_type batman_adv_ptype; 242 243 /** 244 * @mesh_iface: the batman-adv interface which uses this network 245 * interface 246 */ 247 struct net_device *mesh_iface; 248 249 /** @meshif_dev_tracker: device tracker for @mesh_iface */ 250 netdevice_tracker meshif_dev_tracker; 251 252 /** @rcu: struct used for freeing in an RCU-safe manner */ 253 struct rcu_head rcu; 254 255 /** 256 * @hop_penalty: penalty which will be applied to the tq-field 257 * of an OGM received via this interface 258 */ 259 u8 hop_penalty; 260 261 /** @bat_iv: per hard-interface B.A.T.M.A.N. IV data */ 262 struct batadv_hard_iface_bat_iv bat_iv; 263 264 #ifdef CONFIG_BATMAN_ADV_BATMAN_V 265 /** @bat_v: per hard-interface B.A.T.M.A.N. V data */ 266 struct batadv_hard_iface_bat_v bat_v; 267 #endif 268 269 /** 270 * @neigh_list: list of unique single hop neighbors via this interface 271 */ 272 struct hlist_head neigh_list; 273 274 /** @neigh_list_lock: lock protecting neigh_list */ 275 spinlock_t neigh_list_lock; 276 }; 277 278 /** 279 * struct batadv_orig_ifinfo_bat_iv - B.A.T.M.A.N. IV private orig_ifinfo 280 * members 281 */ 282 struct batadv_orig_ifinfo_bat_iv { 283 /** 284 * @bcast_own: bitfield which counts the number of our OGMs this 285 * orig_node rebroadcasted "back" to us (relative to last_real_seqno) 286 */ 287 DECLARE_BITMAP(bcast_own, BATADV_TQ_LOCAL_WINDOW_SIZE); 288 289 /** @bcast_own_sum: sum of bcast_own */ 290 u8 bcast_own_sum; 291 }; 292 293 /** 294 * struct batadv_orig_ifinfo - originator info per outgoing interface 295 */ 296 struct batadv_orig_ifinfo { 297 /** @list: list node for &batadv_orig_node.ifinfo_list */ 298 struct hlist_node list; 299 300 /** @if_outgoing: pointer to outgoing hard-interface */ 301 struct batadv_hard_iface *if_outgoing; 302 303 /** @router: router that should be used to reach this originator */ 304 struct batadv_neigh_node __rcu *router; 305 306 /** @last_real_seqno: last and best known sequence number */ 307 u32 last_real_seqno; 308 309 /** @last_ttl: ttl of last received packet */ 310 u8 last_ttl; 311 312 /** @last_seqno_forwarded: seqno of the OGM which was forwarded last */ 313 u32 last_seqno_forwarded; 314 315 /** @batman_seqno_reset: time when the batman seqno window was reset */ 316 unsigned long batman_seqno_reset; 317 318 /** @bat_iv: B.A.T.M.A.N. IV private structure */ 319 struct batadv_orig_ifinfo_bat_iv bat_iv; 320 321 /** @refcount: number of contexts the object is used */ 322 struct kref refcount; 323 324 /** @rcu: struct used for freeing in an RCU-safe manner */ 325 struct rcu_head rcu; 326 }; 327 328 /** 329 * struct batadv_frag_table_entry - head in the fragment buffer table 330 */ 331 struct batadv_frag_table_entry { 332 /** @fragment_list: head of list with fragments */ 333 struct hlist_head fragment_list; 334 335 /** @lock: lock to protect the list of fragments */ 336 spinlock_t lock; 337 338 /** @timestamp: time (jiffy) of last received fragment */ 339 unsigned long timestamp; 340 341 /** @seqno: sequence number of the fragments in the list */ 342 u16 seqno; 343 344 /** @size: accumulated size of packets in list */ 345 size_t size; 346 347 /** @total_size: expected size of the assembled packet */ 348 u16 total_size; 349 }; 350 351 /** 352 * struct batadv_frag_list_entry - entry in a list of fragments 353 */ 354 struct batadv_frag_list_entry { 355 /** @list: list node information */ 356 struct hlist_node list; 357 358 /** @skb: fragment */ 359 struct sk_buff *skb; 360 361 /** @no: fragment number in the set */ 362 u8 no; 363 }; 364 365 /** 366 * struct batadv_vlan_tt - VLAN specific TT attributes 367 */ 368 struct batadv_vlan_tt { 369 /** @crc: CRC32 checksum of the entries belonging to this vlan */ 370 u32 crc; 371 372 /** @num_entries: number of TT entries for this VLAN */ 373 atomic_t num_entries; 374 }; 375 376 /** 377 * struct batadv_orig_node_vlan - VLAN specific data per orig_node 378 */ 379 struct batadv_orig_node_vlan { 380 /** @vid: the VLAN identifier */ 381 unsigned short vid; 382 383 /** @tt: VLAN specific TT attributes */ 384 struct batadv_vlan_tt tt; 385 386 /** @list: list node for &batadv_orig_node.vlan_list */ 387 struct hlist_node list; 388 389 /** 390 * @refcount: number of context where this object is currently in use 391 */ 392 struct kref refcount; 393 394 /** @rcu: struct used for freeing in a RCU-safe manner */ 395 struct rcu_head rcu; 396 }; 397 398 /** 399 * struct batadv_orig_bat_iv - B.A.T.M.A.N. IV private orig_node members 400 */ 401 struct batadv_orig_bat_iv { 402 /** 403 * @ogm_cnt_lock: lock protecting &batadv_orig_ifinfo_bat_iv.bcast_own, 404 * &batadv_orig_ifinfo_bat_iv.bcast_own_sum, 405 * &batadv_neigh_ifinfo_bat_iv.bat_iv.real_bits and 406 * &batadv_neigh_ifinfo_bat_iv.real_packet_count 407 */ 408 spinlock_t ogm_cnt_lock; 409 }; 410 411 /** 412 * struct batadv_orig_node - structure for orig_list maintaining nodes of mesh 413 */ 414 struct batadv_orig_node { 415 /** @orig: originator ethernet address */ 416 u8 orig[ETH_ALEN]; 417 418 /** @ifinfo_list: list for routers per outgoing interface */ 419 struct hlist_head ifinfo_list; 420 421 /** 422 * @last_bonding_candidate: pointer to last ifinfo of last used router 423 */ 424 struct batadv_orig_ifinfo *last_bonding_candidate; 425 426 #ifdef CONFIG_BATMAN_ADV_DAT 427 /** @dat_addr: address of the orig node in the distributed hash */ 428 batadv_dat_addr_t dat_addr; 429 #endif 430 431 /** @last_seen: time when last packet from this node was received */ 432 unsigned long last_seen; 433 434 /** 435 * @bcast_seqno_reset: time when the broadcast seqno window was reset 436 */ 437 unsigned long bcast_seqno_reset; 438 439 #ifdef CONFIG_BATMAN_ADV_MCAST 440 /** 441 * @mcast_handler_lock: synchronizes mcast-capability and -flag changes 442 */ 443 spinlock_t mcast_handler_lock; 444 445 /** @mcast_flags: multicast flags announced by the orig node */ 446 u8 mcast_flags; 447 448 /** 449 * @mcast_want_all_unsnoopables_node: a list node for the 450 * mcast.want_all_unsnoopables list 451 */ 452 struct hlist_node mcast_want_all_unsnoopables_node; 453 454 /** 455 * @mcast_want_all_ipv4_node: a list node for the mcast.want_all_ipv4 456 * list 457 */ 458 struct hlist_node mcast_want_all_ipv4_node; 459 /** 460 * @mcast_want_all_ipv6_node: a list node for the mcast.want_all_ipv6 461 * list 462 */ 463 struct hlist_node mcast_want_all_ipv6_node; 464 465 /** 466 * @mcast_want_all_rtr4_node: a list node for the mcast.want_all_rtr4 467 * list 468 */ 469 struct hlist_node mcast_want_all_rtr4_node; 470 /** 471 * @mcast_want_all_rtr6_node: a list node for the mcast.want_all_rtr6 472 * list 473 */ 474 struct hlist_node mcast_want_all_rtr6_node; 475 #endif 476 477 /** @capabilities: announced capabilities of this originator */ 478 unsigned long capabilities; 479 480 /** 481 * @capa_initialized: bitfield to remember whether a capability was 482 * initialized 483 */ 484 unsigned long capa_initialized; 485 486 /** @last_ttvn: last seen translation table version number */ 487 u8 last_ttvn; 488 489 /** @tt_buff: last tt changeset this node received from the orig node */ 490 unsigned char *tt_buff; 491 492 /** 493 * @tt_buff_len: length of the last tt changeset this node received 494 * from the orig node 495 */ 496 u16 tt_buff_len; 497 498 /** @tt_buff_lock: lock that protects tt_buff and tt_buff_len */ 499 spinlock_t tt_buff_lock; 500 501 /** 502 * @tt_lock: avoids concurrent read from and write to the table. Table 503 * update is made up of two operations (data structure update and 504 * metadata -CRC/TTVN-recalculation) and they have to be executed 505 * atomically in order to avoid another thread to read the 506 * table/metadata between those. 507 */ 508 spinlock_t tt_lock; 509 510 /** 511 * @bcast_bits: bitfield containing the info which payload broadcast 512 * originated from this orig node this host already has seen (relative 513 * to last_bcast_seqno) 514 */ 515 DECLARE_BITMAP(bcast_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); 516 517 /** 518 * @last_bcast_seqno: last broadcast sequence number received by this 519 * host 520 */ 521 u32 last_bcast_seqno; 522 523 /** 524 * @neigh_list: list of potential next hop neighbor towards this orig 525 * node 526 */ 527 struct hlist_head neigh_list; 528 529 /** 530 * @neigh_list_lock: lock protecting neigh_list, ifinfo_list, 531 * last_bonding_candidate and router 532 */ 533 spinlock_t neigh_list_lock; 534 535 /** @hash_entry: hlist node for &batadv_priv.orig_hash */ 536 struct hlist_node hash_entry; 537 538 /** @bat_priv: pointer to mesh_iface this orig node belongs to */ 539 struct batadv_priv *bat_priv; 540 541 /** @bcast_seqno_lock: lock protecting bcast_bits & last_bcast_seqno */ 542 spinlock_t bcast_seqno_lock; 543 544 /** @refcount: number of contexts the object is used */ 545 struct kref refcount; 546 547 /** @rcu: struct used for freeing in an RCU-safe manner */ 548 struct rcu_head rcu; 549 550 /** @fragments: array with heads for fragment chains */ 551 struct batadv_frag_table_entry fragments[BATADV_FRAG_BUFFER_COUNT]; 552 553 /** 554 * @vlan_list: a list of orig_node_vlan structs, one per VLAN served by 555 * the originator represented by this object 556 */ 557 struct hlist_head vlan_list; 558 559 /** @vlan_list_lock: lock protecting vlan_list */ 560 spinlock_t vlan_list_lock; 561 562 /** @bat_iv: B.A.T.M.A.N. IV private structure */ 563 struct batadv_orig_bat_iv bat_iv; 564 }; 565 566 /** 567 * enum batadv_orig_capabilities - orig node capabilities 568 */ 569 enum batadv_orig_capabilities { 570 /** 571 * @BATADV_ORIG_CAPA_HAS_DAT: orig node has distributed arp table 572 * enabled 573 */ 574 BATADV_ORIG_CAPA_HAS_DAT, 575 576 /** @BATADV_ORIG_CAPA_HAS_TT: orig node has tt capability */ 577 BATADV_ORIG_CAPA_HAS_TT, 578 579 /** 580 * @BATADV_ORIG_CAPA_HAS_MCAST: orig node has some multicast capability 581 * (= orig node announces a tvlv of type BATADV_TVLV_MCAST) 582 */ 583 BATADV_ORIG_CAPA_HAS_MCAST, 584 }; 585 586 /** 587 * struct batadv_gw_node - structure for orig nodes announcing gw capabilities 588 */ 589 struct batadv_gw_node { 590 /** @list: list node for &batadv_priv_gw.list */ 591 struct hlist_node list; 592 593 /** @orig_node: pointer to corresponding orig node */ 594 struct batadv_orig_node *orig_node; 595 596 /** @bandwidth_down: advertised uplink download bandwidth */ 597 u32 bandwidth_down; 598 599 /** @bandwidth_up: advertised uplink upload bandwidth */ 600 u32 bandwidth_up; 601 602 /** @refcount: number of contexts the object is used */ 603 struct kref refcount; 604 605 /** @rcu: struct used for freeing in an RCU-safe manner */ 606 struct rcu_head rcu; 607 }; 608 609 DECLARE_EWMA(throughput, 10, 8) 610 611 /** 612 * struct batadv_hardif_neigh_node_bat_v - B.A.T.M.A.N. V private neighbor 613 * information 614 */ 615 struct batadv_hardif_neigh_node_bat_v { 616 /** @throughput: ewma link throughput towards this neighbor */ 617 struct ewma_throughput throughput; 618 619 /** @elp_interval: time interval between two ELP transmissions */ 620 u32 elp_interval; 621 622 /** @elp_latest_seqno: latest and best known ELP sequence number */ 623 u32 elp_latest_seqno; 624 625 /** 626 * @last_unicast_tx: when the last unicast packet has been sent to this 627 * neighbor 628 */ 629 unsigned long last_unicast_tx; 630 }; 631 632 /** 633 * struct batadv_hardif_neigh_node - unique neighbor per hard-interface 634 */ 635 struct batadv_hardif_neigh_node { 636 /** @list: list node for &batadv_hard_iface.neigh_list */ 637 struct hlist_node list; 638 639 /** @addr: the MAC address of the neighboring interface */ 640 u8 addr[ETH_ALEN]; 641 642 /** 643 * @orig: the address of the originator this neighbor node belongs to 644 */ 645 u8 orig[ETH_ALEN]; 646 647 /** @if_incoming: pointer to incoming hard-interface */ 648 struct batadv_hard_iface *if_incoming; 649 650 /** @last_seen: when last packet via this neighbor was received */ 651 unsigned long last_seen; 652 653 #ifdef CONFIG_BATMAN_ADV_BATMAN_V 654 /** @bat_v: B.A.T.M.A.N. V private data */ 655 struct batadv_hardif_neigh_node_bat_v bat_v; 656 #endif 657 658 /** @refcount: number of contexts the object is used */ 659 struct kref refcount; 660 661 /** @rcu: struct used for freeing in a RCU-safe manner */ 662 struct rcu_head rcu; 663 }; 664 665 /** 666 * struct batadv_neigh_node - structure for single hops neighbors 667 */ 668 struct batadv_neigh_node { 669 /** @list: list node for &batadv_orig_node.neigh_list */ 670 struct hlist_node list; 671 672 #ifdef CONFIG_BATMAN_ADV_BATMAN_V 673 /** 674 * @orig_node_id: pointer to corresponding orig_node. It must only be used 675 * to identify the node but must NEVER be dereferenced. The reference counter 676 * was not increased when this was assigned because it would otherwise create 677 * a reference cycle. 678 */ 679 struct batadv_orig_node *__private orig_node_id; 680 #endif 681 682 /** @addr: the MAC address of the neighboring interface */ 683 u8 addr[ETH_ALEN]; 684 685 /** @ifinfo_list: list for routing metrics per outgoing interface */ 686 struct hlist_head ifinfo_list; 687 688 /** @ifinfo_lock: lock protecting ifinfo_list and its members */ 689 spinlock_t ifinfo_lock; 690 691 /** @if_incoming: pointer to incoming hard-interface */ 692 struct batadv_hard_iface *if_incoming; 693 694 /** @last_seen: when last packet via this neighbor was received */ 695 unsigned long last_seen; 696 697 /** @hardif_neigh: hardif_neigh of this neighbor */ 698 struct batadv_hardif_neigh_node *hardif_neigh; 699 700 /** @refcount: number of contexts the object is used */ 701 struct kref refcount; 702 703 /** @rcu: struct used for freeing in an RCU-safe manner */ 704 struct rcu_head rcu; 705 }; 706 707 /** 708 * struct batadv_neigh_ifinfo_bat_iv - neighbor information per outgoing 709 * interface for B.A.T.M.A.N. IV 710 */ 711 struct batadv_neigh_ifinfo_bat_iv { 712 /** @tq_recv: ring buffer of received TQ values from this neigh node */ 713 u8 tq_recv[BATADV_TQ_GLOBAL_WINDOW_SIZE]; 714 715 /** @tq_index: ring buffer index */ 716 u8 tq_index; 717 718 /** 719 * @tq_avg: averaged tq of all tq values in the ring buffer (tq_recv) 720 */ 721 u8 tq_avg; 722 723 /** 724 * @real_bits: bitfield containing the number of OGMs received from this 725 * neigh node (relative to orig_node->last_real_seqno) 726 */ 727 DECLARE_BITMAP(real_bits, BATADV_TQ_LOCAL_WINDOW_SIZE); 728 729 /** @real_packet_count: counted result of real_bits */ 730 u8 real_packet_count; 731 }; 732 733 /** 734 * struct batadv_neigh_ifinfo_bat_v - neighbor information per outgoing 735 * interface for B.A.T.M.A.N. V 736 */ 737 struct batadv_neigh_ifinfo_bat_v { 738 /** 739 * @throughput: last throughput metric received from originator via this 740 * neigh 741 */ 742 u32 throughput; 743 744 /** @last_seqno: last sequence number known for this neighbor */ 745 u32 last_seqno; 746 }; 747 748 /** 749 * struct batadv_neigh_ifinfo - neighbor information per outgoing interface 750 */ 751 struct batadv_neigh_ifinfo { 752 /** @list: list node for &batadv_neigh_node.ifinfo_list */ 753 struct hlist_node list; 754 755 /** @if_outgoing: pointer to outgoing hard-interface */ 756 struct batadv_hard_iface *if_outgoing; 757 758 /** @bat_iv: B.A.T.M.A.N. IV private structure */ 759 struct batadv_neigh_ifinfo_bat_iv bat_iv; 760 761 #ifdef CONFIG_BATMAN_ADV_BATMAN_V 762 /** @bat_v: B.A.T.M.A.N. V private data */ 763 struct batadv_neigh_ifinfo_bat_v bat_v; 764 #endif 765 766 /** @last_ttl: last received ttl from this neigh node */ 767 u8 last_ttl; 768 769 /** @refcount: number of contexts the object is used */ 770 struct kref refcount; 771 772 /** @rcu: struct used for freeing in a RCU-safe manner */ 773 struct rcu_head rcu; 774 }; 775 776 #ifdef CONFIG_BATMAN_ADV_BLA 777 778 /** 779 * struct batadv_bcast_duplist_entry - structure for LAN broadcast suppression 780 */ 781 struct batadv_bcast_duplist_entry { 782 /** @orig: mac address of orig node originating the broadcast */ 783 u8 orig[ETH_ALEN]; 784 785 /** @crc: crc32 checksum of broadcast payload */ 786 u32 crc; 787 788 /** @entrytime: time when the broadcast packet was received */ 789 unsigned long entrytime; 790 }; 791 #endif 792 793 /** 794 * enum batadv_counters - indices for traffic counters 795 */ 796 enum batadv_counters { 797 /** @BATADV_CNT_TX: transmitted payload traffic packet counter */ 798 BATADV_CNT_TX, 799 800 /** @BATADV_CNT_TX_BYTES: transmitted payload traffic bytes counter */ 801 BATADV_CNT_TX_BYTES, 802 803 /** 804 * @BATADV_CNT_TX_DROPPED: dropped transmission payload traffic packet 805 * counter 806 */ 807 BATADV_CNT_TX_DROPPED, 808 809 /** @BATADV_CNT_RX: received payload traffic packet counter */ 810 BATADV_CNT_RX, 811 812 /** @BATADV_CNT_RX_BYTES: received payload traffic bytes counter */ 813 BATADV_CNT_RX_BYTES, 814 815 /** @BATADV_CNT_FORWARD: forwarded payload traffic packet counter */ 816 BATADV_CNT_FORWARD, 817 818 /** 819 * @BATADV_CNT_FORWARD_BYTES: forwarded payload traffic bytes counter 820 */ 821 BATADV_CNT_FORWARD_BYTES, 822 823 /** 824 * @BATADV_CNT_MGMT_TX: transmitted routing protocol traffic packet 825 * counter 826 */ 827 BATADV_CNT_MGMT_TX, 828 829 /** 830 * @BATADV_CNT_MGMT_TX_BYTES: transmitted routing protocol traffic bytes 831 * counter 832 */ 833 BATADV_CNT_MGMT_TX_BYTES, 834 835 /** 836 * @BATADV_CNT_MGMT_RX: received routing protocol traffic packet counter 837 */ 838 BATADV_CNT_MGMT_RX, 839 840 /** 841 * @BATADV_CNT_MGMT_RX_BYTES: received routing protocol traffic bytes 842 * counter 843 */ 844 BATADV_CNT_MGMT_RX_BYTES, 845 846 /** @BATADV_CNT_FRAG_TX: transmitted fragment traffic packet counter */ 847 BATADV_CNT_FRAG_TX, 848 849 /** 850 * @BATADV_CNT_FRAG_TX_BYTES: transmitted fragment traffic bytes counter 851 */ 852 BATADV_CNT_FRAG_TX_BYTES, 853 854 /** @BATADV_CNT_FRAG_RX: received fragment traffic packet counter */ 855 BATADV_CNT_FRAG_RX, 856 857 /** 858 * @BATADV_CNT_FRAG_RX_BYTES: received fragment traffic bytes counter 859 */ 860 BATADV_CNT_FRAG_RX_BYTES, 861 862 /** @BATADV_CNT_FRAG_FWD: forwarded fragment traffic packet counter */ 863 BATADV_CNT_FRAG_FWD, 864 865 /** 866 * @BATADV_CNT_FRAG_FWD_BYTES: forwarded fragment traffic bytes counter 867 */ 868 BATADV_CNT_FRAG_FWD_BYTES, 869 870 /** 871 * @BATADV_CNT_TT_REQUEST_TX: transmitted tt req traffic packet counter 872 */ 873 BATADV_CNT_TT_REQUEST_TX, 874 875 /** @BATADV_CNT_TT_REQUEST_RX: received tt req traffic packet counter */ 876 BATADV_CNT_TT_REQUEST_RX, 877 878 /** 879 * @BATADV_CNT_TT_RESPONSE_TX: transmitted tt resp traffic packet 880 * counter 881 */ 882 BATADV_CNT_TT_RESPONSE_TX, 883 884 /** 885 * @BATADV_CNT_TT_RESPONSE_RX: received tt resp traffic packet counter 886 */ 887 BATADV_CNT_TT_RESPONSE_RX, 888 889 /** 890 * @BATADV_CNT_TT_ROAM_ADV_TX: transmitted tt roam traffic packet 891 * counter 892 */ 893 BATADV_CNT_TT_ROAM_ADV_TX, 894 895 /** 896 * @BATADV_CNT_TT_ROAM_ADV_RX: received tt roam traffic packet counter 897 */ 898 BATADV_CNT_TT_ROAM_ADV_RX, 899 900 #ifdef CONFIG_BATMAN_ADV_MCAST 901 /** 902 * @BATADV_CNT_MCAST_TX: transmitted batman-adv multicast packets 903 * counter 904 */ 905 BATADV_CNT_MCAST_TX, 906 907 /** 908 * @BATADV_CNT_MCAST_TX_BYTES: transmitted batman-adv multicast packets 909 * bytes counter 910 */ 911 BATADV_CNT_MCAST_TX_BYTES, 912 913 /** 914 * @BATADV_CNT_MCAST_TX_LOCAL: counter for multicast packets which 915 * were locally encapsulated and transmitted as batman-adv multicast 916 * packets 917 */ 918 BATADV_CNT_MCAST_TX_LOCAL, 919 920 /** 921 * @BATADV_CNT_MCAST_TX_LOCAL_BYTES: bytes counter for multicast packets 922 * which were locally encapsulated and transmitted as batman-adv 923 * multicast packets 924 */ 925 BATADV_CNT_MCAST_TX_LOCAL_BYTES, 926 927 /** 928 * @BATADV_CNT_MCAST_RX: received batman-adv multicast packet counter 929 */ 930 BATADV_CNT_MCAST_RX, 931 932 /** 933 * @BATADV_CNT_MCAST_RX_BYTES: received batman-adv multicast packet 934 * bytes counter 935 */ 936 BATADV_CNT_MCAST_RX_BYTES, 937 938 /** 939 * @BATADV_CNT_MCAST_RX_LOCAL: counter for received batman-adv multicast 940 * packets which were forwarded to the local mesh interface 941 */ 942 BATADV_CNT_MCAST_RX_LOCAL, 943 944 /** 945 * @BATADV_CNT_MCAST_RX_LOCAL_BYTES: bytes counter for received 946 * batman-adv multicast packets which were forwarded to the local mesh 947 * interface 948 */ 949 BATADV_CNT_MCAST_RX_LOCAL_BYTES, 950 951 /** 952 * @BATADV_CNT_MCAST_FWD: counter for received batman-adv multicast 953 * packets which were forwarded to other, neighboring nodes 954 */ 955 BATADV_CNT_MCAST_FWD, 956 957 /** 958 * @BATADV_CNT_MCAST_FWD_BYTES: bytes counter for received batman-adv 959 * multicast packets which were forwarded to other, neighboring nodes 960 */ 961 BATADV_CNT_MCAST_FWD_BYTES, 962 #endif 963 964 #ifdef CONFIG_BATMAN_ADV_DAT 965 /** 966 * @BATADV_CNT_DAT_GET_TX: transmitted dht GET traffic packet counter 967 */ 968 BATADV_CNT_DAT_GET_TX, 969 970 /** @BATADV_CNT_DAT_GET_RX: received dht GET traffic packet counter */ 971 BATADV_CNT_DAT_GET_RX, 972 973 /** 974 * @BATADV_CNT_DAT_PUT_TX: transmitted dht PUT traffic packet counter 975 */ 976 BATADV_CNT_DAT_PUT_TX, 977 978 /** @BATADV_CNT_DAT_PUT_RX: received dht PUT traffic packet counter */ 979 BATADV_CNT_DAT_PUT_RX, 980 981 /** 982 * @BATADV_CNT_DAT_CACHED_REPLY_TX: transmitted dat cache reply traffic 983 * packet counter 984 */ 985 BATADV_CNT_DAT_CACHED_REPLY_TX, 986 #endif 987 988 /** @BATADV_CNT_NUM: number of traffic counters */ 989 BATADV_CNT_NUM, 990 }; 991 992 /** 993 * struct batadv_priv_tt - per mesh interface translation table data 994 */ 995 struct batadv_priv_tt { 996 /** @vn: translation table version number */ 997 atomic_t vn; 998 999 /** 1000 * @ogm_append_cnt: counter of number of OGMs containing the local tt 1001 * diff 1002 */ 1003 atomic_t ogm_append_cnt; 1004 1005 /** @local_changes: changes registered in an originator interval */ 1006 size_t local_changes; 1007 1008 /** 1009 * @changes_list: tracks tt local changes within an originator interval 1010 */ 1011 struct list_head changes_list; 1012 1013 /** @local_hash: local translation table hash table */ 1014 struct batadv_hashtable *local_hash; 1015 1016 /** @global_hash: global translation table hash table */ 1017 struct batadv_hashtable *global_hash; 1018 1019 /** @req_list: list of pending & unanswered tt_requests */ 1020 struct hlist_head req_list; 1021 1022 /** 1023 * @roam_list: list of the last roaming events of each client limiting 1024 * the number of roaming events to avoid route flapping 1025 */ 1026 struct list_head roam_list; 1027 1028 /** @changes_list_lock: lock protecting changes_list & local_changes */ 1029 spinlock_t changes_list_lock; 1030 1031 /** @req_list_lock: lock protecting req_list */ 1032 spinlock_t req_list_lock; 1033 1034 /** @roam_list_lock: lock protecting roam_list */ 1035 spinlock_t roam_list_lock; 1036 1037 /** @last_changeset: last tt changeset this host has generated */ 1038 unsigned char *last_changeset; 1039 1040 /** 1041 * @last_changeset_len: length of last tt changeset this host has 1042 * generated 1043 */ 1044 u16 last_changeset_len; 1045 1046 /** 1047 * @last_changeset_lock: lock protecting last_changeset & 1048 * last_changeset_len 1049 */ 1050 spinlock_t last_changeset_lock; 1051 1052 /** 1053 * @commit_lock: prevents from executing a local TT commit while reading 1054 * the local table. The local TT commit is made up of two operations 1055 * (data structure update and metadata -CRC/TTVN- recalculation) and 1056 * they have to be executed atomically in order to avoid another thread 1057 * to read the table/metadata between those. 1058 */ 1059 spinlock_t commit_lock; 1060 1061 /** @work: work queue callback item for translation table purging */ 1062 struct delayed_work work; 1063 }; 1064 1065 #ifdef CONFIG_BATMAN_ADV_BLA 1066 1067 /** 1068 * struct batadv_priv_bla - per mesh interface bridge loop avoidance data 1069 */ 1070 struct batadv_priv_bla { 1071 /** @num_requests: number of bla requests in flight */ 1072 atomic_t num_requests; 1073 1074 /** 1075 * @num_requests_lock: locks update num_requests + 1076 * batadv_backbone_gw::state + batadv_backbone_gw::wait_periods update 1077 */ 1078 spinlock_t num_requests_lock; 1079 1080 /** 1081 * @claim_hash: hash table containing mesh nodes this host has claimed 1082 */ 1083 struct batadv_hashtable *claim_hash; 1084 1085 /** 1086 * @backbone_hash: hash table containing all detected backbone gateways 1087 */ 1088 struct batadv_hashtable *backbone_hash; 1089 1090 /** @loopdetect_addr: MAC address used for own loopdetection frames */ 1091 u8 loopdetect_addr[ETH_ALEN]; 1092 1093 /** 1094 * @loopdetect_lasttime: time when the loopdetection frames were sent 1095 */ 1096 unsigned long loopdetect_lasttime; 1097 1098 /** 1099 * @loopdetect_next: how many periods to wait for the next loopdetect 1100 * process 1101 */ 1102 atomic_t loopdetect_next; 1103 1104 /** 1105 * @bcast_duplist: recently received broadcast packets array (for 1106 * broadcast duplicate suppression) 1107 */ 1108 struct batadv_bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; 1109 1110 /** 1111 * @bcast_duplist_curr: index of last broadcast packet added to 1112 * bcast_duplist 1113 */ 1114 int bcast_duplist_curr; 1115 1116 /** 1117 * @bcast_duplist_lock: lock protecting bcast_duplist & 1118 * bcast_duplist_curr 1119 */ 1120 spinlock_t bcast_duplist_lock; 1121 1122 /** @claim_dest: local claim data (e.g. claim group) */ 1123 struct batadv_bla_claim_dst claim_dest; 1124 1125 /** @work: work queue callback item for cleanups & bla announcements */ 1126 struct delayed_work work; 1127 }; 1128 #endif 1129 1130 /** 1131 * struct batadv_priv_gw - per mesh interface gateway data 1132 */ 1133 struct batadv_priv_gw { 1134 /** @gateway_list: list of available gateway nodes */ 1135 struct hlist_head gateway_list; 1136 1137 /** @list_lock: lock protecting gateway_list, curr_gw, generation */ 1138 spinlock_t list_lock; 1139 1140 /** @curr_gw: pointer to currently selected gateway node */ 1141 struct batadv_gw_node __rcu *curr_gw; 1142 1143 /** @generation: current (generation) sequence number */ 1144 unsigned int generation; 1145 1146 /** 1147 * @mode: gateway operation: off, client or server (see batadv_gw_modes) 1148 */ 1149 enum batadv_gw_modes mode; 1150 1151 /** @sel_class: gateway selection class (applies if gw_mode client) */ 1152 u32 sel_class; 1153 1154 /** 1155 * @bandwidth_down: advertised uplink download bandwidth (if gw_mode 1156 * server) 1157 */ 1158 u32 bandwidth_down; 1159 1160 /** 1161 * @bandwidth_up: advertised uplink upload bandwidth (if gw_mode server) 1162 */ 1163 u32 bandwidth_up; 1164 1165 /** @reselect: bool indicating a gateway re-selection is in progress */ 1166 atomic_t reselect; 1167 }; 1168 1169 /** 1170 * struct batadv_priv_tvlv - per mesh interface tvlv data 1171 */ 1172 struct batadv_priv_tvlv { 1173 /** 1174 * @container_list: list of registered tvlv containers to be sent with 1175 * each OGM 1176 */ 1177 struct hlist_head container_list; 1178 1179 /** @handler_list: list of the various tvlv content handlers */ 1180 struct hlist_head handler_list; 1181 1182 /** @container_list_lock: protects tvlv container list access */ 1183 spinlock_t container_list_lock; 1184 1185 /** @handler_list_lock: protects handler list access */ 1186 spinlock_t handler_list_lock; 1187 }; 1188 1189 #ifdef CONFIG_BATMAN_ADV_DAT 1190 1191 /** 1192 * struct batadv_priv_dat - per mesh interface DAT private data 1193 */ 1194 struct batadv_priv_dat { 1195 /** @addr: node DAT address */ 1196 batadv_dat_addr_t addr; 1197 1198 /** @hash: hashtable representing the local ARP cache */ 1199 struct batadv_hashtable *hash; 1200 1201 /** @work: work queue callback item for cache purging */ 1202 struct delayed_work work; 1203 }; 1204 #endif 1205 1206 #ifdef CONFIG_BATMAN_ADV_MCAST 1207 /** 1208 * struct batadv_mcast_querier_state - IGMP/MLD querier state when bridged 1209 */ 1210 struct batadv_mcast_querier_state { 1211 /** @exists: whether a querier exists in the mesh */ 1212 unsigned char exists:1; 1213 1214 /** 1215 * @shadowing: if a querier exists, whether it is potentially shadowing 1216 * multicast listeners (i.e. querier is behind our own bridge segment) 1217 */ 1218 unsigned char shadowing:1; 1219 }; 1220 1221 /** 1222 * struct batadv_mcast_mla_flags - flags for the querier, bridge and tvlv state 1223 */ 1224 struct batadv_mcast_mla_flags { 1225 /** @querier_ipv4: the current state of an IGMP querier in the mesh */ 1226 struct batadv_mcast_querier_state querier_ipv4; 1227 1228 /** @querier_ipv6: the current state of an MLD querier in the mesh */ 1229 struct batadv_mcast_querier_state querier_ipv6; 1230 1231 /** @enabled: whether the multicast tvlv is currently enabled */ 1232 unsigned char enabled:1; 1233 1234 /** @bridged: whether the mesh interface has a bridge on top */ 1235 unsigned char bridged:1; 1236 1237 /** @tvlv_flags: the flags we have last sent in our mcast tvlv */ 1238 u8 tvlv_flags; 1239 }; 1240 1241 /** 1242 * struct batadv_priv_mcast - per mesh interface mcast data 1243 */ 1244 struct batadv_priv_mcast { 1245 /** 1246 * @mla_list: list of multicast addresses we are currently announcing 1247 * via TT 1248 */ 1249 struct hlist_head mla_list; /* see __batadv_mcast_mla_update() */ 1250 1251 /** 1252 * @want_all_unsnoopables_list: a list of orig_nodes wanting all 1253 * unsnoopable multicast traffic 1254 */ 1255 struct hlist_head want_all_unsnoopables_list; 1256 1257 /** 1258 * @want_all_ipv4_list: a list of orig_nodes wanting all IPv4 multicast 1259 * traffic 1260 */ 1261 struct hlist_head want_all_ipv4_list; 1262 1263 /** 1264 * @want_all_ipv6_list: a list of orig_nodes wanting all IPv6 multicast 1265 * traffic 1266 */ 1267 struct hlist_head want_all_ipv6_list; 1268 1269 /** 1270 * @want_all_rtr4_list: a list of orig_nodes wanting all routable IPv4 1271 * multicast traffic 1272 */ 1273 struct hlist_head want_all_rtr4_list; 1274 1275 /** 1276 * @want_all_rtr6_list: a list of orig_nodes wanting all routable IPv6 1277 * multicast traffic 1278 */ 1279 struct hlist_head want_all_rtr6_list; 1280 1281 /** 1282 * @mla_flags: flags for the querier, bridge and tvlv state 1283 */ 1284 struct batadv_mcast_mla_flags mla_flags; 1285 1286 /** 1287 * @mla_lock: a lock protecting mla_list and mla_flags 1288 */ 1289 spinlock_t mla_lock; 1290 1291 /** 1292 * @num_want_all_unsnoopables: number of nodes wanting unsnoopable IP 1293 * traffic 1294 */ 1295 atomic_t num_want_all_unsnoopables; 1296 1297 /** @num_want_all_ipv4: counter for items in want_all_ipv4_list */ 1298 atomic_t num_want_all_ipv4; 1299 1300 /** @num_want_all_ipv6: counter for items in want_all_ipv6_list */ 1301 atomic_t num_want_all_ipv6; 1302 1303 /** @num_want_all_rtr4: counter for items in want_all_rtr4_list */ 1304 atomic_t num_want_all_rtr4; 1305 1306 /** @num_want_all_rtr6: counter for items in want_all_rtr6_list */ 1307 atomic_t num_want_all_rtr6; 1308 1309 /** 1310 * @num_no_mc_ptype_capa: counter for number of nodes without the 1311 * BATADV_MCAST_HAVE_MC_PTYPE_CAPA flag 1312 */ 1313 atomic_t num_no_mc_ptype_capa; 1314 1315 /** 1316 * @want_lists_lock: lock for protecting modifications to mcasts 1317 * want_all_{unsnoopables,ipv4,ipv6}_list (traversals are rcu-locked) 1318 */ 1319 spinlock_t want_lists_lock; 1320 1321 /** @work: work queue callback item for multicast TT and TVLV updates */ 1322 struct delayed_work work; 1323 }; 1324 #endif 1325 1326 /** 1327 * struct batadv_tp_unacked - unacked packet meta-information 1328 * 1329 * This struct is supposed to represent a buffer unacked packet. However, since 1330 * the purpose of the TP meter is to count the traffic only, there is no need to 1331 * store the entire sk_buff, the starting offset and the length are enough 1332 */ 1333 struct batadv_tp_unacked { 1334 /** @seqno: seqno of the unacked packet */ 1335 u32 seqno; 1336 1337 /** @len: length of the packet */ 1338 u16 len; 1339 1340 /** @list: list node for &batadv_tp_vars_common.unacked_list */ 1341 struct list_head list; 1342 }; 1343 1344 /** 1345 * struct batadv_tp_vars_common - common tp meter private variables per session 1346 */ 1347 struct batadv_tp_vars_common { 1348 /** @list: list node for &bat_priv.tp_sender_list/&bat_priv.tp_receiver_list */ 1349 struct hlist_node list; 1350 1351 /** @timer: timer for ack (receiver) and retry (sender) */ 1352 struct timer_list timer; 1353 1354 /** @bat_priv: pointer to the mesh object */ 1355 struct batadv_priv *bat_priv; 1356 1357 /** @other_end: mac address of remote */ 1358 u8 other_end[ETH_ALEN]; 1359 1360 /** @session: TP session identifier */ 1361 u8 session[2]; 1362 1363 /** @unacked_list: list of unacked packets (meta-info only) */ 1364 struct list_head unacked_list; 1365 1366 /** @unacked_lock: protect unacked_list + &batadv_tp_receiver.last_recv */ 1367 spinlock_t unacked_lock; 1368 1369 /** @unacked_count: number of unacked entries */ 1370 size_t unacked_count; 1371 1372 /** @refcount: number of context where the object is used */ 1373 struct kref refcount; 1374 1375 /** @rcu: struct used for freeing in an RCU-safe manner */ 1376 struct rcu_head rcu; 1377 }; 1378 1379 /** 1380 * struct batadv_tp_sender_cc - congestion control variables 1381 */ 1382 struct batadv_tp_sender_cc { 1383 /** @fast_recovery: true if in Fast Recovery mode */ 1384 bool fast_recovery:1; 1385 1386 /** @dup_acks: duplicate ACKs counter */ 1387 u8 dup_acks; 1388 1389 /** @dec_cwnd: decimal part of the cwnd used during linear growth */ 1390 u16 dec_cwnd; 1391 1392 /** @cwnd: current size of the congestion window */ 1393 u32 cwnd; 1394 1395 /** 1396 * @ss_threshold: Slow Start threshold. Once cwnd exceeds this value the 1397 * connection switches to the Congestion Avoidance state 1398 */ 1399 u32 ss_threshold; 1400 1401 /** @last_acked: last acked byte */ 1402 u32 last_acked; 1403 1404 /** @last_sent: last sent byte, not yet acked */ 1405 u32 last_sent; 1406 1407 /** @recover: last sent seqno when entering Fast Recovery */ 1408 u32 recover; 1409 1410 /** @rto: sender timeout */ 1411 u32 rto; 1412 1413 /** @srtt: smoothed RTT scaled by 2^3 */ 1414 u32 srtt; 1415 1416 /** @rttvar: RTT variation scaled by 2^2 */ 1417 u32 rttvar; 1418 }; 1419 1420 /** 1421 * struct batadv_tp_sender - sender tp meter private variables per session 1422 */ 1423 struct batadv_tp_sender { 1424 /** @common: common batadv_tp_vars_common (must be first member) */ 1425 struct batadv_tp_vars_common common; 1426 1427 /** @start_time: start time in jiffies */ 1428 unsigned long start_time; 1429 1430 /** 1431 * @send_result: 0 when sending is ongoing and otherwise 1432 * enum batadv_tp_meter_reason 1433 */ 1434 atomic_t send_result; 1435 1436 /** @finish_work: work item for the finishing procedure */ 1437 struct delayed_work finish_work; 1438 1439 /** @finished: completion signaled when a sender thread exits */ 1440 struct completion finished; 1441 1442 /** @test_length: test length in milliseconds */ 1443 u32 test_length; 1444 1445 /** @icmp_uid: local ICMP "socket" index */ 1446 u8 icmp_uid; 1447 1448 /** @cc: congestion control variables */ 1449 struct batadv_tp_sender_cc cc; 1450 1451 /** @cc_lock: lock to protect @cc */ 1452 spinlock_t cc_lock; 1453 1454 /** @tot_sent: amount of data sent/ACKed so far */ 1455 atomic64_t tot_sent; 1456 1457 /** 1458 * @more_bytes: waiting queue anchor when waiting for more ack/retry 1459 * timeout 1460 */ 1461 wait_queue_head_t more_bytes; 1462 1463 /** @prerandom_offset: offset inside the prerandom buffer */ 1464 u32 prerandom_offset; 1465 1466 /** @prerandom_lock: spinlock protecting access to prerandom_offset */ 1467 spinlock_t prerandom_lock; 1468 }; 1469 1470 /** 1471 * struct batadv_tp_receiver - receiver tp meter private variables per session 1472 */ 1473 struct batadv_tp_receiver { 1474 /** @common: common batadv_tp_vars_common (must be first member) */ 1475 struct batadv_tp_vars_common common; 1476 1477 /** @receiving: receiving binary semaphore: 1 if receiving, 0 is not */ 1478 atomic_t receiving; 1479 1480 /** @last_recv: last in-order received packet */ 1481 u32 last_recv; 1482 1483 /** @last_recv_time: time (jiffies) a msg was received */ 1484 unsigned long last_recv_time; 1485 }; 1486 1487 /** 1488 * struct batadv_meshif_vlan - per VLAN attributes set 1489 */ 1490 struct batadv_meshif_vlan { 1491 /** @bat_priv: pointer to the mesh object */ 1492 struct batadv_priv *bat_priv; 1493 1494 /** @vid: VLAN identifier */ 1495 unsigned short vid; 1496 1497 /** @ap_isolation: AP isolation state */ 1498 u8 ap_isolation; /* boolean */ 1499 1500 /** @tt: TT private attributes (VLAN specific) */ 1501 struct batadv_vlan_tt tt; 1502 1503 /** @list: list node for &bat_priv.meshif_vlan_list */ 1504 struct hlist_node list; 1505 1506 /** 1507 * @refcount: number of context where this object is currently in use 1508 */ 1509 struct kref refcount; 1510 1511 /** @rcu: struct used for freeing in a RCU-safe manner */ 1512 struct rcu_head rcu; 1513 }; 1514 1515 /** 1516 * struct batadv_priv_bat_v - B.A.T.M.A.N. V per mesh-interface private data 1517 */ 1518 struct batadv_priv_bat_v { 1519 /** @ogm_buff: buffer holding the OGM packet */ 1520 struct batadv_ogm_buf ogm_buff; 1521 1522 /** @ogm_seqno: OGM sequence number - used to identify each OGM */ 1523 atomic_t ogm_seqno; 1524 1525 /** @ogm_buff_mutex: lock protecting ogm_buff */ 1526 struct mutex ogm_buff_mutex; 1527 1528 /** @ogm_wq: workqueue used to schedule OGM transmissions */ 1529 struct delayed_work ogm_wq; 1530 }; 1531 1532 /** 1533 * struct batadv_priv - per mesh interface data 1534 */ 1535 struct batadv_priv { 1536 /** 1537 * @mesh_state: current status of the mesh 1538 * (inactive/active/deactivating) 1539 */ 1540 enum batadv_mesh_state mesh_state; 1541 1542 /** @mesh_iface: net device which holds this struct as private data */ 1543 struct net_device *mesh_iface; 1544 1545 /** 1546 * @mtu_set_by_user: MTU was set once by user 1547 * protected by rtnl_lock 1548 */ 1549 int mtu_set_by_user; 1550 1551 /** 1552 * @bat_counters: mesh internal traffic statistic counters (see 1553 * batadv_counters) 1554 */ 1555 u64 __percpu *bat_counters; /* Per cpu counters */ 1556 1557 /** 1558 * @aggregated_ogms: bool indicating whether OGM aggregation is enabled 1559 */ 1560 u8 aggregated_ogms; 1561 1562 /** @bonding: bool indicating whether traffic bonding is enabled */ 1563 u8 bonding; 1564 1565 /** 1566 * @fragmentation: bool indicating whether traffic fragmentation is 1567 * enabled 1568 */ 1569 u8 fragmentation; 1570 1571 #ifdef CONFIG_BATMAN_ADV_BLA 1572 /** 1573 * @bridge_loop_avoidance: bool indicating whether bridge loop 1574 * avoidance is enabled 1575 */ 1576 u8 bridge_loop_avoidance; 1577 #endif 1578 1579 #ifdef CONFIG_BATMAN_ADV_DAT 1580 /** 1581 * @distributed_arp_table: bool indicating whether distributed ARP table 1582 * is enabled 1583 */ 1584 u8 distributed_arp_table; 1585 #endif 1586 1587 #ifdef CONFIG_BATMAN_ADV_MCAST 1588 /** 1589 * @multicast_mode: Enable or disable multicast optimizations on this 1590 * node's sender/originating side 1591 */ 1592 u8 multicast_mode; 1593 1594 /** 1595 * @multicast_fanout: Maximum number of packet copies to generate for a 1596 * multicast-to-unicast conversion 1597 */ 1598 u32 multicast_fanout; 1599 #endif 1600 1601 /** 1602 * @packet_size_max: max packet size that can be transmitted via 1603 * multiple fragmented skbs or a single frame if fragmentation is 1604 * disabled 1605 */ 1606 int packet_size_max; 1607 1608 /** 1609 * @frag_seqno: incremental counter to identify chains of egress 1610 * fragments 1611 */ 1612 atomic_t frag_seqno; 1613 1614 /** @orig_interval: OGM broadcast interval in milliseconds */ 1615 u32 orig_interval; 1616 1617 /** 1618 * @hop_penalty: penalty which will be applied to an OGM's tq-field on 1619 * every hop 1620 */ 1621 u8 hop_penalty; 1622 1623 #ifdef CONFIG_BATMAN_ADV_DEBUG 1624 /** @log_level: configured log level (see batadv_dbg_level) */ 1625 u32 log_level; 1626 #endif 1627 1628 /** 1629 * @isolation_mark: the skb->mark value used to match packets for AP 1630 * isolation 1631 */ 1632 u32 isolation_mark; 1633 1634 /** 1635 * @isolation_mark_mask: bitmask identifying the bits in skb->mark to be 1636 * used for the isolation mark 1637 */ 1638 u32 isolation_mark_mask; 1639 1640 /** @bcast_seqno: last sent broadcast packet sequence number */ 1641 atomic_t bcast_seqno; 1642 1643 /** 1644 * @bcast_queue_left: number of remaining buffered broadcast packet 1645 * slots 1646 */ 1647 atomic_t bcast_queue_left; 1648 1649 /** @batman_queue_left: number of remaining OGM packet slots */ 1650 atomic_t batman_queue_left; 1651 1652 /** @forw_bat_list: list of aggregated OGMs that will be forwarded */ 1653 struct hlist_head forw_bat_list; 1654 1655 /** 1656 * @forw_bcast_list: list of broadcast packets that will be 1657 * rebroadcasted 1658 */ 1659 struct hlist_head forw_bcast_list; 1660 1661 /** @tp_sender_list: list of tp sender sessions */ 1662 struct hlist_head tp_sender_list; 1663 1664 /** @tp_receiver_list: list of tp receiver sessions */ 1665 struct hlist_head tp_receiver_list; 1666 1667 /** @orig_hash: hash table containing mesh participants (orig nodes) */ 1668 struct batadv_hashtable *orig_hash; 1669 1670 /** @forw_bat_list_lock: lock protecting forw_bat_list */ 1671 spinlock_t forw_bat_list_lock; 1672 1673 /** @forw_bcast_list_lock: lock protecting forw_bcast_list */ 1674 spinlock_t forw_bcast_list_lock; 1675 1676 /** @tp_list_lock: spinlock protecting @tp_sender_list + @tp_receiver_list */ 1677 spinlock_t tp_list_lock; 1678 1679 /** @tp_num: number of currently active tp sessions */ 1680 atomic_t tp_num; 1681 1682 /** @orig_work: work queue callback item for orig node purging */ 1683 struct delayed_work orig_work; 1684 1685 /** 1686 * @primary_if: one of the hard-interfaces assigned to this mesh 1687 * interface becomes the primary interface 1688 */ 1689 struct batadv_hard_iface __rcu *primary_if; /* rcu protected pointer */ 1690 1691 /** @algo_ops: routing algorithm used by this mesh interface */ 1692 struct batadv_algo_ops *algo_ops; 1693 1694 /** 1695 * @meshif_vlan_list: a list of meshif_vlan structs, one per VLAN 1696 * created on top of the mesh interface represented by this object 1697 */ 1698 struct hlist_head meshif_vlan_list; 1699 1700 /** @meshif_vlan_list_lock: lock protecting meshif_vlan_list */ 1701 spinlock_t meshif_vlan_list_lock; 1702 1703 #ifdef CONFIG_BATMAN_ADV_BLA 1704 /** @bla: bridge loop avoidance data */ 1705 struct batadv_priv_bla bla; 1706 #endif 1707 1708 /** @gw: gateway data */ 1709 struct batadv_priv_gw gw; 1710 1711 /** @tt: translation table data */ 1712 struct batadv_priv_tt tt; 1713 1714 /** @tvlv: type-version-length-value data */ 1715 struct batadv_priv_tvlv tvlv; 1716 1717 #ifdef CONFIG_BATMAN_ADV_DAT 1718 /** @dat: distributed arp table data */ 1719 struct batadv_priv_dat dat; 1720 #endif 1721 1722 #ifdef CONFIG_BATMAN_ADV_MCAST 1723 /** @mcast: multicast data */ 1724 struct batadv_priv_mcast mcast; 1725 #endif 1726 1727 #ifdef CONFIG_BATMAN_ADV_BATMAN_V 1728 /** @bat_v: B.A.T.M.A.N. V per mesh-interface private data */ 1729 struct batadv_priv_bat_v bat_v; 1730 #endif 1731 }; 1732 1733 #ifdef CONFIG_BATMAN_ADV_BLA 1734 1735 /** 1736 * enum batadv_bla_backbone_gw_state - state of a bridge loop avoidance 1737 * backbone gateway 1738 */ 1739 enum batadv_bla_backbone_gw_state { 1740 /** 1741 * @BATADV_BLA_BACKBONE_GW_STOPPED: backbone gw is being removed 1742 * and it must no longer work on requests 1743 */ 1744 BATADV_BLA_BACKBONE_GW_STOPPED, 1745 1746 /** 1747 * @BATADV_BLA_BACKBONE_GW_UNSYNCED: backbone was detected out 1748 * of sync and a request was sent. No traffic is forwarded until the 1749 * situation is resolved 1750 */ 1751 BATADV_BLA_BACKBONE_GW_UNSYNCED, 1752 1753 /** 1754 * @BATADV_BLA_BACKBONE_GW_SYNCED: backbone is considered to be in 1755 * sync. traffic can be forwarded 1756 */ 1757 BATADV_BLA_BACKBONE_GW_SYNCED, 1758 }; 1759 1760 /** 1761 * struct batadv_bla_backbone_gw - batman-adv gateway bridged into the LAN 1762 */ 1763 struct batadv_bla_backbone_gw { 1764 /** 1765 * @orig: originator address of backbone node (mac address of primary 1766 * iface) 1767 */ 1768 u8 orig[ETH_ALEN]; 1769 1770 /** @vid: vlan id this gateway was detected on */ 1771 unsigned short vid; 1772 1773 /** @hash_entry: hlist node for &batadv_priv_bla.backbone_hash */ 1774 struct hlist_node hash_entry; 1775 1776 /** @bat_priv: pointer to mesh_iface this backbone gateway belongs to */ 1777 struct batadv_priv *bat_priv; 1778 1779 /** @lasttime: last time we heard of this backbone gw */ 1780 unsigned long lasttime; 1781 1782 /** 1783 * @wait_periods: grace time for bridge forward delays and bla group 1784 * forming at bootup phase - no bcast traffic is formwared until it has 1785 * elapsed. Must only be access with num_requests_lock. 1786 */ 1787 u8 wait_periods; 1788 1789 /** @state: sync state. Must only be access with num_requests_lock. */ 1790 enum batadv_bla_backbone_gw_state state; 1791 1792 /** @crc: crc16 checksum over all claims */ 1793 u16 crc; 1794 1795 /** @crc_lock: lock protecting crc */ 1796 spinlock_t crc_lock; 1797 1798 /** @report_work: work struct for reporting detected loops */ 1799 struct work_struct report_work; 1800 1801 /** @refcount: number of contexts the object is used */ 1802 struct kref refcount; 1803 1804 /** @rcu: struct used for freeing in an RCU-safe manner */ 1805 struct rcu_head rcu; 1806 }; 1807 1808 /** 1809 * struct batadv_bla_claim - claimed non-mesh client structure 1810 */ 1811 struct batadv_bla_claim { 1812 /** @addr: mac address of claimed non-mesh client */ 1813 u8 addr[ETH_ALEN]; 1814 1815 /** @vid: vlan id this client was detected on */ 1816 unsigned short vid; 1817 1818 /** @backbone_gw: pointer to backbone gw claiming this client */ 1819 struct batadv_bla_backbone_gw *backbone_gw; 1820 1821 /** @backbone_lock: lock protecting backbone_gw pointer */ 1822 spinlock_t backbone_lock; 1823 1824 /** @lasttime: last time we heard of claim (locals only) */ 1825 unsigned long lasttime; 1826 1827 /** @hash_entry: hlist node for &batadv_priv_bla.claim_hash */ 1828 struct hlist_node hash_entry; 1829 1830 /** @refcount: number of contexts the object is used */ 1831 struct rcu_head rcu; 1832 1833 /** @rcu: struct used for freeing in an RCU-safe manner */ 1834 struct kref refcount; 1835 }; 1836 #endif 1837 1838 /** 1839 * struct batadv_tt_common_entry - tt local & tt global common data 1840 */ 1841 struct batadv_tt_common_entry { 1842 /** @addr: mac address of non-mesh client */ 1843 u8 addr[ETH_ALEN]; 1844 1845 /** @vid: VLAN identifier */ 1846 unsigned short vid; 1847 1848 /** 1849 * @hash_entry: hlist node for &batadv_priv_tt.local_hash or for 1850 * &batadv_priv_tt.global_hash 1851 */ 1852 struct hlist_node hash_entry; 1853 1854 /** @flags: various state handling flags (see batadv_tt_client_flags) */ 1855 u16 flags; 1856 1857 /** @added_at: timestamp used for purging stale tt common entries */ 1858 unsigned long added_at; 1859 1860 /** @refcount: number of contexts the object is used */ 1861 struct kref refcount; 1862 1863 /** @rcu: struct used for freeing in an RCU-safe manner */ 1864 struct rcu_head rcu; 1865 }; 1866 1867 /** 1868 * struct batadv_tt_local_entry - translation table local entry data 1869 */ 1870 struct batadv_tt_local_entry { 1871 /** @common: general translation table data */ 1872 struct batadv_tt_common_entry common; 1873 1874 /** @last_seen: timestamp used for purging stale tt local entries */ 1875 unsigned long last_seen; 1876 1877 /** @vlan: mesh-interface vlan of the entry */ 1878 struct batadv_meshif_vlan *vlan; 1879 }; 1880 1881 /** 1882 * struct batadv_tt_global_entry - translation table global entry data 1883 */ 1884 struct batadv_tt_global_entry { 1885 /** @common: general translation table data */ 1886 struct batadv_tt_common_entry common; 1887 1888 /** @orig_list: list of orig nodes announcing this non-mesh client */ 1889 struct hlist_head orig_list; 1890 1891 /** @orig_list_count: number of items in the orig_list */ 1892 atomic_t orig_list_count; 1893 1894 /** @list_lock: lock protecting orig_list */ 1895 spinlock_t list_lock; 1896 1897 /** @roam_at: time at which TT_GLOBAL_ROAM was set */ 1898 unsigned long roam_at; 1899 }; 1900 1901 /** 1902 * struct batadv_tt_orig_list_entry - orig node announcing a non-mesh client 1903 */ 1904 struct batadv_tt_orig_list_entry { 1905 /** @orig_node: pointer to orig node announcing this non-mesh client */ 1906 struct batadv_orig_node *orig_node; 1907 1908 /** 1909 * @ttvn: translation table version number which added the non-mesh 1910 * client 1911 */ 1912 u8 ttvn; 1913 1914 /** @flags: per orig entry TT sync flags */ 1915 u8 flags; 1916 1917 /** @list: list node for &batadv_tt_global_entry.orig_list */ 1918 struct hlist_node list; 1919 1920 /** @refcount: number of contexts the object is used */ 1921 struct kref refcount; 1922 1923 /** @rcu: struct used for freeing in an RCU-safe manner */ 1924 struct rcu_head rcu; 1925 }; 1926 1927 /** 1928 * struct batadv_tt_change_node - structure for tt changes occurred 1929 */ 1930 struct batadv_tt_change_node { 1931 /** @list: list node for &batadv_priv_tt.changes_list */ 1932 struct list_head list; 1933 1934 /** @change: holds the actual translation table diff data */ 1935 struct batadv_tvlv_tt_change change; 1936 }; 1937 1938 /** 1939 * struct batadv_tt_req_node - data to keep track of the tt requests in flight 1940 */ 1941 struct batadv_tt_req_node { 1942 /** 1943 * @addr: mac address of the originator this request was sent to 1944 */ 1945 u8 addr[ETH_ALEN]; 1946 1947 /** @issued_at: timestamp used for purging stale tt requests */ 1948 unsigned long issued_at; 1949 1950 /** @refcount: number of contexts the object is used by */ 1951 struct kref refcount; 1952 1953 /** @list: list node for &batadv_priv_tt.req_list */ 1954 struct hlist_node list; 1955 }; 1956 1957 /** 1958 * struct batadv_tt_roam_node - roaming client data 1959 */ 1960 struct batadv_tt_roam_node { 1961 /** @addr: mac address of the client in the roaming phase */ 1962 u8 addr[ETH_ALEN]; 1963 1964 /** @vid: VLAN identifier */ 1965 u16 vid; 1966 1967 /** 1968 * @counter: number of allowed roaming events per client within a single 1969 * OGM interval (changes are committed with each OGM) 1970 */ 1971 atomic_t counter; 1972 1973 /** 1974 * @first_time: timestamp used for purging stale roaming node entries 1975 */ 1976 unsigned long first_time; 1977 1978 /** @list: list node for &batadv_priv_tt.roam_list */ 1979 struct list_head list; 1980 }; 1981 1982 /** 1983 * struct batadv_skb_cb - control buffer structure used to store private data 1984 * relevant to batman-adv in the skb->cb buffer in skbs. 1985 */ 1986 struct batadv_skb_cb { 1987 /** @num_bcasts: Counter for broadcast packet retransmissions */ 1988 unsigned char num_bcasts; 1989 }; 1990 1991 /** 1992 * struct batadv_forw_packet - structure for bcast packets to be sent/forwarded 1993 */ 1994 struct batadv_forw_packet { 1995 /** 1996 * @list: list node for &batadv_priv.forw.bcast_list and 1997 * &batadv_priv.forw.bat_list 1998 */ 1999 struct hlist_node list; 2000 2001 /** @cleanup_list: list node for purging functions */ 2002 struct hlist_node cleanup_list; 2003 2004 /** @send_time: execution time for delayed_work (packet sending) */ 2005 unsigned long send_time; 2006 2007 /** 2008 * @own: bool for locally generated packets (local OGMs are re-scheduled 2009 * after sending) 2010 */ 2011 u8 own; 2012 2013 /** @skb: bcast packet's skb buffer */ 2014 struct sk_buff *skb; 2015 2016 /** @packet_len: size of aggregated OGM packet inside the skb buffer */ 2017 u16 packet_len; 2018 2019 /** @direct_link_flags: direct link flags for aggregated OGM packets */ 2020 DECLARE_BITMAP(direct_link_flags, BATADV_MAX_AGGREGATION_PACKETS); 2021 2022 /** @num_packets: counter for aggregated OGMv1 packets */ 2023 u8 num_packets; 2024 2025 /** @delayed_work: work queue callback item for packet sending */ 2026 struct delayed_work delayed_work; 2027 2028 /** 2029 * @if_incoming: pointer to incoming hard-iface or primary iface if 2030 * locally generated packet 2031 */ 2032 struct batadv_hard_iface *if_incoming; 2033 2034 /** 2035 * @if_outgoing: packet where the packet should be sent to, or NULL if 2036 * unspecified 2037 */ 2038 struct batadv_hard_iface *if_outgoing; 2039 2040 /** @queue_left: The queue (counter) this packet was applied to */ 2041 atomic_t *queue_left; 2042 }; 2043 2044 /** 2045 * struct batadv_algo_iface_ops - mesh algorithm callbacks (interface specific) 2046 */ 2047 struct batadv_algo_iface_ops { 2048 /** 2049 * @activate: start routing mechanisms when hard-interface is brought up 2050 * (optional) 2051 */ 2052 void (*activate)(struct batadv_hard_iface *hard_iface); 2053 2054 /** @enable: init routing info when hard-interface is enabled */ 2055 int (*enable)(struct batadv_hard_iface *hard_iface); 2056 2057 /** @enabled: notification when hard-interface was enabled (optional) */ 2058 void (*enabled)(struct batadv_hard_iface *hard_iface); 2059 2060 /** @disable: de-init routing info when hard-interface is disabled */ 2061 void (*disable)(struct batadv_hard_iface *hard_iface); 2062 2063 /** 2064 * @update_mac: (re-)init mac addresses of the protocol information 2065 * belonging to this hard-interface 2066 */ 2067 void (*update_mac)(struct batadv_hard_iface *hard_iface); 2068 2069 /** @primary_set: called when primary interface is selected / changed */ 2070 void (*primary_set)(struct batadv_hard_iface *hard_iface); 2071 }; 2072 2073 /** 2074 * struct batadv_algo_neigh_ops - mesh algorithm callbacks (neighbour specific) 2075 */ 2076 struct batadv_algo_neigh_ops { 2077 /** @hardif_init: called on creation of single hop entry (optional) */ 2078 void (*hardif_init)(struct batadv_hardif_neigh_node *neigh); 2079 2080 /** 2081 * @cmp: compare the metrics of two neighbors for their respective 2082 * outgoing interfaces 2083 */ 2084 int (*cmp)(struct batadv_neigh_node *neigh1, 2085 struct batadv_hard_iface *if_outgoing1, 2086 struct batadv_neigh_node *neigh2, 2087 struct batadv_hard_iface *if_outgoing2); 2088 2089 /** 2090 * @is_similar_or_better: check if neigh1 is equally similar or better 2091 * than neigh2 for their respective outgoing interface from the metric 2092 * prospective 2093 */ 2094 bool (*is_similar_or_better)(struct batadv_neigh_node *neigh1, 2095 struct batadv_hard_iface *if_outgoing1, 2096 struct batadv_neigh_node *neigh2, 2097 struct batadv_hard_iface *if_outgoing2); 2098 2099 /** @dump: dump neighbors to a netlink socket (optional) */ 2100 void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, 2101 struct batadv_priv *priv, 2102 struct batadv_hard_iface *hard_iface); 2103 }; 2104 2105 /** 2106 * struct batadv_algo_orig_ops - mesh algorithm callbacks (originator specific) 2107 */ 2108 struct batadv_algo_orig_ops { 2109 /** @dump: dump originators to a netlink socket (optional) */ 2110 void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, 2111 struct batadv_priv *priv, 2112 struct batadv_hard_iface *hard_iface); 2113 }; 2114 2115 /** 2116 * struct batadv_algo_gw_ops - mesh algorithm callbacks (GW specific) 2117 */ 2118 struct batadv_algo_gw_ops { 2119 /** @init_sel_class: initialize GW selection class (optional) */ 2120 void (*init_sel_class)(struct batadv_priv *bat_priv); 2121 2122 /** 2123 * @sel_class_max: maximum allowed GW selection class 2124 */ 2125 u32 sel_class_max; 2126 2127 /** 2128 * @get_best_gw_node: select the best GW from the list of available 2129 * nodes (optional) 2130 */ 2131 struct batadv_gw_node *(*get_best_gw_node) 2132 (struct batadv_priv *bat_priv); 2133 2134 /** 2135 * @is_eligible: check if a newly discovered GW is a potential candidate 2136 * for the election as best GW (optional) 2137 */ 2138 bool (*is_eligible)(struct batadv_priv *bat_priv, 2139 struct batadv_orig_node *curr_gw_orig, 2140 struct batadv_orig_node *orig_node); 2141 2142 /** @dump: dump gateways to a netlink socket (optional) */ 2143 void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, 2144 struct batadv_priv *priv); 2145 }; 2146 2147 /** 2148 * struct batadv_algo_ops - mesh algorithm callbacks 2149 */ 2150 struct batadv_algo_ops { 2151 /** @list: list node for the batadv_algo_list */ 2152 struct hlist_node list; 2153 2154 /** @name: name of the algorithm */ 2155 char *name; 2156 2157 /** @iface: callbacks related to interface handling */ 2158 struct batadv_algo_iface_ops iface; 2159 2160 /** @neigh: callbacks related to neighbors handling */ 2161 struct batadv_algo_neigh_ops neigh; 2162 2163 /** @orig: callbacks related to originators handling */ 2164 struct batadv_algo_orig_ops orig; 2165 2166 /** @gw: callbacks related to GW mode */ 2167 struct batadv_algo_gw_ops gw; 2168 }; 2169 2170 /** 2171 * struct batadv_dat_entry - it is a single entry of batman-adv ARP backend. It 2172 * is used to stored ARP entries needed for the global DAT cache 2173 */ 2174 struct batadv_dat_entry { 2175 /** @ip: the IPv4 corresponding to this DAT/ARP entry */ 2176 __be32 ip; 2177 2178 /** @mac_addr: the MAC address associated to the stored IPv4 */ 2179 u8 mac_addr[ETH_ALEN]; 2180 2181 /** @vid: the vlan ID associated to this entry */ 2182 unsigned short vid; 2183 2184 /** 2185 * @last_update: time in jiffies when this entry was refreshed last time 2186 */ 2187 unsigned long last_update; 2188 2189 /** @hash_entry: hlist node for &batadv_priv_dat.hash */ 2190 struct hlist_node hash_entry; 2191 2192 /** @refcount: number of contexts the object is used */ 2193 struct kref refcount; 2194 2195 /** @rcu: struct used for freeing in an RCU-safe manner */ 2196 struct rcu_head rcu; 2197 }; 2198 2199 /** 2200 * struct batadv_hw_addr - a list entry for a MAC address 2201 */ 2202 struct batadv_hw_addr { 2203 /** @list: list node for the linking of entries */ 2204 struct hlist_node list; 2205 2206 /** @addr: the MAC address of this list entry */ 2207 unsigned char addr[ETH_ALEN]; 2208 }; 2209 2210 /** 2211 * struct batadv_dat_candidate - candidate destination for DAT operations 2212 */ 2213 struct batadv_dat_candidate { 2214 /** 2215 * @type: the type of the selected candidate. It can one of the 2216 * following: 2217 * - BATADV_DAT_CANDIDATE_NOT_FOUND 2218 * - BATADV_DAT_CANDIDATE_ORIG 2219 */ 2220 int type; 2221 2222 /** 2223 * @orig_node: if type is BATADV_DAT_CANDIDATE_ORIG this field points to 2224 * the corresponding originator node structure 2225 */ 2226 struct batadv_orig_node *orig_node; 2227 }; 2228 2229 /** 2230 * struct batadv_tvlv_container - container for tvlv appended to OGMs 2231 */ 2232 struct batadv_tvlv_container { 2233 /** @list: hlist node for &batadv_priv_tvlv.container_list */ 2234 struct hlist_node list; 2235 2236 /** @tvlv_hdr: tvlv header information needed to construct the tvlv */ 2237 struct batadv_tvlv_hdr tvlv_hdr; 2238 2239 /** @refcount: number of contexts the object is used */ 2240 struct kref refcount; 2241 }; 2242 2243 /** 2244 * struct batadv_tvlv_handler - handler for specific tvlv type and version 2245 */ 2246 struct batadv_tvlv_handler { 2247 /** @list: hlist node for &batadv_priv_tvlv.handler_list */ 2248 struct hlist_node list; 2249 2250 /** 2251 * @ogm_handler: handler callback which is given the tvlv payload to 2252 * process on incoming OGM packets 2253 */ 2254 void (*ogm_handler)(struct batadv_priv *bat_priv, 2255 struct batadv_orig_node *orig, 2256 u8 flags, void *tvlv_value, u16 tvlv_value_len); 2257 2258 /** 2259 * @unicast_handler: handler callback which is given the tvlv payload to 2260 * process on incoming unicast tvlv packets 2261 */ 2262 int (*unicast_handler)(struct batadv_priv *bat_priv, 2263 u8 *src, u8 *dst, 2264 void *tvlv_value, u16 tvlv_value_len); 2265 2266 /** 2267 * @mcast_handler: handler callback which is given the tvlv payload to 2268 * process on incoming mcast packet 2269 */ 2270 int (*mcast_handler)(struct batadv_priv *bat_priv, struct sk_buff *skb); 2271 2272 /** @type: tvlv type this handler feels responsible for */ 2273 u8 type; 2274 2275 /** @version: tvlv version this handler feels responsible for */ 2276 u8 version; 2277 2278 /** @flags: tvlv handler flags */ 2279 u8 flags; 2280 2281 /** @refcount: number of contexts the object is used */ 2282 struct kref refcount; 2283 2284 /** @rcu: struct used for freeing in an RCU-safe manner */ 2285 struct rcu_head rcu; 2286 }; 2287 2288 /** 2289 * enum batadv_tvlv_handler_flags - tvlv handler flags definitions 2290 */ 2291 enum batadv_tvlv_handler_flags { 2292 /** 2293 * @BATADV_TVLV_HANDLER_OGM_CIFNOTFND: tvlv ogm processing function 2294 * will call this handler even if its type was not found (with no data) 2295 */ 2296 BATADV_TVLV_HANDLER_OGM_CIFNOTFND = BIT(1), 2297 }; 2298 2299 #endif /* _NET_BATMAN_ADV_TYPES_H_ */ 2300