HEX
Server: Apache/2.4.63 (Unix)
System: Linux TOMS-220NAS 4.4.302+ #86009 SMP Wed Nov 26 18:19:17 CST 2025 x86_64
User: flavio87 (1026)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: //proc/25637/root/bin/iptables-restore
#!/bin/sh
# Copyright (c) 2000-2016 Synology Inc. All rights reserved.
#
# A iptables-restore wrapper that aims to replace with original iptables-restore
# This wrapper will excute the orginal iptables-restores and retry when EAGAIN is received

RETRY_TIMES=5
RETRY_INTERVAL_MIN_MSECS=1000000
RETRY_INTERVAL_MAX_MSECS=3000000
PIPE_INFO=""

if [ -e "/proc/$$/fd/0" ] && grep -sq '^flags.*[02]$' "/proc/$$/fdinfo/0" && [ ! -t 0 ]; then
	while read -r line; do
		PIPE_INFO=$(printf "%s\n%s" "${PIPE_INFO}" "${line}")
	done
fi

i=0
while [ ${i} -lt ${RETRY_TIMES} ]; do
	if [ -z "${PIPE_INFO}" ];then
		/usr/bin/xtables-legacy-multi iptables-restore "$@"
	else
		echo "${PIPE_INFO}" | /usr/bin/xtables-legacy-multi iptables-restore "$@"
	fi
	originalExitCode=$?
	# Resource problem (resource temporarily unavailable)
	if [ ${originalExitCode} -ne 1 ]; then
		if [ ${originalExitCode} -ne 0 ]; then
			logger -p err -t "iptable_debug" "iptables-restore failed, error=${originalExitCode}"
		fi
		exit ${originalExitCode}
	fi
	usleep $((RETRY_INTERVAL_MIN_MSECS + ((RANDOM * 100) % (RETRY_INTERVAL_MAX_MSECS - RETRY_INTERVAL_MIN_MSECS))))
	i=$((i+1))
	logger -p err -t "iptable_debug" "iptables-restore retry, error=${originalExitCode}, times=$i"
done

exit ${originalExitCode}