[PATCH v3 4/4] net/tap: use bool for boolean flags
Maxime Leroy
maxime at leroys.fr
Mon Jul 27 15:54:10 CEST 2026
persist, flow_init and flow_isolate only ever hold true or false but were
declared as int. Use bool, consistent with the interrupt-mode flags added
in this series and with common DPDK practice, and convert the parameters
and local variable that feed persist along with them.
Signed-off-by: Maxime Leroy <maxime at leroys.fr>
---
drivers/net/tap/rte_eth_tap.c | 14 +++++++-------
drivers/net/tap/rte_eth_tap.h | 6 +++---
drivers/net/tap/tap_flow.c | 6 +++---
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index f846ce1fda..b1c5237fb1 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -158,7 +158,7 @@ static int tap_intr_handle_set(struct rte_eth_dev *dev, int set);
* -1 on failure, fd on success
*/
static int
-tun_alloc(struct pmd_internals *pmd, int is_keepalive, int persistent)
+tun_alloc(struct pmd_internals *pmd, bool is_keepalive, bool persistent)
{
struct ifreq ifr;
#ifdef IFF_MULTI_QUEUE
@@ -1540,7 +1540,7 @@ tap_setup_queue(struct rte_eth_dev *dev,
pmd->name, fd, dir, qid);
gso_ctx = NULL;
} else {
- fd = tun_alloc(pmd, 0, 0);
+ fd = tun_alloc(pmd, false, false);
if (fd < 0) {
TAP_LOG(ERR, "%s: tun_alloc() failed.", pmd->name);
return -1;
@@ -2147,7 +2147,7 @@ static const struct eth_dev_ops ops = {
static int
eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,
const char *remote_iface, struct rte_ether_addr *mac_addr,
- enum rte_tuntap_type type, int persist)
+ enum rte_tuntap_type type, bool persist)
{
int numa_node = rte_socket_id();
struct rte_eth_dev *dev;
@@ -2234,7 +2234,7 @@ eth_dev_tap_create(struct rte_vdev_device *vdev, const char *tap_name,
* This keep-alive file descriptor will guarantee that the TUN device
* exists even when all of its queues are closed
*/
- pmd->ka_fd = tun_alloc(pmd, 1, persist);
+ pmd->ka_fd = tun_alloc(pmd, true, persist);
if (pmd->ka_fd == -1) {
TAP_LOG(ERR, "Unable to create %s interface", tuntap_name);
goto error_exit;
@@ -2507,7 +2507,7 @@ rte_pmd_tun_probe(struct rte_vdev_device *dev)
TAP_LOG(DEBUG, "Initializing pmd_tun for %s", name);
ret = eth_dev_tap_create(dev, tun_name, remote_iface, 0,
- ETH_TUNTAP_TYPE_TUN, 0);
+ ETH_TUNTAP_TYPE_TUN, false);
leave:
if (ret == -1) {
@@ -2630,7 +2630,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
struct rte_ether_addr user_mac = { .addr_bytes = {0} };
struct rte_eth_dev *eth_dev;
int tap_devices_count_increased = 0;
- int persist = 0;
+ bool persist = false;
name = rte_vdev_device_name(dev);
params = rte_vdev_device_args(dev);
@@ -2718,7 +2718,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev)
}
if (rte_kvargs_count(kvlist, ETH_TAP_PERSIST_ARG) == 1)
- persist = 1;
+ persist = true;
}
}
diff --git a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h
index 24fd055df9..ad497d5ce2 100644
--- a/drivers/net/tap/rte_eth_tap.h
+++ b/drivers/net/tap/rte_eth_tap.h
@@ -73,7 +73,7 @@ struct pmd_internals {
char remote_iface[IFNAMSIZ]; /* Remote netdevice name */
char name[IFNAMSIZ]; /* Internal Tap device name */
int type; /* Type field - TUN|TAP */
- int persist; /* 1 if keep link up, else 0 */
+ bool persist; /* keep link up */
struct rte_ether_addr eth_addr; /* Mac address of the device port */
struct rte_ether_addr *mc_addrs; /* multicast address list */
uint32_t nb_mc_addrs; /* multicast address count */
@@ -83,8 +83,8 @@ struct pmd_internals {
int nlsk_fd; /* Netlink socket fd */
#ifdef HAVE_TCA_FLOWER
- int flow_init; /* 1 if qdiscs were created */
- int flow_isolate; /* 1 if flow isolation is enabled */
+ bool flow_init; /* qdiscs were created */
+ bool flow_isolate; /* flow isolation is enabled */
struct tap_rss *rss; /* BPF program */
diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c
index a9d8e09562..2187b9a019 100644
--- a/drivers/net/tap/tap_flow.c
+++ b/drivers/net/tap/tap_flow.c
@@ -1244,7 +1244,7 @@ tap_flow_create(struct rte_eth_dev *dev,
struct tap_nlmsg *msg = NULL;
int err;
- if (pmd->flow_init == 0 && tap_flow_init(pmd) < 0) {
+ if (!pmd->flow_init && tap_flow_init(pmd) < 0) {
rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_HANDLE,
NULL,
"can't create rule, qdisc not initialized");
@@ -1521,7 +1521,7 @@ tap_flow_isolate(struct rte_eth_dev *dev,
}
return 0;
error:
- pmd->flow_isolate = 0;
+ pmd->flow_isolate = false;
return rte_flow_error_set(
error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
"TC rule creation failed");
@@ -1914,7 +1914,7 @@ tap_flow_init(struct pmd_internals *pmd)
return -1;
}
- pmd->flow_init = 1;
+ pmd->flow_init = true;
return 0;
}
--
2.43.0
More information about the dev
mailing list