Skip to content

Fix: preserve banip blocklist mtime when dedup content unchanged#1708

Closed
gsanchietti wants to merge 1 commit into
mainfrom
fix-banip-1146
Closed

Fix: preserve banip blocklist mtime when dedup content unchanged#1708
gsanchietti wants to merge 1 commit into
mainfrom
fix-banip-1146

Conversation

@gsanchietti
Copy link
Copy Markdown
Member

Summary

This PR addresses the immediate cause of non-deterministic backup generation: banip blocklist timestamp issue.

1. banip blocklist timestamp (IMPLEMENTED)

When ban_deduplicate=1 (the default), banip unconditionally rewrites the blocklist file even when content is unchanged. This updates the mtime and causes backup differences. Fixed by wrapping the write with a cmp -s check to only write when content actually changes.

Files changed:

  • packages/banip/files/banip-functions.sh — IPv4 and IPv6 dedup paths now use cmp -s check
  • packages/banip/Makefile — PKG_RELEASE 3→4

2. sysupgrade disable_services and installed_packages timestamps (DEFERRED)

OpenWrt's sysupgrade creates /etc/uci-defaults/10_disable_services and /etc/backup/installed_packages.txt with the current timestamp. This requires patching upstream OpenWrt base-files which is non-trivial for the v24.10.5 release. This will be addressed as part of upgrading to OpenWrt v25 which includes the upstream fix (OpenWrt PR #16146).

Related issue

#1146

How to test

  1. Deploy the fixed packages
  2. Create two backups on consecutive days: sysupgrade -k -b /tmp/backup1.tar.gz and sysupgrade -k -b /tmp/backup2.tar.gz
  3. Compare: md5sum /tmp/backup?.tar.gz — they should now be more consistent (banip blocklist won't cause differences)
  4. Verify banip still functions normally when content actually changes
  5. Verify sysupgrade backup/restore still works correctly

Wrap the blocklist file write in the IPv4 and IPv6 deduplicate paths
with a cmp -s check. This prevents unnecessary file mtime updates when
deduplication removes no entries.

Since banip.blocklist is a conffile included in sysupgrade backups, the
unconditional writes caused the backup tar to differ every night even
when actual configuration was unchanged.

With this fix, the file is only written when content actually changes,
preserving mtime and preventing spurious backup differences.

Closes #1146
@gsanchietti
Copy link
Copy Markdown
Member Author

Closing in favor of #1709 which targets the correct branch (nethsecurity-8.8 as requested)

@gsanchietti gsanchietti closed this Jun 4, 2026
@gsanchietti gsanchietti deleted the fix-banip-1146 branch June 5, 2026 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant