blob: 88c822b200b39580258d20932030ee7c0eb18f7a [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001#!/bin/sh /etc/rc.common
2# Copyright (C) 2006 OpenWrt.org
3
4START=11
5
6apply_defaults() {
7 local mem="$(awk '/^MemTotal:/ {print $2}' /proc/meminfo)"
8 local min_free frag_low_thresh frag_high_thresh
9
10 if [ "$mem" -gt 131072 ]; then # >=256M DDR device
11 min_free=8192
12 elif [ "$mem" -gt 65536 ]; then # 128M DDR device
13 min_free=4196
14 else
15 min_free=1024
16 frag_low_thresh=393216
17 frag_high_thresh=524288
18 fi
19
20 sysctl -qw vm.min_free_kbytes="$min_free"
21
22 [ "$frag_low_thresh" ] && sysctl -qw \
23 net.ipv4.ipfrag_low_thresh="$frag_low_thresh" \
24 net.ipv4.ipfrag_high_thresh="$frag_high_thresh" \
25 net.ipv6.ip6frag_low_thresh="$frag_low_thresh" \
26 net.ipv6.ip6frag_high_thresh="$frag_high_thresh" \
27 net.netfilter.nf_conntrack_frag6_low_thresh="$frag_low_thresh" \
28 net.netfilter.nf_conntrack_frag6_high_thresh="$frag_high_thresh"
29
30 # first set default, then all interfaces to avoid races with appearing interfaces
31 if [ -d /proc/sys/net/ipv6/conf ]; then
32 echo 0 > /proc/sys/net/ipv6/conf/default/accept_ra
33 for iface in /proc/sys/net/ipv6/conf/*/accept_ra; do
34 echo 0 > "$iface"
35 done
36 fi
37}
38
39start() {
40 apply_defaults
41 for CONF in /etc/sysctl.d/*.conf /etc/sysctl.conf; do
42 [ -f "$CONF" ] && sysctl -e -p "$CONF" >&-
43 done
44}