net/batman-adv/distributed-arp-table.c
Source file repositories/reference/linux-study-clean/net/batman-adv/distributed-arp-table.c
File Facts
- System
- Linux kernel
- Corpus path
net/batman-adv/distributed-arp-table.c- Extension
.c- Size
- 51448 bytes
- Lines
- 1824
- 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
distributed-arp-table.hmain.hlinux/atomic.hlinux/bitops.hlinux/bug.hlinux/byteorder/generic.hlinux/container_of.hlinux/err.hlinux/errno.hlinux/etherdevice.hlinux/gfp.hlinux/if_arp.hlinux/if_ether.hlinux/if_vlan.hlinux/in.hlinux/ip.hlinux/jiffies.hlinux/kref.hlinux/list.hlinux/netlink.hlinux/rculist.hlinux/rcupdate.hlinux/skbuff.hlinux/slab.hlinux/spinlock.hlinux/stddef.hlinux/string.hlinux/udp.hlinux/unaligned.hlinux/workqueue.hnet/arp.hnet/genetlink.h
Detected Declarations
struct batadv_dhcp_packetenum batadv_bootpopenum batadv_boothtypeenum batadv_dhcpoptioncodeenum batadv_dhcptypefunction batadv_dat_start_timerfunction batadv_dat_entry_releasefunction batadv_dat_entry_putfunction batadv_dat_to_purgefunction __batadv_dat_purgefunction hlist_for_each_entry_safefunction batadv_dat_purgefunction batadv_compare_datfunction batadv_arp_hw_srcfunction batadv_arp_ip_srcfunction batadv_arp_hw_dstfunction batadv_arp_ip_dstfunction batadv_hash_datfunction batadv_dat_entry_hash_findfunction batadv_dat_entry_addfunction batadv_dbg_arpfunction batadv_dbg_arpfunction batadv_choose_next_candidatefunction hlist_for_each_entry_rcufunction batadv_dat_select_candidatesfunction batadv_dat_forward_datafunction batadv_dat_tvlv_container_updatefunction batadv_dat_status_updatefunction batadv_dat_tvlv_ogm_handler_v1function batadv_dat_hash_freefunction batadv_dat_initfunction batadv_dat_freefunction batadv_dat_cache_dump_entryfunction batadv_dat_cache_dump_bucketfunction hlist_for_each_entryfunction batadv_dat_cache_dumpfunction batadv_arp_get_typefunction batadv_dat_get_vidfunction batadv_dat_arp_create_replyfunction batadv_dat_snoop_outgoing_arp_requestfunction batadv_dat_snoop_incoming_arp_requestfunction batadv_dat_snoop_outgoing_arp_replyfunction batadv_dat_snoop_incoming_arp_replyfunction batadv_dat_check_dhcp_ipudpfunction batadv_dat_check_dhcpfunction batadv_dat_get_dhcp_message_typefunction batadv_dat_dhcp_get_yiaddrfunction batadv_dat_get_dhcp_chaddr
Annotated Snippet
struct batadv_dhcp_packet {
__u8 op;
__u8 htype;
__u8 hlen;
__u8 hops;
__be32 xid;
__be16 secs;
__be16 flags;
__be32 ciaddr;
__be32 yiaddr;
__be32 siaddr;
__be32 giaddr;
__u8 chaddr[16];
__u8 sname[64];
__u8 file[128];
__be32 magic;
/* __u8 options[]; */
};
#define BATADV_DHCP_YIADDR_LEN sizeof(((struct batadv_dhcp_packet *)0)->yiaddr)
#define BATADV_DHCP_CHADDR_LEN sizeof(((struct batadv_dhcp_packet *)0)->chaddr)
static void batadv_dat_purge(struct work_struct *work);
/**
* batadv_dat_start_timer() - initialise the DAT periodic worker
* @bat_priv: the bat priv with all the mesh interface information
*/
static void batadv_dat_start_timer(struct batadv_priv *bat_priv)
{
queue_delayed_work(batadv_event_workqueue, &bat_priv->dat.work,
msecs_to_jiffies(10000));
}
/**
* batadv_dat_entry_release() - release dat_entry from lists and queue for free
* after rcu grace period
* @ref: kref pointer of the dat_entry
*/
static void batadv_dat_entry_release(struct kref *ref)
{
struct batadv_dat_entry *dat_entry;
dat_entry = container_of(ref, struct batadv_dat_entry, refcount);
kfree_rcu(dat_entry, rcu);
}
/**
* batadv_dat_entry_put() - decrement the dat_entry refcounter and possibly
* release it
* @dat_entry: dat_entry to be free'd
*/
static void batadv_dat_entry_put(struct batadv_dat_entry *dat_entry)
{
if (!dat_entry)
return;
kref_put(&dat_entry->refcount, batadv_dat_entry_release);
}
/**
* batadv_dat_to_purge() - check whether a dat_entry has to be purged or not
* @dat_entry: the entry to check
*
* Return: true if the entry has to be purged now, false otherwise.
*/
static bool batadv_dat_to_purge(struct batadv_dat_entry *dat_entry)
{
return batadv_has_timed_out(dat_entry->last_update,
BATADV_DAT_ENTRY_TIMEOUT);
}
/**
* __batadv_dat_purge() - delete entries from the DAT local storage
* @bat_priv: the bat priv with all the mesh interface information
* @to_purge: function in charge to decide whether an entry has to be purged or
* not. This function takes the dat_entry as argument and has to
* returns a boolean value: true is the entry has to be deleted,
* false otherwise
*
* Loops over each entry in the DAT local storage and deletes it if and only if
* the to_purge function passed as argument returns true.
*/
static void __batadv_dat_purge(struct batadv_priv *bat_priv,
bool (*to_purge)(struct batadv_dat_entry *))
{
spinlock_t *list_lock; /* protects write access to the hash lists */
struct batadv_dat_entry *dat_entry;
struct hlist_node *node_tmp;
Annotation
- Immediate include surface: `distributed-arp-table.h`, `main.h`, `linux/atomic.h`, `linux/bitops.h`, `linux/bug.h`, `linux/byteorder/generic.h`, `linux/container_of.h`, `linux/err.h`.
- Detected declarations: `struct batadv_dhcp_packet`, `enum batadv_bootpop`, `enum batadv_boothtype`, `enum batadv_dhcpoptioncode`, `enum batadv_dhcptype`, `function batadv_dat_start_timer`, `function batadv_dat_entry_release`, `function batadv_dat_entry_put`, `function batadv_dat_to_purge`, `function __batadv_dat_purge`.
- 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.