Modify

Opened 6 years ago

Closed 6 years ago

#7268 closed defect (invalid)

/config/network is not processed properly when using pvid, also swconfig misconfigures vlan/pvid port assignment

Reported by: hvandrie Owned by: juhosg
Priority: normal Milestone: Backfire 10.03.1
Component: base system Version: Backfire 10.03
Keywords: config/network, vlan, pvid Cc:

Description (last modified by jow)

Whenever you want to do port based vlan, this is a pain in the @ss with openwrt! Network config file is not parsed properly and messes up configuration, and swconfig does not set (un)tagging properly on ports.

Example, only way to set a vlan to an pvid on a port using /etc/config/network config file is to use:

config 'switch_vlan'
option 'device' 'rtl8366rb'
option 'vlan' '4'
option 'pvid' '4'
option 'ports' '0t 1 5t'

However, the above desired configuration is interpreted differently by the system:
===================================================================

VLAN 2:
        info: VLAN 2: Ports: 1
                 vid     prio    member          untag   fid
        MC:     4        0       0x0023          0x001f          0
        4K:     4                0x0023          0x001f          0
        ports: 0 1 5t

VLAN 4:
        info: VLAN 4: Ports:
                 vid     prio    member          untag   fid
        MC:     0        0       0x0023          0x0002          0
        4K:     0                0x0025          0x0000          0
        ports: 0t 1 5t

===================================================================
VLAN 2 gets the pvid set, but incorrect tagging is set on ports!
VLAN 4 gets the ports set, however the pvid is not set!

swconfig is not able to remove ports properly from the VLAN's, causing individual ports to be assigned to multiple pvid's or tagging is set incorrectly.

Correct operation would be that following /config/network settings would be configured during startup:

===================================================================

config 'switch_vlan'
  option 'device' 'rtl8366rb'
  option 'vlan' '2'
  option 'pvid' '4'
  option 'ports' '0t 1 5t'

===================================================================

Where VLAN 2 is assigned to ports '0t 1 5t' with pvid '4'.

Attachments (0)

Change History (9)

comment:1 Changed 6 years ago by hvandrie

I found a workaround to the problem. The workaround is quite simple: Configure each VLAN, also VLAN's you don't use. Set a pvid according to the VLAN number and set ports as you like. Except for the 'obsolete' VLAN's, you have to set the 'obsolete' VLAN's ports assignment to '0t 5t'.

VLAN's are configured sequentially for pvid assignment, only not port assignment itself. However, a VLAN is only fully configured when you assign at least 2 ports to it! Therefor, I choose to assign port 0 (my wan port which acts as an Trunk port) and port 5 (which acts as CPU / Internal port): '0t 5t'.

Configuration below shows example of how to properly configure VLAN's with proper pvid and port assignment at startup:

config 'switch'

option 'name' 'rtl8366rb'
option 'reset' '1'
option 'enable_vlan' '1'

config 'switch_vlan'

option 'device' 'rtl8366rb'
option 'vlan' '1'
option 'ports' '3 4 5t'

config 'switch_vlan'

option 'device' 'rtl8366rb'
option 'vlan' '2'
option 'ports' '0t 5t'

config 'switch_vlan'

option 'device' 'rtl8366rb'
option 'vlan' '3'
option 'ports' '0t 5t'

config 'switch_vlan'

option 'device' 'rtl8366rb'
option 'vlan' '4'
option 'pvid' '4'
option 'ports' '0t 1'

config 'switch_vlan'

option 'device' 'rtl8366rb'
option 'vlan' '5'
option 'ports' '0t 5t'

config 'switch_vlan'

option 'device' 'rtl8366rb'
option 'vlan' '6'
option 'pvid' '6'
option 'ports' '0t 5t'

config 'switch_vlan'

option 'device' 'rtl8366rb'
option 'vlan' '7'
option 'pvid' '7'
option 'ports' '0t 2t 5t'

comment:2 Changed 6 years ago by jow

  • Description modified (diff)
  • Owner changed from developers to nbd
  • Status changed from new to assigned

comment:3 Changed 6 years ago by gk

No idea if it's the same bug or other in the same code but 4k vlans (so vlan numbers between 16 and 4096) don't seem to work.

I am not sure if it's swconfig bug or kernel driver bug but code exists in the kernel to handle it and the hardware is capable of doing it so there should be no problem.

I am not experienced enought to easily debug and fix such bugs in kernel drivers or their userspace interface but I am willing to test any patched images.

comment:4 Changed 6 years ago by nbd

  • Owner changed from nbd to juhosg

comment:5 Changed 6 years ago by thomask <thomas.krepkowski@…>

I think there is no error but you mixed up what options belong to what section.

In config 'switch_vlan' you configure everything what comes to a vlan:

  • option 'vlan' '3' i.e. vlan with tag 3
  • option 'ports' '0 1 2' i.e. ports 0, 1 and 2 belong to vlan 3

I makes no sense to set a pvid to a vlan so the option 'pvid' makes no sense in a config 'switch_vlan' section.

Instead a pvid should be set on a port of the switch, to set what tag an incoming untagged packet gets.
So to set pvid 2 on port 4:

config 'switch_port'

option 'port' '4'
option 'pvid' '2'

But I had to admit, that it took me a while to get the idea to use config 'switch_port'. I have not seen it anywhere before in the documentation.

comment:6 Changed 6 years ago by gk

Not sure what pvid is but there are some problems when previous VLANs are not defined.

Also there are problems with VLANs with id > 16.

Also please check this out: https://forum.openwrt.org/viewtopic.php?pid=107050#p107050 Somebody claims there that pvid is the VLAN id.

comment:7 Changed 6 years ago by KanjiMonster

Actually 'pvid' is used for two different things in the switch configuration:

If used as an option for a "switch_port", this is the "Port VID". All untagged frames received by the port get this VID assigned.

If used as an option for a "switch_vlan", this is used to configure the VID for this VLAN. This is for switches that do support all possible VIDs, but only a certain number of simultaneous VLAN entries. If not specified, the "pvid" defaults to the "vlan" number.

E.g. if you want to use two vlans, one with VID 2 and one with VID 2000, but your switch has only 16 entries, then you could change the VID of the third entry to 2000 with the "pvid" option.

comment:8 Changed 6 years ago by gk

Ah, maybe that solves the problem. I will check.

Please, please, please - document it with details in the openwrt configuration, preferably with some examples.

comment:9 Changed 6 years ago by jow

  • Resolution set to invalid
  • Status changed from assigned to closed

-ETIMEOUT

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.