Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#3879 - Incorrect switch config for TP-Link Archer C2 AC750 #8871

Open
openwrt-bot opened this issue Jun 15, 2021 · 11 comments
Open

FS#3879 - Incorrect switch config for TP-Link Archer C2 AC750 #8871

openwrt-bot opened this issue Jun 15, 2021 · 11 comments
Labels
flyspray release/21.02 pull request/issue targeted (also) for OpenWrt 21.02 release

Comments

@openwrt-bot
Copy link

cybermaus:

Model TP-Link Archer C2 v1
Architecture MediaTek MT7620A ver:2 eco:5
Firmware Version OpenWrt 21.02.0-rc2 r16122-c2139eef27 / LuCI openwrt-21.02 branch git-21.148.49484-14511e5

The Archer C2 has a little unusual switch setup, in that the SoC itself only has an unused 100Mb switch and instead there is an extra RTL8367B chip. We can only assume TP-Link wanted to make this a 1Gb device, despite using a 100Mb SoC. (and indeed, the 1Gb ports is why I got this particular cheap device)

OpenWRT 19.07.7 handled this beautifully, as it simply did not show the switch0, neither in UCI nor in Luci, though the RTL8367B chip is labeled switch1 in stead of the more usual switch0

When clean upgrading (so removing and rebuilding all config) to 21.02.0-rc2 I noticed that the internal switch was now populated in UCI and displayed in Luci
The Archer C2 does work, switch1 is configured as expected, but the presence of switch0 seems to cause Luci to display an error "Switch switch0 has an unknown topology - the VLAN settings might not be accurate." and further prevents Luci from updating switch1 settings.

So the presence of switch0 in UCI is confusing and unneeded, and also prevents Luci from working.

Manually removing the switch0 section from /etc/config/network makes it all work again.

/etc/config/network as generated on 19.07.7 (only the switch section)
config switch
option name 'switch1'
option reset '1'
option enable_vlan '1'
option max_length '3'

config switch_vlan
option device 'switch1'
option vlan '1'
option ports '6t 1 2 3 4'

config switch_vlan
option device 'switch1'
option vlan '2'
option ports '6t 0'

/etc/config/network as generated on 21.02.0-rc2 (only the switch section)
config switch
option name 'switch0'
option reset '1'
option enable_vlan '0'

config switch
option name 'switch1'
option reset '1'
option enable_vlan '1'
option enable_vlan4k '1'
option max_length '3'

config switch_vlan
option device 'switch1'
option vlan '1'
option ports '6t 1 2 3 4'

config switch_vlan
option device 'switch1'
option vlan '2'
option ports '6t 0'

so to restate, after manually removing the extra switch0 from rc2, it all was normal again

@openwrt-bot
Copy link
Author

cybermaus:

I retract my "manual remove switch0 makes it work"

It does make the Luci work. And the device continues to work. Until you reboot, all connections lost. Even using IPv6 link-local fe80 address. All I could do is 10 second reset. Tried several times and variants.

So maybe this is a bit more urgent. Still not very urgent, but not low-low.

So:
In v19, it all worked, with switch0 not visible in /etc/config/network
In v21, with switch0 visible in network, device works, but you cannot configure switch1
In v21, with switch0 removed from network, you can configure switch1, but after reboot switch0 does not pass through any of the RGMII traffic to switch1

My current workaround: leave switch0 in network, manually edit config for switch1

Thanks

@openwrt-bot
Copy link
Author

luja:

Thank you for your solution.

I have the same problem with TP-Link Archer C2 AC750 on OpenWrt 21.02.1 here.
In the oroginal state there was switch0 and if one tries to change switch1 wan to tagged/untagged/off it is impossible to change it again. It will become off. Also if one tries to change it in
/etc/config/network

So this should be investigated and the lua for luci shall be fixed.

Removing the switch0 section in /etc/config/network helped me to get proper operation!

But I need to try to reboot, but do I want to reboot :-)

Priority should be high as it is a show stopper if you can not access your network via the internal vlan switch

