DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Cian Ferriter <cian.ferriter@intel.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] net/pcap: Generate unique MAC addresses for interfaces
Date: Mon, 3 Sep 2018 16:00:46 +0100	[thread overview]
Message-ID: <958caf71-2ebe-f436-117b-aa7151688608@intel.com> (raw)
In-Reply-To: <1535983725-84966-1-git-send-email-cian.ferriter@intel.com>

On 9/3/2018 3:08 PM, Cian Ferriter wrote:
> The MAC addresses are generated in the same manner as in the TAP PMD,
> where the address is based on the number of PCAP ports created.
> 
> Signed-off-by: Cian Ferriter <cian.ferriter@intel.com>
> ---
>  drivers/net/pcap/rte_eth_pcap.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
> index e8810a1..ced9cd9 100644
> --- a/drivers/net/pcap/rte_eth_pcap.c
> +++ b/drivers/net/pcap/rte_eth_pcap.c
> @@ -417,11 +417,17 @@ struct pmd_devargs {
>  static int
>  eth_dev_start(struct rte_eth_dev *dev)
>  {
> +	static int iface_idx;
>  	unsigned int i;
>  	struct pmd_internals *internals = dev->data->dev_private;
>  	struct pcap_tx_queue *tx;
>  	struct pcap_rx_queue *rx;
>  
> +	/* Interface MAC = 00:70:63:61:70:<iface_idx> */
> +	memcpy((char *)dev->data->mac_addrs->addr_bytes, "\0pcap",
> +		ETHER_ADDR_LEN);
> +	dev->data->mac_addrs->addr_bytes[ETHER_ADDR_LEN - 1] = iface_idx++;

This won't work as you expected, you will end up having same MAC for pcap
interfaces because data->mac_addrs points to same memory for all instances.

It is better to have "struct ether_addr" in "pmd_internals" and set the MAC
address for that interface in "pmd_init_internals()".
It can be good to set fixed part of the MAC as macro and add static variable
(iface_idx) where other global variables are declared.

And it would be nice if you can add why you need this, what is enabled by having
this update, in commit log.

Thanks,
ferruh

      reply	other threads:[~2018-09-03 15:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-03 14:08 Cian Ferriter
2018-09-03 15:00 ` Ferruh Yigit [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=958caf71-2ebe-f436-117b-aa7151688608@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=cian.ferriter@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).