Skip to content
Open
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
43 changes: 43 additions & 0 deletions heartbeat/IPaddr2
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ OCF_RESKEY_noprefixroute_default="false"
OCF_RESKEY_preferred_lft_default="forever"
OCF_RESKEY_network_namespace_default=""
OCF_RESKEY_check_link_status_default="true"
OCF_RESKEY_kill_connections_on_stop_default="false"

# RHEL specific defaults
if is_redhat_based; then
Expand Down Expand Up @@ -130,6 +131,7 @@ fi
: ${OCF_RESKEY_preferred_lft=${OCF_RESKEY_preferred_lft_default}}
: ${OCF_RESKEY_network_namespace=${OCF_RESKEY_network_namespace_default}}
: ${OCF_RESKEY_check_link_status=${OCF_RESKEY_check_link_status_default}}
: ${OCF_RESKEY_kill_connections_on_stop=${OCF_RESKEY_kill_connections_on_stop_default}}

#######################################################################

Expand Down Expand Up @@ -471,6 +473,14 @@ Consider the resource failed if the interface has status DOWN or LOWERLAYERDOWN.
<shortdesc lang="en">Consider the resource failed if the interface has status DOWN or LOWERLAYERDOWN</shortdesc>
<content type="string" default="${OCF_RESKEY_check_link_status_default}"/>
</parameter>

<parameter name="kill_connections_on_stop">
<longdesc lang="en">
Kill connections using 'ss -K src IP' before and after deleting interface
</longdesc>
<shortdesc lang="en">Kill connections before remove ip</shortdesc>
<content type="string" default="${OCF_RESKEY_kill_connections_on_stop_default}"/>
</parameter>
</parameters>

<actions>
Expand Down Expand Up @@ -666,6 +676,31 @@ find_interface() {
return 0
}

#
# Kill dangling ip connections
#
kill_ip_connections() {
local ss_output ipaddr="$1"

check_binary ss

cmd="ss -Knp src $ipaddr"

ocf_log info "Calling $cmd"

ss_output=`$cmd 2>&1`
rc=$?

if [ $rc -ne 0 ]; then
ocf_log warn "Command $cmd failed (rc = $rc)"
ocf_log error "$ss_output"
else
ocf_log info "$ss_output"
fi

return $OCF_SUCCESS
}

#
# Delete an interface
#
Expand Down Expand Up @@ -1206,6 +1241,11 @@ ip_stop() {
exit $OCF_SUCCESS
fi

if ocf_is_true ${OCF_RESKEY_kill_connections_on_stop}; then
kill_ip_connections $OCF_RESKEY_ip
fi


if [ -n "$IP_CIP" ] && [ $ip_status != "partial2" ]; then
if [ $ip_status = "partial" ]; then
exit $OCF_SUCCESS
Expand Down Expand Up @@ -1240,6 +1280,9 @@ ip_stop() {
restore_loopback "$OCF_RESKEY_ip"
fi
fi
if ocf_is_true ${OCF_RESKEY_kill_connections_on_stop}; then
kill_ip_connections $OCF_RESKEY_ip
fi

exit $OCF_SUCCESS
}
Expand Down