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_common.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 /** 1371 * struct batadv_tp_sender_cc - congestion control variables 1372 */ 1373 struct batadv_tp_sender_cc { 1374 /** @fast_recovery: true if in Fast Recovery mode */ 1375 bool fast_recovery:1; 1376 1377 /** @dup_acks: duplicate ACKs counter */ 1378 u8 dup_acks; 1379 1380 /** @dec_cwnd: decimal part of the cwnd used during linear growth */ 1381 u16 dec_cwnd; 1382 1383 /** @cwnd: current size of the congestion window */ 1384 u32 cwnd; 1385 1386 /** 1387 * @ss_threshold: Slow Start threshold. Once cwnd exceeds this value the 1388 * connection switches to the Congestion Avoidance state 1389 */ 1390 u32 ss_threshold; 1391 1392 /** @last_acked: last acked byte */ 1393 u32 last_acked; 1394 1395 /** @last_sent: last sent byte, not yet acked */ 1396 u32 last_sent; 1397 1398 /** @recover: last sent seqno when entering Fast Recovery */ 1399 u32 recover; 1400 1401 /** @rto: sender timeout */ 1402 u32 rto; 1403 1404 /** @srtt: smoothed RTT scaled by 2^3 */ 1405 u32 srtt; 1406 1407 /** @rttvar: RTT variation scaled by 2^2 */ 1408 u32 rttvar; 1409 }; 1410 1411 /** 1412 * struct batadv_tp_sender - sender tp meter private variables per session 1413 */ 1414 struct batadv_tp_sender { 1415 /** @common: common batadv_tp_vars_common (must be first member) */ 1416 struct batadv_tp_vars_common common; 1417 1418 /** @start_time: start time in jiffies */ 1419 unsigned long start_time; 1420 1421 /** 1422 * @send_result: 0 when sending is ongoing and otherwise 1423 * enum batadv_tp_meter_reason 1424 */ 1425 atomic_t send_result; 1426 1427 /** @finish_work: work item for the finishing procedure */ 1428 struct delayed_work finish_work; 1429 1430 /** @finished: completion signaled when a sender thread exits */ 1431 struct completion finished; 1432 1433 /** @test_length: test length in milliseconds */ 1434 u32 test_length; 1435 1436 /** @icmp_uid: local ICMP "socket" index */ 1437 u8 icmp_uid; 1438 1439 /** @cc: congestion control variables */ 1440 struct batadv_tp_sender_cc cc; 1441 1442 /** @cc_lock: lock to protect @cc */ 1443 spinlock_t cc_lock; 1444 1445 /** @tot_sent: amount of data sent/ACKed so far */ 1446 atomic64_t tot_sent; 1447 1448 /** 1449 * @more_bytes: waiting queue anchor when waiting for more ack/retry 1450 * timeout 1451 */ 1452 wait_queue_head_t more_bytes; 1453 1454 /** @prerandom_offset: offset inside the prerandom buffer */ 1455 u32 prerandom_offset; 1456 1457 /** @prerandom_lock: spinlock protecting access to prerandom_offset */ 1458 spinlock_t prerandom_lock; 1459 }; 1460 1461 /** 1462 * struct batadv_tp_receiver - receiver tp meter private variables per session 1463 */ 1464 struct batadv_tp_receiver { 1465 /** @common: common batadv_tp_vars_common (must be first member) */ 1466 struct batadv_tp_vars_common common; 1467 1468 /** @receiving: receiving binary semaphore: 1 if receiving, 0 is not */ 1469 atomic_t receiving; 1470 1471 /** @last_recv: last in-order received packet */ 1472 u32 last_recv; 1473 1474 /** @last_recv_time: time (jiffies) a msg was received */ 1475 unsigned long last_recv_time; 1476 }; 1477 1478 /** 1479 * struct batadv_meshif_vlan - per VLAN attributes set 1480 */ 1481 struct batadv_meshif_vlan { 1482 /** @bat_priv: pointer to the mesh object */ 1483 struct batadv_priv *bat_priv; 1484 1485 /** @vid: VLAN identifier */ 1486 unsigned short vid; 1487 1488 /** @ap_isolation: AP isolation state */ 1489 u8 ap_isolation; /* boolean */ 1490 1491 /** @tt: TT private attributes (VLAN specific) */ 1492 struct batadv_vlan_tt tt; 1493 1494 /** @list: list node for &bat_priv.meshif_vlan_list */ 1495 struct hlist_node list; 1496 1497 /** 1498 * @refcount: number of context where this object is currently in use 1499 */ 1500 struct kref refcount; 1501 1502 /** @rcu: struct used for freeing in a RCU-safe manner */ 1503 struct rcu_head rcu; 1504 }; 1505 1506 /** 1507 * struct batadv_priv_bat_v - B.A.T.M.A.N. V per mesh-interface private data 1508 */ 1509 struct batadv_priv_bat_v { 1510 /** @ogm_buff: buffer holding the OGM packet */ 1511 struct batadv_ogm_buf ogm_buff; 1512 1513 /** @ogm_seqno: OGM sequence number - used to identify each OGM */ 1514 atomic_t ogm_seqno; 1515 1516 /** @ogm_buff_mutex: lock protecting ogm_buff */ 1517 struct mutex ogm_buff_mutex; 1518 1519 /** @ogm_wq: workqueue used to schedule OGM transmissions */ 1520 struct delayed_work ogm_wq; 1521 }; 1522 1523 /** 1524 * struct batadv_priv - per mesh interface data 1525 */ 1526 struct batadv_priv { 1527 /** 1528 * @mesh_state: current status of the mesh 1529 * (inactive/active/deactivating) 1530 */ 1531 enum batadv_mesh_state mesh_state; 1532 1533 /** @mesh_iface: net device which holds this struct as private data */ 1534 struct net_device *mesh_iface; 1535 1536 /** 1537 * @mtu_set_by_user: MTU was set once by user 1538 * protected by rtnl_lock 1539 */ 1540 int mtu_set_by_user; 1541 1542 /** 1543 * @bat_counters: mesh internal traffic statistic counters (see 1544 * batadv_counters) 1545 */ 1546 u64 __percpu *bat_counters; /* Per cpu counters */ 1547 1548 /** 1549 * @aggregated_ogms: bool indicating whether OGM aggregation is enabled 1550 */ 1551 u8 aggregated_ogms; 1552 1553 /** @bonding: bool indicating whether traffic bonding is enabled */ 1554 u8 bonding; 1555 1556 /** 1557 * @fragmentation: bool indicating whether traffic fragmentation is 1558 * enabled 1559 */ 1560 u8 fragmentation; 1561 1562 #ifdef CONFIG_BATMAN_ADV_BLA 1563 /** 1564 * @bridge_loop_avoidance: bool indicating whether bridge loop 1565 * avoidance is enabled 1566 */ 1567 u8 bridge_loop_avoidance; 1568 #endif 1569 1570 #ifdef CONFIG_BATMAN_ADV_DAT 1571 /** 1572 * @distributed_arp_table: bool indicating whether distributed ARP table 1573 * is enabled 1574 */ 1575 u8 distributed_arp_table; 1576 #endif 1577 1578 #ifdef CONFIG_BATMAN_ADV_MCAST 1579 /** 1580 * @multicast_mode: Enable or disable multicast optimizations on this 1581 * node's sender/originating side 1582 */ 1583 u8 multicast_mode; 1584 1585 /** 1586 * @multicast_fanout: Maximum number of packet copies to generate for a 1587 * multicast-to-unicast conversion 1588 */ 1589 u32 multicast_fanout; 1590 #endif 1591 1592 /** 1593 * @packet_size_max: max packet size that can be transmitted via 1594 * multiple fragmented skbs or a single frame if fragmentation is 1595 * disabled 1596 */ 1597 int packet_size_max; 1598 1599 /** 1600 * @frag_seqno: incremental counter to identify chains of egress 1601 * fragments 1602 */ 1603 atomic_t frag_seqno; 1604 1605 /** @orig_interval: OGM broadcast interval in milliseconds */ 1606 u32 orig_interval; 1607 1608 /** 1609 * @hop_penalty: penalty which will be applied to an OGM's tq-field on 1610 * every hop 1611 */ 1612 u8 hop_penalty; 1613 1614 #ifdef CONFIG_BATMAN_ADV_DEBUG 1615 /** @log_level: configured log level (see batadv_dbg_level) */ 1616 u32 log_level; 1617 #endif 1618 1619 /** 1620 * @isolation_mark: the skb->mark value used to match packets for AP 1621 * isolation 1622 */ 1623 u32 isolation_mark; 1624 1625 /** 1626 * @isolation_mark_mask: bitmask identifying the bits in skb->mark to be 1627 * used for the isolation mark 1628 */ 1629 u32 isolation_mark_mask; 1630 1631 /** @bcast_seqno: last sent broadcast packet sequence number */ 1632 atomic_t bcast_seqno; 1633 1634 /** 1635 * @bcast_queue_left: number of remaining buffered broadcast packet 1636 * slots 1637 */ 1638 atomic_t bcast_queue_left; 1639 1640 /** @batman_queue_left: number of remaining OGM packet slots */ 1641 atomic_t batman_queue_left; 1642 1643 /** @forw_bat_list: list of aggregated OGMs that will be forwarded */ 1644 struct hlist_head forw_bat_list; 1645 1646 /** 1647 * @forw_bcast_list: list of broadcast packets that will be 1648 * rebroadcasted 1649 */ 1650 struct hlist_head forw_bcast_list; 1651 1652 /** @tp_sender_list: list of tp sender sessions */ 1653 struct hlist_head tp_sender_list; 1654 1655 /** @tp_receiver_list: list of tp receiver sessions */ 1656 struct hlist_head tp_receiver_list; 1657 1658 /** @orig_hash: hash table containing mesh participants (orig nodes) */ 1659 struct batadv_hashtable *orig_hash; 1660 1661 /** @forw_bat_list_lock: lock protecting forw_bat_list */ 1662 spinlock_t forw_bat_list_lock; 1663 1664 /** @forw_bcast_list_lock: lock protecting forw_bcast_list */ 1665 spinlock_t forw_bcast_list_lock; 1666 1667 /** @tp_list_lock: spinlock protecting @tp_sender_list + @tp_receiver_list */ 1668 spinlock_t tp_list_lock; 1669 1670 /** @tp_num: number of currently active tp sessions */ 1671 atomic_t tp_num; 1672 1673 /** @orig_work: work queue callback item for orig node purging */ 1674 struct delayed_work orig_work; 1675 1676 /** 1677 * @primary_if: one of the hard-interfaces assigned to this mesh 1678 * interface becomes the primary interface 1679 */ 1680 struct batadv_hard_iface __rcu *primary_if; /* rcu protected pointer */ 1681 1682 /** @algo_ops: routing algorithm used by this mesh interface */ 1683 struct batadv_algo_ops *algo_ops; 1684 1685 /** 1686 * @meshif_vlan_list: a list of meshif_vlan structs, one per VLAN 1687 * created on top of the mesh interface represented by this object 1688 */ 1689 struct hlist_head meshif_vlan_list; 1690 1691 /** @meshif_vlan_list_lock: lock protecting meshif_vlan_list */ 1692 spinlock_t meshif_vlan_list_lock; 1693 1694 #ifdef CONFIG_BATMAN_ADV_BLA 1695 /** @bla: bridge loop avoidance data */ 1696 struct batadv_priv_bla bla; 1697 #endif 1698 1699 /** @gw: gateway data */ 1700 struct batadv_priv_gw gw; 1701 1702 /** @tt: translation table data */ 1703 struct batadv_priv_tt tt; 1704 1705 /** @tvlv: type-version-length-value data */ 1706 struct batadv_priv_tvlv tvlv; 1707 1708 #ifdef CONFIG_BATMAN_ADV_DAT 1709 /** @dat: distributed arp table data */ 1710 struct batadv_priv_dat dat; 1711 #endif 1712 1713 #ifdef CONFIG_BATMAN_ADV_MCAST 1714 /** @mcast: multicast data */ 1715 struct batadv_priv_mcast mcast; 1716 #endif 1717 1718 #ifdef CONFIG_BATMAN_ADV_BATMAN_V 1719 /** @bat_v: B.A.T.M.A.N. V per mesh-interface private data */ 1720 struct batadv_priv_bat_v bat_v; 1721 #endif 1722 }; 1723 1724 #ifdef CONFIG_BATMAN_ADV_BLA 1725 1726 /** 1727 * enum batadv_bla_backbone_gw_state - state of a bridge loop avoidance 1728 * backbone gateway 1729 */ 1730 enum batadv_bla_backbone_gw_state { 1731 /** 1732 * @BATADV_BLA_BACKBONE_GW_STOPPED: backbone gw is being removed 1733 * and it must no longer work on requests 1734 */ 1735 BATADV_BLA_BACKBONE_GW_STOPPED, 1736 1737 /** 1738 * @BATADV_BLA_BACKBONE_GW_UNSYNCED: backbone was detected out 1739 * of sync and a request was sent. No traffic is forwarded until the 1740 * situation is resolved 1741 */ 1742 BATADV_BLA_BACKBONE_GW_UNSYNCED, 1743 1744 /** 1745 * @BATADV_BLA_BACKBONE_GW_SYNCED: backbone is considered to be in 1746 * sync. traffic can be forwarded 1747 */ 1748 BATADV_BLA_BACKBONE_GW_SYNCED, 1749 }; 1750 1751 /** 1752 * struct batadv_bla_backbone_gw - batman-adv gateway bridged into the LAN 1753 */ 1754 struct batadv_bla_backbone_gw { 1755 /** 1756 * @orig: originator address of backbone node (mac address of primary 1757 * iface) 1758 */ 1759 u8 orig[ETH_ALEN]; 1760 1761 /** @vid: vlan id this gateway was detected on */ 1762 unsigned short vid; 1763 1764 /** @hash_entry: hlist node for &batadv_priv_bla.backbone_hash */ 1765 struct hlist_node hash_entry; 1766 1767 /** @bat_priv: pointer to mesh_iface this backbone gateway belongs to */ 1768 struct batadv_priv *bat_priv; 1769 1770 /** @lasttime: last time we heard of this backbone gw */ 1771 unsigned long lasttime; 1772 1773 /** 1774 * @wait_periods: grace time for bridge forward delays and bla group 1775 * forming at bootup phase - no bcast traffic is formwared until it has 1776 * elapsed. Must only be access with num_requests_lock. 1777 */ 1778 u8 wait_periods; 1779 1780 /** @state: sync state. Must only be access with num_requests_lock. */ 1781 enum batadv_bla_backbone_gw_state state; 1782 1783 /** @crc: crc16 checksum over all claims */ 1784 u16 crc; 1785 1786 /** @crc_lock: lock protecting crc */ 1787 spinlock_t crc_lock; 1788 1789 /** @report_work: work struct for reporting detected loops */ 1790 struct work_struct report_work; 1791 1792 /** @refcount: number of contexts the object is used */ 1793 struct kref refcount; 1794 1795 /** @rcu: struct used for freeing in an RCU-safe manner */ 1796 struct rcu_head rcu; 1797 }; 1798 1799 /** 1800 * struct batadv_bla_claim - claimed non-mesh client structure 1801 */ 1802 struct batadv_bla_claim { 1803 /** @addr: mac address of claimed non-mesh client */ 1804 u8 addr[ETH_ALEN]; 1805 1806 /** @vid: vlan id this client was detected on */ 1807 unsigned short vid; 1808 1809 /** @backbone_gw: pointer to backbone gw claiming this client */ 1810 struct batadv_bla_backbone_gw *backbone_gw; 1811 1812 /** @backbone_lock: lock protecting backbone_gw pointer */ 1813 spinlock_t backbone_lock; 1814 1815 /** @lasttime: last time we heard of claim (locals only) */ 1816 unsigned long lasttime; 1817 1818 /** @hash_entry: hlist node for &batadv_priv_bla.claim_hash */ 1819 struct hlist_node hash_entry; 1820 1821 /** @refcount: number of contexts the object is used */ 1822 struct rcu_head rcu; 1823 1824 /** @rcu: struct used for freeing in an RCU-safe manner */ 1825 struct kref refcount; 1826 }; 1827 #endif 1828 1829 /** 1830 * struct batadv_tt_common_entry - tt local & tt global common data 1831 */ 1832 struct batadv_tt_common_entry { 1833 /** @addr: mac address of non-mesh client */ 1834 u8 addr[ETH_ALEN]; 1835 1836 /** @vid: VLAN identifier */ 1837 unsigned short vid; 1838 1839 /** 1840 * @hash_entry: hlist node for &batadv_priv_tt.local_hash or for 1841 * &batadv_priv_tt.global_hash 1842 */ 1843 struct hlist_node hash_entry; 1844 1845 /** @flags: various state handling flags (see batadv_tt_client_flags) */ 1846 u16 flags; 1847 1848 /** @added_at: timestamp used for purging stale tt common entries */ 1849 unsigned long added_at; 1850 1851 /** @refcount: number of contexts the object is used */ 1852 struct kref refcount; 1853 1854 /** @rcu: struct used for freeing in an RCU-safe manner */ 1855 struct rcu_head rcu; 1856 }; 1857 1858 /** 1859 * struct batadv_tt_local_entry - translation table local entry data 1860 */ 1861 struct batadv_tt_local_entry { 1862 /** @common: general translation table data */ 1863 struct batadv_tt_common_entry common; 1864 1865 /** @last_seen: timestamp used for purging stale tt local entries */ 1866 unsigned long last_seen; 1867 1868 /** @vlan: mesh-interface vlan of the entry */ 1869 struct batadv_meshif_vlan *vlan; 1870 }; 1871 1872 /** 1873 * struct batadv_tt_global_entry - translation table global entry data 1874 */ 1875 struct batadv_tt_global_entry { 1876 /** @common: general translation table data */ 1877 struct batadv_tt_common_entry common; 1878 1879 /** @orig_list: list of orig nodes announcing this non-mesh client */ 1880 struct hlist_head orig_list; 1881 1882 /** @orig_list_count: number of items in the orig_list */ 1883 atomic_t orig_list_count; 1884 1885 /** @list_lock: lock protecting orig_list */ 1886 spinlock_t list_lock; 1887 1888 /** @roam_at: time at which TT_GLOBAL_ROAM was set */ 1889 unsigned long roam_at; 1890 }; 1891 1892 /** 1893 * struct batadv_tt_orig_list_entry - orig node announcing a non-mesh client 1894 */ 1895 struct batadv_tt_orig_list_entry { 1896 /** @orig_node: pointer to orig node announcing this non-mesh client */ 1897 struct batadv_orig_node *orig_node; 1898 1899 /** 1900 * @ttvn: translation table version number which added the non-mesh 1901 * client 1902 */ 1903 u8 ttvn; 1904 1905 /** @flags: per orig entry TT sync flags */ 1906 u8 flags; 1907 1908 /** @list: list node for &batadv_tt_global_entry.orig_list */ 1909 struct hlist_node list; 1910 1911 /** @refcount: number of contexts the object is used */ 1912 struct kref refcount; 1913 1914 /** @rcu: struct used for freeing in an RCU-safe manner */ 1915 struct rcu_head rcu; 1916 }; 1917 1918 /** 1919 * struct batadv_tt_change_node - structure for tt changes occurred 1920 */ 1921 struct batadv_tt_change_node { 1922 /** @list: list node for &batadv_priv_tt.changes_list */ 1923 struct list_head list; 1924 1925 /** @change: holds the actual translation table diff data */ 1926 struct batadv_tvlv_tt_change change; 1927 }; 1928 1929 /** 1930 * struct batadv_tt_req_node - data to keep track of the tt requests in flight 1931 */ 1932 struct batadv_tt_req_node { 1933 /** 1934 * @addr: mac address of the originator this request was sent to 1935 */ 1936 u8 addr[ETH_ALEN]; 1937 1938 /** @issued_at: timestamp used for purging stale tt requests */ 1939 unsigned long issued_at; 1940 1941 /** @refcount: number of contexts the object is used by */ 1942 struct kref refcount; 1943 1944 /** @list: list node for &batadv_priv_tt.req_list */ 1945 struct hlist_node list; 1946 }; 1947 1948 /** 1949 * struct batadv_tt_roam_node - roaming client data 1950 */ 1951 struct batadv_tt_roam_node { 1952 /** @addr: mac address of the client in the roaming phase */ 1953 u8 addr[ETH_ALEN]; 1954 1955 /** 1956 * @counter: number of allowed roaming events per client within a single 1957 * OGM interval (changes are committed with each OGM) 1958 */ 1959 atomic_t counter; 1960 1961 /** 1962 * @first_time: timestamp used for purging stale roaming node entries 1963 */ 1964 unsigned long first_time; 1965 1966 /** @list: list node for &batadv_priv_tt.roam_list */ 1967 struct list_head list; 1968 }; 1969 1970 /** 1971 * struct batadv_skb_cb - control buffer structure used to store private data 1972 * relevant to batman-adv in the skb->cb buffer in skbs. 1973 */ 1974 struct batadv_skb_cb { 1975 /** @num_bcasts: Counter for broadcast packet retransmissions */ 1976 unsigned char num_bcasts; 1977 }; 1978 1979 /** 1980 * struct batadv_forw_packet - structure for bcast packets to be sent/forwarded 1981 */ 1982 struct batadv_forw_packet { 1983 /** 1984 * @list: list node for &batadv_priv.forw.bcast_list and 1985 * &batadv_priv.forw.bat_list 1986 */ 1987 struct hlist_node list; 1988 1989 /** @cleanup_list: list node for purging functions */ 1990 struct hlist_node cleanup_list; 1991 1992 /** @send_time: execution time for delayed_work (packet sending) */ 1993 unsigned long send_time; 1994 1995 /** 1996 * @own: bool for locally generated packets (local OGMs are re-scheduled 1997 * after sending) 1998 */ 1999 u8 own; 2000 2001 /** @skb: bcast packet's skb buffer */ 2002 struct sk_buff *skb; 2003 2004 /** @packet_len: size of aggregated OGM packet inside the skb buffer */ 2005 u16 packet_len; 2006 2007 /** @direct_link_flags: direct link flags for aggregated OGM packets */ 2008 DECLARE_BITMAP(direct_link_flags, BATADV_MAX_AGGREGATION_PACKETS); 2009 2010 /** @num_packets: counter for aggregated OGMv1 packets */ 2011 u8 num_packets; 2012 2013 /** @delayed_work: work queue callback item for packet sending */ 2014 struct delayed_work delayed_work; 2015 2016 /** 2017 * @if_incoming: pointer to incoming hard-iface or primary iface if 2018 * locally generated packet 2019 */ 2020 struct batadv_hard_iface *if_incoming; 2021 2022 /** 2023 * @if_outgoing: packet where the packet should be sent to, or NULL if 2024 * unspecified 2025 */ 2026 struct batadv_hard_iface *if_outgoing; 2027 2028 /** @queue_left: The queue (counter) this packet was applied to */ 2029 atomic_t *queue_left; 2030 }; 2031 2032 /** 2033 * struct batadv_algo_iface_ops - mesh algorithm callbacks (interface specific) 2034 */ 2035 struct batadv_algo_iface_ops { 2036 /** 2037 * @activate: start routing mechanisms when hard-interface is brought up 2038 * (optional) 2039 */ 2040 void (*activate)(struct batadv_hard_iface *hard_iface); 2041 2042 /** @enable: init routing info when hard-interface is enabled */ 2043 int (*enable)(struct batadv_hard_iface *hard_iface); 2044 2045 /** @enabled: notification when hard-interface was enabled (optional) */ 2046 void (*enabled)(struct batadv_hard_iface *hard_iface); 2047 2048 /** @disable: de-init routing info when hard-interface is disabled */ 2049 void (*disable)(struct batadv_hard_iface *hard_iface); 2050 2051 /** 2052 * @update_mac: (re-)init mac addresses of the protocol information 2053 * belonging to this hard-interface 2054 */ 2055 void (*update_mac)(struct batadv_hard_iface *hard_iface); 2056 2057 /** @primary_set: called when primary interface is selected / changed */ 2058 void (*primary_set)(struct batadv_hard_iface *hard_iface); 2059 }; 2060 2061 /** 2062 * struct batadv_algo_neigh_ops - mesh algorithm callbacks (neighbour specific) 2063 */ 2064 struct batadv_algo_neigh_ops { 2065 /** @hardif_init: called on creation of single hop entry (optional) */ 2066 void (*hardif_init)(struct batadv_hardif_neigh_node *neigh); 2067 2068 /** 2069 * @cmp: compare the metrics of two neighbors for their respective 2070 * outgoing interfaces 2071 */ 2072 int (*cmp)(struct batadv_neigh_node *neigh1, 2073 struct batadv_hard_iface *if_outgoing1, 2074 struct batadv_neigh_node *neigh2, 2075 struct batadv_hard_iface *if_outgoing2); 2076 2077 /** 2078 * @is_similar_or_better: check if neigh1 is equally similar or better 2079 * than neigh2 for their respective outgoing interface from the metric 2080 * prospective 2081 */ 2082 bool (*is_similar_or_better)(struct batadv_neigh_node *neigh1, 2083 struct batadv_hard_iface *if_outgoing1, 2084 struct batadv_neigh_node *neigh2, 2085 struct batadv_hard_iface *if_outgoing2); 2086 2087 /** @dump: dump neighbors to a netlink socket (optional) */ 2088 void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, 2089 struct batadv_priv *priv, 2090 struct batadv_hard_iface *hard_iface); 2091 }; 2092 2093 /** 2094 * struct batadv_algo_orig_ops - mesh algorithm callbacks (originator specific) 2095 */ 2096 struct batadv_algo_orig_ops { 2097 /** @dump: dump originators to a netlink socket (optional) */ 2098 void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, 2099 struct batadv_priv *priv, 2100 struct batadv_hard_iface *hard_iface); 2101 }; 2102 2103 /** 2104 * struct batadv_algo_gw_ops - mesh algorithm callbacks (GW specific) 2105 */ 2106 struct batadv_algo_gw_ops { 2107 /** @init_sel_class: initialize GW selection class (optional) */ 2108 void (*init_sel_class)(struct batadv_priv *bat_priv); 2109 2110 /** 2111 * @sel_class_max: maximum allowed GW selection class 2112 */ 2113 u32 sel_class_max; 2114 2115 /** 2116 * @get_best_gw_node: select the best GW from the list of available 2117 * nodes (optional) 2118 */ 2119 struct batadv_gw_node *(*get_best_gw_node) 2120 (struct batadv_priv *bat_priv); 2121 2122 /** 2123 * @is_eligible: check if a newly discovered GW is a potential candidate 2124 * for the election as best GW (optional) 2125 */ 2126 bool (*is_eligible)(struct batadv_priv *bat_priv, 2127 struct batadv_orig_node *curr_gw_orig, 2128 struct batadv_orig_node *orig_node); 2129 2130 /** @dump: dump gateways to a netlink socket (optional) */ 2131 void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, 2132 struct batadv_priv *priv); 2133 }; 2134 2135 /** 2136 * struct batadv_algo_ops - mesh algorithm callbacks 2137 */ 2138 struct batadv_algo_ops { 2139 /** @list: list node for the batadv_algo_list */ 2140 struct hlist_node list; 2141 2142 /** @name: name of the algorithm */ 2143 char *name; 2144 2145 /** @iface: callbacks related to interface handling */ 2146 struct batadv_algo_iface_ops iface; 2147 2148 /** @neigh: callbacks related to neighbors handling */ 2149 struct batadv_algo_neigh_ops neigh; 2150 2151 /** @orig: callbacks related to originators handling */ 2152 struct batadv_algo_orig_ops orig; 2153 2154 /** @gw: callbacks related to GW mode */ 2155 struct batadv_algo_gw_ops gw; 2156 }; 2157 2158 /** 2159 * struct batadv_dat_entry - it is a single entry of batman-adv ARP backend. It 2160 * is used to stored ARP entries needed for the global DAT cache 2161 */ 2162 struct batadv_dat_entry { 2163 /** @ip: the IPv4 corresponding to this DAT/ARP entry */ 2164 __be32 ip; 2165 2166 /** @mac_addr: the MAC address associated to the stored IPv4 */ 2167 u8 mac_addr[ETH_ALEN]; 2168 2169 /** @vid: the vlan ID associated to this entry */ 2170 unsigned short vid; 2171 2172 /** 2173 * @last_update: time in jiffies when this entry was refreshed last time 2174 */ 2175 unsigned long last_update; 2176 2177 /** @hash_entry: hlist node for &batadv_priv_dat.hash */ 2178 struct hlist_node hash_entry; 2179 2180 /** @refcount: number of contexts the object is used */ 2181 struct kref refcount; 2182 2183 /** @rcu: struct used for freeing in an RCU-safe manner */ 2184 struct rcu_head rcu; 2185 }; 2186 2187 /** 2188 * struct batadv_hw_addr - a list entry for a MAC address 2189 */ 2190 struct batadv_hw_addr { 2191 /** @list: list node for the linking of entries */ 2192 struct hlist_node list; 2193 2194 /** @addr: the MAC address of this list entry */ 2195 unsigned char addr[ETH_ALEN]; 2196 }; 2197 2198 /** 2199 * struct batadv_dat_candidate - candidate destination for DAT operations 2200 */ 2201 struct batadv_dat_candidate { 2202 /** 2203 * @type: the type of the selected candidate. It can one of the 2204 * following: 2205 * - BATADV_DAT_CANDIDATE_NOT_FOUND 2206 * - BATADV_DAT_CANDIDATE_ORIG 2207 */ 2208 int type; 2209 2210 /** 2211 * @orig_node: if type is BATADV_DAT_CANDIDATE_ORIG this field points to 2212 * the corresponding originator node structure 2213 */ 2214 struct batadv_orig_node *orig_node; 2215 }; 2216 2217 /** 2218 * struct batadv_tvlv_container - container for tvlv appended to OGMs 2219 */ 2220 struct batadv_tvlv_container { 2221 /** @list: hlist node for &batadv_priv_tvlv.container_list */ 2222 struct hlist_node list; 2223 2224 /** @tvlv_hdr: tvlv header information needed to construct the tvlv */ 2225 struct batadv_tvlv_hdr tvlv_hdr; 2226 2227 /** @refcount: number of contexts the object is used */ 2228 struct kref refcount; 2229 }; 2230 2231 /** 2232 * struct batadv_tvlv_handler - handler for specific tvlv type and version 2233 */ 2234 struct batadv_tvlv_handler { 2235 /** @list: hlist node for &batadv_priv_tvlv.handler_list */ 2236 struct hlist_node list; 2237 2238 /** 2239 * @ogm_handler: handler callback which is given the tvlv payload to 2240 * process on incoming OGM packets 2241 */ 2242 void (*ogm_handler)(struct batadv_priv *bat_priv, 2243 struct batadv_orig_node *orig, 2244 u8 flags, void *tvlv_value, u16 tvlv_value_len); 2245 2246 /** 2247 * @unicast_handler: handler callback which is given the tvlv payload to 2248 * process on incoming unicast tvlv packets 2249 */ 2250 int (*unicast_handler)(struct batadv_priv *bat_priv, 2251 u8 *src, u8 *dst, 2252 void *tvlv_value, u16 tvlv_value_len); 2253 2254 /** 2255 * @mcast_handler: handler callback which is given the tvlv payload to 2256 * process on incoming mcast packet 2257 */ 2258 int (*mcast_handler)(struct batadv_priv *bat_priv, struct sk_buff *skb); 2259 2260 /** @type: tvlv type this handler feels responsible for */ 2261 u8 type; 2262 2263 /** @version: tvlv version this handler feels responsible for */ 2264 u8 version; 2265 2266 /** @flags: tvlv handler flags */ 2267 u8 flags; 2268 2269 /** @refcount: number of contexts the object is used */ 2270 struct kref refcount; 2271 2272 /** @rcu: struct used for freeing in an RCU-safe manner */ 2273 struct rcu_head rcu; 2274 }; 2275 2276 /** 2277 * enum batadv_tvlv_handler_flags - tvlv handler flags definitions 2278 */ 2279 enum batadv_tvlv_handler_flags { 2280 /** 2281 * @BATADV_TVLV_HANDLER_OGM_CIFNOTFND: tvlv ogm processing function 2282 * will call this handler even if its type was not found (with no data) 2283 */ 2284 BATADV_TVLV_HANDLER_OGM_CIFNOTFND = BIT(1), 2285 2286 /** 2287 * @BATADV_TVLV_HANDLER_OGM_CALLED: interval tvlv handling flag - the 2288 * API marks a handler as being called, so it won't be called if the 2289 * BATADV_TVLV_HANDLER_OGM_CIFNOTFND flag was set 2290 */ 2291 BATADV_TVLV_HANDLER_OGM_CALLED = BIT(2), 2292 }; 2293 2294 #endif /* _NET_BATMAN_ADV_TYPES_H_ */ 2295