[PATCH] net/tap: add new macpair option for split MAC address
Stephen Hemminger
stephen at networkplumber.org
Tue Dec 3 18:56:54 CET 2024
On Tue, 17 Sep 2024 14:51:47 +0300
Isaac Boukris <iboukris at gmail.com> wrote:
> Normally, the MAC address of the kernel interface is the same as in the
> interface in dpdk, as they represent the same interface. It is useful
> to allow viewing them as separate connected interfaces (like ip's veth).
>
> This solves a problem I have running a freebsd-based IPv6 stack on top
> of dpdk and using the tap interface, as both the kernel and freebsd
> stacks configure the MAC derived IPv6 address on the interface (as can
> be seen with ifconfig for the kernel), and they both complain about
> duplicate IPv6 address and the freebsd disables IPv6 as a result.
>
> Signed-off-by: Isaac Boukris <iboukris at gmail.com>
Makes sense but a couple of small comments and rebase needed.
1. Could use rte_ether_addr_copy hear as is done elsewhere.
And {} non needed.
@@ -2023,12 +2031,20 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,
if (pmd->type == ETH_TUNTAP_TYPE_TAP) {
memset(&ifr, 0, sizeof(struct ifreq));
ifr.ifr_hwaddr.sa_family = AF_LOCAL;
- rte_memcpy(ifr.ifr_hwaddr.sa_data, &pmd->eth_addr,
- RTE_ETHER_ADDR_LEN);
+
+ if (mac_pair) {
+ rte_eth_random_addr((uint8_t *)ifr.ifr_hwaddr.sa_data);
+ } else {
+ memcpy(ifr.ifr_hwaddr.sa_data, &pmd->eth_addr,
+ RTE_ETHER_ADDR_LEN);
rte_ether_addr_copy(&pmd->eth_addr, (struct rte_ether_addr *)&ifr.ifr_hwaddr.sa_data);
2. Need more error checks. macpair won't work with TUN device.
and what happens if mac address is specified?
3. Should the mac address devarg, take two args?
More information about the dev
mailing list