linux/net/ipv4/tcp_cong.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Pluggable TCP congestion control support and newReno
 * congestion control.
 * Based on ideas from I/O scheduler support and Web100.
 *
 * Copyright (C) 2005 Stephen Hemminger <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <linux/list.h>
#include <linux/gfp.h>
#include <linux/jhash.h>
#include <net/tcp.h>
#include <trace/events/tcp.h>

static DEFINE_SPINLOCK(tcp_cong_list_lock);
static LIST_HEAD(tcp_cong_list);

/* Simple linear search, don't expect many entries! */
struct tcp_congestion_ops *tcp_ca_find(const char *name)
{}

void tcp_set_ca_state(struct sock *sk, const u8 ca_state)
{}

/* Must be called with rcu lock held */
static struct tcp_congestion_ops *tcp_ca_find_autoload(const char *name)
{}

/* Simple linear search, not much in here. */
struct tcp_congestion_ops *tcp_ca_find_key(u32 key)
{}

int tcp_validate_congestion_control(struct tcp_congestion_ops *ca)
{}

/* Attach new congestion control algorithm to the list
 * of available options.
 */
int tcp_register_congestion_control(struct tcp_congestion_ops *ca)
{}
EXPORT_SYMBOL_GPL();

/*
 * Remove congestion control algorithm, called from
 * the module's remove function.  Module ref counts are used
 * to ensure that this can't be done till all sockets using
 * that method are closed.
 */
void tcp_unregister_congestion_control(struct tcp_congestion_ops *ca)
{}
EXPORT_SYMBOL_GPL();

/* Replace a registered old ca with a new one.
 *
 * The new ca must have the same name as the old one, that has been
 * registered.
 */
int tcp_update_congestion_control(struct tcp_congestion_ops *ca, struct tcp_congestion_ops *old_ca)
{}

u32 tcp_ca_get_key_by_name(const char *name, bool *ecn_ca)
{}

char *tcp_ca_get_name_by_key(u32 key, char *buffer)
{}

/* Assign choice of congestion control. */
void tcp_assign_congestion_control(struct sock *sk)
{}

void tcp_init_congestion_control(struct sock *sk)
{}

static void tcp_reinit_congestion_control(struct sock *sk,
					  const struct tcp_congestion_ops *ca)
{}

/* Manage refcounts on socket close. */
void tcp_cleanup_congestion_control(struct sock *sk)
{}

/* Used by sysctl to change default congestion control */
int tcp_set_default_congestion_control(struct net *net, const char *name)
{}

/* Set default value from kernel configuration at bootup */
static int __init tcp_congestion_default(void)
{}
late_initcall(tcp_congestion_default);

/* Build string with list of available congestion control values */
void tcp_get_available_congestion_control(char *buf, size_t maxlen)
{}

/* Get current default congestion control */
void tcp_get_default_congestion_control(struct net *net, char *name)
{}

/* Built list of non-restricted congestion control values */
void tcp_get_allowed_congestion_control(char *buf, size_t maxlen)
{}

/* Change list of non-restricted congestion control */
int tcp_set_allowed_congestion_control(char *val)
{}

/* Change congestion control for socket. If load is false, then it is the
 * responsibility of the caller to call tcp_init_congestion_control or
 * tcp_reinit_congestion_control (if the current congestion control was
 * already initialized.
 */
int tcp_set_congestion_control(struct sock *sk, const char *name, bool load,
			       bool cap_net_admin)
{}

/* Slow start is used when congestion window is no greater than the slow start
 * threshold. We base on RFC2581 and also handle stretch ACKs properly.
 * We do not implement RFC3465 Appropriate Byte Counting (ABC) per se but
 * something better;) a packet is only considered (s)acked in its entirety to
 * defend the ACK attacks described in the RFC. Slow start processes a stretch
 * ACK of degree N as if N acks of degree 1 are received back to back except
 * ABC caps N to 2. Slow start exits when cwnd grows over ssthresh and
 * returns the leftover acks to adjust cwnd in congestion avoidance mode.
 */
__bpf_kfunc u32 tcp_slow_start(struct tcp_sock *tp, u32 acked)
{}
EXPORT_SYMBOL_GPL();

/* In theory this is tp->snd_cwnd += 1 / tp->snd_cwnd (or alternative w),
 * for every packet that was ACKed.
 */
__bpf_kfunc void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w, u32 acked)
{}
EXPORT_SYMBOL_GPL();

/*
 * TCP Reno congestion control
 * This is special case used for fallback as well.
 */
/* This is Jacobson's slow start and congestion avoidance.
 * SIGCOMM '88, p. 328.
 */
__bpf_kfunc void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 acked)
{}
EXPORT_SYMBOL_GPL();

/* Slow start threshold is half the congestion window (min 2) */
__bpf_kfunc u32 tcp_reno_ssthresh(struct sock *sk)
{}
EXPORT_SYMBOL_GPL();

__bpf_kfunc u32 tcp_reno_undo_cwnd(struct sock *sk)
{}
EXPORT_SYMBOL_GPL();

struct tcp_congestion_ops tcp_reno =;