Modify

Opened 2 years ago

Last modified 19 months ago

#20739 new defect

VLAN configuration doesn't work on the web interface (LuCi)

Reported by: achmetow84@… Owned by: developers
Priority: normal Milestone:
Component: packages Version: Trunk
Keywords: Cc:

Description

I have tried to setup the vlan configuration about the web interface without success.

After a look up on the config file (/etc/config/network), I've found that all vlans are set on eth0 instead of eth1. Example: eth0.1, eth0.2 etc.

But "eth0" is the WAN interface and "eth1" is the switch interface.
IMHO all vlans have to be set on eth1 and not to eth0.

After that I have changed this manually in the config file from eth0.1 to eth1.1 and all was fine.

My hardware device:

  • TP-Link Archer C7 (v.2)
  • OpenWrt softare release: 15.05 [1]

[1] https://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/openwrt-15.05-ar71xx-generic-archer-c7-v2-squashfs-factory.bin

Attachments (0)

Change History (7)

comment:1 follow-up: Changed 2 years ago by anonymous

Short description from wiki [1]:

Different routers have different switch layouts, so look at the Wiki for your specific device. The TP-Link Archer C7 has eth0 = WAN, and eth1 = LAN (the 4 switch ports). Port 0 of the switch = eth1 (labelled CPU in Luci), Port 6 = eth0. Port 1 is labelled WAN in Luci. Look at the wiki for your router. Every router is different. The popular TP-Link WDR4300 only has eth0.

[1] http://wiki.openwrt.org/doc/uci/network/switch

comment:2 in reply to: ↑ 1 Changed 2 years ago by GregorHoffleit

Replying to anonymous:

Different routers have different switch layouts, so look at the Wiki for your specific device. The TP-Link Archer C7 has eth0 = WAN, and eth1 = LAN (the 4 switch ports). Port 0 of the switch = eth1 (labelled CPU in Luci), Port 6 = eth0. Port 1 is labelled WAN in Luci. Look at the wiki for your router. Every router is different. The popular TP-Link WDR4300 only has eth0.

That's true.

Still the point is that it is indeed a bug in the web interface:

On an Archer C5/C7, if you go to "Network", "Interfaces", "Interface WAN" and then to the tab "Physical Settings", you're presented with the following options:

  • Ethernet Adapter: "@wan" (wan6)
  • Ethernet Adapter: "eth0" (wan, wan6)
  • VLAN Interface: "eth0.1"
  • VLAN Interface: "eth0.2"
  • Ethernet Switch: "eth1" (lan)
  • Ethernet Adapter: "wlan" (lan)
  • Wireless Network: Master "cola09a" (lan)
  • Wireless Network: Master "cola09" (lan)
  • Custom Interface: [...]

The switch is correctly identified as "eth1", so the VLANs should be "eth1.1" and "eth1.2".

It's a bug that the VLAN interfaces are listed under eth0.

As far as I can see, the problem starts with the output of "swconfig dev switch0 help" on the Archer. The web interface would expect something like "switch0: eth1(Atheros AR8327)...", but on the Archer, the output looks like this:

# swconfig dev switch0 help
switch0: ag71xx-mdio.0(Atheros AR8327), ports: 7 (cpu @ 0), vlans: 128
     --switch
	Attribute 1 (int): enable_vlan (Enable VLAN mode)
	Attribute 2 (none): reset_mibs (Reset all MIB counters)
	Attribute 3 (int): enable_mirror_rx (Enable mirroring of RX packets)
	Attribute 4 (int): enable_mirror_tx (Enable mirroring of TX packets)
	Attribute 5 (int): mirror_monitor_port (Mirror monitor port)
	Attribute 6 (int): mirror_source_port (Mirror source port)
	Attribute 7 (string): arl_table (Get ARL table)
	Attribute 8 (none): apply (Activate changes in the hardware)
	Attribute 9 (none): reset (Reset the switch)
     --vlan
	Attribute 1 (int): vid (VLAN ID (0-4094))
	Attribute 2 (ports): ports (VLAN port mapping)
     --port
	Attribute 1 (none): reset_mib (Reset single port MIB counters)
	Attribute 2 (string): mib (Get port's MIB counters)
	Attribute 3 (int): enable_eee (Enable EEE PHY sleep mode)
	Attribute 4 (int): pvid (Primary VLAN ID)
	Attribute 5 (string): link (Get port link information)

/usr/lib/lua/luci/model/network.lua tries to match against this string, but fails to find a reasonable (i.e. "ethX") value, and therefore uses "eth0" as fallback:

local l                      
for l in utl.execi("swconfig dev %q help 2>/dev/null" % s.device) do
        if not base then
                base = l:match("^%w+: (%w+)")
        end
end                       
if not base or not base:match("^eth%d") then                  
        base = "eth0"                                   
end                                           

That's as far as I get at this moment.

I've not yet understood how the web interface identifies "eth1" as switch in the first place.

Anyhow, I wonder if the output above is a bug in swconfig?

comment:3 Changed 2 years ago by anonymous

I can confirm this behavior, as I ran into the exact same problem. VLANs created through web interface are created as eth0.XXX - but eth1 is the LAN interface. A manual change in the config (if you didn't lock yourself out of the router by this bug!) to eth1.XXX corrects the problem.

The LUA file is the right source of the bug. Changeset 7675 from October 2011 (http://luci.subsignal.org/trac/changeset/7675) introduced the heuristic to infer ethX device name from the 'swconfig dev help' command, with a fallback to eth0.

At the time the lua function get_interfaces (self) line 488 is called, the hash baseof is initialized as an empty hash {} in line 493.

In line 519, we are trying to lookup the base for s.device (which is passed into the function from the ici-lua binding - anything that looks like network.@switch_vlan...") which since we are looking up in an empty hash fails.

Since this check fails in line 520, we attempt to match s.device against the regular expression "etc%d" in line 521. This fails as well, for instance, for me this value is 'network.@switch_vlan[0].device='switch0

Thus, the next call in line 523 is running swconfig dev s.device help. It's attempting to match that output to find ethic. Since that fails too, it sets base to ethic (hard coded) in line 529.

On the Archer C7 the output of swconfig above is: switch0: ag71xx-mdio.0(Atheros AR8327), ports: 7 (cpu @ 0), vlans: 128
ag71xx-mdio.0 is the BUS ID set by the network driver.

This code probably hasn't worked on other devices such as the WDR4300, but incidentally, they used eth0 as the LAN interface, so the hard coded fallback was appropriate.

comment:4 Changed 2 years ago by jow

I added support to LuCI to read the switch netdev from /etc/board.json in https://github.com/openwrt/luci/commit/55f458326dc77dd35dce2c22df2353b2a0192627 and switched the ar71xx to the board detect infrastructure in r47534.

comment:5 Changed 2 years ago by bitbrusher@…

I am affected by this bug as well: RB450G

What is the parameter name to change/add in the config file?
In what section is the change made?

Thank you.

comment:6 Changed 20 months ago by comete@…

Same bug on TP-LINK WR1043ND ver2.1 with Openwrt 15.0.1

VLANs are affected to eth0 (WAN) instead of eth1 (LAN)

comment:7 Changed 19 months ago by rtsm

Same problem on WRT1200AC with Openwrt 15.05.1. Workaround solution here https://forum.openwrt.org/viewtopic.php?pid=332010#p332010

Add Comment

Modify Ticket

Action
as new .
Author


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

 
Note: See TracTickets for help on using tickets.