• Home
  • Raw
  • Download

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_flags_get() - get the new multicast flags
240 * @bat_priv: the bat priv with all the soft interface information
248 struct net_device *dev = bat_priv->soft_iface; in batadv_mcast_mla_flags_get()
270 pr_warn_once("No bridge IGMP snooping compiled - multicast optimizations disabled\n"); in batadv_mcast_mla_flags_get()
272 qr4->exists = br_multicast_has_querier_anywhere(dev, ETH_P_IP); in batadv_mcast_mla_flags_get()
273 qr4->shadowing = br_multicast_has_querier_adjacent(dev, ETH_P_IP); in batadv_mcast_mla_flags_get()
275 qr6->exists = br_multicast_has_querier_anywhere(dev, ETH_P_IPV6); in batadv_mcast_mla_flags_get()
276 qr6->shadowing = br_multicast_has_querier_adjacent(dev, ETH_P_IPV6); in batadv_mcast_mla_flags_get()
289 if (!qr4->exists || qr4->shadowing) { in batadv_mcast_mla_flags_get()
294 if (!qr6->exists || qr6->shadowing) { in batadv_mcast_mla_flags_get()
303 * batadv_mcast_mla_is_duplicate() - check whether an address is in a list
316 if (batadv_compare_eth(mcast_entry->addr, mcast_addr)) in batadv_mcast_mla_is_duplicate()
323 * batadv_mcast_mla_softif_get_ipv4() - get softif IPv4 multicast listeners
329 * on this kernel on the given soft interface, dev, in
331 * your multicast receiving applications run directly on this node.
333 * Return: -ENOMEM on memory allocation error or the number of
347 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV4) in batadv_mcast_mla_softif_get_ipv4()
358 for (pmc = rcu_dereference(in_dev->mc_list); pmc; in batadv_mcast_mla_softif_get_ipv4()
359 pmc = rcu_dereference(pmc->next_rcu)) { in batadv_mcast_mla_softif_get_ipv4()
360 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES && in batadv_mcast_mla_softif_get_ipv4()
361 ipv4_is_local_multicast(pmc->multiaddr)) in batadv_mcast_mla_softif_get_ipv4()
364 if (!(flags->tvlv_flags & BATADV_MCAST_WANT_NO_RTR4) && in batadv_mcast_mla_softif_get_ipv4()
365 !ipv4_is_local_multicast(pmc->multiaddr)) in batadv_mcast_mla_softif_get_ipv4()
368 ip_eth_mc_map(pmc->multiaddr, mcast_addr); in batadv_mcast_mla_softif_get_ipv4()
375 ret = -ENOMEM; in batadv_mcast_mla_softif_get_ipv4()
379 ether_addr_copy(new->addr, mcast_addr); in batadv_mcast_mla_softif_get_ipv4()
380 hlist_add_head(&new->list, mcast_list); in batadv_mcast_mla_softif_get_ipv4()
389 * batadv_mcast_mla_softif_get_ipv6() - get softif IPv6 multicast listeners
395 * on this kernel on the given soft interface, dev, in
397 * your multicast receiving applications run directly on this node.
399 * Return: -ENOMEM on memory allocation error or the number of
414 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV6) in batadv_mcast_mla_softif_get_ipv6()
425 for (pmc6 = rcu_dereference(in6_dev->mc_list); in batadv_mcast_mla_softif_get_ipv6()
427 pmc6 = rcu_dereference(pmc6->next)) { in batadv_mcast_mla_softif_get_ipv6()
428 if (IPV6_ADDR_MC_SCOPE(&pmc6->mca_addr) < in batadv_mcast_mla_softif_get_ipv6()
432 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES && in batadv_mcast_mla_softif_get_ipv6()
433 ipv6_addr_is_ll_all_nodes(&pmc6->mca_addr)) in batadv_mcast_mla_softif_get_ipv6()
436 if (!(flags->tvlv_flags & BATADV_MCAST_WANT_NO_RTR6) && in batadv_mcast_mla_softif_get_ipv6()
437 IPV6_ADDR_MC_SCOPE(&pmc6->mca_addr) > in batadv_mcast_mla_softif_get_ipv6()
441 ipv6_eth_mc_map(&pmc6->mca_addr, mcast_addr); in batadv_mcast_mla_softif_get_ipv6()
448 ret = -ENOMEM; in batadv_mcast_mla_softif_get_ipv6()
452 ether_addr_copy(new->addr, mcast_addr); in batadv_mcast_mla_softif_get_ipv6()
453 hlist_add_head(&new->list, mcast_list); in batadv_mcast_mla_softif_get_ipv6()
471 * batadv_mcast_mla_softif_get() - get softif multicast listeners
477 * on this kernel on the given soft interface, dev, in
479 * your multicast receiving applications run directly on this node.
481 * If there is a bridge interface on top of dev, collect from that one
483 * will(/should) register to the bridge interface instead of an
486 * Return: -ENOMEM on memory allocation error or the number of
517 * batadv_mcast_mla_br_addr_cpy() - copy a bridge multicast address
518 * @dst: destination to write to - a multicast MAC address
519 * @src: source to read from - a multicast IP address
530 if (src->proto == htons(ETH_P_IP)) in batadv_mcast_mla_br_addr_cpy()
531 ip_eth_mc_map(src->dst.ip4, dst); in batadv_mcast_mla_br_addr_cpy()
533 else if (src->proto == htons(ETH_P_IPV6)) in batadv_mcast_mla_br_addr_cpy()
534 ipv6_eth_mc_map(&src->dst.ip6, dst); in batadv_mcast_mla_br_addr_cpy()
541 * batadv_mcast_mla_bridge_get() - get bridged-in multicast listeners
547 * on foreign, non-mesh devices which we gave access to our mesh via
548 * a bridge on top of the given soft interface, dev, in the given
551 * Return: -ENOMEM on memory allocation error or the number of
560 u8 tvlv_flags = flags->tvlv_flags; in batadv_mcast_mla_bridge_get()
573 if (br_ip_entry->addr.proto == htons(ETH_P_IP)) { in batadv_mcast_mla_bridge_get()
578 ipv4_is_local_multicast(br_ip_entry->addr.dst.ip4)) in batadv_mcast_mla_bridge_get()
582 !ipv4_is_local_multicast(br_ip_entry->addr.dst.ip4)) in batadv_mcast_mla_bridge_get()
587 if (br_ip_entry->addr.proto == htons(ETH_P_IPV6)) { in batadv_mcast_mla_bridge_get()
592 ipv6_addr_is_ll_all_nodes(&br_ip_entry->addr.dst.ip6)) in batadv_mcast_mla_bridge_get()
596 IPV6_ADDR_MC_SCOPE(&br_ip_entry->addr.dst.ip6) > in batadv_mcast_mla_bridge_get()
602 batadv_mcast_mla_br_addr_cpy(mcast_addr, &br_ip_entry->addr); in batadv_mcast_mla_bridge_get()
608 ret = -ENOMEM; in batadv_mcast_mla_bridge_get()
612 ether_addr_copy(new->addr, mcast_addr); in batadv_mcast_mla_bridge_get()
613 hlist_add_head(&new->list, mcast_list); in batadv_mcast_mla_bridge_get()
618 list_del(&br_ip_entry->list); in batadv_mcast_mla_bridge_get()
626 * batadv_mcast_mla_list_free() - free a list of multicast addresses
637 hlist_del(&mcast_entry->list); in batadv_mcast_mla_list_free()
643 * batadv_mcast_mla_tt_retract() - clean up multicast listener announcements
644 * @bat_priv: the bat priv with all the soft interface information
658 hlist_for_each_entry_safe(mcast_entry, tmp, &bat_priv->mcast.mla_list, in batadv_mcast_mla_tt_retract()
661 batadv_mcast_mla_is_duplicate(mcast_entry->addr, in batadv_mcast_mla_tt_retract()
665 batadv_tt_local_remove(bat_priv, mcast_entry->addr, in batadv_mcast_mla_tt_retract()
669 hlist_del(&mcast_entry->list); in batadv_mcast_mla_tt_retract()
675 * batadv_mcast_mla_tt_add() - add multicast listener announcements
676 * @bat_priv: the bat priv with all the soft interface information
692 if (batadv_mcast_mla_is_duplicate(mcast_entry->addr, in batadv_mcast_mla_tt_add()
693 &bat_priv->mcast.mla_list)) in batadv_mcast_mla_tt_add()
696 if (!batadv_tt_local_add(bat_priv->soft_iface, in batadv_mcast_mla_tt_add()
697 mcast_entry->addr, BATADV_NO_FLAGS, in batadv_mcast_mla_tt_add()
701 hlist_del(&mcast_entry->list); in batadv_mcast_mla_tt_add()
702 hlist_add_head(&mcast_entry->list, &bat_priv->mcast.mla_list); in batadv_mcast_mla_tt_add()
707 * batadv_mcast_querier_log() - debug output regarding the querier status on
709 * @bat_priv: the bat priv with all the soft interface information
721 * forward listener reports to the querier, therefore batman-adv and
722 * the bridge will potentially not see these listeners - the querier is
726 * soft interface.
733 if (!old_state->exists && new_state->exists) in batadv_mcast_querier_log()
734 batadv_info(bat_priv->soft_iface, "%s Querier appeared\n", in batadv_mcast_querier_log()
736 else if (old_state->exists && !new_state->exists) in batadv_mcast_querier_log()
737 batadv_info(bat_priv->soft_iface, in batadv_mcast_querier_log()
738 "%s Querier disappeared - multicast optimizations disabled\n", in batadv_mcast_querier_log()
740 else if (!bat_priv->mcast.mla_flags.bridged && !new_state->exists) in batadv_mcast_querier_log()
741 batadv_info(bat_priv->soft_iface, in batadv_mcast_querier_log()
742 "No %s Querier present - multicast optimizations disabled\n", in batadv_mcast_querier_log()
745 if (new_state->exists) { in batadv_mcast_querier_log()
746 if ((!old_state->shadowing && new_state->shadowing) || in batadv_mcast_querier_log()
747 (!old_state->exists && new_state->shadowing)) in batadv_mcast_querier_log()
751 else if (old_state->shadowing && !new_state->shadowing) in batadv_mcast_querier_log()
759 * batadv_mcast_bridge_log() - debug output for topology changes in bridged
761 * @bat_priv: the bat priv with all the soft interface information
764 * If no bridges are ever used on this node, then this function does nothing.
769 * More precisely, it outputs information when a bridge interface is added or
770 * removed from a soft interface. And when a bridge is present, it further
772 * multicast flags this node is going to set.
778 struct batadv_mcast_mla_flags *old_flags = &bat_priv->mcast.mla_flags; in batadv_mcast_bridge_log()
780 if (!old_flags->bridged && new_flags->bridged) in batadv_mcast_bridge_log()
782 "Bridge added: Setting Unsnoopables(U)-flag\n"); in batadv_mcast_bridge_log()
783 else if (old_flags->bridged && !new_flags->bridged) in batadv_mcast_bridge_log()
785 "Bridge removed: Unsetting Unsnoopables(U)-flag\n"); in batadv_mcast_bridge_log()
787 if (new_flags->bridged) { in batadv_mcast_bridge_log()
789 &old_flags->querier_ipv4, in batadv_mcast_bridge_log()
790 &new_flags->querier_ipv4); in batadv_mcast_bridge_log()
792 &old_flags->querier_ipv6, in batadv_mcast_bridge_log()
793 &new_flags->querier_ipv6); in batadv_mcast_bridge_log()
798 * batadv_mcast_flags_log() - output debug information about mcast flag changes
799 * @bat_priv: the bat priv with all the soft interface information
802 * Whenever the multicast TVLV flags this node announces change, this function
807 bool old_enabled = bat_priv->mcast.mla_flags.enabled; in batadv_mcast_flags_log()
808 u8 old_flags = bat_priv->mcast.mla_flags.tvlv_flags; in batadv_mcast_flags_log()
829 * batadv_mcast_mla_flags_update() - update multicast flags
830 * @bat_priv: the bat priv with all the soft interface information
842 if (!memcmp(flags, &bat_priv->mcast.mla_flags, sizeof(*flags))) in batadv_mcast_mla_flags_update()
846 batadv_mcast_flags_log(bat_priv, flags->tvlv_flags); in batadv_mcast_mla_flags_update()
848 mcast_data.flags = flags->tvlv_flags; in batadv_mcast_mla_flags_update()
854 bat_priv->mcast.mla_flags = *flags; in batadv_mcast_mla_flags_update()
858 * __batadv_mcast_mla_update() - update the own MLAs
859 * @bat_priv: the bat priv with all the soft interface information
864 * Note that non-conflicting reads and writes to bat_priv->mcast.mla_list
866 * ensured by the non-parallel execution of the worker this function
871 struct net_device *soft_iface = bat_priv->soft_iface; in __batadv_mcast_mla_update()
886 spin_lock(&bat_priv->mcast.mla_lock); in __batadv_mcast_mla_update()
890 spin_unlock(&bat_priv->mcast.mla_lock); in __batadv_mcast_mla_update()
897 * batadv_mcast_mla_update() - update the own MLAs
920 * batadv_mcast_is_report_ipv4() - check for IGMP reports
934 switch (igmp_hdr(skb)->type) { in batadv_mcast_is_report_ipv4()
945 * batadv_mcast_forw_mode_check_ipv4() - check for optimized forwarding
947 * @bat_priv: the bat priv with all the soft interface information
955 * Return: If so then 0. Otherwise -EINVAL or -ENOMEM in case of memory
965 /* We might fail due to out-of-memory -> drop it */ in batadv_mcast_forw_mode_check_ipv4()
967 return -ENOMEM; in batadv_mcast_forw_mode_check_ipv4()
970 return -EINVAL; in batadv_mcast_forw_mode_check_ipv4()
974 /* link-local multicast listeners behind a bridge are in batadv_mcast_forw_mode_check_ipv4()
977 if (ipv4_is_local_multicast(iphdr->daddr)) in batadv_mcast_forw_mode_check_ipv4()
986 * batadv_mcast_is_report_ipv6() - check for MLD reports
1000 switch (icmp6_hdr(skb)->icmp6_type) { in batadv_mcast_is_report_ipv6()
1010 * batadv_mcast_forw_mode_check_ipv6() - check for optimized forwarding
1012 * @bat_priv: the bat priv with all the soft interface information
1020 * Return: If so then 0. Otherwise -EINVAL is or -ENOMEM if we are out of memory
1029 /* We might fail due to out-of-memory -> drop it */ in batadv_mcast_forw_mode_check_ipv6()
1031 return -ENOMEM; in batadv_mcast_forw_mode_check_ipv6()
1034 return -EINVAL; in batadv_mcast_forw_mode_check_ipv6()
1038 if (IPV6_ADDR_MC_SCOPE(&ip6hdr->daddr) < IPV6_ADDR_SCOPE_LINKLOCAL) in batadv_mcast_forw_mode_check_ipv6()
1039 return -EINVAL; in batadv_mcast_forw_mode_check_ipv6()
1041 /* link-local-all-nodes multicast listeners behind a bridge are in batadv_mcast_forw_mode_check_ipv6()
1044 if (ipv6_addr_is_ll_all_nodes(&ip6hdr->daddr)) in batadv_mcast_forw_mode_check_ipv6()
1046 else if (IPV6_ADDR_MC_SCOPE(&ip6hdr->daddr) > IPV6_ADDR_SCOPE_LINKLOCAL) in batadv_mcast_forw_mode_check_ipv6()
1053 * batadv_mcast_forw_mode_check() - check for optimized forwarding potential
1054 * @bat_priv: the bat priv with all the soft interface information
1062 * Return: If so then 0. Otherwise -EINVAL is or -ENOMEM if we are out of memory
1071 if (!atomic_read(&bat_priv->multicast_mode)) in batadv_mcast_forw_mode_check()
1072 return -EINVAL; in batadv_mcast_forw_mode_check()
1074 switch (ntohs(ethhdr->h_proto)) { in batadv_mcast_forw_mode_check()
1081 return -EINVAL; in batadv_mcast_forw_mode_check()
1087 return -EINVAL; in batadv_mcast_forw_mode_check()
1092 * batadv_mcast_forw_want_all_ip_count() - count nodes with unspecific mcast
1094 * @bat_priv: the bat priv with all the soft interface information
1104 switch (ntohs(ethhdr->h_proto)) { in batadv_mcast_forw_want_all_ip_count()
1106 return atomic_read(&bat_priv->mcast.num_want_all_ipv4); in batadv_mcast_forw_want_all_ip_count()
1108 return atomic_read(&bat_priv->mcast.num_want_all_ipv6); in batadv_mcast_forw_want_all_ip_count()
1116 * batadv_mcast_forw_rtr_count() - count nodes with a multicast router
1117 * @bat_priv: the bat priv with all the soft interface information
1130 return atomic_read(&bat_priv->mcast.num_want_all_rtr4); in batadv_mcast_forw_rtr_count()
1132 return atomic_read(&bat_priv->mcast.num_want_all_rtr6); in batadv_mcast_forw_rtr_count()
1139 * batadv_mcast_forw_mode() - check on how to forward a multicast packet
1140 * @bat_priv: the bat priv with all the soft interface information
1157 if (ret == -ENOMEM) in batadv_mcast_forw_mode()
1164 tt_count = batadv_tt_global_hash_count(bat_priv, ethhdr->h_dest, in batadv_mcast_forw_mode()
1168 atomic_read(&bat_priv->mcast.num_want_all_unsnoopables); in batadv_mcast_forw_mode()
1178 if (total_count <= atomic_read(&bat_priv->multicast_fanout)) in batadv_mcast_forw_mode()
1185 * batadv_mcast_forw_send_orig() - send a multicast packet to an originator
1186 * @bat_priv: the bat priv with all the soft interface information
1198 /* Avoid sending multicast-in-unicast packets to other BLA in batadv_mcast_forw_send_orig()
1199 * gateways - they already got the frame from the LAN side in batadv_mcast_forw_send_orig()
1204 if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig, vid)) { in batadv_mcast_forw_send_orig()
1214 * batadv_mcast_forw_tt() - forwards a packet to multicast listeners
1215 * @bat_priv: the bat priv with all the soft interface information
1221 * via a batman-adv unicast packet for each such destination node.
1236 const u8 *addr = eth_hdr(skb)->h_dest; in batadv_mcast_forw_tt()
1243 hlist_for_each_entry_rcu(orig_entry, &tt_global->orig_list, list) { in batadv_mcast_forw_tt()
1251 orig_entry->orig_node); in batadv_mcast_forw_tt()
1262 * batadv_mcast_forw_want_all_ipv4() - forward to nodes with want-all-ipv4
1263 * @bat_priv: the bat priv with all the soft interface information
1267 * Sends copies of a frame with multicast destination to any node with a
1269 * batman-adv unicast packet for each such destination node.
1284 &bat_priv->mcast.want_all_ipv4_list, in batadv_mcast_forw_want_all_ipv4()
1299 * batadv_mcast_forw_want_all_ipv6() - forward to nodes with want-all-ipv6
1300 * @bat_priv: the bat priv with all the soft interface information
1304 * Sends copies of a frame with multicast destination to any node with a
1306 * batman-adv unicast packet for each such destination node.
1321 &bat_priv->mcast.want_all_ipv6_list, in batadv_mcast_forw_want_all_ipv6()
1336 * batadv_mcast_forw_want_all() - forward packet to nodes in a want-all list
1337 * @bat_priv: the bat priv with all the soft interface information
1341 * Sends copies of a frame with multicast destination to any node with a
1343 * transmission is performed via a batman-adv unicast packet for each such
1344 * destination node.
1353 switch (ntohs(eth_hdr(skb)->h_proto)) { in batadv_mcast_forw_want_all()
1365 * batadv_mcast_forw_want_all_rtr4() - forward to nodes with want-all-rtr4
1366 * @bat_priv: the bat priv with all the soft interface information
1370 * Sends copies of a frame with multicast destination to any node with a
1372 * batman-adv unicast packet for each such destination node.
1387 &bat_priv->mcast.want_all_rtr4_list, in batadv_mcast_forw_want_all_rtr4()
1402 * batadv_mcast_forw_want_all_rtr6() - forward to nodes with want-all-rtr6
1403 * @bat_priv: the bat priv with all the soft interface information
1407 * Sends copies of a frame with multicast destination to any node with a
1409 * batman-adv unicast packet for each such destination node.
1424 &bat_priv->mcast.want_all_rtr6_list, in batadv_mcast_forw_want_all_rtr6()
1439 * batadv_mcast_forw_want_rtr() - forward packet to nodes in a want-all-rtr list
1440 * @bat_priv: the bat priv with all the soft interface information
1444 * Sends copies of a frame with multicast destination to any node with a
1446 * transmission is performed via a batman-adv unicast packet for each such
1447 * destination node.
1456 switch (ntohs(eth_hdr(skb)->h_proto)) { in batadv_mcast_forw_want_rtr()
1468 * batadv_mcast_forw_send() - send packet to any detected multicast recipient
1469 * @bat_priv: the bat priv with all the soft interface information
1474 * Sends copies of a frame with multicast destination to any node that signaled
1476 * want-all flags. A transmission is performed via a batman-adv unicast packet
1477 * for each such destination node.
1516 * batadv_mcast_want_unsnoop_update() - update unsnoop counter and list
1517 * @bat_priv: the bat priv with all the soft interface information
1525 * Caller needs to hold orig->mcast_handler_lock.
1531 struct hlist_node *node = &orig->mcast_want_all_unsnoopables_node; in batadv_mcast_want_unsnoop_update() local
1532 struct hlist_head *head = &bat_priv->mcast.want_all_unsnoopables_list; in batadv_mcast_want_unsnoop_update()
1534 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_unsnoop_update()
1538 !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES)) { in batadv_mcast_want_unsnoop_update()
1539 atomic_inc(&bat_priv->mcast.num_want_all_unsnoopables); in batadv_mcast_want_unsnoop_update()
1541 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1543 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_unsnoop_update()
1545 hlist_add_head_rcu(node, head); in batadv_mcast_want_unsnoop_update()
1546 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1549 orig->mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES) { in batadv_mcast_want_unsnoop_update()
1550 atomic_dec(&bat_priv->mcast.num_want_all_unsnoopables); in batadv_mcast_want_unsnoop_update()
1552 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1554 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_unsnoop_update()
1556 hlist_del_init_rcu(node); in batadv_mcast_want_unsnoop_update()
1557 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1562 * batadv_mcast_want_ipv4_update() - update want-all-ipv4 counter and list
1563 * @bat_priv: the bat priv with all the soft interface information
1570 * Caller needs to hold orig->mcast_handler_lock.
1576 struct hlist_node *node = &orig->mcast_want_all_ipv4_node; in batadv_mcast_want_ipv4_update() local
1577 struct hlist_head *head = &bat_priv->mcast.want_all_ipv4_list; in batadv_mcast_want_ipv4_update()
1579 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_ipv4_update()
1583 !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV4)) { in batadv_mcast_want_ipv4_update()
1584 atomic_inc(&bat_priv->mcast.num_want_all_ipv4); in batadv_mcast_want_ipv4_update()
1586 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1588 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_ipv4_update()
1590 hlist_add_head_rcu(node, head); in batadv_mcast_want_ipv4_update()
1591 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1594 orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV4) { in batadv_mcast_want_ipv4_update()
1595 atomic_dec(&bat_priv->mcast.num_want_all_ipv4); in batadv_mcast_want_ipv4_update()
1597 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1599 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_ipv4_update()
1601 hlist_del_init_rcu(node); in batadv_mcast_want_ipv4_update()
1602 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1607 * batadv_mcast_want_ipv6_update() - update want-all-ipv6 counter and list
1608 * @bat_priv: the bat priv with all the soft interface information
1615 * Caller needs to hold orig->mcast_handler_lock.
1621 struct hlist_node *node = &orig->mcast_want_all_ipv6_node; in batadv_mcast_want_ipv6_update() local
1622 struct hlist_head *head = &bat_priv->mcast.want_all_ipv6_list; in batadv_mcast_want_ipv6_update()
1624 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_ipv6_update()
1628 !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV6)) { in batadv_mcast_want_ipv6_update()
1629 atomic_inc(&bat_priv->mcast.num_want_all_ipv6); in batadv_mcast_want_ipv6_update()
1631 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1633 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_ipv6_update()
1635 hlist_add_head_rcu(node, head); in batadv_mcast_want_ipv6_update()
1636 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1639 orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV6) { in batadv_mcast_want_ipv6_update()
1640 atomic_dec(&bat_priv->mcast.num_want_all_ipv6); in batadv_mcast_want_ipv6_update()
1642 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1644 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_ipv6_update()
1646 hlist_del_init_rcu(node); in batadv_mcast_want_ipv6_update()
1647 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1652 * batadv_mcast_want_rtr4_update() - update want-all-rtr4 counter and list
1653 * @bat_priv: the bat priv with all the soft interface information
1660 * Caller needs to hold orig->mcast_handler_lock.
1666 struct hlist_node *node = &orig->mcast_want_all_rtr4_node; in batadv_mcast_want_rtr4_update() local
1667 struct hlist_head *head = &bat_priv->mcast.want_all_rtr4_list; in batadv_mcast_want_rtr4_update()
1669 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_rtr4_update()
1673 orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR4) { in batadv_mcast_want_rtr4_update()
1674 atomic_inc(&bat_priv->mcast.num_want_all_rtr4); in batadv_mcast_want_rtr4_update()
1676 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1678 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_rtr4_update()
1680 hlist_add_head_rcu(node, head); in batadv_mcast_want_rtr4_update()
1681 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1684 !(orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR4)) { in batadv_mcast_want_rtr4_update()
1685 atomic_dec(&bat_priv->mcast.num_want_all_rtr4); in batadv_mcast_want_rtr4_update()
1687 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1689 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_rtr4_update()
1691 hlist_del_init_rcu(node); in batadv_mcast_want_rtr4_update()
1692 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1697 * batadv_mcast_want_rtr6_update() - update want-all-rtr6 counter and list
1698 * @bat_priv: the bat priv with all the soft interface information
1705 * Caller needs to hold orig->mcast_handler_lock.
1711 struct hlist_node *node = &orig->mcast_want_all_rtr6_node; in batadv_mcast_want_rtr6_update() local
1712 struct hlist_head *head = &bat_priv->mcast.want_all_rtr6_list; in batadv_mcast_want_rtr6_update()
1714 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_rtr6_update()
1718 orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR6) { in batadv_mcast_want_rtr6_update()
1719 atomic_inc(&bat_priv->mcast.num_want_all_rtr6); in batadv_mcast_want_rtr6_update()
1721 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1723 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_rtr6_update()
1725 hlist_add_head_rcu(node, head); in batadv_mcast_want_rtr6_update()
1726 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1729 !(orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR6)) { in batadv_mcast_want_rtr6_update()
1730 atomic_dec(&bat_priv->mcast.num_want_all_rtr6); in batadv_mcast_want_rtr6_update()
1732 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1734 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_rtr6_update()
1736 hlist_del_init_rcu(node); in batadv_mcast_want_rtr6_update()
1737 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1742 * batadv_mcast_tvlv_flags_get() - get multicast flags from an OGM TVLV
1773 * batadv_mcast_tvlv_ogm_handler() - process incoming multicast tvlv container
1774 * @bat_priv: the bat priv with all the soft interface information
1792 spin_lock_bh(&orig->mcast_handler_lock); in batadv_mcast_tvlv_ogm_handler()
1795 !test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities)) { in batadv_mcast_tvlv_ogm_handler()
1796 set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities); in batadv_mcast_tvlv_ogm_handler()
1798 test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities)) { in batadv_mcast_tvlv_ogm_handler()
1799 clear_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities); in batadv_mcast_tvlv_ogm_handler()
1802 set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capa_initialized); in batadv_mcast_tvlv_ogm_handler()
1810 orig->mcast_flags = mcast_flags; in batadv_mcast_tvlv_ogm_handler()
1811 spin_unlock_bh(&orig->mcast_handler_lock); in batadv_mcast_tvlv_ogm_handler()
1815 * batadv_mcast_init() - initialize the multicast optimizations structures
1816 * @bat_priv: the bat priv with all the soft interface information
1824 INIT_DELAYED_WORK(&bat_priv->mcast.work, batadv_mcast_mla_update); in batadv_mcast_init()
1829 * batadv_mcast_mesh_info_put() - put multicast info into a netlink message
1831 * @bat_priv: the bat priv with all the soft interface information
1838 u32 flags = bat_priv->mcast.mla_flags.tvlv_flags; in batadv_mcast_mesh_info_put()
1841 if (bat_priv->mcast.mla_flags.bridged) { in batadv_mcast_mesh_info_put()
1844 if (bat_priv->mcast.mla_flags.querier_ipv4.exists) in batadv_mcast_mesh_info_put()
1846 if (bat_priv->mcast.mla_flags.querier_ipv6.exists) in batadv_mcast_mesh_info_put()
1848 if (bat_priv->mcast.mla_flags.querier_ipv4.shadowing) in batadv_mcast_mesh_info_put()
1850 if (bat_priv->mcast.mla_flags.querier_ipv6.shadowing) in batadv_mcast_mesh_info_put()
1856 return -EMSGSIZE; in batadv_mcast_mesh_info_put()
1862 * batadv_mcast_flags_dump_entry() - dump one entry of the multicast flags table
1878 hdr = genlmsg_put(msg, portid, cb->nlh->nlmsg_seq, in batadv_mcast_flags_dump_entry()
1882 return -ENOBUFS; in batadv_mcast_flags_dump_entry()
1887 orig_node->orig)) { in batadv_mcast_flags_dump_entry()
1889 return -EMSGSIZE; in batadv_mcast_flags_dump_entry()
1893 &orig_node->capabilities)) { in batadv_mcast_flags_dump_entry()
1895 orig_node->mcast_flags)) { in batadv_mcast_flags_dump_entry()
1897 return -EMSGSIZE; in batadv_mcast_flags_dump_entry()
1906 * batadv_mcast_flags_dump_bucket() - dump one bucket of the multicast flags
1926 spin_lock_bh(&hash->list_locks[bucket]); in batadv_mcast_flags_dump_bucket()
1927 cb->seq = atomic_read(&hash->generation) << 1 | 1; in batadv_mcast_flags_dump_bucket()
1929 hlist_for_each_entry(orig_node, &hash->table[bucket], hash_entry) { in batadv_mcast_flags_dump_bucket()
1931 &orig_node->capa_initialized)) in batadv_mcast_flags_dump_bucket()
1938 spin_unlock_bh(&hash->list_locks[bucket]); in batadv_mcast_flags_dump_bucket()
1941 return -EMSGSIZE; in batadv_mcast_flags_dump_bucket()
1947 spin_unlock_bh(&hash->list_locks[bucket]); in batadv_mcast_flags_dump_bucket()
1953 * __batadv_mcast_flags_dump() - dump multicast flags table to a netlink socket
1957 * @bat_priv: the bat priv with all the soft interface information
1968 struct batadv_hashtable *hash = bat_priv->orig_hash; in __batadv_mcast_flags_dump()
1972 while (bucket_tmp < hash->size) { in __batadv_mcast_flags_dump()
1984 return msg->len; in __batadv_mcast_flags_dump()
1988 * batadv_mcast_netlink_get_primary() - get primary interface from netlink
1991 * @primary_if: the primary interface pointer to return the result in
2000 struct net *net = sock_net(cb->skb->sk); in batadv_mcast_netlink_get_primary()
2006 ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); in batadv_mcast_netlink_get_primary()
2008 return -EINVAL; in batadv_mcast_netlink_get_primary()
2012 ret = -ENODEV; in batadv_mcast_netlink_get_primary()
2019 if (!hard_iface || hard_iface->if_status != BATADV_IF_ACTIVE) { in batadv_mcast_netlink_get_primary()
2020 ret = -ENOENT; in batadv_mcast_netlink_get_primary()
2036 * batadv_mcast_flags_dump() - dump multicast flags table to a netlink socket
2045 int portid = NETLINK_CB(cb->skb).portid; in batadv_mcast_flags_dump()
2047 long *bucket = &cb->args[0]; in batadv_mcast_flags_dump()
2048 long *idx = &cb->args[1]; in batadv_mcast_flags_dump()
2055 bat_priv = netdev_priv(primary_if->soft_iface); in batadv_mcast_flags_dump()
2063 * batadv_mcast_free() - free the multicast optimizations structures
2064 * @bat_priv: the bat priv with all the soft interface information
2068 cancel_delayed_work_sync(&bat_priv->mcast.work); in batadv_mcast_free()
2078 * batadv_mcast_purge_orig() - reset originator global mcast state modifications
2083 struct batadv_priv *bat_priv = orig->bat_priv; in batadv_mcast_purge_orig()
2085 spin_lock_bh(&orig->mcast_handler_lock); in batadv_mcast_purge_orig()
2095 spin_unlock_bh(&orig->mcast_handler_lock); in batadv_mcast_purge_orig()