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