The stp could not work on netdev-dpdk if network is loop. Because the stp protocol negotiates designate port by sending BPDU packets which contains MAC address. However the device doesn't have MAC address in vhostuser type. Thus, function send_bpdu_cb would not send BPDU packets.
This patch will set the MAC for device when received first packet. Signed-off-by: Hailin Chen <[email protected]> --- lib/netdev-dpdk.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index ee53c4cd0..8496d7a9d 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -143,6 +143,11 @@ BUILD_ASSERT_DECL((MAX_NB_MBUF / ROUND_DOWN_POW2(MAX_NB_MBUF/MIN_NB_MBUF)) #define VHOST_ENQ_RETRY_NUM 8 #define IF_NAME_SZ (PATH_MAX > IFNAMSIZ ? PATH_MAX : IFNAMSIZ) +/* State of virtio device. */ +#define DEVICE_MAC_LEARNING 0 +#define DEVICE_RX 1 +#define DEVICE_SAFE_REMOVE 2 + static const struct rte_eth_conf port_conf = { .rxmode = { .mq_mode = ETH_MQ_RX_RSS, @@ -353,6 +358,9 @@ struct netdev_dpdk { /* True if vHost device is 'up' and has been reconfigured at least once */ bool vhost_reconfigured; + /* A device is set as ready if the MAC address has been set. */ + volatile uint8_t ready; + /* Identifier used to distinguish vhost devices from each other. */ char vhost_id[PATH_MAX]; @@ -1549,6 +1557,16 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq, return EAGAIN; } + if (unlikely(dev->ready == DEVICE_MAC_LEARNING)) { + struct ether_hdr *pkt_hdr = + rte_pktmbuf_mtod(*(struct rte_mbuf**)batch->packets, struct ether_hdr*); + ovs_mutex_lock(&dev->mutex); + dev->hwaddr = *(struct eth_addr*)pkt_hdr->s_addr.addr_bytes; + netdev_change_seq_changed(&dev->up); + dev->ready = DEVICE_RX; + ovs_mutex_unlock(&dev->mutex); + } + if (policer) { dropped = nb_rx; nb_rx = ingress_policer_run(policer, @@ -2548,6 +2566,7 @@ new_device(int vid) LIST_FOR_EACH(dev, list_node, &dpdk_list) { ovs_mutex_lock(&dev->mutex); if (strncmp(ifname, dev->vhost_id, IF_NAME_SZ) == 0) { + dev->ready = DEVICE_MAC_LEARNING; uint32_t qp_num = rte_vhost_get_queue_num(vid); /* Get NUMA information */ @@ -2629,6 +2648,7 @@ destroy_device(int vid) if (netdev_dpdk_get_vid(dev) == vid) { ovs_mutex_lock(&dev->mutex); + dev->ready = DEVICE_SAFE_REMOVE; dev->vhost_reconfigured = false; ovsrcu_index_set(&dev->vid, -1); netdev_dpdk_txq_map_clear(dev); -- 2.13.2 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
