• Home
  • Raw
  • Download

Lines Matching +full:interface +full:- +full:node

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2014-2020 B.A.T.M.A.N. contributors:
55 #include "hard-interface.h"
60 #include "soft-interface.h"
61 #include "translation-table.h"
67 * batadv_mcast_start_timer() - schedule the multicast periodic worker
68 * @bat_priv: the bat priv with all the soft interface information
72 queue_delayed_work(batadv_event_workqueue, &bat_priv->mcast.work, in batadv_mcast_start_timer()
77 * batadv_mcast_get_bridge() - get the bridge on top of the softif if it exists
78 * @soft_iface: netdev struct of the mesh interface
80 * If the given soft interface has a bridge on top then the refcount
93 } while (upper && !(upper->priv_flags & IFF_EBRIDGE)); in batadv_mcast_get_bridge()
103 * batadv_mcast_mla_rtr_flags_softif_get_ipv4() - get mcast router flags from
104 * node for IPv4
105 * @dev: the interface to check
107 * Checks the presence of an IPv4 multicast router on this node.
124 * batadv_mcast_mla_rtr_flags_softif_get_ipv6() - get mcast router flags from
125 * node for IPv6
126 * @dev: the interface to check
128 * Checks the presence of an IPv6 multicast router on this node.
139 if (in6_dev && atomic_read(&in6_dev->cnf.mc_forwarding)) in batadv_mcast_mla_rtr_flags_softif_get_ipv6()
153 * batadv_mcast_mla_rtr_flags_softif_get() - get mcast router flags from node
154 * @bat_priv: the bat priv with all the soft interface information
155 * @bridge: bridge interface on top of the soft_iface if present,
159 * node.
170 struct net_device *dev = bridge ? bridge : bat_priv->soft_iface; in batadv_mcast_mla_rtr_flags_softif_get()
184 * batadv_mcast_mla_rtr_flags_bridge_get() - get mcast router flags from bridge
185 * @bat_priv: the bat priv with all the soft interface information
186 * @bridge: bridge interface on top of the soft_iface if present,
202 struct net_device *dev = bat_priv->soft_iface; in batadv_mcast_mla_rtr_flags_bridge_get()
219 /* the bridge snooping does not maintain IPv4 link-local in batadv_mcast_mla_rtr_flags_bridge_get()
220 * addresses - therefore we won't find any IPv4 multicast router in batadv_mcast_mla_rtr_flags_bridge_get()
223 if (br_ip_entry->addr.proto == htons(ETH_P_IPV6) && in batadv_mcast_mla_rtr_flags_bridge_get()
224 ipv6_addr_is_ll_all_routers(&br_ip_entry->addr.dst.ip6)) in batadv_mcast_mla_rtr_flags_bridge_get()
227 list_del(&br_ip_entry->list); in batadv_mcast_mla_rtr_flags_bridge_get()
246 * batadv_mcast_mla_rtr_flags_get() - get multicast router flags
247 * @bat_priv: the bat priv with all the soft interface information
248 * @bridge: bridge interface on top of the soft_iface if present,
252 * node or behind its bridge.
272 * batadv_mcast_mla_flags_get() - get the new multicast flags
273 * @bat_priv: the bat priv with all the soft interface information
281 struct net_device *dev = bat_priv->soft_iface; in batadv_mcast_mla_flags_get()
303 pr_warn_once("No bridge IGMP snooping compiled - multicast optimizations disabled\n"); in batadv_mcast_mla_flags_get()
305 qr4->exists = br_multicast_has_querier_anywhere(dev, ETH_P_IP); in batadv_mcast_mla_flags_get()
306 qr4->shadowing = br_multicast_has_querier_adjacent(dev, ETH_P_IP); in batadv_mcast_mla_flags_get()
308 qr6->exists = br_multicast_has_querier_anywhere(dev, ETH_P_IPV6); in batadv_mcast_mla_flags_get()
309 qr6->shadowing = br_multicast_has_querier_adjacent(dev, ETH_P_IPV6); in batadv_mcast_mla_flags_get()
322 if (!qr4->exists || qr4->shadowing) { in batadv_mcast_mla_flags_get()
327 if (!qr6->exists || qr6->shadowing) { in batadv_mcast_mla_flags_get()
336 * batadv_mcast_mla_is_duplicate() - check whether an address is in a list
349 if (batadv_compare_eth(mcast_entry->addr, mcast_addr)) in batadv_mcast_mla_is_duplicate()
356 * batadv_mcast_mla_softif_get_ipv4() - get softif IPv4 multicast listeners
362 * on this kernel on the given soft interface, dev, in
364 * your multicast receiving applications run directly on this node.
366 * Return: -ENOMEM on memory allocation error or the number of
380 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV4) in batadv_mcast_mla_softif_get_ipv4()
391 for (pmc = rcu_dereference(in_dev->mc_list); pmc; in batadv_mcast_mla_softif_get_ipv4()
392 pmc = rcu_dereference(pmc->next_rcu)) { in batadv_mcast_mla_softif_get_ipv4()
393 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES && in batadv_mcast_mla_softif_get_ipv4()
394 ipv4_is_local_multicast(pmc->multiaddr)) in batadv_mcast_mla_softif_get_ipv4()
397 if (!(flags->tvlv_flags & BATADV_MCAST_WANT_NO_RTR4) && in batadv_mcast_mla_softif_get_ipv4()
398 !ipv4_is_local_multicast(pmc->multiaddr)) in batadv_mcast_mla_softif_get_ipv4()
401 ip_eth_mc_map(pmc->multiaddr, mcast_addr); in batadv_mcast_mla_softif_get_ipv4()
408 ret = -ENOMEM; in batadv_mcast_mla_softif_get_ipv4()
412 ether_addr_copy(new->addr, mcast_addr); in batadv_mcast_mla_softif_get_ipv4()
413 hlist_add_head(&new->list, mcast_list); in batadv_mcast_mla_softif_get_ipv4()
422 * batadv_mcast_mla_softif_get_ipv6() - get softif IPv6 multicast listeners
428 * on this kernel on the given soft interface, dev, in
430 * your multicast receiving applications run directly on this node.
432 * Return: -ENOMEM on memory allocation error or the number of
447 if (flags->tvlv_flags & BATADV_MCAST_WANT_ALL_IPV6) in batadv_mcast_mla_softif_get_ipv6()
458 read_lock_bh(&in6_dev->lock); in batadv_mcast_mla_softif_get_ipv6()
459 for (pmc6 = in6_dev->mc_list; pmc6; pmc6 = 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()
488 read_unlock_bh(&in6_dev->lock); in batadv_mcast_mla_softif_get_ipv6()
504 * batadv_mcast_mla_softif_get() - get softif multicast listeners
510 * on this kernel on the given soft interface, dev, in
512 * your multicast receiving applications run directly on this node.
514 * If there is a bridge interface on top of dev, collect from that one
516 * will(/should) register to the bridge interface instead of an
519 * Return: -ENOMEM on memory allocation error or the number of
551 * batadv_mcast_mla_br_addr_cpy() - copy a bridge multicast address
552 * @dst: destination to write to - a multicast MAC address
553 * @src: source to read from - a multicast IP address
564 if (src->proto == htons(ETH_P_IP)) in batadv_mcast_mla_br_addr_cpy()
565 ip_eth_mc_map(src->dst.ip4, dst); in batadv_mcast_mla_br_addr_cpy()
567 else if (src->proto == htons(ETH_P_IPV6)) in batadv_mcast_mla_br_addr_cpy()
568 ipv6_eth_mc_map(&src->dst.ip6, dst); in batadv_mcast_mla_br_addr_cpy()
575 * batadv_mcast_mla_bridge_get() - get bridged-in multicast listeners
581 * on foreign, non-mesh devices which we gave access to our mesh via
582 * a bridge on top of the given soft interface, dev, in the given
585 * Return: -ENOMEM on memory allocation error or the number of
594 u8 tvlv_flags = flags->tvlv_flags; in batadv_mcast_mla_bridge_get()
607 if (br_ip_entry->addr.proto == htons(ETH_P_IP)) { in batadv_mcast_mla_bridge_get()
612 ipv4_is_local_multicast(br_ip_entry->addr.dst.ip4)) in batadv_mcast_mla_bridge_get()
616 !ipv4_is_local_multicast(br_ip_entry->addr.dst.ip4)) in batadv_mcast_mla_bridge_get()
621 if (br_ip_entry->addr.proto == htons(ETH_P_IPV6)) { in batadv_mcast_mla_bridge_get()
626 ipv6_addr_is_ll_all_nodes(&br_ip_entry->addr.dst.ip6)) in batadv_mcast_mla_bridge_get()
630 IPV6_ADDR_MC_SCOPE(&br_ip_entry->addr.dst.ip6) > in batadv_mcast_mla_bridge_get()
636 batadv_mcast_mla_br_addr_cpy(mcast_addr, &br_ip_entry->addr); in batadv_mcast_mla_bridge_get()
642 ret = -ENOMEM; in batadv_mcast_mla_bridge_get()
646 ether_addr_copy(new->addr, mcast_addr); in batadv_mcast_mla_bridge_get()
647 hlist_add_head(&new->list, mcast_list); in batadv_mcast_mla_bridge_get()
652 list_del(&br_ip_entry->list); in batadv_mcast_mla_bridge_get()
660 * batadv_mcast_mla_list_free() - free a list of multicast addresses
671 hlist_del(&mcast_entry->list); in batadv_mcast_mla_list_free()
677 * batadv_mcast_mla_tt_retract() - clean up multicast listener announcements
678 * @bat_priv: the bat priv with all the soft interface information
692 hlist_for_each_entry_safe(mcast_entry, tmp, &bat_priv->mcast.mla_list, in batadv_mcast_mla_tt_retract()
695 batadv_mcast_mla_is_duplicate(mcast_entry->addr, in batadv_mcast_mla_tt_retract()
699 batadv_tt_local_remove(bat_priv, mcast_entry->addr, in batadv_mcast_mla_tt_retract()
703 hlist_del(&mcast_entry->list); in batadv_mcast_mla_tt_retract()
709 * batadv_mcast_mla_tt_add() - add multicast listener announcements
710 * @bat_priv: the bat priv with all the soft interface information
726 if (batadv_mcast_mla_is_duplicate(mcast_entry->addr, in batadv_mcast_mla_tt_add()
727 &bat_priv->mcast.mla_list)) in batadv_mcast_mla_tt_add()
730 if (!batadv_tt_local_add(bat_priv->soft_iface, in batadv_mcast_mla_tt_add()
731 mcast_entry->addr, BATADV_NO_FLAGS, in batadv_mcast_mla_tt_add()
735 hlist_del(&mcast_entry->list); in batadv_mcast_mla_tt_add()
736 hlist_add_head(&mcast_entry->list, &bat_priv->mcast.mla_list); in batadv_mcast_mla_tt_add()
741 * batadv_mcast_querier_log() - debug output regarding the querier status on
743 * @bat_priv: the bat priv with all the soft interface information
755 * forward listener reports to the querier, therefore batman-adv and
756 * the bridge will potentially not see these listeners - the querier is
760 * soft interface.
767 if (!old_state->exists && new_state->exists) in batadv_mcast_querier_log()
768 batadv_info(bat_priv->soft_iface, "%s Querier appeared\n", in batadv_mcast_querier_log()
770 else if (old_state->exists && !new_state->exists) in batadv_mcast_querier_log()
771 batadv_info(bat_priv->soft_iface, in batadv_mcast_querier_log()
772 "%s Querier disappeared - multicast optimizations disabled\n", in batadv_mcast_querier_log()
774 else if (!bat_priv->mcast.mla_flags.bridged && !new_state->exists) in batadv_mcast_querier_log()
775 batadv_info(bat_priv->soft_iface, in batadv_mcast_querier_log()
776 "No %s Querier present - multicast optimizations disabled\n", in batadv_mcast_querier_log()
779 if (new_state->exists) { in batadv_mcast_querier_log()
780 if ((!old_state->shadowing && new_state->shadowing) || in batadv_mcast_querier_log()
781 (!old_state->exists && new_state->shadowing)) in batadv_mcast_querier_log()
785 else if (old_state->shadowing && !new_state->shadowing) in batadv_mcast_querier_log()
793 * batadv_mcast_bridge_log() - debug output for topology changes in bridged
795 * @bat_priv: the bat priv with all the soft interface information
798 * If no bridges are ever used on this node, then this function does nothing.
803 * More precisely, it outputs information when a bridge interface is added or
804 * removed from a soft interface. And when a bridge is present, it further
806 * multicast flags this node is going to set.
812 struct batadv_mcast_mla_flags *old_flags = &bat_priv->mcast.mla_flags; in batadv_mcast_bridge_log()
814 if (!old_flags->bridged && new_flags->bridged) in batadv_mcast_bridge_log()
816 "Bridge added: Setting Unsnoopables(U)-flag\n"); in batadv_mcast_bridge_log()
817 else if (old_flags->bridged && !new_flags->bridged) in batadv_mcast_bridge_log()
819 "Bridge removed: Unsetting Unsnoopables(U)-flag\n"); in batadv_mcast_bridge_log()
821 if (new_flags->bridged) { in batadv_mcast_bridge_log()
823 &old_flags->querier_ipv4, in batadv_mcast_bridge_log()
824 &new_flags->querier_ipv4); in batadv_mcast_bridge_log()
826 &old_flags->querier_ipv6, in batadv_mcast_bridge_log()
827 &new_flags->querier_ipv6); in batadv_mcast_bridge_log()
832 * batadv_mcast_flags_logs() - output debug information about mcast flag changes
833 * @bat_priv: the bat priv with all the soft interface information
836 * Whenever the multicast TVLV flags this node announces change, this function
841 bool old_enabled = bat_priv->mcast.mla_flags.enabled; in batadv_mcast_flags_log()
842 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_tt_node_get() - get a multicast tt node
1174 * @bat_priv: the bat priv with all the soft interface information
1184 return batadv_transtable_search(bat_priv, NULL, ethhdr->h_dest, in batadv_mcast_forw_tt_node_get()
1189 * batadv_mcast_forw_ipv4_node_get() - get a node with an ipv4 flag
1190 * @bat_priv: the bat priv with all the soft interface information
1202 &bat_priv->mcast.want_all_ipv4_list, in batadv_mcast_forw_ipv4_node_get()
1204 if (!kref_get_unless_zero(&tmp_orig_node->refcount)) in batadv_mcast_forw_ipv4_node_get()
1216 * batadv_mcast_forw_ipv6_node_get() - get a node with an ipv6 flag
1217 * @bat_priv: the bat priv with all the soft interface information
1229 &bat_priv->mcast.want_all_ipv6_list, in batadv_mcast_forw_ipv6_node_get()
1231 if (!kref_get_unless_zero(&tmp_orig_node->refcount)) in batadv_mcast_forw_ipv6_node_get()
1243 * batadv_mcast_forw_ip_node_get() - get a node with an ipv4/ipv6 flag
1244 * @bat_priv: the bat priv with all the soft interface information
1255 switch (ntohs(ethhdr->h_proto)) { in batadv_mcast_forw_ip_node_get()
1267 * batadv_mcast_forw_unsnoop_node_get() - get a node with an unsnoopable flag
1268 * @bat_priv: the bat priv with all the soft interface information
1280 &bat_priv->mcast.want_all_unsnoopables_list, in batadv_mcast_forw_unsnoop_node_get()
1282 if (!kref_get_unless_zero(&tmp_orig_node->refcount)) in batadv_mcast_forw_unsnoop_node_get()
1294 * batadv_mcast_forw_rtr4_node_get() - get a node with an ipv4 mcast router flag
1295 * @bat_priv: the bat priv with all the soft interface information
1307 &bat_priv->mcast.want_all_rtr4_list, in batadv_mcast_forw_rtr4_node_get()
1309 if (!kref_get_unless_zero(&tmp_orig_node->refcount)) in batadv_mcast_forw_rtr4_node_get()
1321 * batadv_mcast_forw_rtr6_node_get() - get a node with an ipv6 mcast router flag
1322 * @bat_priv: the bat priv with all the soft interface information
1334 &bat_priv->mcast.want_all_rtr6_list, in batadv_mcast_forw_rtr6_node_get()
1336 if (!kref_get_unless_zero(&tmp_orig_node->refcount)) in batadv_mcast_forw_rtr6_node_get()
1348 * batadv_mcast_forw_rtr_node_get() - get a node with an ipv4/ipv6 router flag
1349 * @bat_priv: the bat priv with all the soft interface information
1360 switch (ntohs(ethhdr->h_proto)) { in batadv_mcast_forw_rtr_node_get()
1372 * batadv_mcast_forw_mode() - check on how to forward a multicast packet
1373 * @bat_priv: the bat priv with all the soft interface information
1394 if (ret == -ENOMEM) in batadv_mcast_forw_mode()
1401 tt_count = batadv_tt_global_hash_count(bat_priv, ethhdr->h_dest, in batadv_mcast_forw_mode()
1405 atomic_read(&bat_priv->mcast.num_want_all_unsnoopables); in batadv_mcast_forw_mode()
1429 mcast_fanout = atomic_read(&bat_priv->multicast_fanout); in batadv_mcast_forw_mode()
1439 * batadv_mcast_forw_send_orig() - send a multicast packet to an originator
1440 * @bat_priv: the bat priv with all the soft interface information
1452 /* Avoid sending multicast-in-unicast packets to other BLA in batadv_mcast_forw_send_orig()
1453 * gateways - they already got the frame from the LAN side in batadv_mcast_forw_send_orig()
1458 if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig, vid)) { in batadv_mcast_forw_send_orig()
1468 * batadv_mcast_forw_tt() - forwards a packet to multicast listeners
1469 * @bat_priv: the bat priv with all the soft interface information
1475 * via a batman-adv unicast packet for each such destination node.
1490 const u8 *addr = eth_hdr(skb)->h_dest; in batadv_mcast_forw_tt()
1497 hlist_for_each_entry_rcu(orig_entry, &tt_global->orig_list, list) { in batadv_mcast_forw_tt()
1505 orig_entry->orig_node); in batadv_mcast_forw_tt()
1516 * batadv_mcast_forw_want_all_ipv4() - forward to nodes with want-all-ipv4
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 * batman-adv unicast packet for each such destination node.
1538 &bat_priv->mcast.want_all_ipv4_list, in batadv_mcast_forw_want_all_ipv4()
1553 * batadv_mcast_forw_want_all_ipv6() - forward to nodes with want-all-ipv6
1554 * @bat_priv: the bat priv with all the soft interface information
1558 * Sends copies of a frame with multicast destination to any node with a
1560 * batman-adv unicast packet for each such destination node.
1575 &bat_priv->mcast.want_all_ipv6_list, in batadv_mcast_forw_want_all_ipv6()
1590 * batadv_mcast_forw_want_all() - forward packet to nodes in a want-all list
1591 * @bat_priv: the bat priv with all the soft interface information
1595 * Sends copies of a frame with multicast destination to any node with a
1597 * transmission is performed via a batman-adv unicast packet for each such
1598 * destination node.
1607 switch (ntohs(eth_hdr(skb)->h_proto)) { in batadv_mcast_forw_want_all()
1619 * batadv_mcast_forw_want_all_rtr4() - forward to nodes with want-all-rtr4
1620 * @bat_priv: the bat priv with all the soft interface information
1624 * Sends copies of a frame with multicast destination to any node with a
1626 * batman-adv unicast packet for each such destination node.
1641 &bat_priv->mcast.want_all_rtr4_list, in batadv_mcast_forw_want_all_rtr4()
1656 * batadv_mcast_forw_want_all_rtr6() - forward to nodes with want-all-rtr6
1657 * @bat_priv: the bat priv with all the soft interface information
1661 * Sends copies of a frame with multicast destination to any node with a
1663 * batman-adv unicast packet for each such destination node.
1678 &bat_priv->mcast.want_all_rtr6_list, in batadv_mcast_forw_want_all_rtr6()
1693 * batadv_mcast_forw_want_rtr() - forward packet to nodes in a want-all-rtr list
1694 * @bat_priv: the bat priv with all the soft interface information
1698 * Sends copies of a frame with multicast destination to any node with a
1700 * transmission is performed via a batman-adv unicast packet for each such
1701 * destination node.
1710 switch (ntohs(eth_hdr(skb)->h_proto)) { in batadv_mcast_forw_want_rtr()
1722 * batadv_mcast_forw_send() - send packet to any detected multicast recipient
1723 * @bat_priv: the bat priv with all the soft interface information
1728 * Sends copies of a frame with multicast destination to any node that signaled
1730 * want-all flags. A transmission is performed via a batman-adv unicast packet
1731 * for each such destination node.
1770 * batadv_mcast_want_unsnoop_update() - update unsnoop counter and list
1771 * @bat_priv: the bat priv with all the soft interface information
1779 * Caller needs to hold orig->mcast_handler_lock.
1785 struct hlist_node *node = &orig->mcast_want_all_unsnoopables_node; in batadv_mcast_want_unsnoop_update() local
1786 struct hlist_head *head = &bat_priv->mcast.want_all_unsnoopables_list; in batadv_mcast_want_unsnoop_update()
1788 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_unsnoop_update()
1792 !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES)) { in batadv_mcast_want_unsnoop_update()
1793 atomic_inc(&bat_priv->mcast.num_want_all_unsnoopables); in batadv_mcast_want_unsnoop_update()
1795 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1797 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_unsnoop_update()
1799 hlist_add_head_rcu(node, head); in batadv_mcast_want_unsnoop_update()
1800 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1803 orig->mcast_flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES) { in batadv_mcast_want_unsnoop_update()
1804 atomic_dec(&bat_priv->mcast.num_want_all_unsnoopables); in batadv_mcast_want_unsnoop_update()
1806 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1808 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_unsnoop_update()
1810 hlist_del_init_rcu(node); in batadv_mcast_want_unsnoop_update()
1811 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_unsnoop_update()
1816 * batadv_mcast_want_ipv4_update() - update want-all-ipv4 counter and list
1817 * @bat_priv: the bat priv with all the soft interface information
1824 * Caller needs to hold orig->mcast_handler_lock.
1830 struct hlist_node *node = &orig->mcast_want_all_ipv4_node; in batadv_mcast_want_ipv4_update() local
1831 struct hlist_head *head = &bat_priv->mcast.want_all_ipv4_list; in batadv_mcast_want_ipv4_update()
1833 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_ipv4_update()
1837 !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV4)) { in batadv_mcast_want_ipv4_update()
1838 atomic_inc(&bat_priv->mcast.num_want_all_ipv4); in batadv_mcast_want_ipv4_update()
1840 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1842 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_ipv4_update()
1844 hlist_add_head_rcu(node, head); in batadv_mcast_want_ipv4_update()
1845 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1848 orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV4) { in batadv_mcast_want_ipv4_update()
1849 atomic_dec(&bat_priv->mcast.num_want_all_ipv4); in batadv_mcast_want_ipv4_update()
1851 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1853 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_ipv4_update()
1855 hlist_del_init_rcu(node); in batadv_mcast_want_ipv4_update()
1856 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv4_update()
1861 * batadv_mcast_want_ipv6_update() - update want-all-ipv6 counter and list
1862 * @bat_priv: the bat priv with all the soft interface information
1869 * Caller needs to hold orig->mcast_handler_lock.
1875 struct hlist_node *node = &orig->mcast_want_all_ipv6_node; in batadv_mcast_want_ipv6_update() local
1876 struct hlist_head *head = &bat_priv->mcast.want_all_ipv6_list; in batadv_mcast_want_ipv6_update()
1878 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_ipv6_update()
1882 !(orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV6)) { in batadv_mcast_want_ipv6_update()
1883 atomic_inc(&bat_priv->mcast.num_want_all_ipv6); in batadv_mcast_want_ipv6_update()
1885 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1887 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_ipv6_update()
1889 hlist_add_head_rcu(node, head); in batadv_mcast_want_ipv6_update()
1890 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1893 orig->mcast_flags & BATADV_MCAST_WANT_ALL_IPV6) { in batadv_mcast_want_ipv6_update()
1894 atomic_dec(&bat_priv->mcast.num_want_all_ipv6); in batadv_mcast_want_ipv6_update()
1896 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1898 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_ipv6_update()
1900 hlist_del_init_rcu(node); in batadv_mcast_want_ipv6_update()
1901 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_ipv6_update()
1906 * batadv_mcast_want_rtr4_update() - update want-all-rtr4 counter and list
1907 * @bat_priv: the bat priv with all the soft interface information
1914 * Caller needs to hold orig->mcast_handler_lock.
1920 struct hlist_node *node = &orig->mcast_want_all_rtr4_node; in batadv_mcast_want_rtr4_update() local
1921 struct hlist_head *head = &bat_priv->mcast.want_all_rtr4_list; in batadv_mcast_want_rtr4_update()
1923 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_rtr4_update()
1927 orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR4) { in batadv_mcast_want_rtr4_update()
1928 atomic_inc(&bat_priv->mcast.num_want_all_rtr4); in batadv_mcast_want_rtr4_update()
1930 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1932 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_rtr4_update()
1934 hlist_add_head_rcu(node, head); in batadv_mcast_want_rtr4_update()
1935 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1938 !(orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR4)) { in batadv_mcast_want_rtr4_update()
1939 atomic_dec(&bat_priv->mcast.num_want_all_rtr4); in batadv_mcast_want_rtr4_update()
1941 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1943 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_rtr4_update()
1945 hlist_del_init_rcu(node); in batadv_mcast_want_rtr4_update()
1946 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr4_update()
1951 * batadv_mcast_want_rtr6_update() - update want-all-rtr6 counter and list
1952 * @bat_priv: the bat priv with all the soft interface information
1959 * Caller needs to hold orig->mcast_handler_lock.
1965 struct hlist_node *node = &orig->mcast_want_all_rtr6_node; in batadv_mcast_want_rtr6_update() local
1966 struct hlist_head *head = &bat_priv->mcast.want_all_rtr6_list; in batadv_mcast_want_rtr6_update()
1968 lockdep_assert_held(&orig->mcast_handler_lock); in batadv_mcast_want_rtr6_update()
1972 orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR6) { in batadv_mcast_want_rtr6_update()
1973 atomic_inc(&bat_priv->mcast.num_want_all_rtr6); in batadv_mcast_want_rtr6_update()
1975 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1977 WARN_ON(!hlist_unhashed(node)); in batadv_mcast_want_rtr6_update()
1979 hlist_add_head_rcu(node, head); in batadv_mcast_want_rtr6_update()
1980 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1983 !(orig->mcast_flags & BATADV_MCAST_WANT_NO_RTR6)) { in batadv_mcast_want_rtr6_update()
1984 atomic_dec(&bat_priv->mcast.num_want_all_rtr6); in batadv_mcast_want_rtr6_update()
1986 spin_lock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1988 WARN_ON(hlist_unhashed(node)); in batadv_mcast_want_rtr6_update()
1990 hlist_del_init_rcu(node); in batadv_mcast_want_rtr6_update()
1991 spin_unlock_bh(&bat_priv->mcast.want_lists_lock); in batadv_mcast_want_rtr6_update()
1996 * batadv_mcast_tvlv_flags_get() - get multicast flags from an OGM TVLV
2027 * batadv_mcast_tvlv_ogm_handler() - process incoming multicast tvlv container
2028 * @bat_priv: the bat priv with all the soft interface information
2046 spin_lock_bh(&orig->mcast_handler_lock); in batadv_mcast_tvlv_ogm_handler()
2049 !test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities)) { in batadv_mcast_tvlv_ogm_handler()
2050 set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities); in batadv_mcast_tvlv_ogm_handler()
2052 test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities)) { in batadv_mcast_tvlv_ogm_handler()
2053 clear_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities); in batadv_mcast_tvlv_ogm_handler()
2056 set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capa_initialized); in batadv_mcast_tvlv_ogm_handler()
2064 orig->mcast_flags = mcast_flags; in batadv_mcast_tvlv_ogm_handler()
2065 spin_unlock_bh(&orig->mcast_handler_lock); in batadv_mcast_tvlv_ogm_handler()
2069 * batadv_mcast_init() - initialize the multicast optimizations structures
2070 * @bat_priv: the bat priv with all the soft interface information
2078 INIT_DELAYED_WORK(&bat_priv->mcast.work, batadv_mcast_mla_update); in batadv_mcast_init()
2084 * batadv_mcast_flags_print_header() - print own mcast flags to debugfs table
2085 * @bat_priv: the bat priv with all the soft interface information
2095 struct batadv_mcast_mla_flags *mla_flags = &bat_priv->mcast.mla_flags; in batadv_mcast_flags_print_header()
2097 bool bridged = mla_flags->bridged; in batadv_mcast_flags_print_header()
2098 u8 flags = mla_flags->tvlv_flags; in batadv_mcast_flags_print_header()
2101 querier4 = mla_flags->querier_ipv4.exists ? '.' : '4'; in batadv_mcast_flags_print_header()
2102 querier6 = mla_flags->querier_ipv6.exists ? '.' : '6'; in batadv_mcast_flags_print_header()
2103 shadowing4 = mla_flags->querier_ipv4.shadowing ? '4' : '.'; in batadv_mcast_flags_print_header()
2104 shadowing6 = mla_flags->querier_ipv6.shadowing ? '6' : '.'; in batadv_mcast_flags_print_header()
2123 seq_puts(seq, "-------------------------------------------\n"); in batadv_mcast_flags_print_header()
2124 seq_printf(seq, " %-10s %s\n", "Originator", "Flags"); in batadv_mcast_flags_print_header()
2128 * batadv_mcast_flags_seq_print_text() - print the mcast flags of other nodes
2139 struct net_device *net_dev = (struct net_device *)seq->private; in batadv_mcast_flags_seq_print_text()
2142 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_mcast_flags_seq_print_text()
2154 for (i = 0; i < hash->size; i++) { in batadv_mcast_flags_seq_print_text()
2155 head = &hash->table[i]; in batadv_mcast_flags_seq_print_text()
2160 &orig_node->capa_initialized)) in batadv_mcast_flags_seq_print_text()
2164 &orig_node->capabilities)) { in batadv_mcast_flags_seq_print_text()
2165 seq_printf(seq, "%pM -\n", orig_node->orig); in batadv_mcast_flags_seq_print_text()
2169 flags = orig_node->mcast_flags; in batadv_mcast_flags_seq_print_text()
2171 seq_printf(seq, "%pM [%c%c%c%s%s]\n", orig_node->orig, in batadv_mcast_flags_seq_print_text()
2193 * batadv_mcast_mesh_info_put() - put multicast info into a netlink message
2195 * @bat_priv: the bat priv with all the soft interface information
2202 u32 flags = bat_priv->mcast.mla_flags.tvlv_flags; in batadv_mcast_mesh_info_put()
2205 if (bat_priv->mcast.mla_flags.bridged) { in batadv_mcast_mesh_info_put()
2208 if (bat_priv->mcast.mla_flags.querier_ipv4.exists) in batadv_mcast_mesh_info_put()
2210 if (bat_priv->mcast.mla_flags.querier_ipv6.exists) in batadv_mcast_mesh_info_put()
2212 if (bat_priv->mcast.mla_flags.querier_ipv4.shadowing) in batadv_mcast_mesh_info_put()
2214 if (bat_priv->mcast.mla_flags.querier_ipv6.shadowing) in batadv_mcast_mesh_info_put()
2220 return -EMSGSIZE; in batadv_mcast_mesh_info_put()
2226 * batadv_mcast_flags_dump_entry() - dump one entry of the multicast flags table
2242 hdr = genlmsg_put(msg, portid, cb->nlh->nlmsg_seq, in batadv_mcast_flags_dump_entry()
2246 return -ENOBUFS; in batadv_mcast_flags_dump_entry()
2251 orig_node->orig)) { in batadv_mcast_flags_dump_entry()
2253 return -EMSGSIZE; in batadv_mcast_flags_dump_entry()
2257 &orig_node->capabilities)) { in batadv_mcast_flags_dump_entry()
2259 orig_node->mcast_flags)) { in batadv_mcast_flags_dump_entry()
2261 return -EMSGSIZE; in batadv_mcast_flags_dump_entry()
2270 * batadv_mcast_flags_dump_bucket() - dump one bucket of the multicast flags
2290 spin_lock_bh(&hash->list_locks[bucket]); in batadv_mcast_flags_dump_bucket()
2291 cb->seq = atomic_read(&hash->generation) << 1 | 1; in batadv_mcast_flags_dump_bucket()
2293 hlist_for_each_entry(orig_node, &hash->table[bucket], hash_entry) { in batadv_mcast_flags_dump_bucket()
2295 &orig_node->capa_initialized)) in batadv_mcast_flags_dump_bucket()
2302 spin_unlock_bh(&hash->list_locks[bucket]); in batadv_mcast_flags_dump_bucket()
2305 return -EMSGSIZE; in batadv_mcast_flags_dump_bucket()
2311 spin_unlock_bh(&hash->list_locks[bucket]); in batadv_mcast_flags_dump_bucket()
2317 * __batadv_mcast_flags_dump() - dump multicast flags table to a netlink socket
2321 * @bat_priv: the bat priv with all the soft interface information
2332 struct batadv_hashtable *hash = bat_priv->orig_hash; in __batadv_mcast_flags_dump()
2336 while (bucket_tmp < hash->size) { in __batadv_mcast_flags_dump()
2348 return msg->len; in __batadv_mcast_flags_dump()
2352 * batadv_mcast_netlink_get_primary() - get primary interface from netlink
2355 * @primary_if: the primary interface pointer to return the result in
2364 struct net *net = sock_net(cb->skb->sk); in batadv_mcast_netlink_get_primary()
2370 ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); in batadv_mcast_netlink_get_primary()
2372 return -EINVAL; in batadv_mcast_netlink_get_primary()
2376 ret = -ENODEV; in batadv_mcast_netlink_get_primary()
2383 if (!hard_iface || hard_iface->if_status != BATADV_IF_ACTIVE) { in batadv_mcast_netlink_get_primary()
2384 ret = -ENOENT; in batadv_mcast_netlink_get_primary()
2401 * batadv_mcast_flags_dump() - dump multicast flags table to a netlink socket
2410 int portid = NETLINK_CB(cb->skb).portid; in batadv_mcast_flags_dump()
2412 long *bucket = &cb->args[0]; in batadv_mcast_flags_dump()
2413 long *idx = &cb->args[1]; in batadv_mcast_flags_dump()
2420 bat_priv = netdev_priv(primary_if->soft_iface); in batadv_mcast_flags_dump()
2428 * batadv_mcast_free() - free the multicast optimizations structures
2429 * @bat_priv: the bat priv with all the soft interface information
2433 cancel_delayed_work_sync(&bat_priv->mcast.work); in batadv_mcast_free()
2443 * batadv_mcast_purge_orig() - reset originator global mcast state modifications
2448 struct batadv_priv *bat_priv = orig->bat_priv; in batadv_mcast_purge_orig()
2450 spin_lock_bh(&orig->mcast_handler_lock); in batadv_mcast_purge_orig()
2460 spin_unlock_bh(&orig->mcast_handler_lock); in batadv_mcast_purge_orig()