Lines Matching +full:interface +full:- +full:node
1 // SPDX-License-Identifier: GPL-2.0
54 #include "hard-interface.h"
59 #include "translation-table.h"
65 * batadv_mcast_start_timer() - schedule the multicast periodic worker
66 * @bat_priv: the bat priv with all the mesh interface information
70 queue_delayed_work(batadv_event_workqueue, &bat_priv->mcast.work, in batadv_mcast_start_timer()
75 * batadv_mcast_get_bridge() - get the bridge on top of the meshif if it exists
76 * @mesh_iface: netdev struct of the mesh interface
78 * If the given mesh interface has a bridge on top then the refcount
100 * batadv_mcast_mla_rtr_flags_meshif_get_ipv4() - get mcast router flags from
101 * node for IPv4
102 * @dev: the interface to check
104 * Checks the presence of an IPv4 multicast router on this node.
121 * batadv_mcast_mla_rtr_flags_meshif_get_ipv6() - get mcast router flags from
122 * node for IPv6
123 * @dev: the interface to check
125 * Checks the presence of an IPv6 multicast router on this node.
136 if (in6_dev && atomic_read(&in6_dev->cnf.mc_forwarding)) in batadv_mcast_mla_rtr_flags_meshif_get_ipv6()
150 * batadv_mcast_mla_rtr_flags_meshif_get() - get mcast router flags from node
151 * @bat_priv: the bat priv with all the mesh interface information
152 * @bridge: bridge interface on top of the mesh_iface if present,
156 * node.
167 struct net_device *dev = bridge ? bridge : bat_priv->mesh_iface; in batadv_mcast_mla_rtr_flags_meshif_get()
181 * batadv_mcast_mla_rtr_flags_bridge_get() - get mcast router flags from bridge
182 * @bat_priv: the bat priv with all the mesh interface information
183 * @bridge: bridge interface on top of the mesh_iface if present,
197 struct net_device *dev = bat_priv->mesh_iface; in batadv_mcast_mla_rtr_flags_bridge_get()
212 * batadv_mcast_mla_rtr_flags_get() - get multicast router flags
213 * @bat_priv: the bat priv with all the mesh interface information
214 * @bridge: bridge interface on top of the mesh_iface if present,
218 * node or behind its bridge.
238 * batadv_mcast_mla_forw_flags_get() - get multicast forwarding flags
239 * @bat_priv: the bat priv with all the mesh interface information
252 netdev_for_each_lower_private_rcu(bat_priv->mesh_iface, hard_iface, iter) { in batadv_mcast_mla_forw_flags_get()
253 if (hard_iface->if_status != BATADV_IF_ACTIVE) in batadv_mcast_mla_forw_flags_get()
256 if (hard_iface->net_dev->mtu < IPV6_MIN_MTU) { in batadv_mcast_mla_forw_flags_get()
267 * batadv_mcast_mla_flags_get() - get the new multicast flags
268 * @bat_priv: the bat priv with all the mesh interface information
276 struct net_device *dev = bat_priv->mesh_iface; in batadv_mcast_mla_flags_get()
299 pr_warn_once("No bridge IGMP snooping compiled - multicast optimizations disabled\n"); in batadv_mcast_mla_flags_get()
301 qr4->exists = br_multicast_has_querier_anywhere(dev, ETH_P_IP); in batadv_mcast_mla_flags_get()
302 qr4->shadowing = br_multicast_has_querier_adjacent(dev, ETH_P_IP); in batadv_mcast_mla_flags_get()
304 qr6->exists = br_multicast_has_querier_anywhere(dev, ETH_P_IPV6); in batadv_mcast_mla_flags_get()
305 qr6->shadowing = br_multicast_has_querier_adjacent(dev, ETH_P_IPV6); in batadv_mcast_mla_flags_get()
318 if (!qr4->exists || qr4->shadowing) { in batadv_mcast_mla_flags_get()
323 if (!qr6->exists || qr6->shadowing) { in batadv_mcast_mla_flags_get()
332 * batadv_mcast_mla_is_duplicate() - check whether an address is in a list
345 if (batadv_compare_eth(mcast_entry->addr, mcast_addr)) in batadv_mcast_mla_is_duplicate()
352 * batadv_mcast_mla_meshif_get_ipv4() - get meshif IPv4 multicast listeners
358 * on this kernel on the given mesh interface, dev, in
360 * your multicast receiving applications run directly on this node.
362 * Return: -ENOMEM on memory allocation error or the number of
376 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV4) in batadv_mcast_mla_meshif_get_ipv4()
387 for (pmc = rcu_dereference(in_dev->mc_list); pmc; in batadv_mcast_mla_meshif_get_ipv4()
388 pmc = rcu_dereference(pmc->next_rcu)) { in batadv_mcast_mla_meshif_get_ipv4()
389 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES && in batadv_mcast_mla_meshif_get_ipv4()
390 ipv4_is_local_multicast(pmc->multiaddr)) in batadv_mcast_mla_meshif_get_ipv4()
393 if (!(flags->tvlv_flags & BATADV_MCAST_WANT_NO_RTR4) && in batadv_mcast_mla_meshif_get_ipv4()
394 !ipv4_is_local_multicast(pmc->multiaddr)) in batadv_mcast_mla_meshif_get_ipv4()
397 ip_eth_mc_map(pmc->multiaddr, mcast_addr); in batadv_mcast_mla_meshif_get_ipv4()
404 ret = -ENOMEM; in batadv_mcast_mla_meshif_get_ipv4()
408 ether_addr_copy(new->addr, mcast_addr); in batadv_mcast_mla_meshif_get_ipv4()
409 hlist_add_head(&new->list, mcast_list); in batadv_mcast_mla_meshif_get_ipv4()
418 * batadv_mcast_mla_meshif_get_ipv6() - get meshif IPv6 multicast listeners
424 * on this kernel on the given mesh interface, dev, in
426 * your multicast receiving applications run directly on this node.
428 * Return: -ENOMEM on memory allocation error or the number of
443 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV6) in batadv_mcast_mla_meshif_get_ipv6()
454 for (pmc6 = rcu_dereference(in6_dev->mc_list); in batadv_mcast_mla_meshif_get_ipv6()
456 pmc6 = rcu_dereference(pmc6->next)) { in batadv_mcast_mla_meshif_get_ipv6()
457 if (IPV6_ADDR_MC_SCOPE(&pmc6->mca_addr) < in batadv_mcast_mla_meshif_get_ipv6()
461 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES && in batadv_mcast_mla_meshif_get_ipv6()
462 ipv6_addr_is_ll_all_nodes(&pmc6->mca_addr)) in batadv_mcast_mla_meshif_get_ipv6()
465 if (!(flags->tvlv_flags & BATADV_MCAST_WANT_NO_RTR6) && in batadv_mcast_mla_meshif_get_ipv6()
466 IPV6_ADDR_MC_SCOPE(&pmc6->mca_addr) > in batadv_mcast_mla_meshif_get_ipv6()
470 ipv6_eth_mc_map(&pmc6->mca_addr, mcast_addr); in batadv_mcast_mla_meshif_get_ipv6()
477 ret = -ENOMEM; in batadv_mcast_mla_meshif_get_ipv6()
481 ether_addr_copy(new->addr, mcast_addr); in batadv_mcast_mla_meshif_get_ipv6()
482 hlist_add_head(&new->list, mcast_list); in batadv_mcast_mla_meshif_get_ipv6()
500 * batadv_mcast_mla_meshif_get() - get meshif multicast listeners
506 * on this kernel on the given mesh interface, dev, in
508 * your multicast receiving applications run directly on this node.
510 * If there is a bridge interface on top of dev, collect from that one
512 * will(/should) register to the bridge interface instead of an
515 * Return: -ENOMEM on memory allocation error or the number of
546 * batadv_mcast_mla_br_addr_cpy() - copy a bridge multicast address
547 * @dst: destination to write to - a multicast MAC address
548 * @src: source to read from - a multicast IP address
559 if (src->proto == htons(ETH_P_IP)) in batadv_mcast_mla_br_addr_cpy()
560 ip_eth_mc_map(src->dst.ip4, dst); in batadv_mcast_mla_br_addr_cpy()
562 else if (src->proto == htons(ETH_P_IPV6)) in batadv_mcast_mla_br_addr_cpy()
563 ipv6_eth_mc_map(&src->dst.ip6, dst); in batadv_mcast_mla_br_addr_cpy()
570 * batadv_mcast_mla_bridge_get() - get bridged-in multicast listeners
576 * on foreign, non-mesh devices which we gave access to our mesh via
577 * a bridge on top of the given mesh interface, dev, in the given
580 * Return: -ENOMEM on memory allocation error or the number of
589 u8 tvlv_flags = flags->tvlv_flags; in batadv_mcast_mla_bridge_get()
602 if (br_ip_entry->addr.proto == htons(ETH_P_IP)) { in batadv_mcast_mla_bridge_get()
607 ipv4_is_local_multicast(br_ip_entry->addr.dst.ip4)) in batadv_mcast_mla_bridge_get()
611 !ipv4_is_local_multicast(br_ip_entry->addr.dst.ip4)) in batadv_mcast_mla_bridge_get()
616 if (br_ip_entry->addr.proto == htons(ETH_P_IPV6)) { in batadv_mcast_mla_bridge_get()
621 ipv6_addr_is_ll_all_nodes(&br_ip_entry->addr.dst.ip6)) in batadv_mcast_mla_bridge_get()
625 IPV6_ADDR_MC_SCOPE(&br_ip_entry->addr.dst.ip6) > in batadv_mcast_mla_bridge_get()
631 batadv_mcast_mla_br_addr_cpy(mcast_addr, &br_ip_entry->addr); in batadv_mcast_mla_bridge_get()
637 ret = -ENOMEM; in batadv_mcast_mla_bridge_get()
641 ether_addr_copy(new->addr, mcast_addr); in batadv_mcast_mla_bridge_get()
642 hlist_add_head(&new->list, mcast_list); in batadv_mcast_mla_bridge_get()
647 list_del(&br_ip_entry->list); in batadv_mcast_mla_bridge_get()
655 * batadv_mcast_mla_list_free() - free a list of multicast addresses
666 hlist_del(&mcast_entry->list); in batadv_mcast_mla_list_free()
672 * batadv_mcast_mla_tt_retract() - clean up multicast listener announcements
673 * @bat_priv: the bat priv with all the mesh interface information
687 hlist_for_each_entry_safe(mcast_entry, tmp, &bat_priv->mcast.mla_list, in batadv_mcast_mla_tt_retract()
690 batadv_mcast_mla_is_duplicate(mcast_entry->addr, in batadv_mcast_mla_tt_retract()
694 batadv_tt_local_remove(bat_priv, mcast_entry->addr, in batadv_mcast_mla_tt_retract()
698 hlist_del(&mcast_entry->list); in batadv_mcast_mla_tt_retract()
704 * batadv_mcast_mla_tt_add() - add multicast listener announcements
705 * @bat_priv: the bat priv with all the mesh interface information
721 if (batadv_mcast_mla_is_duplicate(mcast_entry->addr, in batadv_mcast_mla_tt_add()
722 &bat_priv->mcast.mla_list)) in batadv_mcast_mla_tt_add()
725 if (!batadv_tt_local_add(bat_priv->mesh_iface, in batadv_mcast_mla_tt_add()
726 mcast_entry->addr, BATADV_NO_FLAGS, in batadv_mcast_mla_tt_add()
730 hlist_del(&mcast_entry->list); in batadv_mcast_mla_tt_add()
731 hlist_add_head(&mcast_entry->list, &bat_priv->mcast.mla_list); in batadv_mcast_mla_tt_add()
736 * batadv_mcast_querier_log() - debug output regarding the querier status on
738 * @bat_priv: the bat priv with all the mesh interface information
750 * forward listener reports to the querier, therefore batman-adv and
751 * the bridge will potentially not see these listeners - the querier is
755 * mesh interface.
762 if (!old_state->exists && new_state->exists) in batadv_mcast_querier_log()
763 batadv_info(bat_priv->mesh_iface, "%s Querier appeared\n", in batadv_mcast_querier_log()
765 else if (old_state->exists && !new_state->exists) in batadv_mcast_querier_log()
766 batadv_info(bat_priv->mesh_iface, in batadv_mcast_querier_log()
767 "%s Querier disappeared - multicast optimizations disabled\n", in batadv_mcast_querier_log()
769 else if (!bat_priv->mcast.mla_flags.bridged && !new_state->exists) in batadv_mcast_querier_log()
770 batadv_info(bat_priv->mesh_iface, in batadv_mcast_querier_log()
771 "No %s Querier present - multicast optimizations disabled\n", in batadv_mcast_querier_log()
774 if (new_state->exists) { in batadv_mcast_querier_log()
775 if ((!old_state->shadowing && new_state->shadowing) || in batadv_mcast_querier_log()
776 (!old_state->exists && new_state->shadowing)) in batadv_mcast_querier_log()
780 else if (old_state->shadowing && !new_state->shadowing) in batadv_mcast_querier_log()
788 * batadv_mcast_bridge_log() - debug output for topology changes in bridged
790 * @bat_priv: the bat priv with all the mesh interface information
793 * If no bridges are ever used on this node, then this function does nothing.
798 * More precisely, it outputs information when a bridge interface is added or
799 * removed from a mesh interface. And when a bridge is present, it further
801 * multicast flags this node is going to set.
807 struct batadv_mcast_mla_flags *old_flags = &bat_priv->mcast.mla_flags; in batadv_mcast_bridge_log()
809 if (!old_flags->bridged && new_flags->bridged) in batadv_mcast_bridge_log()
811 "Bridge added: Setting Unsnoopables(U)-flag\n"); in batadv_mcast_bridge_log()
812 else if (old_flags->bridged && !new_flags->bridged) in batadv_mcast_bridge_log()
814 "Bridge removed: Unsetting Unsnoopables(U)-flag\n"); in batadv_mcast_bridge_log()
816 if (new_flags->bridged) { in batadv_mcast_bridge_log()
818 &old_flags->querier_ipv4, in batadv_mcast_bridge_log()
819 &new_flags->querier_ipv4); in batadv_mcast_bridge_log()
821 &old_flags->querier_ipv6, in batadv_mcast_bridge_log()
822 &new_flags->querier_ipv6); in batadv_mcast_bridge_log()
827 * batadv_mcast_flags_log() - output debug information about mcast flag changes
828 * @bat_priv: the bat priv with all the mesh interface information
831 * Whenever the multicast TVLV flags this node announces change, this function
836 bool old_enabled = bat_priv->mcast.mla_flags.enabled; in batadv_mcast_flags_log()
837 u8 old_flags = bat_priv->mcast.mla_flags.tvlv_flags; in batadv_mcast_flags_log()
860 * batadv_mcast_mla_flags_update() - update multicast flags
861 * @bat_priv: the bat priv with all the mesh interface information
873 if (!memcmp(flags, &bat_priv->mcast.mla_flags, sizeof(*flags))) in batadv_mcast_mla_flags_update()
877 batadv_mcast_flags_log(bat_priv, flags->tvlv_flags); in batadv_mcast_mla_flags_update()
879 mcast_data.flags = flags->tvlv_flags; in batadv_mcast_mla_flags_update()
885 bat_priv->mcast.mla_flags = *flags; in batadv_mcast_mla_flags_update()
889 * __batadv_mcast_mla_update() - update the own MLAs
890 * @bat_priv: the bat priv with all the mesh interface information
895 * Note that non-conflicting reads and writes to bat_priv->mcast.mla_list
897 * ensured by the non-parallel execution of the worker this function
902 struct net_device *mesh_iface = bat_priv->mesh_iface; in __batadv_mcast_mla_update()
917 spin_lock(&bat_priv->mcast.mla_lock); in __batadv_mcast_mla_update()
921 spin_unlock(&bat_priv->mcast.mla_lock); in __batadv_mcast_mla_update()
928 * batadv_mcast_mla_update() - update the own MLAs
951 * batadv_mcast_is_report_ipv4() - check for IGMP reports
965 switch (igmp_hdr(skb)->type) { in batadv_mcast_is_report_ipv4()
976 * batadv_mcast_forw_mode_check_ipv4() - check for optimized forwarding
978 * @bat_priv: the bat priv with all the mesh interface information
986 * Return: If so then 0. Otherwise -EINVAL or -ENOMEM in case of memory
996 /* We might fail due to out-of-memory -> drop it */ in batadv_mcast_forw_mode_check_ipv4()
998 return -ENOMEM; in batadv_mcast_forw_mode_check_ipv4()
1001 return -EINVAL; in batadv_mcast_forw_mode_check_ipv4()
1005 /* link-local multicast listeners behind a bridge are in batadv_mcast_forw_mode_check_ipv4()
1008 if (ipv4_is_local_multicast(iphdr->daddr)) in batadv_mcast_forw_mode_check_ipv4()
1017 * batadv_mcast_is_report_ipv6() - check for MLD reports
1031 switch (icmp6_hdr(skb)->icmp6_type) { in batadv_mcast_is_report_ipv6()
1041 * batadv_mcast_forw_mode_check_ipv6() - check for optimized forwarding
1043 * @bat_priv: the bat priv with all the mesh interface information
1051 * Return: If so then 0. Otherwise -EINVAL is or -ENOMEM if we are out of memory
1060 /* We might fail due to out-of-memory -> drop it */ in batadv_mcast_forw_mode_check_ipv6()
1062 return -ENOMEM; in batadv_mcast_forw_mode_check_ipv6()
1065 return -EINVAL; in batadv_mcast_forw_mode_check_ipv6()
1069 if (IPV6_ADDR_MC_SCOPE(&ip6hdr->daddr) < IPV6_ADDR_SCOPE_LINKLOCAL) in batadv_mcast_forw_mode_check_ipv6()
1070 return -EINVAL; in batadv_mcast_forw_mode_check_ipv6()
1072 /* link-local-all-nodes multicast listeners behind a bridge are in batadv_mcast_forw_mode_check_ipv6()
1075 if (ipv6_addr_is_ll_all_nodes(&ip6hdr->daddr)) in batadv_mcast_forw_mode_check_ipv6()
1077 else if (IPV6_ADDR_MC_SCOPE(&ip6hdr->daddr) > IPV6_ADDR_SCOPE_LINKLOCAL) in batadv_mcast_forw_mode_check_ipv6()
1084 * batadv_mcast_forw_mode_check() - check for optimized forwarding potential
1085 * @bat_priv: the bat priv with all the mesh interface information
1093 * Return: If so then 0. Otherwise -EINVAL is or -ENOMEM if we are out of memory
1102 if (!atomic_read(&bat_priv->multicast_mode)) in batadv_mcast_forw_mode_check()
1103 return -EINVAL; in batadv_mcast_forw_mode_check()
1105 switch (ntohs(ethhdr->h_proto)) { in batadv_mcast_forw_mode_check()
1112 return -EINVAL; in batadv_mcast_forw_mode_check()
1118 return -EINVAL; in batadv_mcast_forw_mode_check()
1123 * batadv_mcast_forw_want_all_ip_count() - count nodes with unspecific mcast
1125 * @bat_priv: the bat priv with all the mesh interface information
1135 switch (ntohs(ethhdr->h_proto)) { in batadv_mcast_forw_want_all_ip_count()
1137 return atomic_read(&bat_priv->mcast.num_want_all_ipv4); in batadv_mcast_forw_want_all_ip_count()
1139 return atomic_read(&bat_priv->mcast.num_want_all_ipv6); in batadv_mcast_forw_want_all_ip_count()
1147 * batadv_mcast_forw_rtr_count() - count nodes with a multicast router
1148 * @bat_priv: the bat priv with all the mesh interface information
1161 return atomic_read(&bat_priv->mcast.num_want_all_rtr4); in batadv_mcast_forw_rtr_count()
1163 return atomic_read(&bat_priv->mcast.num_want_all_rtr6); in batadv_mcast_forw_rtr_count()
1170 * batadv_mcast_forw_mode_by_count() - get forwarding mode by count
1171 * @bat_priv: the bat priv with all the mesh interface information
1179 * complete batman-adv multicast header.
1185 * would still fit into an 1280 bytes batman-adv multicast packet
1187 * the full batman-adv multicast packet header.
1188 * BATADV_FORW_UCASTS: If the packet cannot be sent in a batman-adv
1189 * multicast packet and the amount of batman-adv unicast packets needed
1199 u8 own_tvlv_flags = bat_priv->mcast.mla_flags.tvlv_flags; in batadv_mcast_forw_mode_by_count()
1201 if (!atomic_read(&bat_priv->mcast.num_no_mc_ptype_capa) && in batadv_mcast_forw_mode_by_count()
1203 skb->len + mcast_hdrlen <= IPV6_MIN_MTU && in batadv_mcast_forw_mode_by_count()
1207 if (count <= atomic_read(&bat_priv->multicast_fanout)) in batadv_mcast_forw_mode_by_count()
1214 * batadv_mcast_forw_mode() - check on how to forward a multicast packet
1215 * @bat_priv: the bat priv with all the mesh interface information
1233 if (ret == -ENOMEM) in batadv_mcast_forw_mode()
1240 tt_count = batadv_tt_global_hash_count(bat_priv, ethhdr->h_dest, in batadv_mcast_forw_mode()
1244 atomic_read(&bat_priv->mcast.num_want_all_unsnoopables); in batadv_mcast_forw_mode()
1259 * batadv_mcast_forw_send_orig() - send a multicast packet to an originator
1260 * @bat_priv: the bat priv with all the mesh interface information
1272 /* Avoid sending multicast-in-unicast packets to other BLA in batadv_mcast_forw_send_orig()
1273 * gateways - they already got the frame from the LAN side in batadv_mcast_forw_send_orig()
1278 if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig, vid)) { in batadv_mcast_forw_send_orig()
1288 * batadv_mcast_forw_tt() - forwards a packet to multicast listeners
1289 * @bat_priv: the bat priv with all the mesh interface information
1295 * via a batman-adv unicast packet for each such destination node.
1310 const u8 *addr = eth_hdr(skb)->h_dest; in batadv_mcast_forw_tt()
1317 hlist_for_each_entry_rcu(orig_entry, &tt_global->orig_list, list) { in batadv_mcast_forw_tt()
1325 orig_entry->orig_node); in batadv_mcast_forw_tt()
1336 * batadv_mcast_forw_want_all_ipv4() - forward to nodes with want-all-ipv4
1337 * @bat_priv: the bat priv with all the mesh interface information
1341 * Sends copies of a frame with multicast destination to any node with a
1343 * batman-adv unicast packet for each such destination node.
1358 &bat_priv->mcast.want_all_ipv4_list, in batadv_mcast_forw_want_all_ipv4()
1373 * batadv_mcast_forw_want_all_ipv6() - forward to nodes with want-all-ipv6
1374 * @bat_priv: the bat priv with all the mesh interface information
1378 * Sends copies of a frame with multicast destination to any node with a
1380 * batman-adv unicast packet for each such destination node.
1395 &bat_priv->mcast.want_all_ipv6_list, in batadv_mcast_forw_want_all_ipv6()
1410 * batadv_mcast_forw_want_all() - forward packet to nodes in a want-all list
1411 * @bat_priv: the bat priv with all the mesh interface information
1415 * Sends copies of a frame with multicast destination to any node with a
1417 * transmission is performed via a batman-adv unicast packet for each such
1418 * destination node.
1427 switch (ntohs(eth_hdr(skb)->h_proto)) { in batadv_mcast_forw_want_all()
1439 * batadv_mcast_forw_want_all_rtr4() - forward to nodes with want-all-rtr4
1440 * @bat_priv: the bat priv with all the mesh interface information
1444 * Sends copies of a frame with multicast destination to any node with a
1446 * batman-adv unicast packet for each such destination node.
1461 &bat_priv->mcast.want_all_rtr4_list, in batadv_mcast_forw_want_all_rtr4()
1476 * batadv_mcast_forw_want_all_rtr6() - forward to nodes with want-all-rtr6
1477 * @bat_priv: the bat priv with all the mesh interface information
1481 * Sends copies of a frame with multicast destination to any node with a
1483 * batman-adv unicast packet for each such destination node.
1498 &bat_priv->mcast.want_all_rtr6_list, in batadv_mcast_forw_want_all_rtr6()
1513 * batadv_mcast_forw_want_rtr() - forward packet to nodes in a want-all-rtr list
1514 * @bat_priv: the bat priv with all the mesh interface information
1518 * Sends copies of a frame with multicast destination to any node with a
1520 * transmission is performed via a batman-adv unicast packet for each such
1521 * destination node.
1530 switch (ntohs(eth_hdr(skb)->h_proto)) { in batadv_mcast_forw_want_rtr()
1542 * batadv_mcast_forw_send() - send packet to any detected multicast recipient
1543 * @bat_priv: the bat priv with all the mesh interface information
1548 * Sends copies of a frame with multicast destination to any node that signaled
1550 * want-all flags. A transmission is performed via a batman-adv unicast packet
1551 * for each such destination node.
1590 * batadv_mcast_want_unsnoop_update() - update unsnoop counter and list
1591 * @bat_priv: the bat priv with all the mesh interface information
1599 * Caller needs to hold orig->mcast_handler_lock.
1605 struct hlist_node *node = &orig->mcast_want_all_unsnoopables_node; in batadv_mcast_want_unsnoop_update() local
1606 struct hlist_head *head = &bat_priv->mcast.want_all_unsnoopables_list; in batadv_mcast_want_unsnoop_update()
1608 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_unsnoop_update()
1612 !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES)) { in batadv_mcast_want_unsnoop_update()
1613 atomic_inc(&bat_priv->mcast.num_want_all_unsnoopables); in batadv_mcast_want_unsnoop_update()
1615 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1617 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_unsnoop_update()
1619 hlist_add_head_rcu(node, head); in batadv_mcast_want_unsnoop_update()
1620 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1623 orig->mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES) { in batadv_mcast_want_unsnoop_update()
1624 atomic_dec(&bat_priv->mcast.num_want_all_unsnoopables); in batadv_mcast_want_unsnoop_update()
1626 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1628 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_unsnoop_update()
1630 hlist_del_init_rcu(node); in batadv_mcast_want_unsnoop_update()
1631 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1636 * batadv_mcast_want_ipv4_update() - update want-all-ipv4 counter and list
1637 * @bat_priv: the bat priv with all the mesh interface information
1644 * Caller needs to hold orig->mcast_handler_lock.
1650 struct hlist_node *node = &orig->mcast_want_all_ipv4_node; in batadv_mcast_want_ipv4_update() local
1651 struct hlist_head *head = &bat_priv->mcast.want_all_ipv4_list; in batadv_mcast_want_ipv4_update()
1653 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_ipv4_update()
1657 !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV4)) { in batadv_mcast_want_ipv4_update()
1658 atomic_inc(&bat_priv->mcast.num_want_all_ipv4); in batadv_mcast_want_ipv4_update()
1660 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1662 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_ipv4_update()
1664 hlist_add_head_rcu(node, head); in batadv_mcast_want_ipv4_update()
1665 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1668 orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV4) { in batadv_mcast_want_ipv4_update()
1669 atomic_dec(&bat_priv->mcast.num_want_all_ipv4); in batadv_mcast_want_ipv4_update()
1671 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1673 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_ipv4_update()
1675 hlist_del_init_rcu(node); in batadv_mcast_want_ipv4_update()
1676 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1681 * batadv_mcast_want_ipv6_update() - update want-all-ipv6 counter and list
1682 * @bat_priv: the bat priv with all the mesh interface information
1689 * Caller needs to hold orig->mcast_handler_lock.
1695 struct hlist_node *node = &orig->mcast_want_all_ipv6_node; in batadv_mcast_want_ipv6_update() local
1696 struct hlist_head *head = &bat_priv->mcast.want_all_ipv6_list; in batadv_mcast_want_ipv6_update()
1698 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_ipv6_update()
1702 !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV6)) { in batadv_mcast_want_ipv6_update()
1703 atomic_inc(&bat_priv->mcast.num_want_all_ipv6); in batadv_mcast_want_ipv6_update()
1705 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1707 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_ipv6_update()
1709 hlist_add_head_rcu(node, head); in batadv_mcast_want_ipv6_update()
1710 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1713 orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV6) { in batadv_mcast_want_ipv6_update()
1714 atomic_dec(&bat_priv->mcast.num_want_all_ipv6); in batadv_mcast_want_ipv6_update()
1716 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1718 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_ipv6_update()
1720 hlist_del_init_rcu(node); in batadv_mcast_want_ipv6_update()
1721 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1726 * batadv_mcast_want_rtr4_update() - update want-all-rtr4 counter and list
1727 * @bat_priv: the bat priv with all the mesh interface information
1734 * Caller needs to hold orig->mcast_handler_lock.
1740 struct hlist_node *node = &orig->mcast_want_all_rtr4_node; in batadv_mcast_want_rtr4_update() local
1741 struct hlist_head *head = &bat_priv->mcast.want_all_rtr4_list; in batadv_mcast_want_rtr4_update()
1743 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_rtr4_update()
1747 orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR4) { in batadv_mcast_want_rtr4_update()
1748 atomic_inc(&bat_priv->mcast.num_want_all_rtr4); in batadv_mcast_want_rtr4_update()
1750 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1752 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_rtr4_update()
1754 hlist_add_head_rcu(node, head); in batadv_mcast_want_rtr4_update()
1755 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1758 !(orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR4)) { in batadv_mcast_want_rtr4_update()
1759 atomic_dec(&bat_priv->mcast.num_want_all_rtr4); in batadv_mcast_want_rtr4_update()
1761 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1763 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_rtr4_update()
1765 hlist_del_init_rcu(node); in batadv_mcast_want_rtr4_update()
1766 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1771 * batadv_mcast_want_rtr6_update() - update want-all-rtr6 counter and list
1772 * @bat_priv: the bat priv with all the mesh interface information
1779 * Caller needs to hold orig->mcast_handler_lock.
1785 struct hlist_node *node = &orig->mcast_want_all_rtr6_node; in batadv_mcast_want_rtr6_update() local
1786 struct hlist_head *head = &bat_priv->mcast.want_all_rtr6_list; in batadv_mcast_want_rtr6_update()
1788 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_rtr6_update()
1792 orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR6) { in batadv_mcast_want_rtr6_update()
1793 atomic_inc(&bat_priv->mcast.num_want_all_rtr6); in batadv_mcast_want_rtr6_update()
1795 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1797 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_rtr6_update()
1799 hlist_add_head_rcu(node, head); in batadv_mcast_want_rtr6_update()
1800 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1803 !(orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR6)) { in batadv_mcast_want_rtr6_update()
1804 atomic_dec(&bat_priv->mcast.num_want_all_rtr6); in batadv_mcast_want_rtr6_update()
1806 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1808 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_rtr6_update()
1810 hlist_del_init_rcu(node); in batadv_mcast_want_rtr6_update()
1811 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1816 * batadv_mcast_have_mc_ptype_update() - update multicast packet type counter
1817 * @bat_priv: the bat priv with all the mesh interface information
1828 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_have_mc_ptype_update()
1832 orig->mcast_flags & BATADV_MCAST_HAVE_MC_PTYPE_CAPA) in batadv_mcast_have_mc_ptype_update()
1833 atomic_inc(&bat_priv->mcast.num_no_mc_ptype_capa); in batadv_mcast_have_mc_ptype_update()
1836 !(orig->mcast_flags & BATADV_MCAST_HAVE_MC_PTYPE_CAPA)) in batadv_mcast_have_mc_ptype_update()
1837 atomic_dec(&bat_priv->mcast.num_no_mc_ptype_capa); in batadv_mcast_have_mc_ptype_update()
1841 * batadv_mcast_tvlv_flags_get() - get multicast flags from an OGM TVLV
1872 * batadv_mcast_tvlv_ogm_handler() - process incoming multicast tvlv container
1873 * @bat_priv: the bat priv with all the mesh interface information
1891 spin_lock_bh(&orig->mcast_handler_lock); in batadv_mcast_tvlv_ogm_handler()
1894 !test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities)) { in batadv_mcast_tvlv_ogm_handler()
1895 set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities); in batadv_mcast_tvlv_ogm_handler()
1897 test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities)) { in batadv_mcast_tvlv_ogm_handler()
1898 clear_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities); in batadv_mcast_tvlv_ogm_handler()
1901 set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capa_initialized); in batadv_mcast_tvlv_ogm_handler()
1910 orig->mcast_flags = mcast_flags; in batadv_mcast_tvlv_ogm_handler()
1911 spin_unlock_bh(&orig->mcast_handler_lock); in batadv_mcast_tvlv_ogm_handler()
1915 * batadv_mcast_init() - initialize the multicast optimizations structures
1916 * @bat_priv: the bat priv with all the mesh interface information
1928 INIT_DELAYED_WORK(&bat_priv->mcast.work, batadv_mcast_mla_update); in batadv_mcast_init()
1933 * batadv_mcast_mesh_info_put() - put multicast info into a netlink message
1935 * @bat_priv: the bat priv with all the mesh interface information
1942 u32 flags = bat_priv->mcast.mla_flags.tvlv_flags; in batadv_mcast_mesh_info_put()
1945 if (bat_priv->mcast.mla_flags.bridged) { in batadv_mcast_mesh_info_put()
1948 if (bat_priv->mcast.mla_flags.querier_ipv4.exists) in batadv_mcast_mesh_info_put()
1950 if (bat_priv->mcast.mla_flags.querier_ipv6.exists) in batadv_mcast_mesh_info_put()
1952 if (bat_priv->mcast.mla_flags.querier_ipv4.shadowing) in batadv_mcast_mesh_info_put()
1954 if (bat_priv->mcast.mla_flags.querier_ipv6.shadowing) in batadv_mcast_mesh_info_put()
1960 return -EMSGSIZE; in batadv_mcast_mesh_info_put()
1966 * batadv_mcast_flags_dump_entry() - dump one entry of the multicast flags table
1982 hdr = genlmsg_put(msg, portid, cb->nlh->nlmsg_seq, in batadv_mcast_flags_dump_entry()
1986 return -ENOBUFS; in batadv_mcast_flags_dump_entry()
1991 orig_node->orig)) { in batadv_mcast_flags_dump_entry()
1993 return -EMSGSIZE; in batadv_mcast_flags_dump_entry()
1997 &orig_node->capabilities)) { in batadv_mcast_flags_dump_entry()
1999 orig_node->mcast_flags)) { in batadv_mcast_flags_dump_entry()
2001 return -EMSGSIZE; in batadv_mcast_flags_dump_entry()
2010 * batadv_mcast_flags_dump_bucket() - dump one bucket of the multicast flags
2030 spin_lock_bh(&hash->list_locks[bucket]); in batadv_mcast_flags_dump_bucket()
2031 cb->seq = atomic_read(&hash->generation) << 1 | 1; in batadv_mcast_flags_dump_bucket()
2033 hlist_for_each_entry(orig_node, &hash->table[bucket], hash_entry) { in batadv_mcast_flags_dump_bucket()
2035 &orig_node->capa_initialized)) in batadv_mcast_flags_dump_bucket()
2042 spin_unlock_bh(&hash->list_locks[bucket]); in batadv_mcast_flags_dump_bucket()
2045 return -EMSGSIZE; in batadv_mcast_flags_dump_bucket()
2051 spin_unlock_bh(&hash->list_locks[bucket]); in batadv_mcast_flags_dump_bucket()
2057 * __batadv_mcast_flags_dump() - dump multicast flags table to a netlink socket
2061 * @bat_priv: the bat priv with all the mesh interface information
2072 struct batadv_hashtable *hash = bat_priv->orig_hash; in __batadv_mcast_flags_dump()
2076 while (bucket_tmp < hash->size) { in __batadv_mcast_flags_dump()
2088 return msg->len; in __batadv_mcast_flags_dump()
2092 * batadv_mcast_netlink_get_primary() - get primary interface from netlink
2095 * @primary_if: the primary interface pointer to return the result in
2115 if (!hard_iface || hard_iface->if_status != BATADV_IF_ACTIVE) { in batadv_mcast_netlink_get_primary()
2116 ret = -ENOENT; in batadv_mcast_netlink_get_primary()
2132 * batadv_mcast_flags_dump() - dump multicast flags table to a netlink socket
2141 int portid = NETLINK_CB(cb->skb).portid; in batadv_mcast_flags_dump()
2143 long *bucket = &cb->args[0]; in batadv_mcast_flags_dump()
2144 long *idx = &cb->args[1]; in batadv_mcast_flags_dump()
2151 bat_priv = netdev_priv(primary_if->mesh_iface); in batadv_mcast_flags_dump()
2159 * batadv_mcast_free() - free the multicast optimizations structures
2160 * @bat_priv: the bat priv with all the mesh interface information
2164 cancel_delayed_work_sync(&bat_priv->mcast.work); in batadv_mcast_free()
2175 * batadv_mcast_purge_orig() - reset originator global mcast state modifications
2180 struct batadv_priv *bat_priv = orig->bat_priv; in batadv_mcast_purge_orig()
2182 spin_lock_bh(&orig->mcast_handler_lock); in batadv_mcast_purge_orig()
2194 spin_unlock_bh(&orig->mcast_handler_lock); in batadv_mcast_purge_orig()