Skip to content

Commit

Permalink
tunspace: support for direct uplink interface usage
Browse files Browse the repository at this point in the history
  • Loading branch information
pktpls committed Sep 20, 2024
1 parent 91b007a commit e95ce8d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions locations/pktplsmobil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ networks:
untagged: true
ifname: wwan0
role: uplink
uplink_mode: direct
wwan:
proto: qmi
device: /dev/cdc-wdm0
Expand Down
4 changes: 2 additions & 2 deletions roles/cfg_openwrt/templates/common/config/network.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
5 changes: 4 additions & 1 deletion roles/cfg_openwrt/templates/corerouter/config/tunspace.j2
Original file line number Diff line number Diff line change
@@ -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 %}
Expand Down

0 comments on commit e95ce8d

Please sign in to comment.