net/mac80211/mesh_hwmp.c
Source file repositories/reference/linux-study-clean/net/mac80211/mesh_hwmp.c
File Facts
- System
- Linux kernel
- Corpus path
net/mac80211/mesh_hwmp.c- Extension
.c- Size
- 39507 bytes
- Lines
- 1359
- 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/etherdevice.hlinux/unaligned.hwme.hmesh.h
Detected Declarations
enum mpath_frame_typefunction SN_DELTAfunction mesh_path_sel_frame_txfunction prepare_frame_for_deferred_txfunction mesh_path_error_txfunction ieee80211s_update_metricfunction airtime_link_metric_getfunction is_metric_betterfunction hwmp_route_info_getfunction hwmp_preq_frame_processfunction next_hop_deref_protectedfunction hwmp_prep_frame_processfunction hwmp_perr_frame_processfunction hwmp_rann_frame_processfunction mesh_rx_path_sel_framefunction mesh_queue_preqfunction mesh_path_start_discoveryfunction time_beforefunction mesh_nexthop_resolvefunction meshDAfunction mesh_path_refreshfunction mesh_nexthop_lookupfunction mesh_path_timerfunction mesh_path_tx_root_frame
Annotated Snippet
if (action == MPATH_PREQ) {
put_unaligned_le32(preq_id, pos);
pos += 4;
}
memcpy(pos, orig_addr, ETH_ALEN);
pos += ETH_ALEN;
put_unaligned_le32(orig_sn, pos);
pos += 4;
}
put_unaligned_le32(lifetime, pos); /* interval for RANN */
pos += 4;
put_unaligned_le32(metric, pos);
pos += 4;
if (action == MPATH_PREQ) {
*pos++ = 1; /* destination count */
*pos++ = target_flags;
memcpy(pos, target, ETH_ALEN);
pos += ETH_ALEN;
put_unaligned_le32(target_sn, pos);
pos += 4;
} else if (action == MPATH_PREP) {
memcpy(pos, orig_addr, ETH_ALEN);
pos += ETH_ALEN;
put_unaligned_le32(orig_sn, pos);
pos += 4;
}
ieee80211_tx_skb(sdata, skb);
return 0;
}
/* Headroom is not adjusted. Caller should ensure that skb has sufficient
* headroom in case the frame is encrypted. */
static void prepare_frame_for_deferred_tx(struct ieee80211_sub_if_data *sdata,
struct sk_buff *skb)
{
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
skb_reset_mac_header(skb);
skb_reset_network_header(skb);
skb_reset_transport_header(skb);
/* Send all internal mgmt frames on VO. Accordingly set TID to 7. */
skb_set_queue_mapping(skb, IEEE80211_AC_VO);
skb->priority = 7;
info->control.vif = &sdata->vif;
info->control.flags |= IEEE80211_TX_INTCFL_NEED_TXPROCESSING;
ieee80211_set_qos_hdr(sdata, skb);
ieee80211_mps_set_frame_flags(sdata, NULL, hdr);
}
/**
* mesh_path_error_tx - Sends a PERR mesh management frame
*
* @sdata: local mesh subif
* @ttl: allowed remaining hops
* @target: broken destination
* @target_sn: SN of the broken destination
* @target_rcode: reason code for this PERR
* @ra: node this frame is addressed to
*
* Note: This function may be called with driver locks taken that the driver
* also acquires in the TX path. To avoid a deadlock we don't transmit the
* frame directly but add it to the pending queue instead.
*
* Returns: 0 on success
*/
int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
u8 ttl, const u8 *target, u32 target_sn,
u16 target_rcode, const u8 *ra)
{
int hdr_len = IEEE80211_MIN_ACTION_SIZE(mesh_action);
struct ieee80211_local *local = sdata->local;
struct sk_buff *skb;
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
struct ieee80211_mgmt *mgmt;
u8 *pos, ie_len;
if (time_before(jiffies, ifmsh->next_perr))
return -EAGAIN;
skb = dev_alloc_skb(local->tx_headroom +
IEEE80211_ENCRYPT_HEADROOM +
IEEE80211_ENCRYPT_TAILROOM +
hdr_len +
2 + 15 /* PERR IE */);
if (!skb)
Annotation
- Immediate include surface: `linux/slab.h`, `linux/etherdevice.h`, `linux/unaligned.h`, `wme.h`, `mesh.h`.
- Detected declarations: `enum mpath_frame_type`, `function SN_DELTA`, `function mesh_path_sel_frame_tx`, `function prepare_frame_for_deferred_tx`, `function mesh_path_error_tx`, `function ieee80211s_update_metric`, `function airtime_link_metric_get`, `function is_metric_better`, `function hwmp_route_info_get`, `function hwmp_preq_frame_process`.
- 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.