aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Wieczorkiewicz <pwieczorkiewicz@suse.de>2015-09-09 11:11:19 +0200
committerJiri Pirko <jiri@resnulli.us>2015-09-09 11:34:39 +0200
commitfc98d32866a119baf93194c3b5bd42101996c04a (patch)
tree1df0d8ac8aaa756ca1128a5c78c3d7edd0e0c66a
parent8eb684c8ed338313fe53fa6588bde1d7654ff08a (diff)
downloadlibteam-fc98d32866a119baf93194c3b5bd42101996c04a.tar.gz
Do not fail teamd_add_ports() when one port is missing
When multiple ports are specified in the config and one of them is not present (e.g. usb2eth device) during team instance start up time, instead of failing the whole setup, just report failure with a missing port and carry on with the rest. Signed-off-by: Pawel Wieczorkiewicz <pwieczorkiewicz@suse.de> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
-rw-r--r--teamd/teamd.c8
-rw-r--r--teamd/teamd_ctl.c5
-rw-r--r--teamd/teamd_per_port.c6
3 files changed, 13 insertions, 6 deletions
diff --git a/teamd/teamd.c b/teamd/teamd.c
index a7c0f77..764e4f6 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -846,8 +846,14 @@ static int teamd_add_ports(struct teamd_context *ctx)
teamd_config_for_each_key(key, ctx, "$.ports") {
err = teamd_port_add_ifname(ctx, key);
- if (err)
+ if (err == -ENODEV) {
+ teamd_log_warn("%s: Skipped adding a missing port.", key);
+ continue;
+ } else if (err) {
+ teamd_log_err("%s: Failed to add port (%s).", key,
+ strerror(-err));
return err;
+ }
}
return 0;
}
diff --git a/teamd/teamd_ctl.c b/teamd/teamd_ctl.c
index 9d57f22..b30b273 100644
--- a/teamd/teamd_ctl.c
+++ b/teamd/teamd_ctl.c
@@ -102,6 +102,11 @@ static int teamd_ctl_method_port_add(struct teamd_context *ctx,
teamd_log_dbgx(ctx, 2, "port_devname \"%s\"", port_devname);
err = teamd_port_add_ifname(ctx, port_devname);
+ if (err) {
+ teamd_log_err("%s: Failed to add port (%s).", port_devname,
+ strerror(-err));
+ }
+
switch (err) {
case -ENODEV:
return ops->reply_err(ops_priv, "NoSuchDev", "No such device.");
diff --git a/teamd/teamd_per_port.c b/teamd/teamd_per_port.c
index 0e62091..09d1dc7 100644
--- a/teamd/teamd_per_port.c
+++ b/teamd/teamd_per_port.c
@@ -333,16 +333,12 @@ next_one:
int teamd_port_add_ifname(struct teamd_context *ctx, const char *port_name)
{
- int err;
uint32_t ifindex;
ifindex = team_ifname2ifindex(ctx->th, port_name);
teamd_log_dbg("%s: Adding port (found ifindex \"%d\").",
port_name, ifindex);
- err = team_port_add(ctx->th, ifindex);
- if (err)
- teamd_log_err("%s: Failed to add port.", port_name);
- return err;
+ return team_port_add(ctx->th, ifindex);
}
static int teamd_port_remove(struct teamd_context *ctx,