diff mbox series

[PATCH-22.03] netifd: bridge: add support option for untagged

Message ID 1662690338-72979-1-git-send-email-lxliu@ikuai8.com
State New
Headers show
Series [PATCH-22.03] netifd: bridge: add support option for untagged | expand

Commit Message

LiXiong Liu Sept. 9, 2022, 2:25 a.m. UTC
### swconfig & DSA VLAN Configuration Comparison
Doesn't just support Tunnk on lan5,
also need access to 192.168.1.1
so must setting untagged at br-lan

#switch-vlan
config switch
	option name 'switch0'
	option reset '1'
	option enable_vlan '1'

config switch_vlan
	option device 'switch0'
	option vlan '0'
	option vid '0'
	option ports '2 3 5 6'

config switch_vlan
	option device 'switch0'
	option vlan '100'
	option vid '100'
	option ports '0 1 4t'


#bridge-vlan
config interface 'lan'
	option device 'br-lan'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
	option ip6assign '60'
config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'
        list ports 'lan5'

config bridge-vlan
	option device 'br-lan'
	option untagged '1'
	option vlan '1'
	list ports 'lan3'
	list ports 'lan4'
	list ports 'lan5'

config bridge-vlan
	option device 'br-lan'
	option vlan '100'
	list ports 'lan1:u*'
	list ports 'lan1:u*'
	list ports 'lan5:t'

#bridge vlan show
port              vlan-id  
lan1              100 PVID Egress Untagged
lan2              100 PVID Egress Untagged
lan3              1 PVID Egress Untagged
lan4              1 PVID Egress Untagged
lan5              1 PVID Egress Untagged
                  10
br-lan            1 PVID Egress Untagged
                  10

Signed-off-by: LiXiong Liu <lxliu@ikuai8.com>
---
 .../patches/100-bridge-vlan-support-untagged.patch | 58 ++++++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 package/network/config/netifd/patches/100-bridge-vlan-support-untagged.patch

Comments

Janusz Dziedzic Sept. 9, 2022, 7:16 a.m. UTC | #1
pt., 9 wrz 2022 o 04:32 LiXiong Liu <lxliu@ikuai8.com> napisał(a):
>
> ### swconfig & DSA VLAN Configuration Comparison
> Doesn't just support Tunnk on lan5,
> also need access to 192.168.1.1
> so must setting untagged at br-lan
>
> #switch-vlan
> config switch
>         option name 'switch0'
>         option reset '1'
>         option enable_vlan '1'
>
> config switch_vlan
>         option device 'switch0'
>         option vlan '0'
>         option vid '0'
>         option ports '2 3 5 6'
>
> config switch_vlan
>         option device 'switch0'
>         option vlan '100'
>         option vid '100'
>         option ports '0 1 4t'
>
>
> #bridge-vlan
> config interface 'lan'
>         option device 'br-lan'
>         option proto 'static'
>         option ipaddr '192.168.1.1'
>         option netmask '255.255.255.0'
>         option ip6assign '60'
> config device
>         option name 'br-lan'
>         option type 'bridge'
>         list ports 'lan1'
>         list ports 'lan2'
>         list ports 'lan3'
>         list ports 'lan4'
>         list ports 'lan5'
>
> config bridge-vlan
>         option device 'br-lan'
>         option untagged '1'
>         option vlan '1'
>         list ports 'lan3'
>         list ports 'lan4'
>         list ports 'lan5'
>
> config bridge-vlan
>         option device 'br-lan'
>         option vlan '100'
>         list ports 'lan1:u*'
>         list ports 'lan1:u*'
>         list ports 'lan5:t'
>
> #bridge vlan show
> port              vlan-id
> lan1              100 PVID Egress Untagged
> lan2              100 PVID Egress Untagged
> lan3              1 PVID Egress Untagged
> lan4              1 PVID Egress Untagged
> lan5              1 PVID Egress Untagged
>                   10
> br-lan            1 PVID Egress Untagged
>                   10
>

We are using smth like this:

config bridge-vlan 'vlan1'
    option name 'vlan1'
    option device 'br-lan'
    option vlan '1'
    option flags 'untagged pvid'
    option local '1'
    list ports 'eth2:*'
    list ports 'eth3:*'

And attached patch - not sure what is best. For sure any option to set
self br config looks good.

BR
Janusz
Andrey Jr. Melnikov Sept. 9, 2022, 10:18 a.m. UTC | #2
Janusz Dziedzic <janusz.dziedzic@gmail.com> wrote:
> [-- text/plain, encoding quoted-printable, charset: UTF-8, 86 lines --]

