From: Martin Schwenke Date: Mon, 30 Sep 2024 00:50:00 +0000 (+1000) Subject: ctdb-scripts: Get connections after tickle list X-Git-Tag: samba-4.20.7~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=664538a65fd6e195a07d9b98b85b66e64882ff90;p=thirdparty%2Fsamba.git ctdb-scripts: Get connections after tickle list Running ss to get current connections before running ctdb gettickles means the ss output might be out of date when the 2 lists are compared. Some tickles might have been added after ss was run by some other means (e.g. SMB tickles, added internally) and they would be deleted according to the stale ss output. This isn't currently a problem because update_tickles() is currently only called with port 2049, so all tickles are managed by this code. That will change in a subsequent commit. Changing the order means the reverse problem can occur, where update_tickles() attempts to delete an already deleted tickle. That may happen occasionally but is harmless because it doesn't result in missing information. It (currently) just causes a message to be logged at DEBUG level. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15320 RN: Update CTDB to track all TCP connections to public IP addresses Signed-off-by: Martin Schwenke Reviewed-by: Volker Lendecke Reviewed-by: Jerry Heyman (cherry picked from commit c3695722b6316b624aa6c44cad4f44279303d1b1) --- diff --git a/ctdb/config/functions b/ctdb/config/functions index 521f0cdfacc..7d371e81505 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -1166,6 +1166,14 @@ update_tickles() done <"$CTDB_MY_PUBLIC_IPS_CACHE" _port_filter="sport == :${_port}" + # Record our current tickles in a temporary file + _my_tickles="${tickledir}/${_port}.tickles.$$" + while read -r _i; do + $CTDB -X gettickles "$_i" "$_port" | + awk -F'|' 'NR > 1 { printf "%s:%s %s:%s\n", $2, $3, $4, $5 }' + done <"$CTDB_MY_PUBLIC_IPS_CACHE" | + sort >"$_my_tickles" + # Record connections to our public IPs in a temporary file. # This temporary file is in CTDB's private state directory and # $$ is used to avoid a very rare race involving CTDB's script @@ -1179,14 +1187,6 @@ update_tickles() awk '{print $4, $3}' | sort >"$_my_connections" - # Record our current tickles in a temporary file - _my_tickles="${tickledir}/${_port}.tickles.$$" - while read -r _i; do - $CTDB -X gettickles "$_i" "$_port" | - awk -F'|' 'NR > 1 { printf "%s:%s %s:%s\n", $2, $3, $4, $5 }' - done <"$CTDB_MY_PUBLIC_IPS_CACHE" | - sort >"$_my_tickles" - # Add tickles for connections that we haven't already got tickles for comm -23 "$_my_connections" "$_my_tickles" | $CTDB addtickle