net/batman-adv/tp_meter.c
Source file repositories/reference/linux-study-clean/net/batman-adv/tp_meter.c
File Facts
- System
- Linux kernel
- Corpus path
net/batman-adv/tp_meter.c- Extension
.c- Size
- 50897 bytes
- Lines
- 1735
- 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
tp_meter.hmain.hlinux/atomic.hlinux/bug.hlinux/build_bug.hlinux/byteorder/generic.hlinux/cache.hlinux/compiler.hlinux/completion.hlinux/container_of.hlinux/err.hlinux/etherdevice.hlinux/gfp.hlinux/if_ether.hlinux/init.hlinux/jiffies.hlinux/kref.hlinux/kthread.hlinux/limits.hlinux/list.hlinux/minmax.hlinux/netdevice.hlinux/param.hlinux/printk.hlinux/random.hlinux/rculist.hlinux/rcupdate.hlinux/sched.hlinux/skbuff.hlinux/slab.hlinux/spinlock.hlinux/stddef.h
Detected Declarations
enum batadv_tp_ack_reactionfunction batadv_tp_session_cookiefunction batadv_tp_cwndfunction batadv_tp_update_cwndfunction batadv_tp_update_rtofunction tcp_rtt_estimatorfunction batadv_tp_batctl_notifyfunction batadv_tp_batctl_error_notifyfunction batadv_tp_list_find_senderfunction batadv_tp_list_activefunction hlist_for_each_entry_rcufunction hlist_for_each_entry_rcufunction batadv_tp_list_find_sender_sessionfunction batadv_tp_vars_common_releasefunction batadv_tp_sender_putfunction batadv_tp_list_detachfunction batadv_tp_sender_cleanupfunction batadv_tp_sender_endfunction batadv_tp_sender_shutdownfunction batadv_tp_sender_stoppedfunction batadv_tp_sender_finishfunction batadv_tp_reset_sender_timerfunction batadv_tp_sender_timeoutfunction batadv_tp_fill_prerandomfunction batadv_tp_send_msgfunction batadv_tp_handle_ackfunction batadv_tp_recv_ackfunction batadv_tp_availfunction batadv_tp_wait_availablefunction batadv_tp_sendfunction batadv_tp_start_kthreadfunction batadv_tp_startfunction batadv_tp_stopfunction batadv_tp_list_find_receiver_sessionfunction batadv_tp_receiver_putfunction batadv_tp_reset_receiver_timerfunction batadv_tp_receiver_shutdownfunction batadv_tp_send_ackfunction batadv_tp_handle_out_of_orderfunction packetfunction batadv_tp_ack_unorderedfunction batadv_tp_init_recvfunction batadv_tp_recv_msgfunction batadv_tp_meter_recvfunction batadv_tp_stop_allfunction hlist_for_each_entryfunction batadv_tp_meter_init
Annotated Snippet
if (batadv_seq_before(recv_ack, tp_vars->cc.recover)) {
/* this is another hole in the window. React
* immediately as specified by NewReno (see
* Section 3.2 of RFC6582 for details)
*/
reaction = BATADV_TP_ACK_REACTION_RESEND_WAKEUP;
tp_vars->cc.cwnd = batadv_tp_cwnd(tp_vars->cc.cwnd,
mss, mss);
} else {
tp_vars->cc.fast_recovery = false;
/* set cwnd to the value of ss_threshold at the
* moment that Fast Recovery was entered.
* RFC6582, Section 3.2, step 3
*/
tp_vars->cc.cwnd = batadv_tp_cwnd(tp_vars->cc.ss_threshold,
0, mss);
reaction = BATADV_TP_ACK_REACTION_WAKEUP;
}
} else {
if (recv_ack - tp_vars->cc.last_acked >= mss)
batadv_tp_update_cwnd(tp_vars, mss);
reaction = BATADV_TP_ACK_REACTION_WAKEUP;
}
/* move the Transmit Window */
WRITE_ONCE(tp_vars->cc.last_acked, recv_ack);
return reaction;
}
/**
* batadv_tp_recv_ack() - ACK receiving function
* @bat_priv: the bat priv with all the mesh interface information
* @skb: the buffer containing the received packet
*
* Process a received TP ACK packet
*/
static void batadv_tp_recv_ack(struct batadv_priv *bat_priv,
const struct sk_buff *skb)
{
struct batadv_hard_iface *primary_if = NULL;
struct batadv_orig_node *orig_node = NULL;
const struct batadv_icmp_tp_packet *icmp;
enum batadv_tp_ack_reaction reaction;
struct batadv_tp_sender *tp_vars;
size_t packet_len;
u32 recv_ack;
size_t mss;
u32 rtt;
packet_len = BATADV_TP_PLEN;
mss = BATADV_TP_PLEN;
packet_len += sizeof(struct batadv_unicast_packet);
icmp = (struct batadv_icmp_tp_packet *)skb->data;
recv_ack = ntohl(icmp->seqno);
/* find the tp_vars */
tp_vars = batadv_tp_list_find_sender_session(bat_priv, icmp->orig,
icmp->session);
if (unlikely(!tp_vars))
return;
if (unlikely(batadv_tp_sender_stopped(tp_vars)))
goto out;
/* old ACK? silently drop it.. */
if (batadv_seq_before(recv_ack, READ_ONCE(tp_vars->cc.last_acked)))
goto out;
primary_if = batadv_primary_if_get_selected(bat_priv);
if (unlikely(!primary_if))
goto out;
orig_node = batadv_orig_hash_find(bat_priv, icmp->orig);
if (unlikely(!orig_node))
goto out;
spin_lock_bh(&tp_vars->cc_lock);
/* update RTO with the new sampled RTT, if any */
rtt = jiffies_to_msecs(jiffies) - ntohl(icmp->timestamp);
if (icmp->timestamp && rtt)
batadv_tp_update_rto(tp_vars, rtt);
reaction = batadv_tp_handle_ack(bat_priv, tp_vars, recv_ack, mss);
spin_unlock_bh(&tp_vars->cc_lock);
if (reaction == BATADV_TP_ACK_REACTION_OLD_ACK)
goto out;
Annotation
- Immediate include surface: `tp_meter.h`, `main.h`, `linux/atomic.h`, `linux/bug.h`, `linux/build_bug.h`, `linux/byteorder/generic.h`, `linux/cache.h`, `linux/compiler.h`.
- Detected declarations: `enum batadv_tp_ack_reaction`, `function batadv_tp_session_cookie`, `function batadv_tp_cwnd`, `function batadv_tp_update_cwnd`, `function batadv_tp_update_rto`, `function tcp_rtt_estimator`, `function batadv_tp_batctl_notify`, `function batadv_tp_batctl_error_notify`, `function batadv_tp_list_find_sender`, `function batadv_tp_list_active`.
- 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.