diff --git a/src/ieee1905/topologyd.c b/src/ieee1905/topologyd.c index c626e1e6bba6f20d26fbb2d53cc3efa1d7fc3b1f..197b7c3ce9c4197be6b1b30c126dcd6bcff85279 100644 --- a/src/ieee1905/topologyd.c +++ b/src/ieee1905/topologyd.c @@ -1508,6 +1508,7 @@ void topologyd_dump_node(struct blob_buf *bb, struct node *p, int is_self) blobmsg_add_u32(bb, "l2_neighbor_num", p->l2_nbr_num); l2_neighbor = blobmsg_open_array(bb, "l2_neighbor"); for (j = 0; j < p->l2_nbr_num; j++) { + int length = 0; table = blobmsg_open_table(bb, NULL); hwaddr_ntoa(p->l2_nbr[j].l2_intf_addr, mac_str); blobmsg_add_string(bb, "local_intf_id", mac_str); @@ -1524,6 +1525,10 @@ void topologyd_dump_node(struct blob_buf *bb, struct node *p, int is_self) snprintf(behind_mac_str + len, size - len , "%s,", mac_str); } + length = strlen(behind_mac_str); + /*to overwrite the last comma*/ + if (length > 0) + behind_mac_str[length - 1] = '\0'; blobmsg_add_string(bb, "behind_mac_id", behind_mac_str); blobmsg_close_table(bb, table); }