> pt., 9 wrz 2022 o 04:32 LiXiong Liu <lxliu@ikuai8.com> napisał(a):
> >
> > ### swconfig & DSA VLAN Configuration Comparison

[....]

> > #bridge vlan show
> > port              vlan-id
> > lan1              100 PVID Egress Untagged
> > lan2              100 PVID Egress Untagged
> > lan3              1 PVID Egress Untagged
> > lan4              1 PVID Egress Untagged
> > lan5              1 PVID Egress Untagged
> >                   10
> > br-lan            1 PVID Egress Untagged
> >                   10
> >

> We are using smth like this:

> config bridge-vlan 'vlan1'
>     option name 'vlan1'
>     option device 'br-lan'
>     option vlan '1'
>     option flags 'untagged pvid'
"untagged pvid" is tautology. PVID stands for "Port VLAN ID" - is a default VLAN ID that is assigned to an access
port. Access ports only for untagged (stripped tag) frames. So, drop 'untagged'
from options or 'pvid'.

>     option local '1'
>     list ports 'eth2:*'
>     list ports 'eth3:*'

[...]
Janusz Dziedzic Sept. 9, 2022, 10:39 a.m. UTC | #3
pt., 9 wrz 2022 o 12:30 Andrey Jr. Melnikov <temnota.am@gmail.com> napisał(a):
>
> Janusz Dziedzic <janusz.dziedzic@gmail.com> wrote:
> > [-- text/plain, encoding quoted-printable, charset: UTF-8, 86 lines --]
>
> > pt., 9 wrz 2022 o 04:32 LiXiong Liu <lxliu@ikuai8.com> napisał(a):
> > >
> > > ### swconfig & DSA VLAN Configuration Comparison
>
> [....]
>
> > > #bridge vlan show
> > > port              vlan-id
> > > lan1              100 PVID Egress Untagged
> > > lan2              100 PVID Egress Untagged
> > > lan3              1 PVID Egress Untagged
> > > lan4              1 PVID Egress Untagged
> > > lan5              1 PVID Egress Untagged
> > >                   10
> > > br-lan            1 PVID Egress Untagged
> > >                   10
> > >
>
> > We are using smth like this:
>
> > config bridge-vlan 'vlan1'
> >     option name 'vlan1'
> >     option device 'br-lan'
> >     option vlan '1'
> >     option flags 'untagged pvid'
> "untagged pvid" is tautology. PVID stands for "Port VLAN ID" - is a default VLAN ID that is assigned to an access
> port. Access ports only for untagged (stripped tag) frames. So, drop 'untagged'
> from options or 'pvid'.
>

What in case I would like to have smth like:
br-lan            1 PVID Egress Untagged
                  10 Egress Untagged

bridge vlan <> - tool allow this configuration. Why we should add any
limitation in UCI?

BR
Janusz
> >     option local '1'
> >     list ports 'eth2:*'
> >     list ports 'eth3:*'
>
> [...]
>
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Andrey Jr. Melnikov Sept. 9, 2022, 1:38 p.m. UTC | #4
Janusz Dziedzic <janusz.dziedzic@gmail.com> wrote:
> pt., 9 wrz 2022 o 12:30 Andrey Jr. Melnikov <temnota.am@gmail.com> napisał(a):
> >
> > Janusz Dziedzic <janusz.dziedzic@gmail.com> wrote:
> > > [-- text/plain, encoding quoted-printable, charset: UTF-8, 86 lines --]
> >
> > > pt., 9 wrz 2022 o 04:32 LiXiong Liu <lxliu@ikuai8.com> napisał(a):
> > > >
> > > > ### swconfig & DSA VLAN Configuration Comparison
> >
> > [....]
> >
> > > > #bridge vlan show
> > > > port              vlan-id
> > > > lan1              100 PVID Egress Untagged
> > > > lan2              100 PVID Egress Untagged
> > > > lan3              1 PVID Egress Untagged
> > > > lan4              1 PVID Egress Untagged
> > > > lan5              1 PVID Egress Untagged
> > > >                   10
> > > > br-lan            1 PVID Egress Untagged
> > > >                   10
> > > >
> >
> > > We are using smth like this:
> >
> > > config bridge-vlan 'vlan1'
> > >     option name 'vlan1'
> > >     option device 'br-lan'
> > >     option vlan '1'
> > >     option flags 'untagged pvid'
> > "untagged pvid" is tautology. PVID stands for "Port VLAN ID" - is a default VLAN ID that is assigned to an access
> > port. Access ports only for untagged (stripped tag) frames. So, drop 'untagged'
> > from options or 'pvid'.
> >

