net/mac80211/mesh.c
Source file repositories/reference/linux-study-clean/net/mac80211/mesh.c
File Facts
- System
- Linux kernel
- Corpus path
net/mac80211/mesh.c- Extension
.c- Size
- 50294 bytes
- Lines
- 1795
- 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
linux/slab.hlinux/unaligned.hnet/sock.hieee80211_i.hmesh.hwme.hdriver-ops.h
Detected Declarations
function mesh_action_is_path_selfunction ieee80211s_initfunction ieee80211s_stopfunction ieee80211_mesh_housekeeping_timerfunction mesh_matches_localfunction mesh_peer_accepts_plinksfunction mesh_accept_plinks_updatefunction mesh_sta_cleanupfunction mesh_rmc_initfunction mesh_rmc_freefunction hlist_for_each_entry_safefunction mesh_rmc_checkfunction mesh_add_meshconf_iefunction mesh_add_meshid_iefunction mesh_add_awake_window_iefunction mesh_add_vendor_iesfunction mesh_add_rsn_iefunction mesh_add_ds_params_iefunction mesh_add_ht_cap_iefunction mesh_add_ht_oper_iefunction mesh_add_vht_cap_iefunction mesh_add_vht_oper_iefunction mesh_add_he_cap_iefunction mesh_add_he_oper_iefunction mesh_add_he_6ghz_cap_iefunction mesh_add_eht_cap_iefunction mesh_add_eht_oper_iefunction ieee80211_mesh_path_timerfunction ieee80211_mesh_path_root_timerfunction ieee80211_mesh_root_setupfunction ieee80211_mesh_update_bss_paramsfunction ieee80211_mesh_xmit_fastfunction ieee80211_fill_mesh_addressesfunction ieee80211_new_mesh_headerfunction ieee80211_mesh_housekeepingfunction ieee80211_mesh_rootpathfunction ieee80211_mesh_build_beaconfunction ieee80211_mesh_rebuild_beaconfunction ieee80211_mbss_info_change_notifyfunction ieee80211_start_meshfunction ieee80211_stop_meshfunction ieee80211_mesh_csa_mark_radarfunction ieee80211_mesh_process_chnswitchfunction ieee80211_mesh_rx_probe_reqfunction ieee80211_mesh_rx_bcn_prespfunction ieee80211_mesh_finish_csafunction ieee80211_mesh_csa_beaconfunction mesh_fwd_csa_frame
Annotated Snippet
hlist_for_each_entry_safe(p, n, &rmc->bucket[i], list) {
hlist_del(&p->list);
kmem_cache_free(rm_cache, p);
}
}
kfree(rmc);
sdata->u.mesh.rmc = NULL;
}
/**
* mesh_rmc_check - Check frame in recent multicast cache and add if absent.
*
* @sdata: interface
* @sa: source address
* @mesh_hdr: mesh_header
*
* Returns: 0 if the frame is not in the cache, nonzero otherwise.
*
* Checks using the source address and the mesh sequence number if we have
* received this frame lately. If the frame is not in the cache, it is added to
* it.
*/
int mesh_rmc_check(struct ieee80211_sub_if_data *sdata,
const u8 *sa, struct ieee80211s_hdr *mesh_hdr)
{
struct mesh_rmc *rmc = sdata->u.mesh.rmc;
u32 seqnum = 0;
int entries = 0;
u8 idx;
struct rmc_entry *p;
struct hlist_node *n;
if (!rmc)
return -1;
/* Don't care about endianness since only match matters */
memcpy(&seqnum, &mesh_hdr->seqnum, sizeof(mesh_hdr->seqnum));
idx = le32_to_cpu(mesh_hdr->seqnum) & rmc->idx_mask;
hlist_for_each_entry_safe(p, n, &rmc->bucket[idx], list) {
++entries;
if (time_after(jiffies, p->exp_time) ||
entries == RMC_QUEUE_MAX_LEN) {
hlist_del(&p->list);
kmem_cache_free(rm_cache, p);
--entries;
} else if ((seqnum == p->seqnum) && ether_addr_equal(sa, p->sa))
return -1;
}
p = kmem_cache_alloc(rm_cache, GFP_ATOMIC);
if (!p)
return 0;
p->seqnum = seqnum;
p->exp_time = jiffies + RMC_TIMEOUT;
memcpy(p->sa, sa, ETH_ALEN);
hlist_add_head(&p->list, &rmc->bucket[idx]);
return 0;
}
int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata,
struct sk_buff *skb)
{
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
u8 *pos, neighbors;
u8 meshconf_len = sizeof(struct ieee80211_meshconf_ie);
bool is_connected_to_gate = ifmsh->num_gates > 0 ||
ifmsh->mshcfg.dot11MeshGateAnnouncementProtocol ||
ifmsh->mshcfg.dot11MeshConnectedToMeshGate;
bool is_connected_to_as = ifmsh->mshcfg.dot11MeshConnectedToAuthServer;
if (skb_tailroom(skb) < 2 + meshconf_len)
return -ENOMEM;
pos = skb_put(skb, 2 + meshconf_len);
*pos++ = WLAN_EID_MESH_CONFIG;
*pos++ = meshconf_len;
/* save a pointer for quick updates in pre-tbtt */
ifmsh->meshconf_offset = pos - skb->data;
/* Active path selection protocol ID */
*pos++ = ifmsh->mesh_pp_id;
/* Active path selection metric ID */
*pos++ = ifmsh->mesh_pm_id;
/* Congestion control mode identifier */
*pos++ = ifmsh->mesh_cc_id;
/* Synchronization protocol identifier */
*pos++ = ifmsh->mesh_sp_id;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/unaligned.h`, `net/sock.h`, `ieee80211_i.h`, `mesh.h`, `wme.h`, `driver-ops.h`.
- Detected declarations: `function mesh_action_is_path_sel`, `function ieee80211s_init`, `function ieee80211s_stop`, `function ieee80211_mesh_housekeeping_timer`, `function mesh_matches_local`, `function mesh_peer_accepts_plinks`, `function mesh_accept_plinks_update`, `function mesh_sta_cleanup`, `function mesh_rmc_init`, `function mesh_rmc_free`.
- 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.