Browse Source

Merge pull request #7402 from TDT-AG/pr/20182610-keepalived

keepalived: add ipvs uci support
lilik-openwrt-22.03
Hannu Nyman 6 years ago
committed by GitHub
parent
commit
d8bb8c3ff6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 165 additions and 1 deletions
  1. +1
    -1
      net/keepalived/Makefile
  2. +54
    -0
      net/keepalived/files/keepalived.config
  3. +110
    -0
      net/keepalived/files/keepalived.init

+ 1
- 1
net/keepalived/Makefile View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=keepalived PKG_NAME:=keepalived
PKG_VERSION:=2.0.7 PKG_VERSION:=2.0.7
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.keepalived.org/software PKG_SOURCE_URL:=http://www.keepalived.org/software


+ 54
- 0
net/keepalived/files/keepalived.config View File

@ -145,3 +145,57 @@ config global_defs
# option fall "2" # option fall "2"
# option rise "3" # option rise "3"
#config virtual_server
# option enabled "1"
# option ipaddr "192.168.200.2"
# option port "80"
# option fwmark "0x42"
# option delay_loop "30"
# valid values for lb_algo rr|wrr|lc|wlc
# option lb_algo "rr"
# valid values for lb_kind NAT|DR|TUN
# option lb_kind "NAT"
# option persistence_timeout "50"
# option persistence_granularity "192.168.110.2"
# option virtualhost "www.domain1.com"
# valid values for protocol TCP|UDP
# option protocol "TCP"
# option sorry_server_ip "192.168.100.100"
# option sorry_server_port "80"
# list real_server "Server1"
# list real_server "Server2"
#config real_server
# option enabled "1"
# option name "Server1"
# option weight "2"
# option check "HTTP_GET"
# only for check TCP_CHECK|HTTP_GET|SSL_GET
# option connect_port "80"
# option connect_timeout "3"
# only for check MISC_CHECK
# option misc_path "<user-defined-check-script>"
# only for check HTTP_GET | SSL_GET
# list url "url1"
# list url "url2"
# option nb_get_retry "3"
# option delay_before_retry "2"
#config real_server
# option enabled "1"
# option name "Server2"
# option weight "2"
# option check "TCP_CHECK"
# option connect_port "80"
# option connect_timeout "3"
#config url
# option name "url1"
# option path "/testurl/test1.jsp"
# option digest "11"
#config url
# option name "url2"
# option path "/testurl/test2.jsp"
# option digest "22"

+ 110
- 0
net/keepalived/files/keepalived.init View File

@ -10,6 +10,8 @@ KEEPALIVED_CONF=/tmp/keepalived.conf
INDENT_1=\\t INDENT_1=\\t
INDENT_2=$INDENT_1$INDENT_1 INDENT_2=$INDENT_1$INDENT_1
INDENT_3=$INDENT_1$INDENT_1$INDENT_1
INDENT_4=$INDENT_1$INDENT_1$INDENT_1$INDENT_1
config_section_open() { config_section_open() {
local tag=$1 local tag=$1
@ -366,6 +368,113 @@ vrrp_script() {
config_section_close config_section_close
} }
url() {
local url="$2"
local name path digest
config_get name $1 name
[ "$url" = "$name" ] || return 0
config_get path $1 path
config_get digest $1 digest
[ -n "$digest" -a -n "$path" ] && {
printf "${INDENT_3}url {\n" >> $KEEPALIVED_CONF
printf "${INDENT_4}path "$path"\n" >> $KEEPALIVED_CONF
printf "${INDENT_4}digest $digest\n" >> $KEEPALIVED_CONF
printf "${INDENT_3}}\n" >> $KEEPALIVED_CONF
}
}
url_list() {
config_foreach url url "$1"
}
real_server() {
local server="$2"
local enabled name weight ipaddr port check
config_get_bool enabled $1 enabled 1
[ "$enabled" -eq 1 ] || return 0
config_get name $1 name
[ "$server" = "$name" ] || return 0
config_get weight $1 weight
[ -n "$weight" ] || return 0
config_get ipaddr $1 ipaddr
config_get port $1 port
config_get check $1 check
[ -n "$ipaddr" -a -n "$port" ] && {
printf "${INDENT_1}real_server $ipaddr $port {\n" >> $KEEPALIVED_CONF
printf "${INDENT_2}weight $weight\n" >> $KEEPALIVED_CONF
case "$check" in
TCP_CHECK)
printf "${INDENT_2}${check} {\n" >> $KEEPALIVED_CONF
print_elems_indent $1 $INDENT_3 connect_timeout \
connect_port
printf "${INDENT_2}}\n" >> $KEEPALIVED_CONF
;;
MISC_CHECK)
printf "${INDENT_2}${check} {\n" >> $KEEPALIVED_CONF
print_elems_indent $1 $INDENT_3 misc_path
printf "${INDENT_2}}\n" >> $KEEPALIVED_CONF
;;
HTTP_GET | SSL_GET)
printf "${INDENT_2}${check} {\n" >> $KEEPALIVED_CONF
print_elems_indent $1 $INDENT_3 connect_timeout \
connect_port nb_get_retry delay_before_retry
# Handle url list
config_list_foreach $1 url url_list
printf "${INDENT_2}}\n" >> $KEEPALIVED_CONF
;;
esac
printf "${INDENT_1}}\n" >> $KEEPALIVED_CONF
}
}
real_server_list() {
config_foreach real_server real_server "$1"
}
virtual_server() {
local enabled ipaddr port lb_algo sorry_server_ip sorry_server_port
config_get_bool enabled $1 enabled 1
[ "$enabled" -eq 1 ] || return 0
config_get ipaddr $1 ipaddr
[ -z "$ipaddr" ] && return 0
config_get port $1 port
[ -z "$port" ] && return 0
config_section_open "virtual_server" "$ipaddr $port"
print_elems_indent $1 $INDENT_1 fwmark delay_loop \
lb_kind persistence_timeout persistence_granularity \
virtualhost protocol
config_get lb_algo $1 lb_algo
[ -z "$lb_algo" ] && lb_algo="rr"
modprobe ip_vs_${lb_algo} 2>&1 1>/dev/null
printf "${INDENT_1}lb_algo ${lb_algo}\n" >> $KEEPALIVED_CONF
config_get sorry_server_ip $1 sorry_server_ip
config_get sorry_server_port $1 sorry_server_port
[ -n "$sorry_server_ip" -a -n "$sorry_server_port" ] && {
printf "${INDENT_1}sorry_server $sorry_server_ip $sorry_server_port\n" >> $KEEPALIVED_CONF
}
# Handle real_server list
config_list_foreach $1 real_server real_server_list
config_section_close
}
process_config() { process_config() {
local alt_config_file local alt_config_file
@ -401,6 +510,7 @@ process_config() {
config_foreach_wrapper vrrp_script config_foreach_wrapper vrrp_script
config_foreach_wrapper vrrp_sync_group config_foreach_wrapper vrrp_sync_group
config_foreach_wrapper vrrp_instance config_foreach_wrapper vrrp_instance
config_foreach_wrapper virtual_server
return 0 return 0
} }


Loading…
Cancel
Save