LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0010-teamd-look-for-existing-ports-before-adding-new-ones.patch of Package libteam (Project home:ods:ppc64)

From ad11b18771a87fb9aa2f35e2b8c790de0a20afb1 Mon Sep 17 00:00:00 2001
From: Jiri Pirko <jiri@resnulli.us>
Date: Wed, 26 Feb 2014 11:35:51 +0100
Subject: [patch libteam 2/3] teamd: look for existing ports before adding new
 ones

This is handy when we are doing take over of team device. Without this,
teamd is not aware of existing ports.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 teamd/teamd.c | 16 +++++++++++++---
 teamd/teamd.h |  1 +
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/teamd/teamd.c b/teamd/teamd.c
index d1e335b..f8e2347 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -861,6 +861,7 @@ static int teamd_add_ports(struct teamd_context *ctx)
 	int err;
 	const char *key;
 
+	ctx->pre_add_ports = false;
 	if (ctx->init_no_ports)
 		return 0;
 
@@ -903,9 +904,11 @@ static int teamd_event_watch_port_added(struct teamd_context *ctx,
 	int err;
 	int tmp;
 
-	err = teamd_hwaddr_check_change(ctx, tdport);
-	if (err)
-		return err;
+	if (!ctx->pre_add_ports) {
+		err = teamd_hwaddr_check_change(ctx, tdport);
+		if (err)
+			return err;
+	}
 
 	err = teamd_config_int_get(ctx, &tmp, "$.ports.%s.queue_id",
 				   tdport->ifname);
@@ -1341,6 +1344,13 @@ skip_create:
 		goto dbus_fini;
 	}
 
+	ctx->pre_add_ports = true;
+	err = team_refresh(ctx->th);
+	if (err) {
+		teamd_log_err("Team refresh failed.");
+		goto zmq_fini;
+	}
+
 	err = teamd_add_ports(ctx);
 	if (err) {
 		teamd_log_err("Failed to add ports.");
diff --git a/teamd/teamd.h b/teamd/teamd.h
index 103a2bc..e644171 100644
--- a/teamd/teamd.h
+++ b/teamd/teamd.h
@@ -100,6 +100,7 @@ struct teamd_context {
 	bool				force_recreate;
 	bool				take_over;
 	bool				init_no_ports;
+	bool				pre_add_ports;
 	char *				config_file;
 	char *				config_text;
 	json_t *			config_json;
-- 
1.8.5.3