tunnel: Geneve TLV handling support for OpenFlow.
[cascardo/ovs.git] / lib / ovs-lldp.c
index 61534a4..54c70c5 100644 (file)
@@ -391,9 +391,7 @@ update_mapping_on_lldp(struct lldp *lldp, struct lldpd_hardware *hardware,
 {
     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;
@@ -619,16 +617,13 @@ aa_mapping_unregister(void *aux)
             }
 
             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) {
@@ -660,9 +655,9 @@ lldp_init(void)
  * 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);
 }
 
 
@@ -689,6 +684,9 @@ lldp_should_send_packet(struct lldp *cfg) OVS_EXCLUDED(mutex)
     ret = timer_expired(&cfg->tx_timer);
     ovs_mutex_unlock(&mutex);
 
+    /* LLDP must be enabled */
+    ret &= cfg->enabled;
+
     return ret;
 }
 
@@ -699,7 +697,7 @@ lldp_wake_time(const struct lldp *lldp) OVS_EXCLUDED(mutex)
 {
     long long int retval;
 
-    if (!lldp) {
+    if (!lldp || !lldp->enabled) {
         return LLONG_MAX;
     }
 
@@ -744,9 +742,15 @@ lldp_put_packet(struct lldp *lldp, struct dp_packet *packet,
 /* 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);