Previously the mac addresses of virtual netmap devices would clash if
multiple odp processes were run on the same host.

Signed-off-by: Matias Elo <[email protected]>
---
V2:
- Use TID instead of PID (Maxim)

 platform/linux-generic/pktio/netmap.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/platform/linux-generic/pktio/netmap.c 
b/platform/linux-generic/pktio/netmap.c
index ae3db34..04df99f 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -24,6 +24,7 @@
 #include <odp_classification_datamodel.h>
 #include <odp_classification_inlines.h>
 #include <odp_classification_internal.h>
+#include <odp_thread_internal.h>
 
 #include <inttypes.h>
 
@@ -386,6 +387,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, 
pktio_entry_t *pktio_entry,
 
        if (pkt_nm->is_virtual) {
                static unsigned mac;
+               uint32_t tid = sys_thread_id();
 
                pkt_nm->capa.max_input_queues = 1;
                pkt_nm->capa.set_op.op.promisc_mode = 0;
@@ -393,6 +395,10 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, 
pktio_entry_t *pktio_entry,
                pktio_entry->s.stats_type = STATS_UNSUPPORTED;
                /* Set MAC address for virtual interface */
                pkt_nm->if_mac[0] = 0x2;
+               pkt_nm->if_mac[1] = (tid >> 24) & 0xff;
+               pkt_nm->if_mac[2] = (tid >> 16) & 0xff;
+               pkt_nm->if_mac[3] = (tid >> 8) & 0xff;
+               pkt_nm->if_mac[4] = tid & 0xff;
                pkt_nm->if_mac[5] = ++mac;
 
                return 0;
-- 
2.7.4

Reply via email to