On Tue, 8 Sep 2015 08:25:57 +0200
Jiri Pirko <jiri(a)resnulli.us> wrote:
Mon, Sep 07, 2015 at 06:01:34PM CEST, pwieczorkiewicz(a)suse.de wrote:
>In case of e.g. arp_ping (or nsna_ping) link watch used
>when adding a port dynamically (i.e. through PortAdd DBus
>method for instance) teamd crashes on lw_psr_port_removed()
>ops call, when there was no previous corresponding
>lw_ap_port_added() call.
>
>That happens when teamd_link_watch_arp_ping object
>port_priv's .init call did not happen due to some preceding
>error, whereas .fini is called immediately following the error
>flow of port_obj_create().
>
>Calls:
>port_priv_change_handler_func()
> port_obj_create()
> teamd_event_port_added()
> port_priv_init_all() <- some initial .init fails here, before
> port_prov's init. lw_ap_port_added()
> remains uncalled and psr_ppriv->ops
> unset (NULL).
> port_obj_destroy()
> port_priv_fini_all() <- segfault, due to uninitialized ops.
>
>First step fix would be to check for initialization of
>psr_ppriv->ops, indicating that corresponding .init call
>has happened before.
This does not look correct to me. I think this should be rather
handled in generic port code, some "init flag" perhaps?
I was also thinking about some flag to indicate when the port is
initialized and when not. But in this case, when there are several
init callbacks to be initialized (let's say: 1, 2, 3, 4) and the 2
fails, we rollback and destroy port calling fini again on all 1, 2, 3,
4. Then the 1's fini succeeds and 2's fails.
Thus each callback would need to have such flag. For lw_psr the
psr_ppriv->ops pointer could serve that purpose IMO and this is what
this patch is all about.
BTW: this issue comes from the use case of runner=activebackup and
PortAdd being called after teamd instance is created. The problem
arises from failure in changing hwaddr of the port (hwaddr_policy),
since the callback to do so is called after port is enslaved (and it's
link is up), since netlink event triggers that. More on that issue I
described here:
https://github.com/jpirko/libteam/issues/18
--
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