datapath-windows: Allow NdisSwitchPortTypeSynthetic to be updated
[cascardo/ovs.git] / lib / ovs-lldp.c
index b263a60..db97648 100644 (file)
@@ -78,8 +78,8 @@ enum aa_status {
 struct aa_mapping_internal {
     struct hmap_node hmap_node_isid;
     struct hmap_node hmap_node_aux;
-    int64_t          isid;
-    int64_t          vlan;
+    uint32_t         isid;
+    uint16_t         vlan;
     void             *aux;
     enum aa_status   status;
 };
@@ -101,38 +101,6 @@ static struct hmap *const all_mappings OVS_GUARDED_BY(mutex) = &all_mappings__;
 
 static struct lldp_aa_element_system_id system_id_null;
 
-/* Convert an array to an integer.  I-SID are stored in an array of bytes
- * in the LLDP hardware structrure.
- */
-static uint32_t
-array_to_int(uint8_t *array, size_t len)
-{
-    uint32_t res = 0;
-    unsigned int i = 0;
-
-    ovs_assert(len <= sizeof(uint32_t));
-
-    for (i = 0; i < len; i++) {
-        res = res | (array[len - i - 1] << (i * 8));
-    }
-
-    return res;
-}
-
-/* Convert an integer to an array of byte.
- */
-static void
-int_to_array(uint8_t *array, size_t len, uint32_t value)
-{
-    unsigned int i;
-
-    ovs_assert(len <= sizeof(uint32_t));
-
-    for (i = 0; i < len; i++) {
-        array[len - i - 1] = value >> (8 * i);
-    }
-}
-
 /* Convert an LLDP chassis ID to a string.
  */
 static void
@@ -151,14 +119,12 @@ chassisid_to_string(uint8_t *array, size_t len, char **str)
 /* Find an Auto Attach mapping keyed by I-SID.
  */
 static struct aa_mapping_internal *
-mapping_find_by_isid(struct lldp *lldp, const uint64_t isid)
+mapping_find_by_isid(struct lldp *lldp, uint32_t isid)
     OVS_REQUIRES(mutex)
 {
     struct aa_mapping_internal *m;
 
-    HMAP_FOR_EACH_IN_BUCKET (m,
-                             hmap_node_isid,
-                             hash_bytes(&isid, sizeof isid, 0),
+    HMAP_FOR_EACH_IN_BUCKET (m, hmap_node_isid, hash_int(isid, 0),
                              &lldp->mappings_by_isid) {
         if (isid == m->isid) {
             return m;
@@ -213,7 +179,7 @@ aa_print_lldp_and_aa_stats(struct ds *ds, struct lldp *lldp)
         return;
     }
 
-    LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+    LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
         ds_put_format(ds, "\ttx cnt: %"PRIu64"\n", hw->h_tx_cnt);
         ds_put_format(ds, "\trx cnt: %"PRIu64"\n", hw->h_rx_cnt);
         ds_put_format(ds, "\trx discarded cnt: %"PRIu64"\n",
@@ -232,7 +198,7 @@ aa_print_element_status_port(struct ds *ds, struct lldpd_hardware *hw)
 {
     struct lldpd_port *port;
 
-    LIST_FOR_EACH (port, p_entries, &hw->h_rports.p_entries) {
+    LIST_FOR_EACH (port, p_entries, &hw->h_rports) {
         if (memcmp(&port->p_element.system_id,
                    &system_id_null,
                    sizeof port->p_element.system_id)) {
@@ -241,7 +207,7 @@ aa_print_element_status_port(struct ds *ds, struct lldpd_hardware *hw)
 
             if (port->p_chassis) {
                 if (port->p_chassis->c_id_len > 0) {
-                    chassisid_to_string((uint8_t *) port->p_chassis->c_id,
+                    chassisid_to_string(port->p_chassis->c_id,
                                         port->p_chassis->c_id_len, &id);
                 }
 
@@ -252,14 +218,10 @@ aa_print_element_status_port(struct ds *ds, struct lldpd_hardware *hw)
             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 Descr: %s\n",
+            ds_put_format(ds, "\tAuto Attach Primary Server Id: %s\n", id);
+            ds_put_format(ds, "\tAuto Attach Primary Server Descr: %s\n",
                           descr);
-            ds_put_format(ds,
-                          "\tAuto Attach Primary Server System Id: %s\n",
+            ds_put_format(ds, "\tAuto Attach Primary Server System Id: %s\n",
                           system);
 
             free(id);
@@ -282,7 +244,7 @@ aa_print_element_status(struct ds *ds, struct lldp *lldp) OVS_REQUIRES(mutex)
         return;
     }
 
-    LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+    LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
         aa_print_element_status_port(ds, hw);
     }
 }
@@ -293,13 +255,12 @@ aa_print_isid_status_port_isid(struct lldp *lldp, struct lldpd_port *port)
 {
     struct lldpd_aa_isid_vlan_maps_tlv *mapping;
 
-    if (list_is_empty(&port->p_isid_vlan_maps.m_entries)) {
+    if (list_is_empty(&port->p_isid_vlan_maps)) {
         return;
     }
 
-    LIST_FOR_EACH (mapping, m_entries, &port->p_isid_vlan_maps.m_entries) {
-        uint32_t isid = array_to_int(mapping->isid_vlan_data.isid,
-            sizeof mapping->isid_vlan_data.isid);
+    LIST_FOR_EACH (mapping, m_entries, &port->p_isid_vlan_maps) {
+        uint32_t isid = mapping->isid_vlan_data.isid;
         struct aa_mapping_internal *m = mapping_find_by_isid(lldp, isid);
 
         VLOG_INFO("h_rport: isid=%u, vlan=%u, status=%d",
@@ -307,15 +268,13 @@ aa_print_isid_status_port_isid(struct lldp *lldp, struct lldpd_port *port)
                   mapping->isid_vlan_data.vlan,
                   mapping->isid_vlan_data.status);
 
-        /* Update the status of our internal state for the mapping.
-         */
+        /* Update the status of our internal state for the mapping. */
         if (m) {
-            VLOG_INFO("Setting status for ISID=%u to %u",
-                      isid,
-                      mapping->isid_vlan_data.status);
+            VLOG_INFO("Setting status for ISID=%"PRIu32" to %"PRIu16,
+                      isid, mapping->isid_vlan_data.status);
             m->status = mapping->isid_vlan_data.status;
         } else {
-            VLOG_WARN("Couldn't find mapping for I-SID=%u", isid);
+            VLOG_WARN("Couldn't find mapping for I-SID=%"PRIu32, isid);
         }
     }
 }
@@ -326,7 +285,7 @@ aa_print_isid_status_port(struct lldp *lldp, struct lldpd_hardware *hw)
 {
     struct lldpd_port *port;
 
-    LIST_FOR_EACH (port, p_entries, &hw->h_rports.p_entries) {
+    LIST_FOR_EACH (port, p_entries, &hw->h_rports) {
         aa_print_isid_status_port_isid(lldp, port);
     }
 }
@@ -346,7 +305,7 @@ aa_print_isid_status(struct ds *ds, struct lldp *lldp) OVS_REQUIRES(mutex)
 
     ds_put_format(ds, "LLDP: %s\n", lldp->name);
 
-    LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+    LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
         aa_print_isid_status_port(lldp, hw);
     }
 
@@ -358,11 +317,8 @@ aa_print_isid_status(struct ds *ds, struct lldp *lldp) OVS_REQUIRES(mutex)
     ds_put_format(ds, "-------- ---- ----------- --------\n");
 
     HMAP_FOR_EACH (m, hmap_node_isid, &lldp->mappings_by_isid) {
-        ds_put_format(ds, "%-8ld %-4ld %-11s %-11s\n",
-                          (long int) m->isid,
-                          (long int) m->vlan,
-                          "Switch",
-                          aa_status_to_str(m->status));
+        ds_put_format(ds, "%-8"PRIu32" %-4"PRIu16" %-11s %-11s\n",
+                      m->isid, m->vlan, "Switch", aa_status_to_str(m->status));
     }
 }
 
@@ -437,26 +393,21 @@ update_mapping_on_lldp(struct lldp *lldp, struct lldpd_hardware *hardware,
         VLOG_INFO("\t\t hardware->h_ifname=%s", hardware->h_ifname);
     }
 
-    int_to_array(lm->isid_vlan_data.isid,
-                 ARRAY_SIZE(lm->isid_vlan_data.isid),
-                 (uint32_t) m->isid);
+    lm->isid_vlan_data.isid = m->isid;
     lm->isid_vlan_data.vlan = m->vlan;
 
-    list_push_back(&hardware->h_lport.p_isid_vlan_maps.m_entries,
-                   &lm->m_entries);
+    list_push_back(&hardware->h_lport.p_isid_vlan_maps, &lm->m_entries);
 
     /* TODO Should be done in the Auto Attach state machine when a mapping goes
      * from "pending" to "active".
      */
-    {
-        struct bridge_aa_vlan *node = xmalloc(sizeof *node);
+    struct bridge_aa_vlan *node = xmalloc(sizeof *node);
 
-        node->port_name = xstrdup(hardware->h_ifname);
-        node->vlan = m->vlan;
-        node->oper = BRIDGE_AA_VLAN_OPER_ADD;
+    node->port_name = xstrdup(hardware->h_ifname);
+    node->vlan = m->vlan;
+    node->oper = BRIDGE_AA_VLAN_OPER_ADD;
 
-        list_push_back(&lldp->active_mapping_queue, &node->list_node);
-    }
+    list_push_back(&lldp->active_mapping_queue, &node->list_node);
 }
 
 /* Bridge will poll the list of VLAN that needs to be auto configure based on
@@ -529,18 +480,14 @@ aa_configure(const struct aa_settings *s)
     HMAP_FOR_EACH (lldp, hmap_node, all_lldps) {
         struct lldpd_chassis *chassis;
 
-        LIST_FOR_EACH (chassis, list, &lldp->lldpd->g_chassis.list) {
+        LIST_FOR_EACH (chassis, list, &lldp->lldpd->g_chassis) {
             /* System Description */
-            if (chassis->c_descr) {
-                free(chassis->c_descr);
-            }
+            free(chassis->c_descr);
             chassis->c_descr = s->system_description[0] ?
                 xstrdup(s->system_description) : xstrdup(PACKAGE_STRING);
 
             /* System Name */
-            if (chassis->c_name) {
-                free(chassis->c_name);
-            }
+            free(chassis->c_name);
             chassis->c_name = xstrdup(s->system_name);
         }
     }
@@ -558,8 +505,8 @@ aa_mapping_register(void *aux, const struct aa_mapping_settings *s)
     struct aa_mapping_internal *bridge_m;
     struct lldp *lldp;
 
-    VLOG_INFO("Adding mapping ISID=%ld, VLAN=%ld, aux=%p", (long int) s->isid,
-              (long int) s->vlan, aux);
+    VLOG_INFO("Adding mapping ISID=%"PRIu32", VLAN=%"PRIu16", aux=%p",
+              s->isid, s->vlan, aux);
 
     ovs_mutex_lock(&mutex);
 
@@ -572,11 +519,9 @@ aa_mapping_register(void *aux, const struct aa_mapping_settings *s)
     bridge_m->vlan = s->vlan;
     bridge_m->aux = aux;
     bridge_m->status = AA_STATUS_PENDING;
-    hmap_insert(all_mappings,
-                &bridge_m->hmap_node_isid,
-                hash_bytes((const void *) &bridge_m->isid,
-                           sizeof bridge_m->isid,
-                           0));
+    hmap_insert(all_mappings, &bridge_m->hmap_node_isid,
+                hash_int(bridge_m->isid, 0));
+
 
     /* Update mapping on the all the LLDP instances. */
     HMAP_FOR_EACH (lldp, hmap_node, all_lldps) {
@@ -594,17 +539,14 @@ aa_mapping_register(void *aux, const struct aa_mapping_settings *s)
         m->vlan = s->vlan;
         m->status = AA_STATUS_PENDING;
         m->aux = aux;
-        hmap_insert(&lldp->mappings_by_isid,
-                    &m->hmap_node_isid,
-                    hash_bytes((const void *) &m->isid,
-                               sizeof m->isid,
-                               0));
+        hmap_insert(&lldp->mappings_by_isid, &m->hmap_node_isid,
+                    hash_int(m->isid, 0));
         hmap_insert(&lldp->mappings_by_aux,
                     &m->hmap_node_aux,
                     hash_pointer(m->aux, 0));
 
         /* Configure the mapping on each port of the LLDP stack. */
-        LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+        LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
             update_mapping_on_lldp(lldp, hw, m);
         }
     }
@@ -621,14 +563,11 @@ aa_mapping_unregister_mapping(struct lldp *lldp,
 {
     struct lldpd_aa_isid_vlan_maps_tlv *lm, *lm_next;
 
-    LIST_FOR_EACH_SAFE (lm,
-                        lm_next,
-                        m_entries,
-                        &hw->h_lport.p_isid_vlan_maps.m_entries) {
-        uint32_t isid = array_to_int(lm->isid_vlan_data.isid,
-                                     sizeof lm->isid_vlan_data.isid);
+    LIST_FOR_EACH_SAFE (lm, lm_next, m_entries,
+                        &hw->h_lport.p_isid_vlan_maps) {
+        uint32_t isid = lm->isid_vlan_data.isid;
 
-        if (isid == (uint32_t) m->isid) {
+        if (isid == m->isid) {
             VLOG_INFO("\t\t Removing lport, isid=%u, vlan=%u",
                       isid,
                       lm->isid_vlan_data.vlan);
@@ -638,15 +577,13 @@ aa_mapping_unregister_mapping(struct lldp *lldp,
             /* TODO Should be done in the AA SM when a mapping goes
              * from "pending" to "active".
              */
-            {
-                struct bridge_aa_vlan *node = xmalloc(sizeof *node);
+            struct bridge_aa_vlan *node = xmalloc(sizeof *node);
 
-                node->port_name = xstrdup(hw->h_ifname);
-                node->vlan = (uint32_t) m->vlan;
-                node->oper = BRIDGE_AA_VLAN_OPER_REMOVE;
+            node->port_name = xstrdup(hw->h_ifname);
+            node->vlan = m->vlan;
+            node->oper = BRIDGE_AA_VLAN_OPER_REMOVE;
 
-                list_push_back(&lldp->active_mapping_queue, &node->list_node);
-            }
+            list_push_back(&lldp->active_mapping_queue, &node->list_node);
 
             break;
         }
@@ -667,17 +604,15 @@ aa_mapping_unregister(void *aux)
     HMAP_FOR_EACH (lldp, hmap_node, all_lldps) {
         struct lldpd_hardware *hw;
         struct aa_mapping_internal *m = mapping_find_by_aux(lldp, aux);
-        int64_t isid_tmp = -1, vlan_tmp = -1;
 
         /* Remove from internal hash tables. */
         if (m) {
-            struct aa_mapping_internal *p =
-                mapping_find_by_isid(lldp, m->isid);
+            uint32_t isid = m->isid;
+            uint16_t vlan = m->vlan;
+            struct aa_mapping_internal *p = mapping_find_by_isid(lldp, isid);
 
-            isid_tmp = m->isid;
-            vlan_tmp = m->vlan;
-            VLOG_INFO("\t Removing mapping ISID=%ld, VLAN=%ld (lldp->name=%s)",
-                      (long int) m->isid, (long int) m->vlan, lldp->name);
+            VLOG_INFO("\t Removing mapping ISID=%"PRIu32", VLAN=%"PRIu16
+                      " (lldp->name=%s)", isid, vlan, lldp->name);
 
             if (p) {
                 hmap_remove(&lldp->mappings_by_isid, &p->hmap_node_isid);
@@ -687,7 +622,7 @@ aa_mapping_unregister(void *aux)
             free(m);
 
             /* Remove from all the lldp instances */
-            LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+            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);
                 }
@@ -695,13 +630,11 @@ aa_mapping_unregister(void *aux)
                 aa_mapping_unregister_mapping(lldp, hw, m);
             }
 
-            if (isid_tmp >= 0 && vlan_tmp >= 0) {
-                /* Remove from the all_mappings */
-                HMAP_FOR_EACH (m, hmap_node_isid, all_mappings) {
-                    if (m && isid_tmp == m->isid && vlan_tmp == m->vlan) {
-                         hmap_remove(all_mappings, &m->hmap_node_isid);
-                         break;
-                    }
+            /* Remove from the all_mappings */
+            HMAP_FOR_EACH (m, hmap_node_isid, all_mappings) {
+                if (m && isid == m->isid && vlan == m->vlan) {
+                    hmap_remove(all_mappings, &m->hmap_node_isid);
+                    break;
                 }
             }
         }
@@ -739,11 +672,8 @@ void
 lldp_process_packet(struct lldp *lldp, const struct dp_packet *p)
 {
     if (lldp) {
-        lldpd_recv(lldp->lldpd,
-                   (struct lldpd_hardware *)
-                       lldp->lldpd->g_hardware.h_entries.next,
-                   (char *) p->data_,
-                   p->size_);
+        lldpd_recv(lldp->lldpd, lldpd_first_hardware(lldp->lldpd),
+                   (char *) dp_packet_data(p), dp_packet_size(p));
     }
 }
 
@@ -797,8 +727,7 @@ lldp_put_packet(struct lldp *lldp, struct dp_packet *packet,
                 uint8_t eth_src[ETH_ADDR_LEN]) OVS_EXCLUDED(mutex)
 {
     struct lldpd *mylldpd = lldp->lldpd;
-    struct lldpd_hardware *hw = (struct lldpd_hardware *)
-        mylldpd->g_hardware.h_entries.next;
+    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};
@@ -863,15 +792,15 @@ lldp_create(const struct netdev *netdev,
     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, (uint8_t *) lchassis->c_id);
+    netdev_get_etheraddr(netdev, lchassis->c_id);
 
-    list_init(&lchassis->c_mgmt.m_entries);
+    list_init(&lchassis->c_mgmt);
     lchassis->c_ttl = lldp->lldpd->g_config.c_tx_interval *
                       lldp->lldpd->g_config.c_tx_hold;
     lchassis->c_ttl = LLDP_CHASSIS_TTL;
     lldpd_assign_cfg_to_protocols(lldp->lldpd);
-    list_init(&lldp->lldpd->g_chassis.list);
-    list_push_back(&lldp->lldpd->g_chassis.list, &lchassis->list);
+    list_init(&lldp->lldpd->g_chassis);
+    list_push_back(&lldp->lldpd->g_chassis, &lchassis->list);
 
     if ((hw = lldpd_alloc_hardware(lldp->lldpd,
                                    (char *) netdev_get_name(netdev),
@@ -893,20 +822,19 @@ lldp_create(const struct netdev *netdev,
     hw->h_lport.p_id_len = strlen(netdev_get_name(netdev));
 
     /* Auto Attach element tlv */
-    hw->h_lport.p_element.type = LLDP_TLV_AA_ELEM_TYPE_TAG_CLIENT;
+    hw->h_lport.p_element.type = LLDP_TLV_AA_ELEM_TYPE_CLIENT_VIRTUAL_SWITCH;
     hw->h_lport.p_element.mgmt_vlan = 0;
     memcpy(&hw->h_lport.p_element.system_id.system_mac,
            lchassis->c_id, lchassis->c_id_len);
     hw->h_lport.p_element.system_id.conn_type =
         LLDP_TLV_AA_ELEM_CONN_TYPE_SINGLE;
+    hw->h_lport.p_element.system_id.rsvd = 0;
+    hw->h_lport.p_element.system_id.rsvd2[0] = 0;
+    hw->h_lport.p_element.system_id.rsvd2[1] = 0;
 
-    hw->h_lport.p_element.system_id.smlt_id = 0;
-    hw->h_lport.p_element.system_id.mlt_id[0] = 0;
-    hw->h_lport.p_element.system_id.mlt_id[1] = 0;
-
-    list_init(&hw->h_lport.p_isid_vlan_maps.m_entries);
-    list_init(&lldp->lldpd->g_hardware.h_entries);
-    list_push_back(&lldp->lldpd->g_hardware.h_entries, &hw->h_entries);
+    list_init(&hw->h_lport.p_isid_vlan_maps);
+    list_init(&lldp->lldpd->g_hardware);
+    list_push_back(&lldp->lldpd->g_hardware, &hw->h_entries);
 
     ovs_mutex_lock(&mutex);
 
@@ -919,11 +847,8 @@ lldp_create(const struct netdev *netdev,
         }
 
         p = xmemdup(m, sizeof *p);
-        hmap_insert(&lldp->mappings_by_isid,
-                    &p->hmap_node_isid,
-                    hash_bytes((const void *) &p->isid,
-                               sizeof p->isid,
-                               0));
+        hmap_insert(&lldp->mappings_by_isid, &p->hmap_node_isid,
+                    hash_int(p->isid, 0));
         hmap_insert(&lldp->mappings_by_aux,
                     &p->hmap_node_aux,
                     hash_pointer(p->aux, 0));
@@ -962,11 +887,11 @@ lldp_create_dummy(void)
     lchassis->c_id_len = ETH_ADDR_LEN;
     lchassis->c_id = xmalloc(ETH_ADDR_LEN);
 
-    list_init(&lchassis->c_mgmt.m_entries);
+    list_init(&lchassis->c_mgmt);
     lchassis->c_ttl = LLDP_CHASSIS_TTL;
     lldpd_assign_cfg_to_protocols(lldp->lldpd);
-    list_init(&lldp->lldpd->g_chassis.list);
-    list_push_back(&lldp->lldpd->g_chassis.list, &lchassis->list);
+    list_init(&lldp->lldpd->g_chassis);
+    list_push_back(&lldp->lldpd->g_chassis, &lchassis->list);
 
     hw = lldpd_alloc_hardware(lldp->lldpd, "dummy-hw", 0);
 
@@ -982,19 +907,19 @@ lldp_create_dummy(void)
     hw->h_lport.p_id_len = strlen(hw->h_lport.p_id);
 
     /* Auto Attach element tlv */
-    hw->h_lport.p_element.type = LLDP_TLV_AA_ELEM_TYPE_TAG_CLIENT;
+    hw->h_lport.p_element.type = LLDP_TLV_AA_ELEM_TYPE_CLIENT_VIRTUAL_SWITCH;
     hw->h_lport.p_element.mgmt_vlan = 0;
     memcpy(&hw->h_lport.p_element.system_id.system_mac,
            lchassis->c_id, lchassis->c_id_len);
     hw->h_lport.p_element.system_id.conn_type =
         LLDP_TLV_AA_ELEM_CONN_TYPE_SINGLE;
-    hw->h_lport.p_element.system_id.smlt_id = 0;
-    hw->h_lport.p_element.system_id.mlt_id[0] = 0;
-    hw->h_lport.p_element.system_id.mlt_id[1] = 0;
+    hw->h_lport.p_element.system_id.rsvd = 0;
+    hw->h_lport.p_element.system_id.rsvd2[0] = 0;
+    hw->h_lport.p_element.system_id.rsvd2[1] = 0;
 
-    list_init(&hw->h_lport.p_isid_vlan_maps.m_entries);
-    list_init(&lldp->lldpd->g_hardware.h_entries);
-    list_push_back(&lldp->lldpd->g_hardware.h_entries, &hw->h_entries);
+    list_init(&hw->h_lport.p_isid_vlan_maps);
+    list_init(&lldp->lldpd->g_hardware);
+    list_push_back(&lldp->lldpd->g_hardware, &hw->h_entries);
 
     return lldp;
 }