diff --git a/lib/client.c b/lib/client.c index 3cf42849..aa48e517 100644 --- a/lib/client.c +++ b/lib/client.c @@ -28,7 +28,7 @@ struct br_client *br_connect(const char *sock_path) { strncpy(addr.sun_path, sock_path, sizeof(addr.sun_path) - 1); - if (connect(client->sock_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) + if (connect(client->sock_fd, (void *)&addr, sizeof(addr)) < 0) goto err; return client; diff --git a/main/main.c b/main/main.c index 8ba9e051..45d42bf3 100644 --- a/main/main.c +++ b/main/main.c @@ -293,7 +293,7 @@ static int listen_api_socket(void) { strncpy(addr.sun_path, br.api_sock_path, sizeof addr.sun_path - 1); - if (bind(fd, (struct sockaddr *)&addr, sizeof addr) < 0) { + if (bind(fd, (void *)&addr, sizeof addr) < 0) { LOG(ERR, "bind: %s: %s", br.api_sock_path, strerror(errno)); close(fd); return -1; diff --git a/meson.build b/meson.build index 8fa064fa..9764f57e 100644 --- a/meson.build +++ b/meson.build @@ -18,6 +18,8 @@ project( add_project_arguments('-D_GNU_SOURCE', language: 'c') add_project_arguments('-DALLOW_EXPERIMENTAL_API', language: 'c') add_project_arguments('-Wmissing-prototypes', language: 'c') +add_project_arguments('-fstrict-aliasing', language: 'c') +add_project_arguments('-Wstrict-aliasing=2', language: 'c') add_project_arguments('-Wno-format-truncation', language: 'c') dpdk_dep = dependency( diff --git a/modules/infra/control/graph.c b/modules/infra/control/graph.c index 51a196a5..04b3a672 100644 --- a/modules/infra/control/graph.c +++ b/modules/infra/control/graph.c @@ -44,14 +44,17 @@ static void set_key(struct node_data_key *key, const char *graph, const char *no memccpy(key->node, node, 0, sizeof(key->node)); } -int br_node_data_get(const char *graph, const char *node, void **data) { +void *br_node_data_get(const char *graph, const char *node) { struct node_data_key key; + void *data = NULL; + set_key(&key, graph, node); - if (rte_hash_lookup_data(hash, &key, data) < 0) { + + if (rte_hash_lookup_data(hash, &key, &data) < 0) { LOG(ERR, "(%s, %s): %s", graph, node, rte_strerror(rte_errno)); - return -1; + return NULL; } - return 0; + return data; } int br_node_data_set(const char *graph, const char *node, void *data) { @@ -93,7 +96,7 @@ static void node_data_reset(const char *graph) { uint32_t iter; iter = 0; - while (rte_hash_iterate(hash, (const void **)&key, &data, &iter) >= 0) { + while (rte_hash_iterate(hash, (void *)&key, &data, &iter) >= 0) { if (strcmp(key->graph, graph) == 0) { rte_hash_del_key(hash, key); free(data); @@ -399,7 +402,7 @@ static void graph_fini(void) { uint32_t iter; iter = 0; - while (rte_hash_iterate(hash, (const void **)&key, &data, &iter) >= 0) { + while (rte_hash_iterate(hash, (void *)&key, &data, &iter) >= 0) { rte_hash_del_key(hash, key); free(data); } diff --git a/modules/infra/datapath/rx.c b/modules/infra/datapath/rx.c index 2e34ac11..ead7a868 100644 --- a/modules/infra/datapath/rx.c +++ b/modules/infra/datapath/rx.c @@ -54,7 +54,7 @@ static int rx_init(const struct rte_graph *graph, struct rte_node *node) { (void)graph; - if (br_node_data_get(graph->name, node->name, (void **)&data) < 0) + if ((data = br_node_data_get(graph->name, node->name)) == NULL) return -1; ctx = rte_zmalloc( diff --git a/modules/infra/datapath/tx.c b/modules/infra/datapath/tx.c index 64d15d02..6d7f506f 100644 --- a/modules/infra/datapath/tx.c +++ b/modules/infra/datapath/tx.c @@ -36,7 +36,7 @@ static inline uint16_t tx_burst( txq_id = ctx->txq_ids[port_id]; tx_ok = rte_eth_tx_burst(port_id, txq_id, mbufs, n); if (tx_ok < n) - rte_node_enqueue(graph, node, TX_ERROR, (void **)&mbufs[tx_ok], n - tx_ok); + rte_node_enqueue(graph, node, TX_ERROR, (void *)&mbufs[tx_ok], n - tx_ok); return tx_ok; } @@ -54,7 +54,7 @@ tx_process(struct rte_graph *graph, struct rte_node *node, void **objs, uint16_t struct tx_mbuf_priv *priv; if ((priv = tx_mbuf_priv(mbuf)) == NULL) { - rte_node_enqueue(graph, node, NO_PORT, (void **)&mbuf, 1); + rte_node_enqueue(graph, node, NO_PORT, (void *)&mbuf, 1); continue; } if (priv->port_id != port_id) { @@ -64,7 +64,7 @@ tx_process(struct rte_graph *graph, struct rte_node *node, void **objs, uint16_t graph, node, port_id, - (struct rte_mbuf **)&objs[burst_start], + (void *)&objs[burst_start], i - burst_start ); } @@ -109,7 +109,7 @@ static int tx_init(const struct rte_graph *graph, struct rte_node *node) { return -1; } - if (br_node_data_get(graph->name, node->name, (void **)&data) < 0) + if ((data = br_node_data_get(graph->name, node->name)) == NULL) return -1; ctx = rte_malloc(__func__, sizeof(*ctx), RTE_CACHE_LINE_SIZE); diff --git a/modules/infra/include/br_graph.h b/modules/infra/include/br_graph.h index cfbb2e5e..37736ecb 100644 --- a/modules/infra/include/br_graph.h +++ b/modules/infra/include/br_graph.h @@ -15,7 +15,7 @@ var = (void *)node->ctx; \ } while (0) -int br_node_data_get(const char *graph, const char *node, void **data); +void *br_node_data_get(const char *graph, const char *node); int br_node_data_set(const char *graph, const char *node, void *data); diff --git a/modules/infra/lib/graph.c b/modules/infra/lib/graph.c index 6c36394f..9dc331ab 100644 --- a/modules/infra/lib/graph.c +++ b/modules/infra/lib/graph.c @@ -20,7 +20,7 @@ int br_infra_graph_dump(const struct br_client *c, size_t *len, char **dot) { errno = EINVAL; goto out; } - if (send_recv(c, BR_INFRA_GRAPH_DUMP, 0, NULL, (void **)&resp) < 0) + if (send_recv(c, BR_INFRA_GRAPH_DUMP, 0, NULL, (void *)&resp) < 0) goto out; *dot = calloc(1, resp->len); @@ -49,7 +49,7 @@ int br_infra_graph_stats( goto out; } - if (send_recv(c, BR_INFRA_GRAPH_STATS, 0, NULL, (void **)&resp) < 0) + if (send_recv(c, BR_INFRA_GRAPH_STATS, 0, NULL, (void *)&resp) < 0) goto out; *stats = calloc(resp->n_stats, sizeof(*resp->stats)); diff --git a/modules/infra/lib/port.c b/modules/infra/lib/port.c index cb629f2c..add39338 100644 --- a/modules/infra/lib/port.c +++ b/modules/infra/lib/port.c @@ -20,7 +20,7 @@ int br_infra_port_add(const struct br_client *c, const char *devargs, uint16_t * memset(&req, 0, sizeof(req)); memccpy(req.devargs, devargs, 0, sizeof(req.devargs)); - if (send_recv(c, BR_INFRA_PORT_ADD, sizeof(req), &req, (void **)&resp) < 0) + if (send_recv(c, BR_INFRA_PORT_ADD, sizeof(req), &req, (void *)&resp) < 0) goto out; if (port_id != NULL) @@ -48,7 +48,7 @@ int br_infra_port_get(const struct br_client *c, uint16_t port_id, struct br_inf goto out; } - if (send_recv(c, BR_INFRA_PORT_GET, sizeof(req), &req, (void **)&resp) < 0) + if (send_recv(c, BR_INFRA_PORT_GET, sizeof(req), &req, (void *)&resp) < 0) goto out; memcpy(port, &resp->port, sizeof(*port)); @@ -68,7 +68,7 @@ int br_infra_port_list(const struct br_client *c, size_t *n_ports, struct br_inf goto out; } - if (send_recv(c, BR_INFRA_PORT_LIST, 0, NULL, (void **)&resp) < 0) + if (send_recv(c, BR_INFRA_PORT_LIST, 0, NULL, (void *)&resp) < 0) goto out; *n_ports = resp->n_ports; diff --git a/modules/infra/lib/rxq.c b/modules/infra/lib/rxq.c index f6c14841..e8006d01 100644 --- a/modules/infra/lib/rxq.c +++ b/modules/infra/lib/rxq.c @@ -21,7 +21,7 @@ int br_infra_rxq_list(const struct br_client *c, size_t *n_rxqs, struct br_infra goto out; } - if (send_recv(c, BR_INFRA_RXQ_LIST, 0, NULL, (void **)&resp) < 0) + if (send_recv(c, BR_INFRA_RXQ_LIST, 0, NULL, (void *)&resp) < 0) goto out; *n_rxqs = resp->n_rxqs; diff --git a/modules/infra/lib/stats.c b/modules/infra/lib/stats.c index 642ec141..48ba4864 100644 --- a/modules/infra/lib/stats.c +++ b/modules/infra/lib/stats.c @@ -29,7 +29,7 @@ int br_infra_stats_get( if (pattern != NULL) snprintf(req.pattern, sizeof(req.pattern), "%s", pattern); - if (send_recv(c, BR_INFRA_STATS_GET, sizeof(req), &req, (void **)&resp) < 0) + if (send_recv(c, BR_INFRA_STATS_GET, sizeof(req), &req, (void *)&resp) < 0) goto out; *stats = calloc(resp->n_stats, sizeof(*resp->stats)); diff --git a/modules/ip4/control/nh4.c b/modules/ip4/control/nh4.c index a066457a..6a4bb23a 100644 --- a/modules/ip4/control/nh4.c +++ b/modules/ip4/control/nh4.c @@ -40,7 +40,7 @@ int next_hop_lookup(ip4_addr_t gw, struct next_hop **nh) { int ret; if (next_hops == NULL) return -EIO; - if ((ret = rte_hash_lookup_data(next_hops, &gw, (void **)nh)) < 0) { + if ((ret = rte_hash_lookup_data(next_hops, &gw, (void *)nh)) < 0) { return ret; } return 0; @@ -53,7 +53,7 @@ int next_hop_delete(ip4_addr_t gw, bool force) { if (next_hops == NULL) return -EIO; - pos = rte_hash_lookup_data(next_hops, &gw, (void **)&nh); + pos = rte_hash_lookup_data(next_hops, &gw, (void *)&nh); if (pos == -ENOENT && force) return 0; if (pos < 0) @@ -82,7 +82,7 @@ static struct api_out nh4_add(const void *request, void **response) { return api_out(ENODEV, 0); if (next_hop_lookup(req->nh.host, &old_nh) == 0 && !req->exist_ok) return api_out(EEXIST, 0); - if (rte_mempool_get(nh_pool, (void **)&nh) < 0) + if (rte_mempool_get(nh_pool, (void *)&nh) < 0) return api_out(ENOMEM, 0); memset(nh, 0, sizeof(*nh)); @@ -137,7 +137,7 @@ static struct api_out nh4_list(const void *request, void **response) { num = 0; iter = 0; - while (rte_hash_iterate(next_hops, (const void **)&host, (void **)&nh, &iter) >= 0) { + while (rte_hash_iterate(next_hops, (void *)&host, (void *)&nh, &iter) >= 0) { resp->nhs[num].host = nh->ip; resp->nhs[num].port_id = nh->port_id; memcpy(&resp->nhs[num].mac, &nh->eth_addr[0], sizeof(resp->nhs[num].mac)); diff --git a/modules/ip4/datapath/rewrite.c b/modules/ip4/datapath/rewrite.c index ddb70f43..07040c9e 100644 --- a/modules/ip4/datapath/rewrite.c +++ b/modules/ip4/datapath/rewrite.c @@ -51,7 +51,7 @@ rewrite_process(struct rte_graph *graph, struct rte_node *node, void **objs, uin trace_packet(node->name, mbuf); dst_addr = ip4_fwd_mbuf_priv(mbuf)->next_hop; - if (rte_hash_lookup_data(next_hops, &dst_addr, (void **)&nh) < 0) + if (rte_hash_lookup_data(next_hops, &dst_addr, (void *)&nh) < 0) goto next; eth_hdr = rte_pktmbuf_mtod(mbuf, struct rte_ether_hdr *); diff --git a/modules/ip4/lib/nh4.c b/modules/ip4/lib/nh4.c index 13ad3df2..2139795d 100644 --- a/modules/ip4/lib/nh4.c +++ b/modules/ip4/lib/nh4.c @@ -43,7 +43,7 @@ int br_ip_nh4_list(const struct br_client *c, size_t *n_nhs, struct br_ip_nh4 ** goto out; } - if (send_recv(c, BR_IP_NH4_LIST, 0, NULL, (void **)&resp) < 0) + if (send_recv(c, BR_IP_NH4_LIST, 0, NULL, (void *)&resp) < 0) goto out; *n_nhs = resp->n_nhs; diff --git a/modules/ip4/lib/route4.c b/modules/ip4/lib/route4.c index 4f102490..bcb4dc32 100644 --- a/modules/ip4/lib/route4.c +++ b/modules/ip4/lib/route4.c @@ -57,7 +57,7 @@ int br_ip_route4_get(const struct br_client *c, ip4_addr_t dest, struct br_ip_nh } req.dest = dest; - if ((ret = send_recv(c, BR_IP_ROUTE4_GET, sizeof(req), &req, (void **)&resp)) < 0) + if ((ret = send_recv(c, BR_IP_ROUTE4_GET, sizeof(req), &req, (void *)&resp)) < 0) goto out; memcpy(nh, &resp->nh, sizeof(*nh)); @@ -76,7 +76,7 @@ int br_ip_route4_list(const struct br_client *c, size_t *n_routes, struct br_ip_ goto out; } - if (send_recv(c, BR_IP_ROUTE4_LIST, 0, NULL, (void **)&resp) < 0) + if (send_recv(c, BR_IP_ROUTE4_LIST, 0, NULL, (void *)&resp) < 0) goto out; *n_routes = resp->n_routes; diff --git a/subprojects/dpdk.wrap b/subprojects/dpdk.wrap index ddf3a06f..5e8f9101 100644 --- a/subprojects/dpdk.wrap +++ b/subprojects/dpdk.wrap @@ -5,6 +5,7 @@ depth = 1 diff_files = dpdk/build-whole-archive-for-static-libs.patch, dpdk/build-pass-cflags-in-subproject.patch, + dpdk/mbuf-fix-strict-aliasing-error.patch, dpdk/graph-enhance-export-to-graphviz.patch, dpdk/graph-expose-node-context-as-pointers.patch, dpdk/graph-avoid-accessing-global-list-in-rte_graph_clust.patch, diff --git a/subprojects/packagefiles/dpdk/mbuf-fix-strict-aliasing-error.patch b/subprojects/packagefiles/dpdk/mbuf-fix-strict-aliasing-error.patch new file mode 100644 index 00000000..023cc6a5 --- /dev/null +++ b/subprojects/packagefiles/dpdk/mbuf-fix-strict-aliasing-error.patch @@ -0,0 +1,29 @@ +From 880c9688cf7403846dbf6ef0191e722d62a16a23 Mon Sep 17 00:00:00 2001 +From: Robin Jarry +Date: Wed, 27 Mar 2024 22:22:13 +0100 +Subject: [PATCH] mbuf: fix strict-aliasing error + +Signed-off-by: Robin Jarry +--- + lib/mbuf/rte_mbuf.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h +index 286b32b788a5..0076f0d80ba8 100644 +--- a/lib/mbuf/rte_mbuf.h ++++ b/lib/mbuf/rte_mbuf.h +@@ -595,9 +595,9 @@ __rte_mbuf_raw_sanity_check(__rte_unused const struct rte_mbuf *m) + */ + static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp) + { +- struct rte_mbuf *m; ++ void *m; + +- if (rte_mempool_get(mp, (void **)&m) < 0) ++ if (rte_mempool_get(mp, &m) < 0) + return NULL; + __rte_mbuf_raw_sanity_check(m); + return m; +-- +2.44.0 +