Lines Matching +full:interface +full:- +full:node
1 // SPDX-License-Identifier: GPL-2.0
54 #include "hard-interface.h"
59 #include "soft-interface.h"
60 #include "translation-table.h"
66 * batadv_mcast_start_timer() - schedule the multicast periodic worker
67 * @bat_priv: the bat priv with all the soft interface information
71 queue_delayed_work(batadv_event_workqueue, &bat_priv->mcast.work, in batadv_mcast_start_timer()
76 * batadv_mcast_get_bridge() - get the bridge on top of the softif if it exists
77 * @soft_iface: netdev struct of the mesh interface
79 * If the given soft interface has a bridge on top then the refcount
101 * batadv_mcast_mla_rtr_flags_softif_get_ipv4() - get mcast router flags from
102 * node for IPv4
103 * @dev: the interface to check
105 * Checks the presence of an IPv4 multicast router on this node.
122 * batadv_mcast_mla_rtr_flags_softif_get_ipv6() - get mcast router flags from
123 * node for IPv6
124 * @dev: the interface to check
126 * Checks the presence of an IPv6 multicast router on this node.
137 if (in6_dev && atomic_read(&in6_dev->cnf.mc_forwarding)) in batadv_mcast_mla_rtr_flags_softif_get_ipv6()
151 * batadv_mcast_mla_rtr_flags_softif_get() - get mcast router flags from node
152 * @bat_priv: the bat priv with all the soft interface information
153 * @bridge: bridge interface on top of the soft_iface if present,
157 * node.
168 struct net_device *dev = bridge ? bridge : bat_priv->soft_iface; in batadv_mcast_mla_rtr_flags_softif_get()
182 * batadv_mcast_mla_rtr_flags_bridge_get() - get mcast router flags from bridge
183 * @bat_priv: the bat priv with all the soft interface information
184 * @bridge: bridge interface on top of the soft_iface if present,
198 struct net_device *dev = bat_priv->soft_iface; in batadv_mcast_mla_rtr_flags_bridge_get()
213 * batadv_mcast_mla_rtr_flags_get() - get multicast router flags
214 * @bat_priv: the bat priv with all the soft interface information
215 * @bridge: bridge interface on top of the soft_iface if present,
219 * node or behind its bridge.
239 * batadv_mcast_mla_forw_flags_get() - get multicast forwarding flags
240 * @bat_priv: the bat priv with all the soft interface information
253 if (hard_iface->if_status != BATADV_IF_ACTIVE) in batadv_mcast_mla_forw_flags_get()
256 if (hard_iface->soft_iface != bat_priv->soft_iface) in batadv_mcast_mla_forw_flags_get()
259 if (hard_iface->net_dev->mtu < IPV6_MIN_MTU) { in batadv_mcast_mla_forw_flags_get()
270 * batadv_mcast_mla_flags_get() - get the new multicast flags
271 * @bat_priv: the bat priv with all the soft interface information
279 struct net_device *dev = bat_priv->soft_iface; in batadv_mcast_mla_flags_get()
302 pr_warn_once("No bridge IGMP snooping compiled - multicast optimizations disabled\n"); in batadv_mcast_mla_flags_get()
304 qr4->exists = br_multicast_has_querier_anywhere(dev, ETH_P_IP); in batadv_mcast_mla_flags_get()
305 qr4->shadowing = br_multicast_has_querier_adjacent(dev, ETH_P_IP); in batadv_mcast_mla_flags_get()
307 qr6->exists = br_multicast_has_querier_anywhere(dev, ETH_P_IPV6); in batadv_mcast_mla_flags_get()
308 qr6->shadowing = br_multicast_has_querier_adjacent(dev, ETH_P_IPV6); in batadv_mcast_mla_flags_get()
321 if (!qr4->exists || qr4->shadowing) { in batadv_mcast_mla_flags_get()
326 if (!qr6->exists || qr6->shadowing) { in batadv_mcast_mla_flags_get()
335 * batadv_mcast_mla_is_duplicate() - check whether an address is in a list
348 if (batadv_compare_eth(mcast_entry->addr, mcast_addr)) in batadv_mcast_mla_is_duplicate()
355 * batadv_mcast_mla_softif_get_ipv4() - get softif IPv4 multicast listeners
361 * on this kernel on the given soft interface, dev, in
363 * your multicast receiving applications run directly on this node.
365 * Return: -ENOMEM on memory allocation error or the number of
379 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV4) in batadv_mcast_mla_softif_get_ipv4()
390 for (pmc = rcu_dereference(in_dev->mc_list); pmc; in batadv_mcast_mla_softif_get_ipv4()
391 pmc = rcu_dereference(pmc->next_rcu)) { in batadv_mcast_mla_softif_get_ipv4()
392 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES && in batadv_mcast_mla_softif_get_ipv4()
393 ipv4_is_local_multicast(pmc->multiaddr)) in batadv_mcast_mla_softif_get_ipv4()
396 if (!(flags->tvlv_flags & BATADV_MCAST_WANT_NO_RTR4) && in batadv_mcast_mla_softif_get_ipv4()
397 !ipv4_is_local_multicast(pmc->multiaddr)) in batadv_mcast_mla_softif_get_ipv4()
400 ip_eth_mc_map(pmc->multiaddr, mcast_addr); in batadv_mcast_mla_softif_get_ipv4()
407 ret = -ENOMEM; in batadv_mcast_mla_softif_get_ipv4()
411 ether_addr_copy(new->addr, mcast_addr); in batadv_mcast_mla_softif_get_ipv4()
412 hlist_add_head(&new->list, mcast_list); in batadv_mcast_mla_softif_get_ipv4()
421 * batadv_mcast_mla_softif_get_ipv6() - get softif IPv6 multicast listeners
427 * on this kernel on the given soft interface, dev, in
429 * your multicast receiving applications run directly on this node.
431 * Return: -ENOMEM on memory allocation error or the number of
446 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV6) in batadv_mcast_mla_softif_get_ipv6()
457 for (pmc6 = rcu_dereference(in6_dev->mc_list); in batadv_mcast_mla_softif_get_ipv6()
459 pmc6 = rcu_dereference(pmc6->next)) { in batadv_mcast_mla_softif_get_ipv6()
460 if (IPV6_ADDR_MC_SCOPE(&pmc6->mca_addr) < in batadv_mcast_mla_softif_get_ipv6()
464 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES && in batadv_mcast_mla_softif_get_ipv6()
465 ipv6_addr_is_ll_all_nodes(&pmc6->mca_addr)) in batadv_mcast_mla_softif_get_ipv6()
468 if (!(flags->tvlv_flags & BATADV_MCAST_WANT_NO_RTR6) && in batadv_mcast_mla_softif_get_ipv6()
469 IPV6_ADDR_MC_SCOPE(&pmc6->mca_addr) > in batadv_mcast_mla_softif_get_ipv6()
473 ipv6_eth_mc_map(&pmc6->mca_addr, mcast_addr); in batadv_mcast_mla_softif_get_ipv6()
480 ret = -ENOMEM; in batadv_mcast_mla_softif_get_ipv6()
484 ether_addr_copy(new->addr, mcast_addr); in batadv_mcast_mla_softif_get_ipv6()
485 hlist_add_head(&new->list, mcast_list); in batadv_mcast_mla_softif_get_ipv6()
503 * batadv_mcast_mla_softif_get() - get softif multicast listeners
509 * on this kernel on the given soft interface, dev, in
511 * your multicast receiving applications run directly on this node.
513 * If there is a bridge interface on top of dev, collect from that one
515 * will(/should) register to the bridge interface instead of an
518 * Return: -ENOMEM on memory allocation error or the number of
549 * batadv_mcast_mla_br_addr_cpy() - copy a bridge multicast address
550 * @dst: destination to write to - a multicast MAC address
551 * @src: source to read from - a multicast IP address
562 if (src->proto == htons(ETH_P_IP)) in batadv_mcast_mla_br_addr_cpy()
563 ip_eth_mc_map(src->dst.ip4, dst); in batadv_mcast_mla_br_addr_cpy()
565 else if (src->proto == htons(ETH_P_IPV6)) in batadv_mcast_mla_br_addr_cpy()
566 ipv6_eth_mc_map(&src->dst.ip6, dst); in batadv_mcast_mla_br_addr_cpy()
573 * batadv_mcast_mla_bridge_get() - get bridged-in multicast listeners
579 * on foreign, non-mesh devices which we gave access to our mesh via
580 * a bridge on top of the given soft interface, dev, in the given
583 * Return: -ENOMEM on memory allocation error or the number of
592 u8 tvlv_flags = flags->tvlv_flags; in batadv_mcast_mla_bridge_get()
605 if (br_ip_entry->addr.proto == htons(ETH_P_IP)) { in batadv_mcast_mla_bridge_get()
610 ipv4_is_local_multicast(br_ip_entry->addr.dst.ip4)) in batadv_mcast_mla_bridge_get()
614 !ipv4_is_local_multicast(br_ip_entry->addr.dst.ip4)) in batadv_mcast_mla_bridge_get()
619 if (br_ip_entry->addr.proto == htons(ETH_P_IPV6)) { in batadv_mcast_mla_bridge_get()
624 ipv6_addr_is_ll_all_nodes(&br_ip_entry->addr.dst.ip6)) in batadv_mcast_mla_bridge_get()
628 IPV6_ADDR_MC_SCOPE(&br_ip_entry->addr.dst.ip6) > in batadv_mcast_mla_bridge_get()
634 batadv_mcast_mla_br_addr_cpy(mcast_addr, &br_ip_entry->addr); in batadv_mcast_mla_bridge_get()
640 ret = -ENOMEM; in batadv_mcast_mla_bridge_get()
644 ether_addr_copy(new->addr, mcast_addr); in batadv_mcast_mla_bridge_get()
645 hlist_add_head(&new->list, mcast_list); in batadv_mcast_mla_bridge_get()
650 list_del(&br_ip_entry->list); in batadv_mcast_mla_bridge_get()
658 * batadv_mcast_mla_list_free() - free a list of multicast addresses
669 hlist_del(&mcast_entry->list); in batadv_mcast_mla_list_free()
675 * batadv_mcast_mla_tt_retract() - clean up multicast listener announcements
676 * @bat_priv: the bat priv with all the soft interface information
690 hlist_for_each_entry_safe(mcast_entry, tmp, &bat_priv->mcast.mla_list, in batadv_mcast_mla_tt_retract()
693 batadv_mcast_mla_is_duplicate(mcast_entry->addr, in batadv_mcast_mla_tt_retract()
697 batadv_tt_local_remove(bat_priv, mcast_entry->addr, in batadv_mcast_mla_tt_retract()
701 hlist_del(&mcast_entry->list); in batadv_mcast_mla_tt_retract()
707 * batadv_mcast_mla_tt_add() - add multicast listener announcements
708 * @bat_priv: the bat priv with all the soft interface information
724 if (batadv_mcast_mla_is_duplicate(mcast_entry->addr, in batadv_mcast_mla_tt_add()
725 &bat_priv->mcast.mla_list)) in batadv_mcast_mla_tt_add()
728 if (!batadv_tt_local_add(bat_priv->soft_iface, in batadv_mcast_mla_tt_add()
729 mcast_entry->addr, BATADV_NO_FLAGS, in batadv_mcast_mla_tt_add()
733 hlist_del(&mcast_entry->list); in batadv_mcast_mla_tt_add()
734 hlist_add_head(&mcast_entry->list, &bat_priv->mcast.mla_list); in batadv_mcast_mla_tt_add()
739 * batadv_mcast_querier_log() - debug output regarding the querier status on
741 * @bat_priv: the bat priv with all the soft interface information
753 * forward listener reports to the querier, therefore batman-adv and
754 * the bridge will potentially not see these listeners - the querier is
758 * soft interface.
765 if (!old_state->exists && new_state->exists) in batadv_mcast_querier_log()
766 batadv_info(bat_priv->soft_iface, "%s Querier appeared\n", in batadv_mcast_querier_log()
768 else if (old_state->exists && !new_state->exists) in batadv_mcast_querier_log()
769 batadv_info(bat_priv->soft_iface, in batadv_mcast_querier_log()
770 "%s Querier disappeared - multicast optimizations disabled\n", in batadv_mcast_querier_log()
772 else if (!bat_priv->mcast.mla_flags.bridged && !new_state->exists) in batadv_mcast_querier_log()
773 batadv_info(bat_priv->soft_iface, in batadv_mcast_querier_log()
774 "No %s Querier present - multicast optimizations disabled\n", in batadv_mcast_querier_log()
777 if (new_state->exists) { in batadv_mcast_querier_log()
778 if ((!old_state->shadowing && new_state->shadowing) || in batadv_mcast_querier_log()
779 (!old_state->exists && new_state->shadowing)) in batadv_mcast_querier_log()
783 else if (old_state->shadowing && !new_state->shadowing) in batadv_mcast_querier_log()
791 * batadv_mcast_bridge_log() - debug output for topology changes in bridged
793 * @bat_priv: the bat priv with all the soft interface information
796 * If no bridges are ever used on this node, then this function does nothing.
801 * More precisely, it outputs information when a bridge interface is added or
802 * removed from a soft interface. And when a bridge is present, it further
804 * multicast flags this node is going to set.
810 struct batadv_mcast_mla_flags *old_flags = &bat_priv->mcast.mla_flags; in batadv_mcast_bridge_log()
812 if (!old_flags->bridged && new_flags->bridged) in batadv_mcast_bridge_log()
814 "Bridge added: Setting Unsnoopables(U)-flag\n"); in batadv_mcast_bridge_log()
815 else if (old_flags->bridged && !new_flags->bridged) in batadv_mcast_bridge_log()
817 "Bridge removed: Unsetting Unsnoopables(U)-flag\n"); in batadv_mcast_bridge_log()
819 if (new_flags->bridged) { in batadv_mcast_bridge_log()
821 &old_flags->querier_ipv4, in batadv_mcast_bridge_log()
822 &new_flags->querier_ipv4); in batadv_mcast_bridge_log()
824 &old_flags->querier_ipv6, in batadv_mcast_bridge_log()
825 &new_flags->querier_ipv6); in batadv_mcast_bridge_log()
830 * batadv_mcast_flags_log() - output debug information about mcast flag changes
831 * @bat_priv: the bat priv with all the soft interface information
834 * Whenever the multicast TVLV flags this node announces change, this function
839 bool old_enabled = bat_priv->mcast.mla_flags.enabled; in batadv_mcast_flags_log()
840 u8 old_flags = bat_priv->mcast.mla_flags.tvlv_flags; in batadv_mcast_flags_log()
863 * batadv_mcast_mla_flags_update() - update multicast flags
864 * @bat_priv: the bat priv with all the soft interface information
876 if (!memcmp(flags, &bat_priv->mcast.mla_flags, sizeof(*flags))) in batadv_mcast_mla_flags_update()
880 batadv_mcast_flags_log(bat_priv, flags->tvlv_flags); in batadv_mcast_mla_flags_update()
882 mcast_data.flags = flags->tvlv_flags; in batadv_mcast_mla_flags_update()
888 bat_priv->mcast.mla_flags = *flags; in batadv_mcast_mla_flags_update()
892 * __batadv_mcast_mla_update() - update the own MLAs
893 * @bat_priv: the bat priv with all the soft interface information
898 * Note that non-conflicting reads and writes to bat_priv->mcast.mla_list
900 * ensured by the non-parallel execution of the worker this function
905 struct net_device *soft_iface = bat_priv->soft_iface; in __batadv_mcast_mla_update()
920 spin_lock(&bat_priv->mcast.mla_lock); in __batadv_mcast_mla_update()
924 spin_unlock(&bat_priv->mcast.mla_lock); in __batadv_mcast_mla_update()
931 * batadv_mcast_mla_update() - update the own MLAs
954 * batadv_mcast_is_report_ipv4() - check for IGMP reports
968 switch (igmp_hdr(skb)->type) { in batadv_mcast_is_report_ipv4()
979 * batadv_mcast_forw_mode_check_ipv4() - check for optimized forwarding
981 * @bat_priv: the bat priv with all the soft interface information
989 * Return: If so then 0. Otherwise -EINVAL or -ENOMEM in case of memory
999 /* We might fail due to out-of-memory -> drop it */ in batadv_mcast_forw_mode_check_ipv4()
1001 return -ENOMEM; in batadv_mcast_forw_mode_check_ipv4()
1004 return -EINVAL; in batadv_mcast_forw_mode_check_ipv4()
1008 /* link-local multicast listeners behind a bridge are in batadv_mcast_forw_mode_check_ipv4()
1011 if (ipv4_is_local_multicast(iphdr->daddr)) in batadv_mcast_forw_mode_check_ipv4()
1020 * batadv_mcast_is_report_ipv6() - check for MLD reports
1034 switch (icmp6_hdr(skb)->icmp6_type) { in batadv_mcast_is_report_ipv6()
1044 * batadv_mcast_forw_mode_check_ipv6() - check for optimized forwarding
1046 * @bat_priv: the bat priv with all the soft interface information
1054 * Return: If so then 0. Otherwise -EINVAL is or -ENOMEM if we are out of memory
1063 /* We might fail due to out-of-memory -> drop it */ in batadv_mcast_forw_mode_check_ipv6()
1065 return -ENOMEM; in batadv_mcast_forw_mode_check_ipv6()
1068 return -EINVAL; in batadv_mcast_forw_mode_check_ipv6()
1072 if (IPV6_ADDR_MC_SCOPE(&ip6hdr->daddr) < IPV6_ADDR_SCOPE_LINKLOCAL) in batadv_mcast_forw_mode_check_ipv6()
1073 return -EINVAL; in batadv_mcast_forw_mode_check_ipv6()
1075 /* link-local-all-nodes multicast listeners behind a bridge are in batadv_mcast_forw_mode_check_ipv6()
1078 if (ipv6_addr_is_ll_all_nodes(&ip6hdr->daddr)) in batadv_mcast_forw_mode_check_ipv6()
1080 else if (IPV6_ADDR_MC_SCOPE(&ip6hdr->daddr) > IPV6_ADDR_SCOPE_LINKLOCAL) in batadv_mcast_forw_mode_check_ipv6()
1087 * batadv_mcast_forw_mode_check() - check for optimized forwarding potential
1088 * @bat_priv: the bat priv with all the soft interface information
1096 * Return: If so then 0. Otherwise -EINVAL is or -ENOMEM if we are out of memory
1105 if (!atomic_read(&bat_priv->multicast_mode)) in batadv_mcast_forw_mode_check()
1106 return -EINVAL; in batadv_mcast_forw_mode_check()
1108 switch (ntohs(ethhdr->h_proto)) { in batadv_mcast_forw_mode_check()
1115 return -EINVAL; in batadv_mcast_forw_mode_check()
1121 return -EINVAL; in batadv_mcast_forw_mode_check()
1126 * batadv_mcast_forw_want_all_ip_count() - count nodes with unspecific mcast
1128 * @bat_priv: the bat priv with all the soft interface information
1138 switch (ntohs(ethhdr->h_proto)) { in batadv_mcast_forw_want_all_ip_count()
1140 return atomic_read(&bat_priv->mcast.num_want_all_ipv4); in batadv_mcast_forw_want_all_ip_count()
1142 return atomic_read(&bat_priv->mcast.num_want_all_ipv6); in batadv_mcast_forw_want_all_ip_count()
1150 * batadv_mcast_forw_rtr_count() - count nodes with a multicast router
1151 * @bat_priv: the bat priv with all the soft interface information
1164 return atomic_read(&bat_priv->mcast.num_want_all_rtr4); in batadv_mcast_forw_rtr_count()
1166 return atomic_read(&bat_priv->mcast.num_want_all_rtr6); in batadv_mcast_forw_rtr_count()
1173 * batadv_mcast_forw_mode_by_count() - get forwarding mode by count
1174 * @bat_priv: the bat priv with all the soft interface information
1182 * complete batman-adv multicast header.
1188 * would still fit into an 1280 bytes batman-adv multicast packet
1190 * the full batman-adv multicast packet header.
1191 * BATADV_FORW_UCASTS: If the packet cannot be sent in a batman-adv
1192 * multicast packet and the amount of batman-adv unicast packets needed
1202 u8 own_tvlv_flags = bat_priv->mcast.mla_flags.tvlv_flags; in batadv_mcast_forw_mode_by_count()
1204 if (!atomic_read(&bat_priv->mcast.num_no_mc_ptype_capa) && in batadv_mcast_forw_mode_by_count()
1206 skb->len + mcast_hdrlen <= IPV6_MIN_MTU && in batadv_mcast_forw_mode_by_count()
1210 if (count <= atomic_read(&bat_priv->multicast_fanout)) in batadv_mcast_forw_mode_by_count()
1217 * batadv_mcast_forw_mode() - check on how to forward a multicast packet
1218 * @bat_priv: the bat priv with all the soft interface information
1236 if (ret == -ENOMEM) in batadv_mcast_forw_mode()
1243 tt_count = batadv_tt_global_hash_count(bat_priv, ethhdr->h_dest, in batadv_mcast_forw_mode()
1247 atomic_read(&bat_priv->mcast.num_want_all_unsnoopables); in batadv_mcast_forw_mode()
1262 * batadv_mcast_forw_send_orig() - send a multicast packet to an originator
1263 * @bat_priv: the bat priv with all the soft interface information
1275 /* Avoid sending multicast-in-unicast packets to other BLA in batadv_mcast_forw_send_orig()
1276 * gateways - they already got the frame from the LAN side in batadv_mcast_forw_send_orig()
1281 if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig, vid)) { in batadv_mcast_forw_send_orig()
1291 * batadv_mcast_forw_tt() - forwards a packet to multicast listeners
1292 * @bat_priv: the bat priv with all the soft interface information
1298 * via a batman-adv unicast packet for each such destination node.
1313 const u8 *addr = eth_hdr(skb)->h_dest; in batadv_mcast_forw_tt()
1320 hlist_for_each_entry_rcu(orig_entry, &tt_global->orig_list, list) { in batadv_mcast_forw_tt()
1328 orig_entry->orig_node); in batadv_mcast_forw_tt()
1339 * batadv_mcast_forw_want_all_ipv4() - forward to nodes with want-all-ipv4
1340 * @bat_priv: the bat priv with all the soft interface information
1344 * Sends copies of a frame with multicast destination to any node with a
1346 * batman-adv unicast packet for each such destination node.
1361 &bat_priv->mcast.want_all_ipv4_list, in batadv_mcast_forw_want_all_ipv4()
1376 * batadv_mcast_forw_want_all_ipv6() - forward to nodes with want-all-ipv6
1377 * @bat_priv: the bat priv with all the soft interface information
1381 * Sends copies of a frame with multicast destination to any node with a
1383 * batman-adv unicast packet for each such destination node.
1398 &bat_priv->mcast.want_all_ipv6_list, in batadv_mcast_forw_want_all_ipv6()
1413 * batadv_mcast_forw_want_all() - forward packet to nodes in a want-all list
1414 * @bat_priv: the bat priv with all the soft interface information
1418 * Sends copies of a frame with multicast destination to any node with a
1420 * transmission is performed via a batman-adv unicast packet for each such
1421 * destination node.
1430 switch (ntohs(eth_hdr(skb)->h_proto)) { in batadv_mcast_forw_want_all()
1442 * batadv_mcast_forw_want_all_rtr4() - forward to nodes with want-all-rtr4
1443 * @bat_priv: the bat priv with all the soft interface information
1447 * Sends copies of a frame with multicast destination to any node with a
1449 * batman-adv unicast packet for each such destination node.
1464 &bat_priv->mcast.want_all_rtr4_list, in batadv_mcast_forw_want_all_rtr4()
1479 * batadv_mcast_forw_want_all_rtr6() - forward to nodes with want-all-rtr6
1480 * @bat_priv: the bat priv with all the soft interface information
1484 * Sends copies of a frame with multicast destination to any node with a
1486 * batman-adv unicast packet for each such destination node.
1501 &bat_priv->mcast.want_all_rtr6_list, in batadv_mcast_forw_want_all_rtr6()
1516 * batadv_mcast_forw_want_rtr() - forward packet to nodes in a want-all-rtr list
1517 * @bat_priv: the bat priv with all the soft interface information
1521 * Sends copies of a frame with multicast destination to any node with a
1523 * transmission is performed via a batman-adv unicast packet for each such
1524 * destination node.
1533 switch (ntohs(eth_hdr(skb)->h_proto)) { in batadv_mcast_forw_want_rtr()
1545 * batadv_mcast_forw_send() - send packet to any detected multicast recipient
1546 * @bat_priv: the bat priv with all the soft interface information
1551 * Sends copies of a frame with multicast destination to any node that signaled
1553 * want-all flags. A transmission is performed via a batman-adv unicast packet
1554 * for each such destination node.
1593 * batadv_mcast_want_unsnoop_update() - update unsnoop counter and list
1594 * @bat_priv: the bat priv with all the soft interface information
1602 * Caller needs to hold orig->mcast_handler_lock.
1608 struct hlist_node *node = &orig->mcast_want_all_unsnoopables_node; in batadv_mcast_want_unsnoop_update() local
1609 struct hlist_head *head = &bat_priv->mcast.want_all_unsnoopables_list; in batadv_mcast_want_unsnoop_update()
1611 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_unsnoop_update()
1615 !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES)) { in batadv_mcast_want_unsnoop_update()
1616 atomic_inc(&bat_priv->mcast.num_want_all_unsnoopables); in batadv_mcast_want_unsnoop_update()
1618 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1620 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_unsnoop_update()
1622 hlist_add_head_rcu(node, head); in batadv_mcast_want_unsnoop_update()
1623 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1626 orig->mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES) { in batadv_mcast_want_unsnoop_update()
1627 atomic_dec(&bat_priv->mcast.num_want_all_unsnoopables); in batadv_mcast_want_unsnoop_update()
1629 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1631 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_unsnoop_update()
1633 hlist_del_init_rcu(node); in batadv_mcast_want_unsnoop_update()
1634 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1639 * batadv_mcast_want_ipv4_update() - update want-all-ipv4 counter and list
1640 * @bat_priv: the bat priv with all the soft interface information
1647 * Caller needs to hold orig->mcast_handler_lock.
1653 struct hlist_node *node = &orig->mcast_want_all_ipv4_node; in batadv_mcast_want_ipv4_update() local
1654 struct hlist_head *head = &bat_priv->mcast.want_all_ipv4_list; in batadv_mcast_want_ipv4_update()
1656 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_ipv4_update()
1660 !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV4)) { in batadv_mcast_want_ipv4_update()
1661 atomic_inc(&bat_priv->mcast.num_want_all_ipv4); in batadv_mcast_want_ipv4_update()
1663 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1665 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_ipv4_update()
1667 hlist_add_head_rcu(node, head); in batadv_mcast_want_ipv4_update()
1668 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1671 orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV4) { in batadv_mcast_want_ipv4_update()
1672 atomic_dec(&bat_priv->mcast.num_want_all_ipv4); in batadv_mcast_want_ipv4_update()
1674 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1676 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_ipv4_update()
1678 hlist_del_init_rcu(node); in batadv_mcast_want_ipv4_update()
1679 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1684 * batadv_mcast_want_ipv6_update() - update want-all-ipv6 counter and list
1685 * @bat_priv: the bat priv with all the soft interface information
1692 * Caller needs to hold orig->mcast_handler_lock.
1698 struct hlist_node *node = &orig->mcast_want_all_ipv6_node; in batadv_mcast_want_ipv6_update() local
1699 struct hlist_head *head = &bat_priv->mcast.want_all_ipv6_list; in batadv_mcast_want_ipv6_update()
1701 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_ipv6_update()
1705 !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV6)) { in batadv_mcast_want_ipv6_update()
1706 atomic_inc(&bat_priv->mcast.num_want_all_ipv6); in batadv_mcast_want_ipv6_update()
1708 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1710 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_ipv6_update()
1712 hlist_add_head_rcu(node, head); in batadv_mcast_want_ipv6_update()
1713 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1716 orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV6) { in batadv_mcast_want_ipv6_update()
1717 atomic_dec(&bat_priv->mcast.num_want_all_ipv6); in batadv_mcast_want_ipv6_update()
1719 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1721 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_ipv6_update()
1723 hlist_del_init_rcu(node); in batadv_mcast_want_ipv6_update()
1724 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1729 * batadv_mcast_want_rtr4_update() - update want-all-rtr4 counter and list
1730 * @bat_priv: the bat priv with all the soft interface information
1737 * Caller needs to hold orig->mcast_handler_lock.
1743 struct hlist_node *node = &orig->mcast_want_all_rtr4_node; in batadv_mcast_want_rtr4_update() local
1744 struct hlist_head *head = &bat_priv->mcast.want_all_rtr4_list; in batadv_mcast_want_rtr4_update()
1746 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_rtr4_update()
1750 orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR4) { in batadv_mcast_want_rtr4_update()
1751 atomic_inc(&bat_priv->mcast.num_want_all_rtr4); in batadv_mcast_want_rtr4_update()
1753 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1755 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_rtr4_update()
1757 hlist_add_head_rcu(node, head); in batadv_mcast_want_rtr4_update()
1758 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1761 !(orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR4)) { in batadv_mcast_want_rtr4_update()
1762 atomic_dec(&bat_priv->mcast.num_want_all_rtr4); in batadv_mcast_want_rtr4_update()
1764 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1766 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_rtr4_update()
1768 hlist_del_init_rcu(node); in batadv_mcast_want_rtr4_update()
1769 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1774 * batadv_mcast_want_rtr6_update() - update want-all-rtr6 counter and list
1775 * @bat_priv: the bat priv with all the soft interface information
1782 * Caller needs to hold orig->mcast_handler_lock.
1788 struct hlist_node *node = &orig->mcast_want_all_rtr6_node; in batadv_mcast_want_rtr6_update() local
1789 struct hlist_head *head = &bat_priv->mcast.want_all_rtr6_list; in batadv_mcast_want_rtr6_update()
1791 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_rtr6_update()
1795 orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR6) { in batadv_mcast_want_rtr6_update()
1796 atomic_inc(&bat_priv->mcast.num_want_all_rtr6); in batadv_mcast_want_rtr6_update()
1798 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1800 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_rtr6_update()
1802 hlist_add_head_rcu(node, head); in batadv_mcast_want_rtr6_update()
1803 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1806 !(orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR6)) { in batadv_mcast_want_rtr6_update()
1807 atomic_dec(&bat_priv->mcast.num_want_all_rtr6); in batadv_mcast_want_rtr6_update()
1809 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1811 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_rtr6_update()
1813 hlist_del_init_rcu(node); in batadv_mcast_want_rtr6_update()
1814 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1819 * batadv_mcast_have_mc_ptype_update() - update multicast packet type counter
1820 * @bat_priv: the bat priv with all the soft interface information
1831 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_have_mc_ptype_update()
1835 orig->mcast_flags & BATADV_MCAST_HAVE_MC_PTYPE_CAPA) in batadv_mcast_have_mc_ptype_update()
1836 atomic_inc(&bat_priv->mcast.num_no_mc_ptype_capa); in batadv_mcast_have_mc_ptype_update()
1839 !(orig->mcast_flags & BATADV_MCAST_HAVE_MC_PTYPE_CAPA)) in batadv_mcast_have_mc_ptype_update()
1840 atomic_dec(&bat_priv->mcast.num_no_mc_ptype_capa); in batadv_mcast_have_mc_ptype_update()
1844 * batadv_mcast_tvlv_flags_get() - get multicast flags from an OGM TVLV
1875 * batadv_mcast_tvlv_ogm_handler() - process incoming multicast tvlv container
1876 * @bat_priv: the bat priv with all the soft interface information
1894 spin_lock_bh(&orig->mcast_handler_lock); in batadv_mcast_tvlv_ogm_handler()
1897 !test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities)) { in batadv_mcast_tvlv_ogm_handler()
1898 set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities); in batadv_mcast_tvlv_ogm_handler()
1900 test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities)) { in batadv_mcast_tvlv_ogm_handler()
1901 clear_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities); in batadv_mcast_tvlv_ogm_handler()
1904 set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capa_initialized); in batadv_mcast_tvlv_ogm_handler()
1913 orig->mcast_flags = mcast_flags; in batadv_mcast_tvlv_ogm_handler()
1914 spin_unlock_bh(&orig->mcast_handler_lock); in batadv_mcast_tvlv_ogm_handler()
1918 * batadv_mcast_init() - initialize the multicast optimizations structures
1919 * @bat_priv: the bat priv with all the soft interface information
1931 INIT_DELAYED_WORK(&bat_priv->mcast.work, batadv_mcast_mla_update); in batadv_mcast_init()
1936 * batadv_mcast_mesh_info_put() - put multicast info into a netlink message
1938 * @bat_priv: the bat priv with all the soft interface information
1945 u32 flags = bat_priv->mcast.mla_flags.tvlv_flags; in batadv_mcast_mesh_info_put()
1948 if (bat_priv->mcast.mla_flags.bridged) { in batadv_mcast_mesh_info_put()
1951 if (bat_priv->mcast.mla_flags.querier_ipv4.exists) in batadv_mcast_mesh_info_put()
1953 if (bat_priv->mcast.mla_flags.querier_ipv6.exists) in batadv_mcast_mesh_info_put()
1955 if (bat_priv->mcast.mla_flags.querier_ipv4.shadowing) in batadv_mcast_mesh_info_put()
1957 if (bat_priv->mcast.mla_flags.querier_ipv6.shadowing) in batadv_mcast_mesh_info_put()
1963 return -EMSGSIZE; in batadv_mcast_mesh_info_put()
1969 * batadv_mcast_flags_dump_entry() - dump one entry of the multicast flags table
1985 hdr = genlmsg_put(msg, portid, cb->nlh->nlmsg_seq, in batadv_mcast_flags_dump_entry()
1989 return -ENOBUFS; in batadv_mcast_flags_dump_entry()
1994 orig_node->orig)) { in batadv_mcast_flags_dump_entry()
1996 return -EMSGSIZE; in batadv_mcast_flags_dump_entry()
2000 &orig_node->capabilities)) { in batadv_mcast_flags_dump_entry()
2002 orig_node->mcast_flags)) { in batadv_mcast_flags_dump_entry()
2004 return -EMSGSIZE; in batadv_mcast_flags_dump_entry()
2013 * batadv_mcast_flags_dump_bucket() - dump one bucket of the multicast flags
2033 spin_lock_bh(&hash->list_locks[bucket]); in batadv_mcast_flags_dump_bucket()
2034 cb->seq = atomic_read(&hash->generation) << 1 | 1; in batadv_mcast_flags_dump_bucket()
2036 hlist_for_each_entry(orig_node, &hash->table[bucket], hash_entry) { in batadv_mcast_flags_dump_bucket()
2038 &orig_node->capa_initialized)) in batadv_mcast_flags_dump_bucket()
2045 spin_unlock_bh(&hash->list_locks[bucket]); in batadv_mcast_flags_dump_bucket()
2048 return -EMSGSIZE; in batadv_mcast_flags_dump_bucket()
2054 spin_unlock_bh(&hash->list_locks[bucket]); in batadv_mcast_flags_dump_bucket()
2060 * __batadv_mcast_flags_dump() - dump multicast flags table to a netlink socket
2064 * @bat_priv: the bat priv with all the soft interface information
2075 struct batadv_hashtable *hash = bat_priv->orig_hash; in __batadv_mcast_flags_dump()
2079 while (bucket_tmp < hash->size) { in __batadv_mcast_flags_dump()
2091 return msg->len; in __batadv_mcast_flags_dump()
2095 * batadv_mcast_netlink_get_primary() - get primary interface from netlink
2098 * @primary_if: the primary interface pointer to return the result in
2107 struct net *net = sock_net(cb->skb->sk); in batadv_mcast_netlink_get_primary()
2113 ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); in batadv_mcast_netlink_get_primary()
2115 return -EINVAL; in batadv_mcast_netlink_get_primary()
2119 ret = -ENODEV; in batadv_mcast_netlink_get_primary()
2126 if (!hard_iface || hard_iface->if_status != BATADV_IF_ACTIVE) { in batadv_mcast_netlink_get_primary()
2127 ret = -ENOENT; in batadv_mcast_netlink_get_primary()
2143 * batadv_mcast_flags_dump() - dump multicast flags table to a netlink socket
2152 int portid = NETLINK_CB(cb->skb).portid; in batadv_mcast_flags_dump()
2154 long *bucket = &cb->args[0]; in batadv_mcast_flags_dump()
2155 long *idx = &cb->args[1]; in batadv_mcast_flags_dump()
2162 bat_priv = netdev_priv(primary_if->soft_iface); in batadv_mcast_flags_dump()
2170 * batadv_mcast_free() - free the multicast optimizations structures
2171 * @bat_priv: the bat priv with all the soft interface information
2175 cancel_delayed_work_sync(&bat_priv->mcast.work); in batadv_mcast_free()
2186 * batadv_mcast_purge_orig() - reset originator global mcast state modifications
2191 struct batadv_priv *bat_priv = orig->bat_priv; in batadv_mcast_purge_orig()
2193 spin_lock_bh(&orig->mcast_handler_lock); in batadv_mcast_purge_orig()
2205 spin_unlock_bh(&orig->mcast_handler_lock); in batadv_mcast_purge_orig()