On 03/16/17 16:07, Matias Elo wrote: > 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]> > --- > platform/linux-generic/pktio/netmap.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/platform/linux-generic/pktio/netmap.c > b/platform/linux-generic/pktio/netmap.c > index ae3db34..b9e983d 100644 > --- a/platform/linux-generic/pktio/netmap.c > +++ b/platform/linux-generic/pktio/netmap.c > @@ -386,6 +386,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 pid = getpid(); > > pkt_nm->capa.max_input_queues = 1; > pkt_nm->capa.set_op.op.promisc_mode = 0; > @@ -393,6 +394,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] = (pid >> 24) & 0xff; > + pkt_nm->if_mac[2] = (pid >> 16) & 0xff; > + pkt_nm->if_mac[3] = (pid >> 8) & 0xff; > + pkt_nm->if_mac[4] = pid & 0xff; > pkt_nm->if_mac[5] = ++mac; > > return 0; >
(odp_instance_t)odp_global_data.main_pid can be used in that case. But for better support thread and process modes I think getpid()+gettid() is needed. Maxim.
