From: Robin Jarry <rjarry@redhat.com>
To: dev@dpdk.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH dpdk v4 4/4] net/tap: configure link carrier
Date: Thu, 30 Oct 2025 18:55:43 +0100 [thread overview]
Message-ID: <20251030175537.219641-11-rjarry@redhat.com> (raw)
In-Reply-To: <20251030175537.219641-7-rjarry@redhat.com>
In order for net_tap interfaces to be used in linux bonds, they need to
report a carrier.
After at last one RX queue has been configured, force the carrier on
with ioctl(TUNSETCARRIER) (there is no netlink equivalent for this).
Also do the same after the device has been moved to another netns.
TUNSETCARRIER support was added in Linux 5.0. Only enable carrier set if
this ioctl number is defined.
Signed-off-by: Robin Jarry <rjarry@redhat.com>
---
drivers/net/tap/rte_eth_tap.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 7869183c0ffe..730f1859bd28 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1392,6 +1392,22 @@ tap_mac_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
return 0;
}
+static int tap_carrier_set(struct pmd_internals *pmd, int carrier)
+{
+#ifdef TUNSETCARRIER
+ int ret = ioctl(pmd->ka_fd, TUNSETCARRIER, &carrier);
+ if (ret < 0) {
+ TAP_LOG(ERR, "%s: ioctl(TUNSETCARRIER) failed: %s",
+ pmd->name, strerror(errno));
+ return ret;
+ }
+#else
+ (void)pmd;
+ (void)carrier;
+#endif
+ return 0;
+}
+
static int
tap_gso_ctx_setup(struct rte_gso_ctx *gso_ctx, struct rte_eth_dev *dev)
{
@@ -1559,6 +1575,11 @@ tap_rx_queue_setup(struct rte_eth_dev *dev,
tmp = &(*tmp)->next;
}
+ /* set carrier after creating at least one rxq */
+ ret = tap_carrier_set(internals, 1);
+ if (ret < 0)
+ goto error;
+
TAP_LOG(DEBUG, " RX TUNTAP device name %s, qid %d on fd %d",
internals->name, rx_queue_id,
process_private->fds[rx_queue_id]);
@@ -1691,6 +1712,9 @@ tap_netns_change(struct rte_eth_dev *dev)
TAP_LOG(WARNING, "%s: failed to recreate LSC interrupt socket",
pmd->name);
+ /* Force carrier back after switching netns */
+ tap_carrier_set(pmd, 1);
+
/* Switch back to original namespace */
if (setns(orig_netns_fd, CLONE_NEWNET) < 0)
TAP_LOG(ERR, "%s: failed to return to original netns: %s",
--
2.51.1
next prev parent reply other threads:[~2025-10-30 17:56 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 15:37 [PATCH dpdk 0/4] net/tap: add network namespace support Robin Jarry
2025-10-27 15:37 ` [PATCH dpdk 1/4] net/tap: add netlink helpers Robin Jarry
2025-10-27 15:37 ` [PATCH dpdk 2/4] net/tap: rename internal ioctl wrapper Robin Jarry
2025-10-27 15:37 ` [PATCH dpdk 3/4] net/tap: use netlink if possible Robin Jarry
2025-10-27 16:06 ` Stephen Hemminger
2025-10-27 16:10 ` Robin Jarry
2025-10-27 16:58 ` Stephen Hemminger
2025-10-27 15:37 ` [PATCH dpdk 4/4] net/tap: detect namespace change Robin Jarry
2025-10-27 18:19 ` [PATCH dpdk v2 0/3] net/tap: add network namespace support Robin Jarry
2025-10-27 18:19 ` [PATCH dpdk v2 1/3] net/tap: add netlink helpers Robin Jarry
2025-10-27 18:19 ` [PATCH dpdk v2 2/3] net/tap: replace ioctl with netlink Robin Jarry
2025-10-27 18:19 ` [PATCH dpdk v2 3/3] net/tap: detect namespace change Robin Jarry
2025-10-27 21:55 ` [PATCH dpdk v2 0/3] net/tap: add network namespace support Stephen Hemminger
2025-10-27 22:16 ` [PATCH dpdk v3 " Robin Jarry
2025-10-27 22:16 ` [PATCH dpdk v3 1/3] net/tap: add netlink helpers Robin Jarry
2025-10-27 22:16 ` [PATCH dpdk v3 2/3] net/tap: replace ioctl with netlink Robin Jarry
2025-10-27 22:16 ` [PATCH dpdk v3 3/3] net/tap: detect namespace change Robin Jarry
2025-10-30 17:55 ` [PATCH dpdk v4 0/4] net/tap: add network namespace support Robin Jarry
2025-10-30 17:55 ` [PATCH dpdk v4 1/4] net/tap: add netlink helpers Robin Jarry
2025-10-30 17:55 ` [PATCH dpdk v4 2/4] net/tap: replace ioctl with netlink Robin Jarry
2025-10-30 17:55 ` [PATCH dpdk v4 3/4] net/tap: detect namespace change Robin Jarry
2025-10-30 17:55 ` Robin Jarry [this message]
2025-10-30 18:13 ` [PATCH dpdk v4 0/4] net/tap: add network namespace support Stephen Hemminger
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=20251030175537.219641-11-rjarry@redhat.com \
--to=rjarry@redhat.com \
--cc=dev@dpdk.org \
--cc=stephen@networkplumber.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).