net/batman-adv/multicast_forw.c
Source file repositories/reference/linux-study-clean/net/batman-adv/multicast_forw.c
File Facts
- System
- Linux kernel
- Corpus path
net/batman-adv/multicast_forw.c- Extension
.c- Size
- 37035 bytes
- Lines
- 1179
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
multicast.hmain.hlinux/bug.hlinux/build_bug.hlinux/byteorder/generic.hlinux/compiler.hlinux/errno.hlinux/etherdevice.hlinux/gfp.hlinux/if_ether.hlinux/if_vlan.hlinux/ipv6.hlinux/limits.hlinux/netdevice.hlinux/rculist.hlinux/rcupdate.hlinux/skbuff.hlinux/stddef.hlinux/string.hlinux/types.huapi/linux/batadv_packet.hbridge_loop_avoidance.horiginator.hsend.htranslation-table.h
Detected Declarations
function batadv_mcast_forw_skb_pushfunction batadv_mcast_forw_push_paddingfunction batadv_mcast_forw_push_est_paddingfunction batadv_mcast_forw_orig_entryfunction batadv_mcast_forw_push_destfunction batadv_mcast_forw_push_dests_listfunction batadv_mcast_forw_push_ttfunction batadv_mcast_forw_push_want_allfunction batadv_mcast_forw_push_want_rtrfunction batadv_mcast_forw_scrapefunction batadv_mcast_forw_push_scrape_paddingfunction batadv_mcast_forw_push_insert_paddingfunction batadv_mcast_forw_push_adjust_paddingfunction batadv_mcast_forw_push_destsfunction batadv_mcast_forw_push_trackerfunction batadv_mcast_forw_push_tvlvsfunction batadv_mcast_forw_push_hdrfunction batadv_mcast_forw_scrub_destsfunction batadv_mcast_forw_tracker_for_each_dest2function batadv_mcast_forw_shrink_fillfunction batadv_mcast_forw_shrink_pack_destsfunction batadv_mcast_forw_tracker_for_each_destfunction batadv_mcast_forw_shrink_align_offsetfunction batadv_mcast_forw_shrink_update_headersfunction batadv_mcast_forw_shrink_move_headersfunction batadv_mcast_forw_shrink_trackerfunction batadv_mcast_forw_packetfunction batadv_mcast_forw_tracker_for_each_destfunction batadv_mcast_forw_tracker_tvlv_handlerfunction batadv_mcast_forw_packet_hdrlenfunction batadv_mcast_forw_expand_headfunction batadv_mcast_forw_pushfunction batadv_mcast_forw_mcsend
Annotated Snippet
if (is_multicast_ether_addr(next_dest)) {
eth_zero_addr(dest);
eth_zero_addr(next_dest);
continue;
}
next_neigh = batadv_orig_to_router(bat_priv, next_dest, NULL);
if (!next_neigh) {
eth_zero_addr(next_dest);
continue;
}
if (!batadv_compare_eth(next_neigh->addr, comp_neigh->addr)) {
eth_zero_addr(next_dest);
batadv_neigh_node_put(next_neigh);
continue;
}
/* found an entry for our next packet to transmit, so remove it
* from the original packet
*/
eth_zero_addr(dest);
batadv_neigh_node_put(next_neigh);
}
}
/**
* batadv_mcast_forw_shrink_fill() - swap slot with next non-zero destination
* @slot: the to be filled zero-MAC destination entry in a tracker TVLV
* @num_dests_slot: remaining entries in tracker TVLV from/including slot
*
* Searches for the next non-zero-MAC destination entry in a tracker TVLV after
* the given slot pointer. And if found, swaps it with the zero-MAC destination
* entry which the slot points to.
*
* Return: true if slot was swapped/filled successfully, false otherwise.
*/
static bool batadv_mcast_forw_shrink_fill(u8 *slot, u16 num_dests_slot)
{
u16 num_dests_filler;
u8 *filler;
/* sanity check, should not happen */
if (!num_dests_slot)
return false;
num_dests_filler = num_dests_slot - 1;
filler = slot + ETH_ALEN;
/* find a candidate to fill the empty slot */
batadv_mcast_forw_tracker_for_each_dest(filler, num_dests_filler) {
if (is_zero_ether_addr(filler))
continue;
ether_addr_copy(slot, filler);
eth_zero_addr(filler);
return true;
}
return false;
}
/**
* batadv_mcast_forw_shrink_pack_dests() - pack destinations of a tracker TVLV
* @skb: the batman-adv multicast packet to compact destinations in
*
* Compacts the originator destination MAC addresses in the multicast tracker
* TVLV of the given multicast packet. This is done by moving all non-zero
* MAC addresses in direction of the skb head and all zero MAC addresses in skb
* tail direction, within the multicast tracker TVLV.
*
* Return: The number of consecutive zero MAC address destinations which are
* now at the end of the multicast tracker TVLV.
*/
static int batadv_mcast_forw_shrink_pack_dests(struct sk_buff *skb)
{
struct batadv_tvlv_mcast_tracker *mcast_tracker;
unsigned char *skb_net_hdr;
u16 num_dests_slot;
u8 *slot;
skb_net_hdr = skb_network_header(skb);
mcast_tracker = (struct batadv_tvlv_mcast_tracker *)skb_net_hdr;
num_dests_slot = ntohs(mcast_tracker->num_dests);
slot = (u8 *)mcast_tracker + sizeof(*mcast_tracker);
batadv_mcast_forw_tracker_for_each_dest(slot, num_dests_slot) {
/* find an empty slot */
if (!is_zero_ether_addr(slot))
Annotation
- Immediate include surface: `multicast.h`, `main.h`, `linux/bug.h`, `linux/build_bug.h`, `linux/byteorder/generic.h`, `linux/compiler.h`, `linux/errno.h`, `linux/etherdevice.h`.
- Detected declarations: `function batadv_mcast_forw_skb_push`, `function batadv_mcast_forw_push_padding`, `function batadv_mcast_forw_push_est_padding`, `function batadv_mcast_forw_orig_entry`, `function batadv_mcast_forw_push_dest`, `function batadv_mcast_forw_push_dests_list`, `function batadv_mcast_forw_push_tt`, `function batadv_mcast_forw_push_want_all`, `function batadv_mcast_forw_push_want_rtr`, `function batadv_mcast_forw_scrape`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.