On Tue, 8 Sep 2015 08:11:05 +0200
Jiri Pirko <jiri(a)resnulli.us> wrote:
>@@ -340,6 +340,11 @@ int teamd_port_add_ifname(struct
teamd_context
>*ctx, const char *port_name)
> teamd_log_dbg("%s: Adding port (found ifindex \"%d\").",
> port_name, ifindex);
> err = team_port_add(ctx->th, ifindex);
>+ if (err == -ENODEV) {
>+ teamd_log_err("%s: Failed to add missing port.",
>port_name);
>+ return 0;
>+ }
>+
This is not correct. In case user is adding port via ctl
(teamd_ctl_method_port_add), this would make it return success for
non-existent device.
Yes, you are right. I chose wrong function (a general one). The better
one could be IMO:
diff --git a/teamd/teamd.c b/teamd/teamd.c
index a7c0f77..8102c79 100644
--- a/teamd/teamd.c
+++ b/teamd/teamd.c
@@ -846,6 +846,8 @@ 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 == -ENODEV)
+ continue;
if (err)
return err;
}
What is your use-case? You device ports in config file?
The point here is to avoid a general failure (no team device up) when
one of the ports specified in the config is missing. I.e. config
contains three eth ports, one is missing and we start team0 up. Instead
of failing completely it would be better to report port add failure and
setup device with available ports.
When some PortAdd method is used to add non-existing port to existing
teamd instance, indeed an error should be reported.
--
Best Regards,
Pawel Wieczorkiewicz <pwieczorkiewicz(a)suse.de>, Linux System Developer
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu,
Graham Norton, HRB 21284 (AG Nürnberg) Maxfeldstraße 5 / 90409
Nürnberg / Germany / Phone: +49-911-740 53 - 613