b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | #!/bin/sh /etc/rc.common |
| 2 | # Copyright (C) 2006 OpenWrt.org |
| 3 | |
| 4 | START=11 |
| 5 | |
| 6 | apply_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 | |
| 39 | start() { |
| 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 | } |