libteam/SOURCES/libteam-teamd-remove-port-i...

63 lines
2.0 KiB
Diff

From 0f1b2fac03361c5d2bac34e4b19922c60c5c06c6 Mon Sep 17 00:00:00 2001
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Wed, 13 Mar 2019 15:04:29 +0800
Subject: [PATCH 1/3] 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
confused.
Fix it by removing the port if adding fails.
v2: also calls teamd_port_remove in port_obj_remove()
Reported-by: Vladimir Benes <vbenes@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
teamd/teamd_per_port.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/teamd/teamd_per_port.c b/teamd/teamd_per_port.c
index 09d1dc7..f98a90d 100644
--- a/teamd/teamd_per_port.c
+++ b/teamd/teamd_per_port.c
@@ -42,6 +42,8 @@ struct port_obj {
};
#define _port(port_obj) (&(port_obj)->port)
+static int teamd_port_remove(struct teamd_context *ctx,
+ struct teamd_port *tdport);
int teamd_port_priv_create_and_get(void **ppriv, struct teamd_port *tdport,
const struct teamd_port_priv *pp,
@@ -203,6 +205,7 @@ static int port_obj_create(struct teamd_context *ctx,
teamd_event_port_removed:
teamd_event_port_removed(ctx, tdport);
list_del:
+ teamd_port_remove(ctx, tdport);
port_obj_destroy(ctx, port_obj);
port_obj_free(port_obj);
return err;
@@ -214,6 +217,7 @@ static void port_obj_remove(struct teamd_context *ctx,
struct teamd_port *tdport = _port(port_obj);
teamd_event_port_removed(ctx, tdport);
+ teamd_port_remove(ctx, tdport);
port_obj_destroy(ctx, port_obj);
port_obj_free(port_obj);
}
--
2.18.1