diff options
author | jack9603301 <jack9603301@163.com> | 2021-01-22 13:16:55 +0800 |
---|---|---|
committer | jack9603301 <jack9603301@163.com> | 2021-01-23 21:45:31 +0800 |
commit | d05593e68ff0978c278b13a42f246edcfad3902d (patch) | |
tree | 6f3cb7f58fb796c369f80d7d1bf023001617b5ab /src | |
parent | 88a6a034b1cb6a1a43c689281df92831d82c996c (diff) | |
download | vyos-1x-d05593e68ff0978c278b13a42f246edcfad3902d.tar.gz vyos-1x-d05593e68ff0978c278b13a42f246edcfad3902d.zip |
nptv6: T2518: Optimized implementation
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/nat66.py | 14 | ||||
-rw-r--r-- | src/systemd/ndppd.service | 6 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/conf_mode/nat66.py b/src/conf_mode/nat66.py index a5c74259f..7190961e8 100755 --- a/src/conf_mode/nat66.py +++ b/src/conf_mode/nat66.py @@ -151,10 +151,16 @@ def generate(nat): return None def apply(nat): - cmd(f'{iptables_nat_config}') - cmd('systemctl restart ndppd') - if os.path.isfile(iptables_nat_config): - os.unlink(iptables_nat_config) + if not nat: + return None + else: + cmd(f'{iptables_nat_config}') + if 'deleted' in nat or not dict_search('source.rule', nat): + cmd('systemctl stop ndppd') + else: + cmd('systemctl restart ndppd') + if os.path.isfile(iptables_nat_config): + os.unlink(iptables_nat_config) return None diff --git a/src/systemd/ndppd.service b/src/systemd/ndppd.service index 566172fb0..db471c518 100644 --- a/src/systemd/ndppd.service +++ b/src/systemd/ndppd.service @@ -1,13 +1,13 @@ [Unit] Description=NDP Proxy Daemon -After=network.target vyos-router.service +After=vyos-router.service ConditionPathExists=/run/ndppd/ndppd.conf StartLimitIntervalSec=0 [Service] -ExecStart=/usr/sbin/ndppd -d -p /var/run/ndppd/ndppd.pid -c /var/run/ndppd/ndppd.conf +ExecStart=/usr/sbin/ndppd -d -p /run/ndppd/ndppd.pid -c /run/ndppd/ndppd.conf Type=forking -PIDFile=/var/run/ndppd/ndppd.pid +PIDFile=/run/ndppd/ndppd.pid Restart=on-failure RestartSec=20 |