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(a)suse.de>
---
stamp-h1 | 1 +
teamd/teamd.c | 9 ++++++++-
teamd/teamd_ctl.c | 5 +++++
teamd/teamd_per_port.c | 6 +-----
4 files changed, 15 insertions(+), 6 deletions(-)
create mode 100644 stamp-h1
diff --git a/stamp-h1 b/stamp-h1
new file mode 100644
index 0000000..4547fe1
--- /dev/null
+++ b/stamp-h1
@@ -0,0 +1 @@
+timestamp for config.h
diff --git a/teamd/teamd.c b/teamd/teamd.c
index a7c0f77..0cb5e7e 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -846,8 +846,15 @@ 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,
--
2.1.4