Cheers

ludwig

@openwrt-bot
Copy link
Author

luja:

So I played around with it and found that one needs to remove the switch0 config
in /etc/config/network
(thanks to cybermaus!)

and to disable vlan on switch0.

I hacked it in an ugly way as I modified /etc/init.d/network to configure switch0:

here in init_switch() I added:
swconfig dev switch0 set enable_vlan 0

Please look at the attached files they also contain some "history" of looking around.

To get a quick and dirty solution, upload my config
backup-Jade-2022-01-02.tar.gz from the archive
and go from there.

The root password is "toor" the wifi password is "rattensommer"
The IP address is 10.42.42.1

Have fun with this cheap router.

@aparcar aparcar added the release/21.02 pull request/issue targeted (also) for OpenWrt 21.02 release label Feb 22, 2022
@znark
Copy link

znark commented Jun 26, 2022

I can confirm that...

  1. When starting out with a clean “factory configuration”, LuCI still displays an incorrect and confusing VLAN setup for the built-in switches of the TP-Link Archer C2 AC750 on OpenWrt 21.02.3 r16554-1d4dea6d4f / LuCI openwrt-21.02 branch git-22.083.69138-0a0ce2a (openwrt-21.02.3-ramips-mt7620-tplink_archer-c2-v1-squashfs-sysupgrade.bin), and also pops up the warning message “Switch switch0 has an unknown topology - the VLAN settings might not be accurate” when you enter the switch configuration view.

  2. The situation seems to be caused by a needless configuration section in the image for the intermediate, internal switch0, which is an “implementation detail” that the end-users are not interested in (please see the switch topology diagram for this device in the wiki), and which therefore probably should not be visible in LuCI.

  3. The situation can be remedied by issuing the following commands in shell...

    uci delete network.@switch[0]
    uci commit
    reboot
    

    ...which remove the offending configuration for switch0.

This is the situation in /etc/config/network in the default configuration:

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '0'

config switch
        option name 'switch1'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch1'
        option vlan '1'
        option ports '1 2 3 4 6t'

config switch_vlan
        option device 'switch1'
        option vlan '2'
        option ports '0 6t'

...and how it looks like in LuCI:

Screenshot 2022-06-25 at 22-58-59 OpenWrt - Switch - LuCI

This is the situation in /etc/config/network after the manual fix:

config switch
        option name 'switch1'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch1'
        option vlan '1'
        option ports '1 2 3 4 6t'

config switch_vlan
        option device 'switch1'
        option vlan '2'
        option ports '0 6t'

...and how it looks like in LuCI:

Screenshot 2022-06-26 at 14-50-07 OpenWrt - Switch - LuCI

At least for me, simply removing the offending configuration section for switch0 and rebooting seemed to do the trick with no ill effects. This is also how the 19.x release branch handled it – the default configuration in that release branch did not include a configuration section for switch0.

@DragonBluep
Copy link
Contributor

ucidef_add_switch "switch0"
ucidef_add_switch_attr "switch0" "enable" "false"

@znark delete these two lines can solve the problem.

@znark
Copy link

znark commented Jun 28, 2022

ucidef_add_switch "switch0"
ucidef_add_switch_attr "switch0" "enable" "false"

@znark delete these two lines can solve the problem.

@DragonBluep Thanks for the suggestion. I tried a custom build with those two lines removed from 02_network but this makes the device inaccessible via its Ethernet ports. Then again, removing the switch0 config in /etc/config/network (manually on a running system) does not appear to have this effect, even after a cold reboot.

I believe this is because removing those two lines in 02_network not only removes the switch0 definition from /etc/config/network but also from /etc/board.json, which (I believe, but am not sure?) would appear to be used by the script logic in /etc/init.d/preinit and /lib/preinit/10_indicate_preinit to preinitialize the switches to a certain state at boot?

So, my current takeaway is the definition of switch0 (which confuses LuCI) is not required in /etc/config/network but it is needed in /etc/board.json, and therefore cannot be removed from the 02_network template file straight away?

