You can cut out LuCI of the equation, I don't think it is related at all here. The swconfig utility is actually processing the /etc/config/network file directly by itself (using the swconfig dev switch0 load network command). So I think that swconfig's C code reading the config is applying the settings in a wrong order.
swconfig dev eth0 set mirror_monitor_port '5' && swconfig dev eth0 port '1' set enable_mirror_rx '1' && swconfig dev eth0 port '1' set enable_mirror_tx '1'
but the monitoring port works as well as the other one that I use for Luci connection
/* look for port or vlan sections */
uci_foreach_element(&p->sections, e) {
struct uci_element *os;
s = uci_to_section(e);
if (!strcmp(s->type, "switch_port")) {
char *devn = NULL, *port = NULL, *port_err = NULL;
int port_n;
uci_foreach_element(&s->options, os) {
o = uci_to_option(os);
if (o->type != UCI_TYPE_STRING)
continue;
if (!strcmp(os->name, "device")) {
devn = o->v.string;
if (!swlib_match_name(dev, devn))
devn = NULL;
} else if (!strcmp(os->name, "port")) {
port = o->v.string;
}
}
if (!devn || !port || !port[0])
continue;
port_n = strtoul(port, &port_err, 0);
if (port_err && port_err[0])
continue;
swlib_map_settings(dev, SWLIB_ATTR_GROUP_PORT, port_n, s);
} else if (!strcmp(s->type, "switch_vlan")) {
char *devn = NULL, *vlan = NULL, *vlan_err = NULL;
int vlan_n;
uci_foreach_element(&s->options, os) {
o = uci_to_option(os);
if (o->type != UCI_TYPE_STRING)
continue;
here ?
Given that I gave up after
#include <stdio.h>
int main()
{
// printf() displays the string inside quotation
printf("Hello, World!");
return 0;
}
I think I'll pass on it and see if I can something like
swconfig dev eth0 set mirror_monitor_port '5' && swconfig dev eth0 port '1' set enable_mirror_rx '1' && swconfig dev eth0 port '1' set enable_mirror_tx '1'
Apparently the swconfig load operation always triggers 'apply' function which in this switch driver currently clears port mirroring flags effectively undoing port mirroring configuration.
I've submitted a patch for this, however there's one more issue that I'm trying to resolve:
/etc/init.d/network reload works fine
/etc/init.d/network restart initially works fine, the mirror flags are set, but after about 3 seconds they are reset
the same issue is present after reboot, can be worked around with network reload
I cannot determine where this is triggered from though.
According to my research, swconfig load sets up vlans and mirror flags via swconfig netlink API, but shortly afterwards netifd triggers switch reset via ioctl. This occurs when interface eth0 comes up, which happens on boot, during '/etc/init.d/network restart', basically when the first interface (e.g. 'lan') is attached to eth0.
When soft reset is triggered from the driver, the switch chip appears to clear mirror flags, while preserving the vlan config.
I don't know how to fix this - swconfig/netifd behaviour is probably expected and not to be touched, and the driver issuing soft reset during switch reset operation also looks good, and is probably necessary. I'm not sure whether preserving mirror flags in the driver during a switch reset operation should be done.
hi @Pippo how you have resolved/removed the "unknown topology" for switch eth1 ?
I have open a thread about this issue about 5 days ago... apparently there's no solution also over google search.