For the ports to be truly created and removed dynamically, the last used port number has to be remembered by the clock and used for port creation.
Signed-off-by: Jiri Benc <jb...@redhat.com> --- clock.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/clock.c b/clock.c index f70e87bb7239..09ea385443ab 100644 --- a/clock.c +++ b/clock.c @@ -87,6 +87,7 @@ struct clock { struct pollfd *pollfd; int pollfd_valid; int nports; /* does not include the UDS port */ + int last_port_number; int free_running; int freq_est_interval; int grand_master_capable; /* for 802.1AS only */ @@ -752,14 +753,15 @@ UInteger8 clock_class(struct clock *c) } static int clock_add_port(struct clock *c, int phc_index, - enum timestamp_type timestamping, int number, + enum timestamp_type timestamping, struct interface *iface) { struct port *p; if (clock_resize_pollfd(c, c->nports + 1)) return -1; - p = port_open(phc_index, timestamping, number, iface, c); + p = port_open(phc_index, timestamping, ++c->last_port_number, + iface, c); if (!p) { /* No need to shrink pollfd */ return -1; @@ -888,6 +890,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count, LIST_INIT(&c->subscribers); LIST_INIT(&c->ports); + c->last_port_number = 0; /* * Create the UDS interface. @@ -905,7 +908,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count, /* Create the ports. */ for (i = 0; i < count; i++) { - if (clock_add_port(c, phc_index, timestamping, i + 1, &iface[i])) { + if (clock_add_port(c, phc_index, timestamping, &iface[i])) { pr_err("failed to open port %s", iface[i].name); return NULL; } -- 1.7.6.5 ------------------------------------------------------------------------------ Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel