-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #851 from tempesta-tech/ik-51
Live reconfiguration
- Loading branch information
Showing
45 changed files
with
4,177 additions
and
1,721 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# Tempesta FW service script. | ||
# | ||
# Copyright (C) 2014 NatSys Lab. ([email protected]). | ||
# Copyright (C) 2015-2016 Tempesta Technologies, Inc. | ||
# Copyright (C) 2015-2017 Tempesta Technologies, Inc. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License as published by | ||
|
@@ -35,7 +35,7 @@ tfw_mod=tempesta_fw | |
tfw_sched_mod=tfw_sched_$sched | ||
frang_mod="tfw_frang" | ||
declare frang_enable= | ||
declare -r LONG_OPTS="help,load,unload,start,stop,restart" | ||
declare -r LONG_OPTS="help,load,unload,start,stop,restart,reload" | ||
|
||
declare devs=$(ip addr show up | awk '/^[0-9]+/ { sub(/:/, "", $2); print $2}') | ||
|
||
|
@@ -53,6 +53,7 @@ usage() | |
echo -e " --start Load modules and start." | ||
echo -e " --stop Stop and unload modules." | ||
echo -e " --restart Restart.\n" | ||
echo -e " --reload Live reconfiguration.\n" | ||
} | ||
|
||
error() | ||
|
@@ -64,6 +65,22 @@ error() | |
# Tempesta requires kernel module loading, so we need root credentials. | ||
[ `id -u` -ne 0 ] && error "Please, run the script as root" | ||
|
||
load_one_module() | ||
{ | ||
if [ -z "$1" ]; then | ||
echo "$0: Empty argument"; | ||
exit 255; | ||
fi | ||
|
||
MOD_PATH_NAME="$1"; shift; | ||
MOD_NAME="$(basename ${MOD_PATH_NAME%%.*})"; | ||
|
||
lsmod | grep -w "${MOD_NAME}" 2>&1 > /dev/null || { | ||
echo "Loading module ${MOD_NAME} $@"; | ||
insmod "${MOD_PATH_NAME}" "$@"; | ||
} | ||
} | ||
|
||
# The separate load_modules/unload_modules routines are used for unit testing. | ||
load_modules() | ||
{ | ||
|
@@ -73,24 +90,24 @@ load_modules() | |
# so debug messages are shown on serial console as well. | ||
echo '8 7 1 7' > /proc/sys/kernel/printk | ||
|
||
insmod $tls_path/$tls_mod.ko | ||
[ $? -ne 0 ] && error "cannot load tempesta TLS module" | ||
load_one_module "$tls_path/$tls_mod.ko" || | ||
error "cannot load tempesta TLS module" | ||
|
||
insmod $tdb_path/$tdb_mod.ko | ||
[ $? -ne 0 ] && error "cannot load tempesta database module" | ||
load_one_module "$tdb_path/$tdb_mod.ko" || | ||
error "cannot load tempesta database module" | ||
|
||
insmod $tfw_path/$tfw_mod.ko tfw_cfg_path=$tfw_cfg_path | ||
[ $? -ne 0 ] && error "cannot load tempesta module" | ||
load_one_module "$tfw_path/$tfw_mod.ko" "tfw_cfg_path=$tfw_cfg_path" || | ||
error "cannot load tempesta module" | ||
|
||
for ko_file in "${sched_ko_files[@]}"; do | ||
insmod $ko_file | ||
[ $? -ne 0 ] && error "cannot load tempesta scheduler module" | ||
load_one_module "$ko_file" || | ||
error "cannot load tempesta scheduler module" | ||
done | ||
|
||
if [ "$frang_enable" ]; then | ||
echo "Load Frang" | ||
insmod $class_path/$frang_mod.ko | ||
[ $? -ne 0 ] && error "cannot load $frang_mod module" | ||
load_one_module "$class_path/$frang_mod.ko" || | ||
error "cannot load $frang_mod module" | ||
fi | ||
} | ||
|
||
|
@@ -108,10 +125,8 @@ unload_modules() | |
rmmod $tls_mod | ||
} | ||
|
||
start() | ||
setup() | ||
{ | ||
echo "Starting Tempesta..." | ||
|
||
tfw_set_net_queues "$devs" | ||
|
||
# Tempesta builds socket buffers by itself, don't cork TCP segments. | ||
|
@@ -120,16 +135,28 @@ start() | |
sysctl -w net.core.netdev_max_backlog=10000 >/dev/null | ||
sysctl -w net.core.somaxconn=131072 >/dev/null | ||
sysctl -w net.ipv4.tcp_max_syn_backlog=131072 >/dev/null | ||
} | ||
|
||
start() | ||
{ | ||
echo "Starting Tempesta..." | ||
|
||
TFW_STATE=$(sysctl net.tempesta.state 2> /dev/null) | ||
TFW_STATE=${TFW_STATE##* } | ||
|
||
echo "...load Tempesta modules" | ||
load_modules | ||
[[ -z ${TFW_STATE} ]] && { | ||
setup; | ||
|
||
# Create database directory if it doesn't exist. | ||
mkdir -p /opt/tempesta/db/ | ||
# At this time we don't have stable TDB data format, so | ||
# it would be nice to clean all the tables before the start. | ||
# TODO: Remove the hack when TDB is fixed. | ||
rm -f /opt/tempesta/db/*.tdb | ||
echo "...load Tempesta modules" | ||
load_modules; | ||
|
||
# Create database directory if it doesn't exist. | ||
mkdir -p /opt/tempesta/db/; | ||
# At this time we don't have stable TDB data format, so | ||
# it would be nice to clean all the tables before the start. | ||
# TODO: Remove the hack when TDB is fixed. | ||
rm -f /opt/tempesta/db/*.tdb; | ||
} | ||
|
||
echo "...start Tempesta FW" | ||
sysctl -w net.tempesta.state=start >/dev/null | ||
|
@@ -153,6 +180,17 @@ stop() | |
echo "done" | ||
} | ||
|
||
reload() | ||
{ | ||
echo "Running live reconfiguration of Tempesta..." | ||
sysctl -w net.tempesta.state=start >/dev/null | ||
if [ $? -ne 0 ]; then | ||
error "cannot reconfigure Tempesta FW" | ||
else | ||
echo "done" | ||
fi | ||
} | ||
|
||
args=$(getopt -o "d:f" -a -l "$LONG_OPTS" -- "$@") | ||
eval set -- "${args}" | ||
while :; do | ||
|
@@ -180,6 +218,10 @@ while :; do | |
start | ||
exit | ||
;; | ||
--reload) | ||
reload | ||
exit | ||
;; | ||
# Ignore any options after action. | ||
-d) | ||
devs=$2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.