summaryrefslogtreecommitdiff
path: root/data/templates/conntrack
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-04-03 09:16:33 +0200
committerChristian Poessinger <christian@poessinger.com>2022-04-03 09:16:33 +0200
commitd49cd1085f8f2725cf86fd1dc731c1d8a34db796 (patch)
tree773a81a3c86ae7f01cd4053d40f4cf84369d1cdf /data/templates/conntrack
parentcf8a8c0def7e56f1cc47c6c786c72671c32e060b (diff)
downloadvyos-1x-d49cd1085f8f2725cf86fd1dc731c1d8a34db796.tar.gz
vyos-1x-d49cd1085f8f2725cf86fd1dc731c1d8a34db796.zip
conntrack: T4333: migrate to new vyos_defined Jinja2 test
Diffstat (limited to 'data/templates/conntrack')
-rw-r--r--data/templates/conntrack/nftables-ct.tmpl32
-rw-r--r--data/templates/conntrack/sysctl.conf.tmpl2
2 files changed, 15 insertions, 19 deletions
diff --git a/data/templates/conntrack/nftables-ct.tmpl b/data/templates/conntrack/nftables-ct.tmpl
index c0fe5297d..cebc1a54e 100644
--- a/data/templates/conntrack/nftables-ct.tmpl
+++ b/data/templates/conntrack/nftables-ct.tmpl
@@ -10,31 +10,27 @@ flush chain raw {{ nft_ct_timeout_name }}
table raw {
chain {{ nft_ct_ignore_name }} {
-{% if ignore is defined and ignore.rule is defined and ignore.rule is not none %}
+{% if ignore.rule is vyos_defined %}
{% for rule, rule_config in ignore.rule.items() %}
# rule-{{ rule }} {{ '- ' ~ rule_config.description if rule_config.description is defined and rule_config.description is not none }}
{% set nft_command = '' %}
-{% if rule_config.inbound_interface is defined and rule_config.inbound_interface is not none %}
+{% if rule_config.inbound_interface is vyos_defined %}
{% set nft_command = nft_command ~ ' iifname ' ~ rule_config.inbound_interface %}
{% endif %}
-{% if rule_config.protocol is defined and rule_config.protocol is not none %}
+{% if rule_config.protocol is vyos_defined %}
{% set nft_command = nft_command ~ ' ip protocol ' ~ rule_config.protocol %}
{% endif %}
-{% if rule_config.destination is defined and rule_config.destination is not none %}
-{% if rule_config.destination.address is defined and rule_config.destination.address is not none %}
-{% set nft_command = nft_command ~ ' ip daddr ' ~ rule_config.destination.address %}
-{% endif %}
-{% if rule_config.destination.port is defined and rule_config.destination.port is not none %}
-{% set nft_command = nft_command ~ ' ' ~ rule_config.protocol ~ ' dport { ' ~ rule_config.destination.port ~ ' }' %}
-{% endif %}
+{% if rule_config.destination.address is vyos_defined %}
+{% set nft_command = nft_command ~ ' ip daddr ' ~ rule_config.destination.address %}
{% endif %}
-{% if rule_config.source is defined and rule_config.source is not none %}
-{% if rule_config.source.address is defined and rule_config.source.address is not none %}
-{% set nft_command = nft_command ~ ' ip saddr ' ~ rule_config.source.address %}
-{% endif %}
-{% if rule_config.source.port is defined and rule_config.source.port is not none %}
-{% set nft_command = nft_command ~ ' ' ~ rule_config.protocol ~ ' sport { ' ~ rule_config.source.port ~ ' }' %}
-{% endif %}
+{% if rule_config.destination.port is vyos_defined %}
+{% set nft_command = nft_command ~ ' ' ~ rule_config.protocol ~ ' dport { ' ~ rule_config.destination.port ~ ' }' %}
+{% endif %}
+{% if rule_config.source.address is vyos_defined %}
+{% set nft_command = nft_command ~ ' ip saddr ' ~ rule_config.source.address %}
+{% endif %}
+{% if rule_config.source.port is vyos_defined %}
+{% set nft_command = nft_command ~ ' ' ~ rule_config.protocol ~ ' sport { ' ~ rule_config.source.port ~ ' }' %}
{% endif %}
{{ nft_command }} counter notrack comment ignore-{{ rule }}
{% endfor %}
@@ -42,7 +38,7 @@ table raw {
return
}
chain {{ nft_ct_timeout_name }} {
-{% if timeout is defined and timeout.custom is defined and timeout.custom.rule is defined and timeout.custom.rule is not none %}
+{% if timeout.custom.rule is vyos_defined %}
{% for rule, rule_config in timeout.custom.rule.items() %}
# rule-{{ rule }} {{ '- ' ~ rule_config.description if rule_config.description is defined and rule_config.description is not none }}
{% endfor %}
diff --git a/data/templates/conntrack/sysctl.conf.tmpl b/data/templates/conntrack/sysctl.conf.tmpl
index 9e97c3286..075402c04 100644
--- a/data/templates/conntrack/sysctl.conf.tmpl
+++ b/data/templates/conntrack/sysctl.conf.tmpl
@@ -6,7 +6,7 @@ net.netfilter.nf_conntrack_max = {{ table_size }}
net.ipv4.tcp_max_syn_backlog = {{ tcp.half_open_connections }}
-net.netfilter.nf_conntrack_tcp_loose = {{ '1' if tcp.loose == 'enable' else '0' }}
+net.netfilter.nf_conntrack_tcp_loose = {{ '1' if tcp.loose is vyos_defined('enable') else '0' }}
net.netfilter.nf_conntrack_tcp_max_retrans = {{ tcp.max_retrans }}
net.netfilter.nf_conntrack_icmp_timeout = {{ timeout.icmp }}