]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: tunnel: Add support for GRETAP tunnels. (#34)
authorMaximilian Wilhelm <max@sdn.clinic>
Tue, 24 Oct 2017 18:42:10 +0000 (20:42 +0200)
committerJulien Fortin <julien@cumulusnetworks.com>
Thu, 13 Dec 2018 22:42:35 +0000 (14:42 -0800)
This commit adds support to configure and check gretap tunnels. An example
  configuration could look like this:

    iface tap0 inet tunnel
        mode gretap
        local 10.132.255.3
        endpoint 10.132.255.1
        ttl 64
        mtu 1400
        tunnel-physdev eth0
        #
        address 10.10.0.1/2

  ifup will happily configure the interface (which it does even without this
  patch) and ifquery now can successfully validate the configure interface:

    cr03.in.ffho.net:~# ifquery -c tap0
    iface tap0 inet tunnel                   [[ OK ]]
        tunnel-physdev eth0                  [[ OK ]]
        endpoint 10.132.255.1                [[ OK ]]
        local 10.132.255.3                   [[ OK ]]
        mode gretap                          [[ OK ]]
        ttl 64                               [[ OK ]]
        mtu 1400                             [[ OK ]]
        address 10.10.0.1/24                 [[ OK ]]

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
ifupdown2/addons/tunnel.py
ifupdown2/ifupdownaddons/LinkUtils.py

index 9ea3ea4d38a8255d1c412676b71a5e51a12add1d..56182e44e3c0c109ab6a9b8167284f225b0ed191 100644 (file)
@@ -14,11 +14,11 @@ import logging
 # TODO: Add checks for ipip tunnels.
 #
 class tunnel (moduleBase):
-    _modinfo = { 'mhelp' : 'create/configure GRE/IPIP/SIT tunnel interfaces',
+    _modinfo = { 'mhelp' : 'create/configure GRE/IPIP/SIT and GRETAP tunnel interfaces',
                  'attrs' : {
                    'mode' :
                         { 'help' : 'type of tunnel as in \'ip link\' command.',
-                          'validvals' : ['gre', 'ipip', 'sit'],
+                          'validvals' : ['gre', 'gretap', 'ipip', 'sit'],
                           'required' : True,
                           'example' : ['mode gre']},
                    'local' :
index 9afb11d4a7afbba4862b3e2fa7384c1bfa19e639..70f1255f38a00f91a89621e42adc5735ce1de9db 100644 (file)
@@ -528,14 +528,14 @@ class LinkUtils(utilsBase):
                         linkattrs['state'] = citems[i + 1]
                     elif citems[i] == 'link/ether':
                         linkattrs['hwaddress'] = citems[i + 1]
-                    elif citems[i] in [ 'link/gre', 'link/sit' ]:
+                    elif citems[i] in ['link/gre', 'link/sit', 'gretap']:
                         linkattrs['kind'] = 'tunnel'
-                        tunattrs = {'mode' : citems[i].split ('/')[1],
+                        tunattrs = {'mode': citems[i].split('/')[-1],
                                     'endpoint' : None,
                                     'local' : None,
                                     'ttl' : None,
                                     'physdev' : None}
-                        for j in range(i + 2, len(citems)):
+                        for j in range(i, len(citems)):
                             if citems[j] == 'local':
                                 tunattrs['local'] = citems[j + 1]
                             elif citems[j] == 'remote':