Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nat: T4367: Move nat rules from /tmp to /run/nftables_nat.conf #1505

Merged
merged 1 commit into from Aug 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/conf_mode/nat.py
Expand Up @@ -44,7 +44,7 @@
else:
k_mod = ['nft_nat', 'nft_chain_nat_ipv4']

nftables_nat_config = '/tmp/vyos-nat-rules.nft'
nftables_nat_config = '/run/nftables_nat.conf'

def get_handler(json, chain, target):
""" Get nftable rule handler number of given chain/target combination.
Expand Down Expand Up @@ -186,16 +186,12 @@ def generate(nat):
# dry-run newly generated configuration
tmp = run(f'nft -c -f {nftables_nat_config}')
if tmp > 0:
if os.path.exists(nftables_nat_config):
os.unlink(nftables_nat_config)
raise ConfigError('Configuration file errors encountered!')

return None

def apply(nat):
cmd(f'nft -f {nftables_nat_config}')
if os.path.isfile(nftables_nat_config):
os.unlink(nftables_nat_config)

return None

Expand Down