5 # shellcheck disable=SC2034
6 # Used in expected output
7 service_name
="per_ip_routing"
9 setup_script_options
<<EOF
10 CTDB_PER_IP_ROUTING_CONF="${CTDB_BASE}/policy_routing"
11 CTDB_PER_IP_ROUTING_RULE_PREF=100
12 CTDB_PER_IP_ROUTING_TABLE_ID_LOW=1000
13 CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=2000
16 # Tests need to create and populate this file
17 rm -f "$CTDB_PER_IP_ROUTING_CONF"
20 # Create policy routing configuration in $CTDB_PER_IP_ROUTING_CONF.
21 # $1 is the number of assigned IPs to use (<num>, all), defaulting to
22 # 1. If $2 is "default" then a default route is also added.
23 create_policy_routing_config
()
26 _should_add_default
="$2"
28 ctdb_get_my_public_addresses |
29 if [ "$_num_ips" = "all" ]; then
37 while read -r _dev _ip _bits
; do
38 _net
=$
(ipv4_host_addr_to_net
"$_ip" "$_bits")
39 _gw
="${_net%.*}.254" # a dumb, calculated default
43 if [ "$_should_add_default" = "default" ]; then
44 echo "$_ip 0.0.0.0/0 $_gw"
46 done >"$CTDB_PER_IP_ROUTING_CONF"