diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-06-13 20:22:35 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-06-13 20:25:50 +0200 |
commit | 78099bccc510c90ad7cfa5f56475ba024d5d53a7 (patch) | |
tree | edbbdcf8fde3251eef83a2aefb3827532e880a8c /src/conf_mode | |
parent | 5f82e7d92c3d2bf856158067153ccef5e37dc558 (diff) | |
download | vyos-1x-78099bccc510c90ad7cfa5f56475ba024d5d53a7.tar.gz vyos-1x-78099bccc510c90ad7cfa5f56475ba024d5d53a7.zip |
wwan: T3620: auto detect IP protocol based on requested addresses
(cherry picked from commit 1eb6aee88f411127175fdab031d896af1e1adbc3)
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/interfaces-wwan.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/conf_mode/interfaces-wwan.py b/src/conf_mode/interfaces-wwan.py index a477163b9..31c599145 100755 --- a/src/conf_mode/interfaces-wwan.py +++ b/src/conf_mode/interfaces-wwan.py @@ -25,6 +25,7 @@ from vyos.configverify import verify_interface_exists from vyos.configverify import verify_vrf from vyos.ifconfig import WWANIf from vyos.util import cmd +from vyos.util import dict_search from vyos.template import render from vyos import ConfigError from vyos import airbag @@ -65,14 +66,25 @@ def apply(wwan): # we only need the modem number. wwan0 -> 0, wwan1 -> 1 modem = wwan['ifname'].lstrip('wwan') base_cmd = f'mmcli --modem {modem}' + # Number of bearers is limited - always disconnect first + cmd(f'{base_cmd} --simple-disconnect') w = WWANIf(wwan['ifname']) if 'deleted' in wwan or 'disable' in wwan: w.remove() - cmd(f'{base_cmd} --simple-disconnect') return None - options = 'apn=' + wwan['apn'] + ip_type = 'ipv4' + slaac = dict_search('ipv6.address.autoconf', wwan) != None + if 'address' in wwan: + if 'dhcp' in wwan['address'] and ('dhcpv6' in wwan['address'] or slaac): + ip_type = 'ipv4v6' + elif 'dhcpv6' in wwan['address'] or slaac: + ip_type = 'ipv6' + elif 'dhcp' in wwan['address']: + ip_type = 'ipv4' + + options = f'ip-type={ip_type},apn=' + wwan['apn'] if 'authentication' in wwan: options += ',user={user},password={password}'.format(**wwan['authentication']) |