net/batman-adv/send.c
Source file repositories/reference/linux-study-clean/net/batman-adv/send.c
File Facts
- System
- Linux kernel
- Corpus path
net/batman-adv/send.c- Extension
.c- Size
- 34397 bytes
- Lines
- 1121
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
send.hmain.hlinux/atomic.hlinux/bug.hlinux/byteorder/generic.hlinux/container_of.hlinux/errno.hlinux/etherdevice.hlinux/gfp.hlinux/if.hlinux/if_ether.hlinux/jiffies.hlinux/kref.hlinux/list.hlinux/netdevice.hlinux/printk.hlinux/rcupdate.hlinux/skbuff.hlinux/slab.hlinux/spinlock.hlinux/stddef.hlinux/workqueue.hdistributed-arp-table.hfragmentation.hgateway_client.hhard-interface.hlog.hmesh-interface.horiginator.hrouting.htranslation-table.h
Detected Declarations
function batadv_send_skb_packetfunction batadv_send_broadcast_skbfunction batadv_send_unicast_skbfunction batadv_send_skb_to_origfunction batadv_send_skb_push_fill_unicastfunction batadv_send_skb_prepare_unicastfunction batadv_send_skb_prepare_unicast_4addrfunction batadv_send_skb_unicastfunction batadv_send_skb_via_tt_genericfunction batadv_send_skb_via_gwfunction batadv_forw_packet_freefunction batadv_forw_packet_allocfunction batadv_forw_packet_was_stolenfunction batadv_forw_packet_stealfunction batadv_forw_packet_list_stealfunction hlist_for_each_entry_safefunction batadv_forw_packet_list_freefunction hlist_for_each_entry_safefunction batadv_forw_packet_queuefunction batadv_forw_packet_bcast_queuefunction batadv_forw_packet_ogmv1_queuefunction batadv_forw_bcast_packet_to_listfunction batadv_forw_bcast_packet_iffunction batadv_send_no_broadcastfunction __batadv_forw_bcast_packetfunction batadv_forw_bcast_packetfunction batadv_send_bcast_packetfunction batadv_forw_packet_bcasts_leftfunction batadv_forw_packet_bcasts_decfunction batadv_forw_packet_is_rebroadcastfunction batadv_send_outstanding_bcast_packetfunction batadv_purge_outstanding_packets
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (C) B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*/
#include "send.h"
#include "main.h"
#include <linux/atomic.h>
#include <linux/bug.h>
#include <linux/byteorder/generic.h>
#include <linux/container_of.h>
#include <linux/errno.h>
#include <linux/etherdevice.h>
#include <linux/gfp.h>
#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/jiffies.h>
#include <linux/kref.h>
#include <linux/list.h>
#include <linux/netdevice.h>
#include <linux/printk.h>
#include <linux/rcupdate.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/stddef.h>
#include <linux/workqueue.h>
#include "distributed-arp-table.h"
#include "fragmentation.h"
#include "gateway_client.h"
#include "hard-interface.h"
#include "log.h"
#include "mesh-interface.h"
#include "originator.h"
#include "routing.h"
#include "translation-table.h"
static void batadv_send_outstanding_bcast_packet(struct work_struct *work);
/**
* batadv_send_skb_packet() - send an already prepared packet
* @skb: the packet to send
* @hard_iface: the interface to use to send the broadcast packet
* @dst_addr: the payload destination
*
* Send out an already prepared packet to the given neighbor or broadcast it
* using the specified interface. Either hard_iface or neigh_node must be not
* NULL.
* If neigh_node is NULL, then the packet is broadcasted using hard_iface,
* otherwise it is sent as unicast to the given neighbor.
*
* Regardless of the return value, the skb is consumed.
*
* Return: A negative errno code is returned on a failure. A success does not
* guarantee the frame will be transmitted as it may be dropped due
* to congestion or traffic shaping.
*/
int batadv_send_skb_packet(struct sk_buff *skb,
struct batadv_hard_iface *hard_iface,
const u8 *dst_addr)
{
struct ethhdr *ethhdr;
int ret;
if (hard_iface->if_status != BATADV_IF_ACTIVE)
goto send_skb_err;
if (unlikely(!hard_iface->net_dev))
goto send_skb_err;
if (!(hard_iface->net_dev->flags & IFF_UP)) {
pr_warn("Interface %s is not up - can't send packet via that interface!\n",
hard_iface->net_dev->name);
goto send_skb_err;
}
/* push to the ethernet header. */
if (batadv_skb_head_push(skb, ETH_HLEN) < 0)
goto send_skb_err;
skb_reset_mac_header(skb);
ethhdr = eth_hdr(skb);
ether_addr_copy(ethhdr->h_source, hard_iface->net_dev->dev_addr);
ether_addr_copy(ethhdr->h_dest, dst_addr);
ethhdr->h_proto = htons(ETH_P_BATMAN);
Annotation
- Immediate include surface: `send.h`, `main.h`, `linux/atomic.h`, `linux/bug.h`, `linux/byteorder/generic.h`, `linux/container_of.h`, `linux/errno.h`, `linux/etherdevice.h`.
- Detected declarations: `function batadv_send_skb_packet`, `function batadv_send_broadcast_skb`, `function batadv_send_unicast_skb`, `function batadv_send_skb_to_orig`, `function batadv_send_skb_push_fill_unicast`, `function batadv_send_skb_prepare_unicast`, `function batadv_send_skb_prepare_unicast_4addr`, `function batadv_send_skb_unicast`, `function batadv_send_skb_via_tt_generic`, `function batadv_send_skb_via_gw`.
- 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.