net/ipv4/sysctl_net_ipv4.c
Source file repositories/reference/linux-study-clean/net/ipv4/sysctl_net_ipv4.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv4/sysctl_net_ipv4.c- Extension
.c- Size
- 45502 bytes
- Lines
- 1738
- 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/sysctl.hlinux/seqlock.hlinux/init.hlinux/slab.hnet/icmp.hnet/ip.hnet/ip_fib.hnet/tcp.hnet/udp.hnet/cipso_ipv4.hnet/ping.hnet/protocol.hnet/netevent.h
Detected Declarations
function set_local_port_rangefunction ipv4_local_port_rangefunction ipv4_privileged_portsfunction inet_get_ping_group_range_tablefunction set_ping_group_rangefunction ipv4_ping_group_rangefunction ipv4_fwd_update_priorityfunction proc_tcp_congestion_controlfunction proc_tcp_available_congestion_controlfunction proc_allowed_congestion_controlfunction sscanf_keyfunction proc_tcp_fastopen_keyfunction proc_tfo_blackhole_detect_timeoutfunction proc_tcp_available_ulpfunction proc_tcp_ehash_entriesfunction proc_udp_hash_entriesfunction proc_fib_multipath_hash_policyfunction proc_fib_multipath_hash_fieldsfunction proc_fib_multipath_hash_init_rand_seedfunction proc_fib_multipath_hash_set_seedfunction proc_fib_multipath_hash_seedfunction proc_fib_multipath_hash_init_rand_seedfunction ipv4_sysctl_init_netfunction ipv4_sysctl_exit_netfunction sysctl_ipv4_init
Annotated Snippet
if (urange[1] < urange[0] || gid_lt(high, low)) {
low = make_kgid(&init_user_ns, 1);
high = make_kgid(&init_user_ns, 0);
}
set_ping_group_range(table, low, high);
}
return ret;
}
static int ipv4_fwd_update_priority(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
struct net *net;
int ret;
net = container_of(table->data, struct net,
ipv4.sysctl_ip_fwd_update_priority);
ret = proc_dou8vec_minmax(table, write, buffer, lenp, ppos);
if (write && ret == 0)
call_netevent_notifiers(NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE,
net);
return ret;
}
static int proc_tcp_congestion_control(const struct ctl_table *ctl, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
struct net *net = container_of(ctl->data, struct net,
ipv4.tcp_congestion_control);
char val[TCP_CA_NAME_MAX];
struct ctl_table tbl = {
.data = val,
.maxlen = TCP_CA_NAME_MAX,
};
int ret;
tcp_get_default_congestion_control(net, val);
ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
if (write && ret == 0)
ret = tcp_set_default_congestion_control(net, val);
return ret;
}
static int proc_tcp_available_congestion_control(const struct ctl_table *ctl,
int write, void *buffer,
size_t *lenp, loff_t *ppos)
{
struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
int ret;
tbl.data = kmalloc(tbl.maxlen, GFP_USER);
if (!tbl.data)
return -ENOMEM;
tcp_get_available_congestion_control(tbl.data, TCP_CA_BUF_MAX);
ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
kfree(tbl.data);
return ret;
}
static int proc_allowed_congestion_control(const struct ctl_table *ctl,
int write, void *buffer,
size_t *lenp, loff_t *ppos)
{
struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
int ret;
tbl.data = kmalloc(tbl.maxlen, GFP_USER);
if (!tbl.data)
return -ENOMEM;
tcp_get_allowed_congestion_control(tbl.data, tbl.maxlen);
ret = proc_dostring(&tbl, write, buffer, lenp, ppos);
if (write && ret == 0)
ret = tcp_set_allowed_congestion_control(tbl.data);
kfree(tbl.data);
return ret;
}
static int sscanf_key(char *buf, __le32 *key)
{
u32 user_key[4];
int i, ret = 0;
if (sscanf(buf, "%x-%x-%x-%x", user_key, user_key + 1,
user_key + 2, user_key + 3) != 4) {
ret = -EINVAL;
} else {
Annotation
- Immediate include surface: `linux/sysctl.h`, `linux/seqlock.h`, `linux/init.h`, `linux/slab.h`, `net/icmp.h`, `net/ip.h`, `net/ip_fib.h`, `net/tcp.h`.
- Detected declarations: `function set_local_port_range`, `function ipv4_local_port_range`, `function ipv4_privileged_ports`, `function inet_get_ping_group_range_table`, `function set_ping_group_range`, `function ipv4_ping_group_range`, `function ipv4_fwd_update_priority`, `function proc_tcp_congestion_control`, `function proc_tcp_available_congestion_control`, `function proc_allowed_congestion_control`.
- 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.