Skip to content

Commit

Permalink
[feature] Added support for DSA #195
Browse files Browse the repository at this point in the history
- Added VLAN 802.1q and VLAN 802.1ad interfaces

Closes #195
  • Loading branch information
pandafy authored Nov 4, 2024
1 parent 1ddddcf commit f5115c6
Show file tree
Hide file tree
Showing 6 changed files with 816 additions and 54 deletions.
223 changes: 223 additions & 0 deletions docs/source/backends/openwrt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,42 @@ key name type default allowed values
``max_age`` integer ``20`` timeout in seconds until
topology updates on link
loss
``vlan_filtering`` list ``[]``` a list of ``dict ({})``
defining VLANs for the
bridge

Refer to the :ref:`VLAN
options table
<bridge_vlan_options>` below
for a list of available
options.
=========================== ======= ========= ============================

.. _bridge_vlan_options:

VLAN options:

========= ======= =======================================================
key name type allowed values
========= ======= =======================================================
``vlan`` integer VLAN ID
``ports`` list A list of ``dict`` defining interfaces participating in
the VLAN

=============== ======= ===============================
key name type allowed values
=============== ======= ===============================
``ifname`` string interface name (this interface
should be a bridge member)
``tagging`` string whether the port is tagged
(``t``) or untagged (``u``)
``primary_vid`` boolean whether the current VLAN should
be used for all untagged
incoming traffic on this
interface
=============== ======= ===============================
========= ======= =======================================================

Bridge interface example
~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -700,6 +734,89 @@ Will be rendered as follows:
option netmask '255.255.255.0'
option proto 'static'

Using VLAN Filtering on a Bridge
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following *configuration dictionary*:

.. code-block:: python
{
"interfaces": [
{
"type": "bridge",
"bridge_members": ["lan1", "lan2", "lan3"],
"name": "br-lan",
"vlan_filtering": [
{
"vlan": 1,
"ports": [
{
"ifname": "lan1",
"tagging": "t",
"primary_vid": True,
},
{"ifname": "lan2", "tagging": "t"},
],
},
{
"vlan": 2,
"ports": [
{
"ifname": "lan1",
"tagging": "t",
"primary_vid": False,
},
{
"ifname": "lan3",
"tagging": "u",
"primary_vid": True,
},
],
},
],
}
]
}
Will be rendered as follows:

.. code-block::
package network
config device 'device_br_lan'
option name 'br-lan'
list ports 'lan1'
list ports 'lan2'
list ports 'lan3'
option type 'bridge'
option vlan_filtering '1'
config bridge-vlan 'vlan_br_lan_1'
option device 'br-lan'
list ports 'lan1:t*'
list ports 'lan2:t'
option vlan '1'
config bridge-vlan 'vlan_br_lan_2'
option device 'br-lan'
list ports 'lan1:t'
list ports 'lan3:u*'
option vlan '2'
config interface 'vlan_br_lan_1'
option device 'br-lan.1'
option proto 'none'
config interface 'vlan_br_lan_2'
option device 'br-lan.2'
option proto 'none'
config interface 'br_lan'
option device 'br-lan'
option proto 'none'
Wireless settings
-----------------

Expand Down Expand Up @@ -1712,6 +1829,112 @@ Will be rendered as follows:
option signalrate '5'
option username 'user123'

VLAN 802.1q / VLAN 802.1ad settings
-----------------------------------

.. note::

The configuration setting for **VLAN 802.1q** and **VLAN 802.1ad** are
exactly same, except the ``type`` setting. Hence, the documentation
only explains **VLAN 802.1q**.

Interfaces of type ``vlan_8021q`` contain a few options that are specific
to VLAN 802.1q interfaces.

These are the ``OpenWrt`` backend NetJSON extensions for VLAN 802.1q
interfaces:

======================= ======= ============== ===========================
key name type default allowed values
======================= ======= ============== ===========================
``type`` string ``vlan_8021q`` type of interface
(``vlan_8021ad`` for VLAN
802.1ad)
``vid`` integer empty VLAN ID
``ingress_qos_mapping`` string empty Defines a mapping of VLAN
header priority to the
Linux internal packet
priority on incoming frames
``egress_qos_mapping`` string empty Defines a mapping of Linux
internal packet priority to
VLAN header priority but
for outgoing frames
======================= ======= ============== ===========================

VLAN 802.1q example
~~~~~~~~~~~~~~~~~~~

The following *configuration dictionary*:

.. code-block:: python
{
"interfaces": [
{
"type": "8021q",
"vid": 1,
"name": "br-lan",
"mac": "E8:6A:64:3E:4A:3A",
"mtu": 1500,
"ingress_qos_mapping": ["1:1"],
"egress_qos_mapping": ["2:2"],
}
]
}
Will be rendered as follows:

.. code-block:: text
package network
config device 'device_br_lan_1'
list egress_qos_mapping '2:2'
option ifname 'br-lan'
list ingress_qos_mapping '1:1'
option macaddr 'E8:6A:64:3E:4A:3A'
option mtu '1500'
option name 'br-lan.1'
option type '8021q'
option vid '1'
config interface 'vlan_br_lan_1'
option device 'br-lan.1'
option proto 'none'
VLAN 802.1ad example
~~~~~~~~~~~~~~~~~~~~

The following *configuration dictionary*:

.. code-block:: python
{
"interfaces": [
{
"type": "8021ad",
"vid": 6,
"name": "eth0",
}
]
}
Will be rendered as follows:

.. code-block:: text
package network
config device 'device_eth0_6'
option ifname 'eth0'
option name 'eth0.6'
option type '8021ad'
option vid '6'
config interface 'vlan_eth0_6'
option device 'eth0.6'
option proto 'none'
Radio settings
--------------

Expand Down
Loading

0 comments on commit f5115c6

Please sign in to comment.