Is this actually a LuCI issue? Should LuCI be able to interpret the switch0 section in /etc/config/network in a more intelligent way, instead of displaying ghost ports and pseudo VLANs that do not actually exist? Or should the logic that generates config/network and board.json be changed or amended in some way to support boards that have this kind of a “special” switch setup (in order to hide the inner switch from the end user)?

@DragonBluep
Copy link
Contributor

@znark I'm sorry that my misunderstanding caused you trouble. But one thing I can confirm is that lb-link,bl-w1200 (MT7530 switch) can fix the problem by this way.

lb-link,bl-w1200|\
tplink,archer-c2-v1)
ucidef_add_switch "switch0"
ucidef_add_switch_attr "switch0" "enable" "false"

Is this actually a LuCI issue?

I think you're right, it must be a problem with LuCI, switch0 configuration doesn't seem redundant.
8f6334e

@znark
Copy link

znark commented Jun 29, 2022

@DragonBluep wrote:

I think you're right, it must be a problem with LuCI, switch0 configuration doesn't seem redundant.
8f6334e

I think the terminology here is also a bit confusing. What does “disabling a switch” (or setting its enable property to false in 02_network) even mean? “Disable” in what sense? The intermediate inner switch very much needs to be “enabled” (powered on and passing Ethernet frames between the ports without filtering them in any way except for the normal bridging rules) for the CPU to see the traffic and the router to work.

@openfnord
Copy link

openfnord commented Nov 27, 2022

I am running openwrt 22.0.3.0 at the moment. I need to update ...

root@sw4:/etc/config# cat /proc/cpuinfo
system type : MediaTek MT7620A ver:2 eco:6
machine : TP-Link Archer C2 v1
processor : 0
cpu model : MIPS 24KEc V5.0

