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