From e95ce8d0f0bfcf2ae7795c1c5a85858ae6aeda1e Mon Sep 17 00:00:00 2001 From: Packet Please Date: Fri, 20 Sep 2024 02:27:04 +0200 Subject: [PATCH] tunspace: support for direct uplink interface usage --- locations/pktplsmobil.yml | 1 + roles/cfg_openwrt/templates/common/config/network.j2 | 4 ++-- roles/cfg_openwrt/templates/corerouter/config/tunspace.j2 | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/locations/pktplsmobil.yml b/locations/pktplsmobil.yml index 6beb2dacd..b81d2f041 100644 --- a/locations/pktplsmobil.yml +++ b/locations/pktplsmobil.yml @@ -63,6 +63,7 @@ networks: untagged: true ifname: wwan0 role: uplink + uplink_mode: direct wwan: proto: qmi device: /dev/cdc-wdm0 diff --git a/roles/cfg_openwrt/templates/common/config/network.j2 b/roles/cfg_openwrt/templates/common/config/network.j2 index 0d312f831..653c6eebd 100644 --- a/roles/cfg_openwrt/templates/common/config/network.j2 +++ b/roles/cfg_openwrt/templates/common/config/network.j2 @@ -32,14 +32,14 @@ config interface 'loopback' {% set port = int_port + ('' if untagged else '.' + vid) %} {% endif %} {% set bridge_name = 'br-' + name %} - {% set bridge_needed = name in wifi_networks or network.get('mesh_ap') == inventory_hostname or (role == 'corerouter' and 'tunnel_wan_ip' in network) or (role == 'corerouter' and network['role'] == 'uplink') %} + {% set bridge_needed = name in wifi_networks or network.get('mesh_ap') == inventory_hostname or (role == 'corerouter' and 'tunnel_wan_ip' in network) or (role == 'corerouter' and network['role'] == 'uplink' and network.get('uplink_mode') != 'direct') %} {% set port_needed = not (role == 'corerouter' and network.get('mesh_ap') == inventory_hostname) %} {%- if (role == 'corerouter' and network['role'] == 'mesh') or ('assignments' in network and inventory_hostname in network['assignments']) or name in wifi_networks or network.get('mesh_ap') == inventory_hostname or (role == 'corerouter' and 'tunnel_wan_ip' in network) - or (role == 'corerouter' and network['role'] == 'uplink') + or (role == 'corerouter' and network['role'] == 'uplink' and network.get('uplink_mode') != 'direct') %} config interface '{{ name }}' {% if port_needed %} diff --git a/roles/cfg_openwrt/templates/corerouter/config/tunspace.j2 b/roles/cfg_openwrt/templates/corerouter/config/tunspace.j2 index f8422d092..0a6547b0b 100644 --- a/roles/cfg_openwrt/templates/corerouter/config/tunspace.j2 +++ b/roles/cfg_openwrt/templates/corerouter/config/tunspace.j2 @@ -1,10 +1,13 @@ #jinja2: trim_blocks: "true", lstrip_blocks: "true" {% for uplink in networks | selectattr('role', 'equalto', 'uplink') %} {% set name = uplink['name'] if 'name' in uplink else 'uplink' %} + {% set mode = uplink['uplink_mode'] if 'uplink_mode' in uplink else 'bridge' %} + {% set ifname = uplink['ifname'] if mode == 'direct' else 'br-'+name %} config tunspace "tunspace" option uplink_netns "{{ name }}" - option uplink_ifname "br-{{ name }}" + option uplink_ifname "{{ ifname }}" + option uplink_mode "{{ mode }}" option maintenance_interval 60 option debug 1 {% endfor %}