teamd: remove port if adding fails

When we add a port to team via teamdctl, some drivers do not support
changing mac address after dev opened, which would lead to the failure
of port_obj_create(). The call path looks like below for LACP mode:

- port_obj_create()
  - port_priv_init_all()
    - lacp_port_added()
      - lacp_port_set_mac()

Currently, we only destroy the port object if adding port fails. But the
port is still enslaved to team in kernel. IP link command shows the port
is a team_slave, but teamdctl state shows nothing. This may make users

Fix it by removing the port if adding fails.

v2: also calls teamd_port_remove in port_obj_remove()

Reported-by: Vladimir Benes <>
Signed-off-by: Hangbin Liu <>
Signed-off-by: Jiri Pirko <>
1 file changed