On 9/3/25 2:20 PM, Aaron Conole via dev wrote: > Changliang Wu <[email protected]> writes: > >> New appctl 'lldp/neighbor' displays lldp neighbor information. >> Support json output with --format json --pretty >> >> Signed-off-by: Changliang Wu <[email protected]> >> --- >> NEWS | 3 + >> lib/ovs-lldp.c | 371 ++++++++++++++++++++++++++++++++++++- >> vswitchd/ovs-vswitchd.8.in | 4 + >> 3 files changed, 377 insertions(+), 1 deletion(-) >> >> diff --git a/NEWS b/NEWS >> index 96bf4992c..354d83e73 100644 >> --- a/NEWS >> +++ b/NEWS >> @@ -3,6 +3,9 @@ Post-v3.6.0 >> - Userspace datapath: >> * Conntrack now supports the FTP commands EPSV and EPRT with IPv4 >> connections, instead of limiting these commands to IPv6 only. >> + - ovs-vsctl: >> + * Added JSON output support to the 'ovs/route/show' command. >> + * Added 'lldp/neighbor' command that displays lldp neighbor >> information. >> >> >> v3.6.0 - 18 Aug 2025 >> diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c >> index 152777248..d8cf9e372 100644 >> --- a/lib/ovs-lldp.c >> +++ b/lib/ovs-lldp.c >> @@ -36,7 +36,10 @@ >> #include <stdlib.h> >> #include "openvswitch/dynamic-string.h" >> #include "flow.h" >> +#include "openvswitch/json.h" >> #include "openvswitch/list.h" >> +#include "lldp/lldp-const.h" >> +#include "lldp/lldp-tlv.h" >> #include "lldp/lldpd.h" >> #include "lldp/lldpd-structs.h" >> #include "netdev.h" >> @@ -193,7 +196,7 @@ aa_print_element_status_port(struct ds *ds, struct >> lldpd_hardware *hw) >> struct ds system = DS_EMPTY_INITIALIZER; >> >> if (port->p_chassis) { >> - if (port->p_chassis->c_id_len > 0) { >> + if (port->p_chassis->c_id_len) { >> ds_put_hex_with_delimiter(&id, port->p_chassis->c_id, >> port->p_chassis->c_id_len, ":"); >> } >> @@ -310,6 +313,328 @@ aa_print_isid_status(struct ds *ds, struct lldp *lldp) >> OVS_REQUIRES(mutex) >> } >> } >> >> +static void >> +lldp_print_neighbor(struct ds *ds, struct lldp *lldp) OVS_REQUIRES(mutex) >> +{ >> + const char *none_str = "<None>"; >> + struct lldpd_hardware *hw; >> + struct lldpd_port *port; >> + >> + if (!lldp->lldpd) { >> + return; >> + } >> + >> + bool is_first_interface = true; >> + LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) { >> + if (!hw->h_rports.next) { >> + continue; >> + } >> + LIST_FOR_EACH (port, p_entries, &hw->h_rports) { >> + struct ds chassis_id = DS_EMPTY_INITIALIZER; >> + if (!port->p_chassis) { >> + continue; >> + } >> + >> + if (!is_first_interface) { >> + ds_put_format(ds, "\n"); >> + } >> + is_first_interface = false; >> + >> + ds_put_format(ds, "Interface: %s\n", lldp->name); >> + >> + /* Basic TLV, Chassis ID (Type = 1). */ >> + if (port->p_chassis->c_id_len) { >> + ds_put_hex_with_delimiter(&chassis_id, >> port->p_chassis->c_id, >> + port->p_chassis->c_id_len, ":"); >> + } >> + ds_put_format(ds, " %-20s%s\n", "Chassis ID:", >> + chassis_id.length ? ds_cstr_ro(&chassis_id) >> + : none_str); >> + ds_destroy(&chassis_id); >> + /* Basic TLV, Port ID (Type = 2). */ >> + if (port->p_id_subtype == LLDP_PORTID_SUBTYPE_LLADDR) { >> + struct ds lladdr = DS_EMPTY_INITIALIZER; >> + if (port->p_id_len) { >> + ds_put_hex_with_delimiter(&lladdr, (uint8_t *) >> port->p_id, >> + port->p_id_len, ":"); >> + } >> + ds_put_format(ds, " %-20s%s\n", "PortID:", >> + lladdr.length ? ds_cstr_ro(&lladdr) : >> none_str); >> + ds_destroy(&lladdr); >> + } else { >> + ds_put_format(ds, " %-20s%.*s\n", "PortID:", >> + (int) (port->p_id ? port->p_id_len >> + : strlen(none_str)), >> + port->p_id ?: none_str); > > Note that this '?:' construct doesn't work on the windows compiler we're > using in appveyor. I'm not sure if it's out of date, because I've not > looked deeper into it. CC'ing Alin because he knows more about the > windows side.
The ?: shortcut syntax is a GNU extention, it's expected that MSVC doesn't support it. So, it should be avoided. Use the full standard syntax instead. Best regards, Ilya Maximets. _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
