DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/tap: fix the overflow of the network interface index.
@ 2022-07-21 11:13 Alex Kiselev
  2022-07-21 11:13 ` Alex Kiselev
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Kiselev @ 2022-07-21 11:13 UTC (permalink / raw)
  To: dev; +Cc: Keith Wiles

On Linux and most other systems, network interface index is a 32-bit
integer.  Indexes overflowing the 16-bit integer are frequently seen
when used inside a Docker container.

Signed-off-by: Alex Kiselev <alex@bisonrouter.com>
---
 drivers/net/tap/tap_flow.c   |  2 +-
 drivers/net/tap/tap_tcmsgs.c | 18 +++++++++---------
 drivers/net/tap/tap_tcmsgs.h | 16 ++++++++--------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c
index a9a55e439e..efe66fe059 100644
--- a/drivers/net/tap/tap_flow.c
+++ b/drivers/net/tap/tap_flow.c
@@ -1682,7 +1682,7 @@ int tap_flow_implicit_create(struct pmd_internals *pmd,
 	struct rte_flow_item *items = implicit_rte_flows[idx].items;
 	struct rte_flow_attr *attr = &implicit_rte_flows[idx].attr;
 	struct rte_flow_item_eth eth_local = { .type = 0 };
-	uint16_t if_index = pmd->remote_if_index;
+	unsigned int if_index = pmd->remote_if_index;
 	struct rte_flow *remote_flow = NULL;
 	struct nlmsg *msg = NULL;
 	int err = 0;
diff --git a/drivers/net/tap/tap_tcmsgs.c b/drivers/net/tap/tap_tcmsgs.c
index b478b5951e..a3aae3c814 100644
--- a/drivers/net/tap/tap_tcmsgs.c
+++ b/drivers/net/tap/tap_tcmsgs.c
@@ -19,7 +19,7 @@ struct qdisc {
 
 struct list_args {
 	int nlsk_fd;
-	uint16_t ifindex;
+	unsigned int ifindex;
 	void *custom_arg;
 };
 
@@ -42,7 +42,7 @@ struct qdisc_custom_arg {
  *   Overrides the default netlink flags for this msg with those specified.
  */
 void
-tc_init_msg(struct nlmsg *msg, uint16_t ifindex, uint16_t type, uint16_t flags)
+tc_init_msg(struct nlmsg *msg, unsigned int ifindex, uint16_t type, uint16_t flags)
 {
 	struct nlmsghdr *n = &msg->nh;
 
@@ -70,7 +70,7 @@ tc_init_msg(struct nlmsg *msg, uint16_t ifindex, uint16_t type, uint16_t flags)
  *   0 on success, -1 otherwise with errno set.
  */
 static int
-qdisc_del(int nlsk_fd, uint16_t ifindex, struct qdisc *qinfo)
+qdisc_del(int nlsk_fd, unsigned int ifindex, struct qdisc *qinfo)
 {
 	struct nlmsg msg;
 	int fd = 0;
@@ -114,7 +114,7 @@ qdisc_del(int nlsk_fd, uint16_t ifindex, struct qdisc *qinfo)
  *   0 on success, -1 otherwise with errno set.
  */
 int
-qdisc_add_multiq(int nlsk_fd, uint16_t ifindex)
+qdisc_add_multiq(int nlsk_fd, unsigned int ifindex)
 {
 	struct tc_multiq_qopt opt = {0};
 	struct nlmsg msg;
@@ -144,7 +144,7 @@ qdisc_add_multiq(int nlsk_fd, uint16_t ifindex)
  *   0 on success, -1 otherwise with errno set.
  */
 int
-qdisc_add_ingress(int nlsk_fd, uint16_t ifindex)
+qdisc_add_ingress(int nlsk_fd, unsigned int ifindex)
 {
 	struct nlmsg msg;
 
@@ -208,7 +208,7 @@ qdisc_del_cb(struct nlmsghdr *nh, void *arg)
  *   0 on success, -1 otherwise with errno set.
  */
 static int
-qdisc_iterate(int nlsk_fd, uint16_t ifindex,
+qdisc_iterate(int nlsk_fd, unsigned int ifindex,
 	      int (*callback)(struct nlmsghdr *, void *), void *arg)
 {
 	struct nlmsg msg;
@@ -238,7 +238,7 @@ qdisc_iterate(int nlsk_fd, uint16_t ifindex,
  *   0 on success, -1 otherwise with errno set.
  */
 int
-qdisc_flush(int nlsk_fd, uint16_t ifindex)
+qdisc_flush(int nlsk_fd, unsigned int ifindex)
 {
 	return qdisc_iterate(nlsk_fd, ifindex, qdisc_del_cb, NULL);
 }
@@ -256,7 +256,7 @@ qdisc_flush(int nlsk_fd, uint16_t ifindex)
  *   Return -1 otherwise.
  */
 int
-qdisc_create_multiq(int nlsk_fd, uint16_t ifindex)
+qdisc_create_multiq(int nlsk_fd, unsigned int ifindex)
 {
 	int err = 0;
 
@@ -282,7 +282,7 @@ qdisc_create_multiq(int nlsk_fd, uint16_t ifindex)
  *   Return -1 otherwise.
  */
 int
-qdisc_create_ingress(int nlsk_fd, uint16_t ifindex)
+qdisc_create_ingress(int nlsk_fd, unsigned int ifindex)
 {
 	int err = 0;
 
diff --git a/drivers/net/tap/tap_tcmsgs.h b/drivers/net/tap/tap_tcmsgs.h
index 8cedea8462..a64cb29d6f 100644
--- a/drivers/net/tap/tap_tcmsgs.h
+++ b/drivers/net/tap/tap_tcmsgs.h
@@ -24,14 +24,14 @@
 
 #define MULTIQ_MAJOR_HANDLE (1 << 16)
 
-void tc_init_msg(struct nlmsg *msg, uint16_t ifindex, uint16_t type,
+void tc_init_msg(struct nlmsg *msg, unsigned int ifindex, uint16_t type,
 		 uint16_t flags);
-int qdisc_list(int nlsk_fd, uint16_t ifindex);
-int qdisc_flush(int nlsk_fd, uint16_t ifindex);
-int qdisc_create_ingress(int nlsk_fd, uint16_t ifindex);
-int qdisc_create_multiq(int nlsk_fd, uint16_t ifindex);
-int qdisc_add_ingress(int nlsk_fd, uint16_t ifindex);
-int qdisc_add_multiq(int nlsk_fd, uint16_t ifindex);
-int filter_list_ingress(int nlsk_fd, uint16_t ifindex);
+int qdisc_list(int nlsk_fd, unsigned int ifindex);
+int qdisc_flush(int nlsk_fd, unsigned int ifindex);
+int qdisc_create_ingress(int nlsk_fd, unsigned int ifindex);
+int qdisc_create_multiq(int nlsk_fd, unsigned int ifindex);
+int qdisc_add_ingress(int nlsk_fd, unsigned int ifindex);
+int qdisc_add_multiq(int nlsk_fd, unsigned int ifindex);
+int filter_list_ingress(int nlsk_fd, unsigned int ifindex);
 
 #endif /* _TAP_TCMSGS_H_ */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] net/tap: fix the overflow of the network interface index.
  2022-07-21 11:13 [PATCH] net/tap: fix the overflow of the network interface index Alex Kiselev
@ 2022-07-21 11:13 ` Alex Kiselev
  2022-07-21 15:19   ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Kiselev @ 2022-07-21 11:13 UTC (permalink / raw)
  To: dev; +Cc: Keith Wiles

