if (memcmp(&port->p_element.system_id,
&system_id_null,
sizeof port->p_element.system_id)) {
- static char *none_str = "<None>";
- char *id = none_str, *descr = none_str, *system = none_str;
+ const char *none_str = "<None>";
+ const char *descr = NULL;
+ char *id = NULL;
+ char *system;
if (port->p_chassis) {
if (port->p_chassis->c_id_len > 0) {
port->p_chassis->c_id_len, &id);
}
- descr = port->p_chassis->c_descr
- ? port->p_chassis->c_descr : none_str;
+ descr = port->p_chassis->c_descr;
}
chassisid_to_string((uint8_t *) &port->p_element.system_id,
sizeof port->p_element.system_id, &system);
- ds_put_format(ds, "\tAuto Attach Primary Server Id: %s\n", id);
+ ds_put_format(ds, "\tAuto Attach Primary Server Id: %s\n",
+ id ? id : none_str);
ds_put_format(ds, "\tAuto Attach Primary Server Descr: %s\n",
- descr);
+ descr ? descr : none_str);
ds_put_format(ds, "\tAuto Attach Primary Server System Id: %s\n",
system);
{
struct lldpd_aa_isid_vlan_maps_tlv *lm = xzalloc(sizeof *lm);
- if (hardware->h_ifname) {
- VLOG_INFO("\t\t hardware->h_ifname=%s", hardware->h_ifname);
- }
+ VLOG_INFO("\t\t hardware->h_ifname=%s", hardware->h_ifname);
lm->isid_vlan_data.isid = m->isid;
lm->isid_vlan_data.vlan = m->vlan;
ovs_mutex_lock(&mutex);
HMAP_FOR_EACH (lldp, hmap_node, all_lldps) {
- struct bridge_aa_vlan *node, *node_next;
+ struct bridge_aa_vlan *node;
- LIST_FOR_EACH_SAFE (node,
- node_next,
- list_node,
- &lldp->active_mapping_queue) {
+ LIST_FOR_EACH_POP (node, list_node, &lldp->active_mapping_queue) {
struct bridge_aa_vlan *copy;
copy = xmalloc(sizeof *copy);
list_push_back(list, ©->list_node);
/* Cleanup */
- list_remove(&node->list_node);
free(node->port_name);
free(node);
}
LIST_FOR_EACH (chassis, list, &lldp->lldpd->g_chassis) {
/* System Description */
free(chassis->c_descr);
- chassis->c_descr = s->system_description[0] ?
+ chassis->c_descr = s && s->system_description[0] ?
xstrdup(s->system_description) : xstrdup(PACKAGE_STRING);
/* System Name */
- free(chassis->c_name);
- chassis->c_name = xstrdup(s->system_name);
+ if (s) {
+ free(chassis->c_name);
+ chassis->c_name = xstrdup(s->system_name);
+ }
}
}
}
hmap_remove(&lldp->mappings_by_aux, &m->hmap_node_aux);
- free(m);
/* Remove from all the lldp instances */
LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
- if (hw->h_ifname) {
- VLOG_INFO("\t\t hardware->h_ifname=%s", hw->h_ifname);
- }
-
+ VLOG_INFO("\t\t hardware->h_ifname=%s", hw->h_ifname);
aa_mapping_unregister_mapping(lldp, hw, m);
}
+ free(m);
/* Remove from the all_mappings */
HMAP_FOR_EACH (m, hmap_node_isid, all_mappings) {
* fields in 'wc' that were used to make the determination.
*/
bool
-lldp_should_process_flow(const struct flow *flow)
+lldp_should_process_flow(struct lldp *lldp, const struct flow *flow)
{
- return (flow->dl_type == htons(ETH_TYPE_LLDP));
+ return (flow->dl_type == htons(ETH_TYPE_LLDP) && lldp->enabled);
}
ret = timer_expired(&cfg->tx_timer);
ovs_mutex_unlock(&mutex);
+ /* LLDP must be enabled */
+ ret &= cfg->enabled;
+
return ret;
}
{
long long int retval;
- if (!lldp) {
+ if (!lldp || !lldp->enabled) {
return LLONG_MAX;
}
*/
void
lldp_put_packet(struct lldp *lldp, struct dp_packet *packet,
- uint8_t eth_src[ETH_ADDR_LEN]) OVS_EXCLUDED(mutex)
+ const struct eth_addr eth_src) OVS_EXCLUDED(mutex)
{
struct lldpd *mylldpd = lldp->lldpd;
struct lldpd_hardware *hw = lldpd_first_hardware(mylldpd);
- uint32_t lldp_size = 0;
- static const uint8_t eth_addr_lldp[6] =
- {0x01, 0x80, 0xC2, 0x00, 0x00, 0x0e};
+ static const struct eth_addr eth_addr_lldp =
+ { { { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x0e } } };
ovs_mutex_lock(&mutex);
eth_compose(packet, eth_addr_lldp, eth_src, ETH_TYPE_LLDP, 0);
- lldp_size = lldpd_send(hw, packet);
- if (lldp_size + ETH_HEADER_LEN < MINIMUM_ETH_PACKET_SIZE) {
- lldp_size = MINIMUM_ETH_PACKET_SIZE;
- }
+ lldpd_send(hw, packet);
timer_set_duration(&lldp->tx_timer, lldp->lldpd->g_config.c_tx_interval);
ovs_mutex_unlock(&mutex);
/* Configures the LLDP stack.
*/
bool
-lldp_configure(struct lldp *lldp) OVS_EXCLUDED(mutex)
+lldp_configure(struct lldp *lldp, const struct smap *cfg) OVS_EXCLUDED(mutex)
{
if (lldp) {
+ if (cfg && smap_get_bool(cfg, "enable", false)) {
+ lldp->enabled = true;
+ } else {
+ lldp->enabled = false;
+ }
+
ovs_mutex_lock(&mutex);
timer_set_expired(&lldp->tx_timer);
timer_set_duration(&lldp->tx_timer, LLDP_DEFAULT_TRANSMIT_INTERVAL_MS);
lchassis->c_cap_enabled = LLDP_CAP_BRIDGE;
lchassis->c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR;
lchassis->c_id_len = ETH_ADDR_LEN;
- lchassis->c_id = xmalloc(ETH_ADDR_LEN);
- netdev_get_etheraddr(netdev, lchassis->c_id);
+
+ struct eth_addr *mac = xmalloc(ETH_ADDR_LEN);
+ netdev_get_etheraddr(netdev, mac);
+ lchassis->c_id = &mac->ea[0];
list_init(&lchassis->c_mgmt);
lchassis->c_ttl = lldp->lldpd->g_config.c_tx_interval *