cat /proc/version
Linux version 5.10.138 (builder@buildhost) (mipsel-openwrt-linux-musl-gcc

BusyBox v1.35.0 (2022-09-03 02:55:34 UTC) built-in shell (ash)
[acsii art]

OpenWrt 22.03.0, r19685-512e76967f


what did I change?

you need to modify /etc/init.d/network in order to make it work!
look, I did it:

root@sw4:/etc/init.d# cat network
#!/bin/sh /etc/rc.common

START=20
STOP=90

USE_PROCD=1

init_switch() {
#dirty hack for switch0 to pass RGMII and not to use it in luci with removed switch0 config
swconfig dev switch0 set enable_vlan 0
#/hack

    setup_switch() { return 0; }

    include /lib/network
    setup_switch

}

start_service() {
init_switch

    procd_open_instance
    procd_set_param command /sbin/netifd
    procd_set_param respawn
    procd_set_param watch network.interface
    [ -e /proc/sys/kernel/core_pattern ] && {
            procd_set_param limits core="unlimited"
    }
    procd_close_instance

}

reload_service() {
local rv=0

    init_switch
    ubus call network reload || rv=1
    /sbin/wifi reload_legacy
    return $rv

}

stop_service() {
/sbin/wifi down
ifdown -a
sleep 1
}

validate_atm_bridge_section()
{
uci_validate_section network "atm-bridge" "${1}"
'unit:uinteger:0'
'vci:range(32, 65535):35'
'vpi:range(0, 255):8'
'atmdev:uinteger:0'
'encaps:or("llc", "vc"):llc'
'payload:or("bridged", "routed"):bridged'
}

validate_route_section()
{
uci_validate_section network route "${1}"
'interface:string'
'target:cidr4'
'netmask:netmask4'
'gateway:ip4addr'
'metric:uinteger'
'mtu:uinteger'
'table:or(range(0,65535),string)'
}

validate_route6_section()
{
uci_validate_section network route6 "${1}"
'interface:string'
'target:cidr6'
'gateway:ip6addr'
'metric:uinteger'
'mtu:uinteger'
'table:or(range(0,65535),string)'
}

validate_rule_section()
{
uci_validate_section network rule "${1}"
'in:string'
'out:string'
'src:cidr4'
'dest:cidr4'
'tos:range(0,31)'
'mark:string'
'invert:bool'
'lookup:or(range(0,65535),string)'
'goto:range(0,65535)'
'action:or("prohibit", "unreachable", "blackhole", "throw")'
}

validate_rule6_section()
{
uci_validate_section network rule6 "${1}"
'in:string'
'out:string'
'src:cidr6'
'dest:cidr6'
'tos:range(0,31)'
'mark:string'
'invert:bool'
'lookup:or(range(0,65535),string)'
'goto:range(0,65535)'
'action:or("prohibit", "unreachable", "blackhole", "throw")'
}

validate_switch_section()
{
uci_validate_section network switch "${1}"
'name:string'
'enable:bool'
'enable_vlan:bool'
'reset:bool'
'ar8xxx_mib_poll_interval:uinteger'
'ar8xxx_mib_type:range(0,1)'
}

validate_switch_vlan()
{
uci_validate_section network switch_vlan "${1}"
'device:string'
'vlan:uinteger'
'ports:list(ports)'
}

service_triggers()
{
procd_add_reload_trigger network wireless

    procd_open_validate
    validate_atm_bridge_section
    validate_route_section
    [ -e /proc/sys/net/ipv6 ] && validate_route6_section
    validate_rule_section
    [ -e /proc/sys/net/ipv6 ] && validate_rule6_section
    validate_switch_section
    validate_switch_vlan
    procd_close_validate

}

shutdown() {
ifdown -a
sleep 1
}


It is important to modify /etc/init.d/network in the way I did it, as switch0 needs to have vlan switched off, in order to pass the RGMII lan to the external gbit vlan switch called switch 1.
Only switch 1 is to be used for vlan here!

look into a part of my /etc/config/network and see how VLAN is to be done on the C2:


less /etc/config/network

config interface 'loopback'
option device 'lo'
option interface 'lan'
option target '10.0.101.0/24'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
option gateway '10.0.101.11'

[...]
config device
option name 'br-lan'
option type 'bridge'
list ports 'eth0.101'
option macaddr 'E0:19:11:99:11:22'
option vlan_filtering '1'

config interface 'lan'
option device 'br-lan'
option proto 'static'
option netmask '255.255.255.0'
option ip6assign '60'
option ipaddr '10.0.100.14'
option gateway '10.0.100.11'

config device
option name 'eth0.2'
option macaddr 'e0:13:11:23:33:42'

config interface 'wan'
option device 'eth0.2'
option proto 'dhcp'
option hostname '*'

config interface 'wan6'
option device 'eth0.2'
option proto 'dhcpv6'

config switch
option name 'switch1'
option reset '1'
option enable_vlan '1'
option enable_vlan4k '1'

config switch_vlan
option device 'switch1'
option vlan '1'
option ports '6t'

config switch_vlan
option device 'switch1'
option vlan '2'
option ports '0 6t'

config switch_vlan
option vlan '3'
option vid '101'
option ports '1t 3 4t 6t'

config switch_vlan
option device 'switch1'
option vlan '101'
option description 'lan'
option ports '0t 1t 2 3 4t 6t'

config switch_vlan
option device 'switch1'
option vlan '110'
option ports '0t 1t 2t 3t 4t 6t'
option description 'admin'

config switch_vlan
option device 'switch1'
option vlan '901'
option description 'external1'
option ports '0t 1t 2t 3t 4t 6t'

config switch_vlan
option device 'switch1'
option vlan '902'
option description 'external2'
option ports '0t 1t 2t 3t 4t 6t'

config switch_vlan
option device 'switch1'
option ports '0t 1t 2t 3t 4t 6t'
option vlan '903'
option description 'external3'

config switch_vlan
option device 'switch1'
option ports '0t 1t 2t 3t 4t 6t'
option vlan '904'
option description 'external4'
[...]

@openfnord
Copy link

openfnord commented Nov 27, 2022

edit /etc/sysupgrade.conf
to protect the edits and to keep the router accessible after update!

#modified files to make ARCHER C2 WORK
/etc/init.d/network
/etc/config/network

#my openwrt stuff
#use cd /etc and then call ./ui.sh >inst.txt after sysupgrade cd /etc call ./iu.sh and get your user packages installed.
/etc/ui.sh
/etc/iu.sh
/etc/inst.txt
/etc/init.d/network

iu.sh and ui.sh are shell scripts to derive the installed packets and to reinstall them after update.
This is my way of doing it dating from a time when openwrt did not care about custom installations
after updates.
As this way is good, I keep it as it just works

you find the scripts here:
https://github.com/openfnord/openwrt_foo

here is my stuff for the archer C2:
https://github.com/openfnord/openwrt_foo/tree/main/tplink_archer_c2

@openfnord
Copy link

openfnord commented Nov 27, 2022

success: updating the TP-Link C2 to 22.03.2

└─$ ssh root@10.0.101.14

BusyBox v1.35.0 (2022-10-14 22:44:41 UTC) built-in shell (ash)


| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -| || | | || || |
|
_____|| |
||||___||| |____|
|
| W I R E L E S S F R E E D O M

OpenWrt 22.03.2, r19803-9a599fee93

root@sw4:~# cd /etc/
root@sw4:/etc#

running my script to install my stuff ...

root@sw4:/etc# ./iu.sh
Downloading https://downloads.openwrt.org/releases/22.03.2/targets/ramips/mt7620/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_core
Downloading https://downloads.openwrt.org/releases/22.03.2/targets/ramips/mt7620/packages/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/base/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_base
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/base/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/luci/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_luci
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/luci/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/packages/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_packages
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/packages/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/routing/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_routing
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/routing/Packages.sig
Signature check passed.
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/telephony/Packages.gz
Updated list of available packages in /var/opkg-lists/openwrt_telephony
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/telephony/Packages.sig
Signature check passed.
Installing block-mount (2022-06-02-93369be0-2) to root...
Downloading https://downloads.openwrt.org/releases/22.03.2/targets/ramips/mt7620/packages/block-mount_2022-06-02-93369be0-2_mipsel_24kc.ipk
Configuring block-mount.
uci: Entry not found
Installing ip-full (5.15.0-3) to root...
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/base/ip-full_5.15.0-3_mipsel_24kc.ipk
Installing zlib (1.2.11-6) to root...
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/base/zlib_1.2.11-6_mipsel_24kc.ipk
Installing libelf1 (0.186-1) to root...
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/base/libelf1_0.186-1_mipsel_24kc.ipk
Installing libbpf20220308 (2022-03-08-04c465fd-1) to root...
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/base/libbpf20220308_2022-03-08-04c465fd-1_mipsel_24kc.ipk
Configuring zlib.
Configuring libelf1.
Configuring libbpf20220308.
Configuring ip-full.
[..]
Installing tcpdump (4.9.3-4) to root...
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/base/tcpdump_4.9.3-4_mipsel_24kc.ipk
Installing libpcap1 (1.10.1-3) to root...
Downloading https://downloads.openwrt.org/releases/22.03.2/packages/mipsel_24kc/base/libpcap1_1.10.1-3_mipsel_24kc.ipk
Configuring libpcap1.
Configuring tcpdump.
root@sw4:/etc#
root@sw4:/etc# swconfig list
Found: switch0 - mt7620
Found: switch1 - rtl8367rb
root@sw4:/etc#

Again, you want to switch-off vlan support on switch0!
Only witch1 - rtl8367rb is to be used for vlan on the TP-Link C2

so my stuff still works. Maybe someone wants to add it to the official openwrt distribution...
here is my stuff for the archer C2:
https://github.com/openfnord/openwrt_foo/tree/main/tplink_archer_c2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray release/21.02 pull request/issue targeted (also) for OpenWrt 21.02 release
Projects
None yet
Development

No branches or pull requests

5 participants