On Linux and most other systems, network interface index is a 32-bit
integer.  Indexes overflowing the 16-bit integer are frequently seen
when used inside a Docker container.

Signed-off-by: Alex Kiselev <alex@bisonrouter.com>
---
 drivers/net/tap/tap_flow.c   |  2 +-
 drivers/net/tap/tap_tcmsgs.c | 18 +++++++++---------
 drivers/net/tap/tap_tcmsgs.h | 16 ++++++++--------
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c
index a9a55e439e..efe66fe059 100644
--- a/drivers/net/tap/tap_flow.c
+++ b/drivers/net/tap/tap_flow.c
@@ -1682,7 +1682,7 @@ int tap_flow_implicit_create(struct pmd_internals *pmd,
 	struct rte_flow_item *items = implicit_rte_flows[idx].items;
 	struct rte_flow_attr *attr = &implicit_rte_flows[idx].attr;
 	struct rte_flow_item_eth eth_local = { .type = 0 };
-	uint16_t if_index = pmd->remote_if_index;
+	unsigned int if_index = pmd->remote_if_index;
 	struct rte_flow *remote_flow = NULL;
 	struct nlmsg *msg = NULL;
 	int err = 0;
diff --git a/drivers/net/tap/tap_tcmsgs.c b/drivers/net/tap/tap_tcmsgs.c
index b478b5951e..a3aae3c814 100644
--- a/drivers/net/tap/tap_tcmsgs.c
+++ b/drivers/net/tap/tap_tcmsgs.c
@@ -19,7 +19,7 @@ struct qdisc {
 
 struct list_args {
 	int nlsk_fd;
-	uint16_t ifindex;
+	unsigned int ifindex;
 	void *custom_arg;
 };
 
@@ -42,7 +42,7 @@ struct qdisc_custom_arg {
  *   Overrides the default netlink flags for this msg with those specified.
  */
 void
-tc_init_msg(struct nlmsg *msg, uint16_t ifindex, uint16_t type, uint16_t flags)
+tc_init_msg(struct nlmsg *msg, unsigned int ifindex, uint16_t type, uint16_t flags)
 {
 	struct nlmsghdr *n = &msg->nh;
 
@@ -70,7 +70,7 @@ tc_init_msg(struct nlmsg *msg, uint16_t ifindex, uint16_t type, uint16_t flags)
  *   0 on success, -1 otherwise with errno set.
  */
 static int
-qdisc_del(int nlsk_fd, uint16_t ifindex, struct qdisc *qinfo)
+qdisc_del(int nlsk_fd, unsigned int ifindex, struct qdisc *qinfo)
 {
 	struct nlmsg msg;
 	int fd = 0;
@@ -114,7 +114,7 @@ qdisc_del(int nlsk_fd, uint16_t ifindex, struct qdisc *qinfo)
  *   0 on success, -1 otherwise with errno set.
  */
 int
-qdisc_add_multiq(int nlsk_fd, uint16_t ifindex)
+qdisc_add_multiq(int nlsk_fd, unsigned int ifindex)
 {
 	struct tc_multiq_qopt opt = {0};
 	struct nlmsg msg;
@@ -144,7 +144,7 @@ qdisc_add_multiq(int nlsk_fd, uint16_t ifindex)
  *   0 on success, -1 otherwise with errno set.
  */
 int
-qdisc_add_ingress(int nlsk_fd, uint16_t ifindex)
+qdisc_add_ingress(int nlsk_fd, unsigned int ifindex)
 {
 	struct nlmsg msg;
 
@@ -208,7 +208,7 @@ qdisc_del_cb(struct nlmsghdr *nh, void *arg)
  *   0 on success, -1 otherwise with errno set.
  */
 static int
-qdisc_iterate(int nlsk_fd, uint16_t ifindex,
+qdisc_iterate(int nlsk_fd, unsigned int ifindex,
 	      int (*callback)(struct nlmsghdr *, void *), void *arg)
 {
 	struct nlmsg msg;
@@ -238,7 +238,7 @@ qdisc_iterate(int nlsk_fd, uint16_t ifindex,
  *   0 on success, -1 otherwise with errno set.
  */
 int
-qdisc_flush(int nlsk_fd, uint16_t ifindex)
+qdisc_flush(int nlsk_fd, unsigned int ifindex)
 {
 	return qdisc_iterate(nlsk_fd, ifindex, qdisc_del_cb, NULL);
 }
@@ -256,7 +256,7 @@ qdisc_flush(int nlsk_fd, uint16_t ifindex)
  *   Return -1 otherwise.
  */
 int
-qdisc_create_multiq(int nlsk_fd, uint16_t ifindex)
+qdisc_create_multiq(int nlsk_fd, unsigned int ifindex)
 {
 	int err = 0;
 
@@ -282,7 +282,7 @@ qdisc_create_multiq(int nlsk_fd, uint16_t ifindex)
  *   Return -1 otherwise.
  */
 int
-qdisc_create_ingress(int nlsk_fd, uint16_t ifindex)
+qdisc_create_ingress(int nlsk_fd, unsigned int ifindex)
 {
 	int err = 0;
 
diff --git a/drivers/net/tap/tap_tcmsgs.h b/drivers/net/tap/tap_tcmsgs.h
index 8cedea8462..a64cb29d6f 100644
--- a/drivers/net/tap/tap_tcmsgs.h
+++ b/drivers/net/tap/tap_tcmsgs.h
@@ -24,14 +24,14 @@
 
 #define MULTIQ_MAJOR_HANDLE (1 << 16)
 
-void tc_init_msg(struct nlmsg *msg, uint16_t ifindex, uint16_t type,
+void tc_init_msg(struct nlmsg *msg, unsigned int ifindex, uint16_t type,
 		 uint16_t flags);
-int qdisc_list(int nlsk_fd, uint16_t ifindex);
-int qdisc_flush(int nlsk_fd, uint16_t ifindex);
-int qdisc_create_ingress(int nlsk_fd, uint16_t ifindex);
-int qdisc_create_multiq(int nlsk_fd, uint16_t ifindex);
-int qdisc_add_ingress(int nlsk_fd, uint16_t ifindex);
-int qdisc_add_multiq(int nlsk_fd, uint16_t ifindex);
-int filter_list_ingress(int nlsk_fd, uint16_t ifindex);
+int qdisc_list(int nlsk_fd, unsigned int ifindex);
+int qdisc_flush(int nlsk_fd, unsigned int ifindex);
+int qdisc_create_ingress(int nlsk_fd, unsigned int ifindex);
+int qdisc_create_multiq(int nlsk_fd, unsigned int ifindex);
+int qdisc_add_ingress(int nlsk_fd, unsigned int ifindex);
+int qdisc_add_multiq(int nlsk_fd, unsigned int ifindex);
+int filter_list_ingress(int nlsk_fd, unsigned int ifindex);
 
 #endif /* _TAP_TCMSGS_H_ */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net/tap: fix the overflow of the network interface index.
  2022-07-21 11:13 ` Alex Kiselev
@ 2022-07-21 15:19   ` Stephen Hemminger
  2022-10-04 14:34     ` Andrew Rybchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2022-07-21 15:19 UTC (permalink / raw)
  To: Alex Kiselev; +Cc: dev, Keith Wiles

On Thu, 21 Jul 2022 11:13:01 +0000
Alex Kiselev <alex@bisonrouter.com> wrote:

> On Linux and most other systems, network interface index is a 32-bit
> integer.  Indexes overflowing the 16-bit integer are frequently seen
> when used inside a Docker container.
> 
> Signed-off-by: Alex Kiselev <alex@bisonrouter.com>

Looks good, Linux API is inconsistent in use of signed vs unsigned
int for the ifindex. But negative values are never used/returned.

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net/tap: fix the overflow of the network interface index.
  2022-07-21 15:19   ` Stephen Hemminger
@ 2022-10-04 14:34     ` Andrew Rybchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Rybchenko @ 2022-10-04 14:34 UTC (permalink / raw)
  To: Stephen Hemminger, Alex Kiselev; +Cc: dev, Keith Wiles

On 7/21/22 18:19, Stephen Hemminger wrote:
> On Thu, 21 Jul 2022 11:13:01 +0000
> Alex Kiselev <alex@bisonrouter.com> wrote:
> 
>> On Linux and most other systems, network interface index is a 32-bit
>> integer.  Indexes overflowing the 16-bit integer are frequently seen
>> when used inside a Docker container.
>>
>> Signed-off-by: Alex Kiselev <alex@bisonrouter.com>
> 
> Looks good, Linux API is inconsistent in use of signed vs unsigned
> int for the ifindex. But negative values are never used/returned.
> 
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>

Fixes: 7c25284e30c2 ("net/tap: add netlink back-end for flow API")
Fixes: 2bc06869cd94 ("net/tap: add remote netdevice traffic capture")
Cc: stable@dpdk.org

Applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-04 14:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-21 11:13 [PATCH] net/tap: fix the overflow of the network interface index Alex Kiselev
2022-07-21 11:13 ` Alex Kiselev
2022-07-21 15:19   ` Stephen Hemminger
2022-10-04 14:34     ` Andrew Rybchenko

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).