I have an ansible role (historically inherited) to configure nftables for RHEL8, which I have been trying to make sense of. It is copying a systemd file for nftables.service that has a following stanza:
[Service]
Type=oneshot
RemainAfterExit=yes
StandardInput=null
ProtectSystem=full
ProtectHome=true
ExecStart=/sbin/nft -f /etc/sysconfig/nftables.conf
ExecReload=/sbin/nft 'flush ruleset; include "/etc/sysconfig/nftables.conf";'
ExecStop=/sbin/nft flush ruleset
I'm trying to understand the difference between what ExecStart
is doing, vs ExecReload
The execstart seems straightforward enough - its running the config atomically via the -f
flag.
But I dont understand how this is different from ExecReload
. Is /sbin/nft 'flush ruleset; include "/etc/sysconfig/nftables.conf";'
not atomic?
The content of /etc/sysconfig/nftables.conf is as follows:
#!/usr/sbin/nft -f
# clean
flush ruleset
include "/etc/nftables/defines.nft"
table inet filter {
chain global {
# 005 state management
ct state established,related accept
ct state invalid drop
}
include "/etc/nftables/sets_role_haproxy_cvp_apps.nft"
include "/etc/nftables/sets.nft"
include "/etc/nftables/helpers.nft"
include "/etc/nftables/filter-forwared.nft"
include "/etc/nftables/filter-input.nft"
include "/etc/nftables/filter-output.nft"
include "/etc/nftables/input_role_haproxy_cvp_apps.nft"
}
So both ExecStart
and ExecReload
to me looks like doing the same thing - both flushes the ruleset.
The author of the ansible commented that "Reload will avoid to loose Nftables rulebase if an invalid syntax is added". I cant understand though how it is doing this if its flushing the rulesets? Can someone kindly explain?
Thanks J