Skip to content

Commit

Permalink
net/tap: set locally administered bit for fixed MAC address
Browse files Browse the repository at this point in the history
[ upstream commit c3006be2acab49c6b77ae9c9ef04b061e5dacbd6 ]

When the tap driver is loaded and the user selects the optional
"mac=fixed" setting, the tap driver incorrectly uses a globally
unique EUI-48 identifier (as documented in RFC 7042) of
00:64:74:61:70:<iface_idx>. Since this is a locally generated ID,
the Local bit in the MAC address should be set to 1, resulting in
the new address 02:64:74:61:70:<iface_idx>.

Bugzilla ID: 1198
Fixes: f692178 ("net/tap: add support for fixed MAC addresses")

Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
  • Loading branch information
drchristensen authored and kevintraynor committed Jul 11, 2023
1 parent ed992ac commit aae992c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions doc/guides/nics/tap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ Using the option ``mac=fixed`` you can create a fixed known MAC address::

The MAC address will have a fixed value with the last octet incrementing by one
for each interface string containing ``mac=fixed``. The MAC address is formatted
as 00:'d':'t':'a':'p':[00-FF]. Convert the characters to hex and you get the
actual MAC address: ``00:64:74:61:70:[00-FF]``.
as 02:'d':'t':'a':'p':[00-FF]. Convert the characters to hex and you get the
actual MAC address: ``02:64:74:61:70:[00-FF]``.

--vdev=net_tap0,mac="00:64:74:61:70:11"
--vdev=net_tap0,mac="02:64:74:61:70:11"

The MAC address will have a user value passed as string. The MAC address is in
format with delimiter ``:``. The string is byte converted to hex and you get
the actual MAC address: ``00:64:74:61:70:11``.
the actual MAC address: ``02:64:74:61:70:11``.

It is possible to specify a remote netdevice to capture packets from by adding
``remote=foo1``, for example::
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/tap/rte_eth_tap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2275,8 +2275,8 @@ set_mac_type(const char *key __rte_unused,
if (!strncasecmp(ETH_TAP_MAC_FIXED, value, strlen(ETH_TAP_MAC_FIXED))) {
static int iface_idx;

/* fixed mac = 00:64:74:61:70:<iface_idx> */
memcpy((char *)user_mac->addr_bytes, "\0dtap",
/* fixed mac = 02:64:74:61:70:<iface_idx> */
memcpy((char *)user_mac->addr_bytes, "\002dtap",
RTE_ETHER_ADDR_LEN);
user_mac->addr_bytes[RTE_ETHER_ADDR_LEN - 1] =
iface_idx++ + '0';
Expand Down

0 comments on commit aae992c

Please sign in to comment.