diff --git a/heartbeat/IPaddr2 b/heartbeat/IPaddr2 index 230ac853c..acf894231 100755 --- a/heartbeat/IPaddr2 +++ b/heartbeat/IPaddr2 @@ -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 @@ -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}} ####################################################################### @@ -471,6 +473,14 @@ Consider the resource failed if the interface has status DOWN or LOWERLAYERDOWN. Consider the resource failed if the interface has status DOWN or LOWERLAYERDOWN + + + +Kill connections using 'ss -K src IP' before and after deleting interface + +Kill connections before remove ip + + @@ -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 # @@ -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 @@ -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 }