sysctl 1.2 KB

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