net/batman-adv/bat_iv_ogm.c
Source file repositories/reference/linux-study-clean/net/batman-adv/bat_iv_ogm.c
File Facts
- System
- Linux kernel
- Corpus path
net/batman-adv/bat_iv_ogm.c- Extension
.c- Size
- 77754 bytes
- Lines
- 2637
- 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
bat_iv_ogm.hmain.hlinux/atomic.hlinux/bitmap.hlinux/bitops.hlinux/bug.hlinux/byteorder/generic.hlinux/cache.hlinux/compiler.hlinux/container_of.hlinux/errno.hlinux/etherdevice.hlinux/gfp.hlinux/if_ether.hlinux/init.hlinux/jiffies.hlinux/kref.hlinux/list.hlinux/lockdep.hlinux/minmax.hlinux/mutex.hlinux/netdevice.hlinux/netlink.hlinux/pkt_sched.hlinux/printk.hlinux/random.hlinux/rculist.hlinux/rcupdate.hlinux/skbuff.hlinux/slab.hlinux/spinlock.hlinux/stddef.h
Detected Declarations
enum batadv_dup_statusfunction batadv_ring_buffer_setfunction batadv_ring_buffer_avgfunction batadv_iv_ogm_orig_getfunction batadv_iv_ogm_neigh_newfunction batadv_iv_ogm_iface_enablefunction batadv_iv_ogm_iface_disablefunction batadv_iv_ogm_iface_update_macfunction batadv_iv_ogm_primary_iface_setfunction batadv_iv_ogm_emit_send_timefunction batadv_iv_ogm_fwd_send_timefunction batadv_hop_penaltyfunction batadv_iv_ogm_aggr_packetfunction batadv_iv_ogm_send_to_iffunction batadv_iv_ogm_emitfunction batadv_iv_ogm_can_aggregatefunction batadv_iv_ogm_aggregate_newfunction batadv_iv_ogm_aggregatefunction batadv_iv_ogm_queue_addfunction hlist_for_each_entryfunction batadv_iv_ogm_forwardfunction batadv_iv_ogm_slide_own_bcast_windowfunction hlist_for_each_entry_rcufunction batadv_iv_ogm_schedule_bufffunction batadv_iv_ogm_schedulefunction batadv_iv_ogm_reschedulefunction batadv_iv_orig_ifinfo_sumfunction batadv_iv_ogm_neigh_ifinfo_sumfunction batadv_iv_ogm_orig_updatefunction batadv_iv_ogm_calc_tqfunction batadv_iv_ogm_update_seqnosfunction batadv_window_protectedfunction batadv_orig_to_direct_routerfunction batadv_iv_ogm_process_per_outiffunction batadv_iv_ogm_process_replyfunction batadv_iv_ogm_processfunction netdev_for_each_lower_private_rcufunction batadv_iv_send_outstanding_bat_ogm_packetfunction batadv_iv_ogm_receivefunction batadv_iv_ogm_neigh_get_tq_avgfunction batadv_iv_ogm_orig_dump_subentryfunction batadv_iv_ogm_orig_dump_entryfunction hlist_for_each_entry_rcufunction batadv_iv_ogm_orig_dump_bucketfunction batadv_iv_ogm_orig_dumpfunction batadv_iv_ogm_neigh_difffunction batadv_iv_ogm_neigh_dump_neighfunction batadv_iv_ogm_neigh_dump_hardif
Annotated Snippet
if (*ptr != 0) {
count++;
sum += *ptr;
}
i++;
ptr++;
}
if (count == 0)
return 0;
return (u8)(sum / count);
}
/**
* batadv_iv_ogm_orig_get() - retrieve or create (if does not exist) an
* originator
* @bat_priv: the bat priv with all the mesh interface information
* @addr: mac address of the originator
*
* Return: the originator object corresponding to the passed mac address or NULL
* on failure.
* If the object does not exist, it is created and initialised.
*/
static struct batadv_orig_node *
batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr)
{
struct batadv_orig_node *orig_node;
int hash_added;
orig_node = batadv_orig_hash_find(bat_priv, addr);
if (orig_node)
return orig_node;
orig_node = batadv_orig_node_new(bat_priv, addr);
if (!orig_node)
return NULL;
spin_lock_init(&orig_node->bat_iv.ogm_cnt_lock);
kref_get(&orig_node->refcount);
hash_added = batadv_hash_add(bat_priv->orig_hash, batadv_compare_orig,
batadv_choose_orig, orig_node,
&orig_node->hash_entry);
if (hash_added != 0)
goto free_orig_node_hash;
return orig_node;
free_orig_node_hash:
/* reference for batadv_hash_add */
batadv_orig_node_put(orig_node);
/* reference from batadv_orig_node_new */
batadv_orig_node_put(orig_node);
return NULL;
}
static struct batadv_neigh_node *
batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
const u8 *neigh_addr,
struct batadv_orig_node *orig_node)
{
struct batadv_neigh_node *neigh_node;
neigh_node = batadv_neigh_node_get_or_create(orig_node,
hard_iface, neigh_addr);
return neigh_node;
}
static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
{
struct batadv_ogm_packet *batadv_ogm_packet;
unsigned char *ogm_buff;
u32 random_seqno;
mutex_lock(&hard_iface->bat_iv.ogm_buff_mutex);
/* randomize initial seqno to avoid collision */
get_random_bytes(&random_seqno, sizeof(random_seqno));
atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
hard_iface->bat_iv.ogm_buff.len = BATADV_OGM_HLEN;
hard_iface->bat_iv.ogm_buff.capacity = BATADV_OGM_HLEN;
hard_iface->bat_iv.ogm_buff.header_length = BATADV_OGM_HLEN;
ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff.capacity, GFP_ATOMIC);
if (!ogm_buff) {
mutex_unlock(&hard_iface->bat_iv.ogm_buff_mutex);
Annotation
- Immediate include surface: `bat_iv_ogm.h`, `main.h`, `linux/atomic.h`, `linux/bitmap.h`, `linux/bitops.h`, `linux/bug.h`, `linux/byteorder/generic.h`, `linux/cache.h`.
- Detected declarations: `enum batadv_dup_status`, `function batadv_ring_buffer_set`, `function batadv_ring_buffer_avg`, `function batadv_iv_ogm_orig_get`, `function batadv_iv_ogm_neigh_new`, `function batadv_iv_ogm_iface_enable`, `function batadv_iv_ogm_iface_disable`, `function batadv_iv_ogm_iface_update_mac`, `function batadv_iv_ogm_primary_iface_set`, `function batadv_iv_ogm_emit_send_time`.
- 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.