On Wed, Jul 05, 2017 at 05:59:50PM +0800, Hangbin Liu wrote:
> @@ -1502,11 +1506,22 @@ static int port_initialize(struct port *p)
> if (port_set_announce_tmo(p))
> goto no_tmo;
>
> + /* No need to open rtnl socket on UDS port. */
> + if (p->announce_span) {
The type is remembered by the transport instance, so you can and
should test for (transport_type(p->trp) == TRANS_UDS).
> + if (p->fda.fd[FD_RTNL] == -1)
> + p->fda.fd[FD_RTNL] = rtnl_open();
> + if (p->fda.fd[FD_RTNL] == -1)
> + goto no_rtnl;
This test causes almost all of the linuxptp-testsuite (clknetsim)
cases to fail.
Originally, the clock.c code allowed rtnl_open() to fail. I don't
remember why I did that way. In any case, the program will still work
without the rtnl socket.
Maybe you have an argument why rtnl cannot fail?
> + } else {
> + p->fda.fd[FD_RTNL] = -1;
> + }
> +
> port_nrate_initialize(p);
>
> clock_fda_changed(p->clock);
> return 0;
>
> +no_rtnl:
> no_tmo:
> transport_close(p->trp, &p->fda);
> no_tropen:
> @@ -2025,6 +2040,10 @@ void port_close(struct port *p)
> if (port_is_enabled(p)) {
> port_disable(p);
> }
> +
> + if (p->fda.fd[FD_RTNL] >= 0)
> + rtnl_close(p->fda.fd[FD_RTNL]);
See? The test allows for the case when rtnl_open() fails.
> transport_destroy(p->trp);
> tsproc_destroy(p->tsproc);
> if (p->fault_fd >= 0)
> @@ -2242,6 +2279,11 @@ enum fsm_event port_event(struct port *p, int fd_index)
> pr_debug("port %hu: master sync timeout", portnum(p));
> port_set_sync_tx_tmo(p);
> return port_tx_sync(p) ? EV_FAULT_DETECTED : EV_NONE;
> +
> + case FD_RTNL:
> + pr_debug("port %hu: link status changed", portnum(p));
The message isn't always true, is it?
Maybe it should say something like "received link status notification".
> + rtnl_link_status(fd, port_link_status, p);
> + return port_link_status_get(p) ? EV_FAULT_CLEARED :
> EV_FAULT_DETECTED;
> }
Thanks,
Richard
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel