Hello everyone, please take a look at the attached patch. This is for a rather odd use case where applications need to talk to floating IP addresses running locally (that is, the applications is running on the same host that currently holds the IP).
In that case, Linux seems to take a sometimes undesirable shortcut which, for those locally-running applications only, seems to make the IP address disappear "late", with unwanted side effects. Flushing the kernel routing table when unconfiguring the address fixes the issue. The patch is rather trivial and adds an new boolean "flush_route" parameter which when set, flushes the kernel routing table after the IP address is removed. The kernel then repopulates the routing table immediately. The parameter is obviously off by default. Feedback is appreciated. If no-one hollers, I'd push this some time early next week. Cheers, Florian >From florian.h...@linbit.com Thu Sep 30 18:22:18 2010 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [PATCH 1 of 1] Medium: IPaddr2: optionally flush kernel routing table on interface stop X-Mercurial-Node: 149dda4775a9928a5cc4ac5ebf501982822ba474 Message-Id: <149dda4775a9928a5cc4.1285863...@gluehwein.linbit> In-Reply-To: <patchbomb.1285863...@gluehwein.linbit> References: <patchbomb.1285863...@gluehwein.linbit> User-Agent: Mercurial-patchbomb/1.4.3 Date: Thu, 30 Sep 2010 18:22:17 +0200 From: Florian Haas <florian.h...@linbit.com> To: linux-ha-dev@lists.linux-ha.org Bcc: Florian Haas <florian.h...@linbit.com> # HG changeset patch # User Florian Haas <florian.h...@linbit.com> # Date 1285854769 -7200 # Node ID 149dda4775a9928a5cc4ac5ebf501982822ba474 # Parent a401cc017298e50ec34b8d0f8b47ca15ed39bfbf Medium: IPaddr2: optionally flush kernel routing table on interface stop diff -r a401cc017298 -r 149dda4775a9 heartbeat/IPaddr2 --- a/heartbeat/IPaddr2 Thu Sep 30 02:48:54 2010 +0200 +++ b/heartbeat/IPaddr2 Thu Sep 30 15:52:49 2010 +0200 @@ -231,8 +231,26 @@ <content type="string" default="ffffffffffff"/> </parameter> +<parameter name="flush_route"> +<longdesc lang="en"> +Flush the routing table on stop. This is for +applications which use the cluster IP address +and which run on the same physical host that the +IP address lives on. The Linux kernel may force that +application to take a shortcut to the local loopback +interface, instead of the interface the address +is really bound to. Under those circumstances, an +application may, somewhat unexpectedly, continue +to use connections for some time even after the +IP address is deconfigured. Set this parameter in +order to immediately disable said shortcut when the +IP address goes away. +</longdesc> +<shortdesc lang="en">Flush kernel routing table on stop</shortdesc> +<content type="boolean" default="false"/> +</parameter> + </parameters> - <actions> <action name="start" timeout="20s" /> <action name="stop" timeout="20s" /> @@ -396,9 +414,19 @@ CMD="$IP2UTIL -f inet addr delete $ipaddr/$netmask dev $iface" - ocf_log info "$CMD" - $CMD || - return $OCF_ERR_GENERIC + ocf_run $CMD || return $OCF_ERR_GENERIC + + if ocf_is_true $OCF_RESKEY_flush_route; then + local flush_semaphore + flush_semaphore=/proc/sys/net/ipv4/route/flush + if [ -e $flush_semaphore ]; then + ocf_log info "Flushing kernel routing table" + echo 1 > $flush_semaphore + else + ocf_log warn "Configured to flush kernel routing table on stop, but $flush_semaphore is not available" + fi + fi + return $OCF_SUCCESS } _______________________________________________________ Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/