Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cni-server: set sysctl variables only when the env variables are passed in #3929

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions dist/images/start-cniserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ set -euo pipefail
CNI_SOCK=/run/openvswitch/kube-ovn-daemon.sock
OVS_SOCK=/run/openvswitch/db.sock
ENABLE_SSL=${ENABLE_SSL:-false}
SYSCTL_IPV4_IP_NO_PMTU_DISC=${SYSCTL_IPV4_IP_NO_PMTU_DISC:-0}
SYSCTL_NF_CONNTRACK_TCP_BE_LIBERAL=${SYSCTL_NF_CONNTRACK_TCP_BE_LIBERAL:-1}
SYSCTL_IPV4_NEIGH_DEFAULT_GC_THRESH=${SYSCTL_IPV4_NEIGH_DEFAULT_GC_THRESH:-"1024 2048 4096"}
SYSCTL_IPV4_IP_NO_PMTU_DISC=${SYSCTL_IPV4_IP_NO_PMTU_DISC:-}
SYSCTL_NF_CONNTRACK_TCP_BE_LIBERAL=${SYSCTL_NF_CONNTRACK_TCP_BE_LIBERAL:-}
SYSCTL_IPV4_NEIGH_DEFAULT_GC_THRESH=${SYSCTL_IPV4_NEIGH_DEFAULT_GC_THRESH:-}

# usage: set_sysctl key value
function set_sysctl {
if [ ! -n "$2" ]; then
return
fi
echo "setting sysctl variable \"$1\" to \"$2\""
procfs_path="/proc/sys/$(echo "$1" | tr . /)"
if [ -f "$procfs_path" ]; then
Expand Down Expand Up @@ -51,10 +54,10 @@ set -e
gc_thresh1=$(echo "$SYSCTL_IPV4_NEIGH_DEFAULT_GC_THRESH" | awk '{print $1}')
gc_thresh2=$(echo "$SYSCTL_IPV4_NEIGH_DEFAULT_GC_THRESH" | awk '{print $2}')
gc_thresh3=$(echo "$SYSCTL_IPV4_NEIGH_DEFAULT_GC_THRESH" | awk '{print $3}')
set_sysctl net.ipv4.neigh.default.gc_thresh1 $gc_thresh1
set_sysctl net.ipv4.neigh.default.gc_thresh2 $gc_thresh2
set_sysctl net.ipv4.neigh.default.gc_thresh3 $gc_thresh3
set_sysctl net.ipv4.ip_no_pmtu_disc $SYSCTL_IPV4_IP_NO_PMTU_DISC
set_sysctl net.netfilter.nf_conntrack_tcp_be_liberal $SYSCTL_NF_CONNTRACK_TCP_BE_LIBERAL
set_sysctl net.ipv4.neigh.default.gc_thresh1 "$gc_thresh1"
set_sysctl net.ipv4.neigh.default.gc_thresh2 "$gc_thresh2"
set_sysctl net.ipv4.neigh.default.gc_thresh3 "$gc_thresh3"
set_sysctl net.ipv4.ip_no_pmtu_disc "$SYSCTL_IPV4_IP_NO_PMTU_DISC"
set_sysctl net.netfilter.nf_conntrack_tcp_be_liberal "$SYSCTL_NF_CONNTRACK_TCP_BE_LIBERAL"

./kube-ovn-daemon --ovs-socket=${OVS_SOCK} --bind-socket=${CNI_SOCK} "$@"
Loading