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 --- teamd/teamd.c | 9 ++++++++- teamd/teamd_ctl.c | 5 +++++ teamd/teamd_per_port.c | 6 +----- 3 files changed, 14 insertions(+), 6 deletions(-)
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,
Wed, Sep 09, 2015 at 11:11:19AM CEST, pwieczorkiewicz@suse.de wrote:
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.
applied.
Signed-off-by: Pawel Wieczorkiewicz pwieczorkiewicz@suse.de
teamd/teamd.c | 9 ++++++++- teamd/teamd_ctl.c | 5 +++++ teamd/teamd_per_port.c | 6 +----- 3 files changed, 14 insertions(+), 6 deletions(-)
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) {
I fixed this by hand, putting "}" and "else if (err) {" on a single line.
libteam@lists.fedorahosted.org