diff options
author | DmitriyEshenko <dmitriy.eshenko@vyos.io> | 2020-11-25 19:05:47 +0000 |
---|---|---|
committer | DmitriyEshenko <dmitriy.eshenko@vyos.io> | 2020-11-26 14:46:31 +0000 |
commit | 5df05983c663f39953d4779086754416ab94f65f (patch) | |
tree | 928fc04abdd3a48ff61da80f1e7c8717568bf3c7 /src/conf_mode/protocols_igmp.py | |
parent | cf36b7ab1e1eb9d91b0877b55115d9a6ad2f196c (diff) | |
download | vyos-1x-5df05983c663f39953d4779086754416ab94f65f.tar.gz vyos-1x-5df05983c663f39953d4779086754416ab94f65f.zip |
pim: igmp: igmp-proxy: T2744: Add check to prevent pimd and igmp-proxy conflict
Diffstat (limited to 'src/conf_mode/protocols_igmp.py')
-rwxr-xr-x | src/conf_mode/protocols_igmp.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/conf_mode/protocols_igmp.py b/src/conf_mode/protocols_igmp.py index 6f4fc784d..8606e7364 100755 --- a/src/conf_mode/protocols_igmp.py +++ b/src/conf_mode/protocols_igmp.py @@ -21,8 +21,9 @@ from sys import exit from vyos import ConfigError from vyos.config import Config -from vyos.util import call +from vyos.util import call, process_named_running from vyos.template import render +from signal import SIGTERM from vyos import airbag airbag.enable() @@ -36,12 +37,20 @@ def get_config(config=None): conf = Config() igmp_conf = { 'igmp_conf' : False, + 'pim_conf' : False, + 'igmp_proxy_conf' : False, 'old_ifaces' : {}, 'ifaces' : {} } if not (conf.exists('protocols igmp') or conf.exists_effective('protocols igmp')): return None + if conf.exists('protocols igmp-proxy'): + igmp_conf['igmp_proxy_conf'] = True + + if conf.exists('protocols pim'): + igmp_conf['pim_conf'] = True + if conf.exists('protocols igmp'): igmp_conf['igmp_conf'] = True @@ -79,6 +88,10 @@ def verify(igmp): return None if igmp['igmp_conf']: + # Check conflict with IGMP-Proxy + if igmp['igmp_proxy_conf']: + raise ConfigError(f"IGMP proxy and PIM cannot be both configured at the same time") + # Check interfaces if not igmp['ifaces']: raise ConfigError(f"IGMP require defined interfaces!") @@ -99,9 +112,16 @@ def apply(igmp): if igmp is None: return None - if os.path.exists(config_file): - call(f'vtysh -d pimd -f {config_file}') - os.remove(config_file) + pim_pid = process_named_running('pimd') + if igmp['igmp_conf'] or igmp['pim_conf']: + if not pim_pid: + call(f'pimd -d -F traditional --daemon -A 127.0.0.1') + + if os.path.exists(config_file): + call(f'vtysh -d pimd -f {config_file}') + os.remove(config_file) + elif pim_pid: + os.kill(int(pim_pid), SIGTERM) return None |