Re: [PATCH net] net: dsa: tag_8021q: clear the context when dsa_tag_8021q_register() fails

From: Julius Bairaktaris

Date: Sun Dec 06 2026 - 03:34:25 EST


willemb@xxxxxxxxxx wrote:
> The rollback added here is incomplete: it tears down ports 0..(port - 1) and
> frees ctx->vlans nodes in software, but never unwinds the ports that already
> succeeded inside dsa_switch_tag_8021q_vlan_add() during the failing port's
> own dsa_port_tag_8021q_vlan_add() notification.

v2 makes dsa_switch_tag_8021q_vlan_add() delete the VLAN from the ports
of the switch it already programmed when a later port fails. It is a
patch of its own, because a failed bridge join leaves the same partial
add:
https://lore.kernel.org/netdev/20261206083139.1730290-1-julius@xxxxxxxxxxxxxx/

> if the administrator later retries switching to ocelot-8021q and succeeds,
> felix_tag_8021q_vlan_add() inserts duplicate filters with identical id.cookie

With that patch, felix_tag_8021q_vlan_del() removes the user port's
filters when the CPU port's add fails, so a later successful change
installs them once.

> err_free only unlinks and kfree()s each struct dsa_tag_8021q_vlan from
> ctx->vlans without calling ds->ops->tag_8021q_vlan_del()

The rollback now deletes those entries through the driver; err_free
frees only what the rollback could not delete.

Julius