> What in case I would like to have smth like:
> br-lan            1 PVID Egress Untagged
>                   10 Egress Untagged

> bridge vlan <> - tool allow this configuration. Why we should add any
> limitation in UCI?

Problem not in configuration, problem in misleading UCI/tools output - PVID *always* untagged.
diff mbox series

Patch

diff --git a/package/network/config/netifd/patches/100-bridge-vlan-support-untagged.patch b/package/network/config/netifd/patches/100-bridge-vlan-support-untagged.patch
new file mode 100644
index 0000000..02485c0
--- /dev/null
+++ b/package/network/config/netifd/patches/100-bridge-vlan-support-untagged.patch
@@ -0,0 +1,58 @@ 
+Support setting untagged at br-lan
+
+--- a/bridge.c	2022-09-08 21:03:06.401331415 +0800
++++ b/bridge.c	2022-09-08 21:13:19.261304451 +0800
+@@ -230,10 +230,15 @@ bridge_set_member_vlan(struct bridge_mem
+ static void
+ bridge_set_local_vlan(struct bridge_state *bst, struct bridge_vlan *vlan, bool add)
+ {
++	unsigned int vflags = BRVLAN_F_SELF;
++
+ 	if (!vlan->local && add)
+ 		return;
+ 
+-	system_bridge_vlan(bst->dev.ifname, vlan->vid, add, BRVLAN_F_SELF);
++	if (vlan->untagged)
++		vflags |= (BRVLAN_F_PVID|BRVLAN_F_UNTAGGED);
++
++	system_bridge_vlan(bst->dev.ifname, vlan->vid, add, vflags);
+ }
+ 
+ static void
+--- a/config.c	2022-09-08 21:03:06.541331409 +0800
++++ b/config.c	2022-09-08 21:05:26.007372217 +0800
+@@ -311,6 +311,7 @@ config_parse_vlan(struct device *dev, st
+ 		BRVLAN_ATTR_LOCAL,
+ 		BRVLAN_ATTR_PORTS,
+ 		BRVLAN_ATTR_ALIAS,
++		BRVLAN_ATTR_UNTAG,
+ 		__BRVLAN_ATTR_MAX,
+ 	};
+ 	static const struct blobmsg_policy vlan_attrs[__BRVLAN_ATTR_MAX] = {
+@@ -318,6 +319,7 @@ config_parse_vlan(struct device *dev, st
+ 		[BRVLAN_ATTR_LOCAL] = { "local", BLOBMSG_TYPE_BOOL },
+ 		[BRVLAN_ATTR_PORTS] = { "ports", BLOBMSG_TYPE_ARRAY },
+ 		[BRVLAN_ATTR_ALIAS] = { "alias", BLOBMSG_TYPE_ARRAY },
++		[BRVLAN_ATTR_UNTAG] = { "untagged", BLOBMSG_TYPE_BOOL },
+ 	};
+ 	static const struct uci_blob_param_info vlan_attr_info[__BRVLAN_ATTR_MAX] = {
+ 		[BRVLAN_ATTR_PORTS] = { .type = BLOBMSG_TYPE_STRING },
+@@ -367,6 +369,8 @@ config_parse_vlan(struct device *dev, st
+ 	vlan->local = true;
+ 	if (tb[BRVLAN_ATTR_LOCAL])
+ 		vlan->local = blobmsg_get_bool(tb[BRVLAN_ATTR_LOCAL]);
++	if (tb[BRVLAN_ATTR_UNTAG])
++		vlan->untagged = blobmsg_get_bool(tb[BRVLAN_ATTR_UNTAG]);
+ 
+ 	vlan->n_ports = n_ports;
+ 	vlan->ports = port = (struct bridge_vlan_port *)&vlan[1];
+--- a/device.h	2022-09-08 21:03:06.401331415 +0800
++++ b/device.h	2022-09-08 21:03:14.833887415 +0800
+@@ -294,6 +294,7 @@ struct bridge_vlan {
+ 	uint16_t vid;
+ 	bool local;
+ 	bool pending;
++	bool untagged;
+ };
+ 
+ extern const struct uci_blob_param_list device_attr_list;