DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] net/af_packet: fix accidental fanout group ID reuse
@ 2026-11-10 19:06 Frank Dressler
  2026-11-11 10:45 ` [PATCH v2] " Frank Dressler
  0 siblings, 1 reply; 6+ messages in thread
From: Frank Dressler @ 2026-11-10 19:06 UTC (permalink / raw)
  To: stephen; +Cc: dev, stable

This fix ensures that the queues of an AF_PACKET vdev do not
accidentally join an already existing fanout group in the same netns.
Joining such a group would make each member receive only a fraction of
the packets.

It sets the PACKET_FANOUT_FLAG_UNIQUEID flag for the first queue which
asks the kernel to allocate a new, unique fanout group ID, then asks the
kernel for that queue's fanout configuration which includes this
generated ID but not the flag anymore (the flag is ephemeral) and then
uses it for subsequent queues to make them join the same fanout group.

The bug exists since the PMD's introduction in 2014:

  # 2014 DPDK:
  $ git show 364e08f2bb:lib/librte_pmd_af_packet/rte_eth_af_packet.c |
      grep getpid
    fanout_arg = (getpid() ^ (*internals)->if_index) & 0xffff;

  # v26.07:
  $ git show v26.07:drivers/net/af_packet/rte_eth_af_packet.c |
      grep getpid
    return (getpid() ^ if_index) & 0xffff;

The chance for a collision might look low initially as it requires PIDs
to be equal mod 65536. But the chance is high for applications running
in containers having individual pidns but a shared netns, which can be
the case in a k8s pod, or also with manually started containers, e.g.
`--network ns:<path>` in Podman. The individual pidns increase the
chance of different processes having the same PID.

To quickly reproduce the issue, you can start multiple AF_PACKET DPDK
applications with qpairs greater than 1, prefixing them with
`unshare --fork -p` to have each one get the same PID as if they were
executed in a container. Each one then only receives a fraction of
the traffic.

The used UNIQUEID fanout flag is available since Linux v4.12, while DPDK
currently requires Linux v5.4 or newer. The change is also compatible
with RHEL 8.

Fixes: 364e08f2bbc0 ("af_packet: add PMD for AF_PACKET-based virtual devices")
Cc: stable@dpdk.org

Signed-off-by: Frank Dressler <frank@dressler.pro>
---
 drivers/net/af_packet/rte_eth_af_packet.c | 27 +++++++++++++++--------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 44f82c0309..562f0c4abe 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -839,12 +839,6 @@ open_packet_iface(const char *key __rte_unused,
 
 #define PACKET_FANOUT_INVALID -1
 
-static int
-get_fanout_group_id(int if_index)
-{
-	return (getpid() ^ if_index) & 0xffff;
-}
-
 static int
 get_fanout_mode(const char *fanout_mode)
 {
@@ -877,11 +871,11 @@ get_fanout_mode(const char *fanout_mode)
 }
 
 static int
-get_fanout(const char *fanout_mode, int if_index)
+get_fanout(const char *fanout_mode)
 {
 	int load_balance = get_fanout_mode(fanout_mode);
 	if (load_balance != PACKET_FANOUT_INVALID)
-		return get_fanout_group_id(if_index) | (load_balance << 16);
+		return load_balance << 16;
 	else
 		return PACKET_FANOUT_INVALID;
 }
@@ -996,11 +990,12 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 	sockaddr.sll_protocol = htons(ETH_P_ALL);
 	sockaddr.sll_ifindex = (*internals)->if_index;
 
-	fanout_arg = get_fanout(fanout_mode, (*internals)->if_index);
+	fanout_arg = get_fanout(fanout_mode);
 	if (fanout_arg == PACKET_FANOUT_INVALID) {
 		PMD_LOG(ERR, "Invalid fanout mode: %s", fanout_mode);
 		goto error;
 	}
+	fanout_arg |= PACKET_FANOUT_FLAG_UNIQUEID << 16;
 
 	/*
 	 * Set the flag opportunistically if multiple queues are requested.
@@ -1142,6 +1137,20 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 					name, pair->value);
 				goto error;
 			}
+
+			/* read back the fanout arg so later queues join the same fanout group */
+			if (q == 0) {
+				socklen_t fanout_arg_len = sizeof(fanout_arg);
+				rc = getsockopt(qsockfd, SOL_PACKET, PACKET_FANOUT, &fanout_arg,
+						&fanout_arg_len);
+				if (rc == -1 || fanout_arg_len != sizeof(fanout_arg)) {
+					PMD_LOG_ERRNO(ERR,
+						"%s: could not get PACKET_FANOUT "
+						"on AF_PACKET socket for %s",
+						name, pair->value);
+					goto error;
+				}
+			}
 		}
 	}
 
-- 
2.56.0


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

* [PATCH v2] net/af_packet: fix accidental fanout group ID reuse
  2026-11-10 19:06 [PATCH 1/1] net/af_packet: fix accidental fanout group ID reuse Frank Dressler
@ 2026-11-11 10:45 ` Frank Dressler
  2026-11-16 14:17   ` Frank Dressler
  2026-11-16 17:41   ` Stephen Hemminger
  0 siblings, 2 replies; 6+ messages in thread
From: Frank Dressler @ 2026-11-11 10:45 UTC (permalink / raw)
  To: stephen; +Cc: dev, stable

This fix ensures that the queues of an AF_PACKET vdev do not
accidentally join an already existing fanout group in the same netns.
Joining such a group would make each member receive only a fraction of
the packets.

It sets the PACKET_FANOUT_FLAG_UNIQUEID flag for the first queue which
asks the kernel to allocate a new, unique fanout group ID, then asks the
kernel for that queue's fanout configuration which includes this
generated ID but not the flag anymore (the flag is ephemeral) and then
uses it for subsequent queues to make them join the same fanout group.

The bug exists since the PMD's introduction in 2014:

  # 2014 DPDK:
  $ git show 364e08f2bb:lib/librte_pmd_af_packet/rte_eth_af_packet.c |
      grep getpid
    fanout_arg = (getpid() ^ (*internals)->if_index) & 0xffff;

  # v26.07:
  $ git show v26.07:drivers/net/af_packet/rte_eth_af_packet.c |
      grep getpid
    return (getpid() ^ if_index) & 0xffff;

The chance for a collision might look low initially as it requires PIDs
to be equal mod 65536. But the chance is high for applications running
in containers having individual pidns but a shared netns, which can be
the case in a k8s pod, or also with manually started containers, e.g.
`--network ns:<path>` in Podman. The individual pidns increase the
chance of different processes having the same PID.

To quickly reproduce the issue, you can start multiple AF_PACKET DPDK
applications with qpairs greater than 1, prefixing them with
`unshare --fork -p` to have each one get the same PID as if they were
executed in a container. Each one then only receives a fraction of
the traffic.

The used UNIQUEID fanout flag is available since Linux v4.12, while DPDK
currently requires Linux v5.4 or newer. The change is also compatible
with RHEL 8.

Fixes: 364e08f2bbc0 ("af_packet: add PMD for AF_PACKET-based virtual devices")
Cc: stable@dpdk.org

Signed-off-by: Frank Dressler <frank@dressler.pro>
---
v2:
- remove unnecessary getsockopt length check

 drivers/net/af_packet/rte_eth_af_packet.c | 27 +++++++++++++++--------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 44f82c0309..fb75bdc6fe 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -839,12 +839,6 @@ open_packet_iface(const char *key __rte_unused,
 
 #define PACKET_FANOUT_INVALID -1
 
-static int
-get_fanout_group_id(int if_index)
-{
-	return (getpid() ^ if_index) & 0xffff;
-}
-
 static int
 get_fanout_mode(const char *fanout_mode)
 {
@@ -877,11 +871,11 @@ get_fanout_mode(const char *fanout_mode)
 }
 
 static int
-get_fanout(const char *fanout_mode, int if_index)
+get_fanout(const char *fanout_mode)
 {
 	int load_balance = get_fanout_mode(fanout_mode);
 	if (load_balance != PACKET_FANOUT_INVALID)
-		return get_fanout_group_id(if_index) | (load_balance << 16);
+		return load_balance << 16;
 	else
 		return PACKET_FANOUT_INVALID;
 }
@@ -996,11 +990,12 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 	sockaddr.sll_protocol = htons(ETH_P_ALL);
 	sockaddr.sll_ifindex = (*internals)->if_index;
 
-	fanout_arg = get_fanout(fanout_mode, (*internals)->if_index);
+	fanout_arg = get_fanout(fanout_mode);
 	if (fanout_arg == PACKET_FANOUT_INVALID) {
 		PMD_LOG(ERR, "Invalid fanout mode: %s", fanout_mode);
 		goto error;
 	}
+	fanout_arg |= PACKET_FANOUT_FLAG_UNIQUEID << 16;
 
 	/*
 	 * Set the flag opportunistically if multiple queues are requested.
@@ -1142,6 +1137,20 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 					name, pair->value);
 				goto error;
 			}
+
+			/* read back the fanout arg so later queues join the same fanout group */
+			if (q == 0) {
+				socklen_t fanout_arg_len = sizeof(fanout_arg);
+				rc = getsockopt(qsockfd, SOL_PACKET, PACKET_FANOUT, &fanout_arg,
+						&fanout_arg_len);
+				if (rc == -1) {
+					PMD_LOG_ERRNO(ERR,
+						"%s: could not get PACKET_FANOUT "
+						"on AF_PACKET socket for %s",
+						name, pair->value);
+					goto error;
+				}
+			}
 		}
 	}
 
-- 
2.56.0


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

* Re: [PATCH v2] net/af_packet: fix accidental fanout group ID reuse
  2026-11-11 10:45 ` [PATCH v2] " Frank Dressler
@ 2026-11-16 14:17   ` Frank Dressler
  2026-11-16 17:41   ` Stephen Hemminger
  1 sibling, 0 replies; 6+ messages in thread
From: Frank Dressler @ 2026-11-16 14:17 UTC (permalink / raw)
  To: stephen; +Cc: dev, stable

Hi, this patch has been marked “Changes Requested” in Patchwork but I 
cannot find a request. Is there anything I need to do?

- List: 
https://inbox.dpdk.org/dev/20261111104536.248312-1-frank@dressler.pro/
- Patchwork: 
https://patches.dpdk.org/project/dpdk/patch/20261111104536.248312-1-frank@dressler.pro/

On 11/11/26 10:45, Frank Dressler wrote:
> This fix ensures that the queues of an AF_PACKET vdev do not
> accidentally join an already existing fanout group in the same netns.
> Joining such a group would make each member receive only a fraction of
> the packets.
> 
> It sets the PACKET_FANOUT_FLAG_UNIQUEID flag for the first queue which
> asks the kernel to allocate a new, unique fanout group ID, then asks the
> kernel for that queue's fanout configuration which includes this
> generated ID but not the flag anymore (the flag is ephemeral) and then
> uses it for subsequent queues to make them join the same fanout group.
> 
> The bug exists since the PMD's introduction in 2014:
> 
>    # 2014 DPDK:
>    $ git show 364e08f2bb:lib/librte_pmd_af_packet/rte_eth_af_packet.c |
>        grep getpid
>      fanout_arg = (getpid() ^ (*internals)->if_index) & 0xffff;
> 
>    # v26.07:
>    $ git show v26.07:drivers/net/af_packet/rte_eth_af_packet.c |
>        grep getpid
>      return (getpid() ^ if_index) & 0xffff;
> 
> The chance for a collision might look low initially as it requires PIDs
> to be equal mod 65536. But the chance is high for applications running
> in containers having individual pidns but a shared netns, which can be
> the case in a k8s pod, or also with manually started containers, e.g.
> `--network ns:<path>` in Podman. The individual pidns increase the
> chance of different processes having the same PID.
> 
> To quickly reproduce the issue, you can start multiple AF_PACKET DPDK
> applications with qpairs greater than 1, prefixing them with
> `unshare --fork -p` to have each one get the same PID as if they were
> executed in a container. Each one then only receives a fraction of
> the traffic.
> 
> The used UNIQUEID fanout flag is available since Linux v4.12, while DPDK
> currently requires Linux v5.4 or newer. The change is also compatible
> with RHEL 8.
> 
> Fixes: 364e08f2bbc0 ("af_packet: add PMD for AF_PACKET-based virtual devices")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Frank Dressler <frank@dressler.pro>
> ---
> v2:
> - remove unnecessary getsockopt length check
> 
>   drivers/net/af_packet/rte_eth_af_packet.c | 27 +++++++++++++++--------
>   1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
> index 44f82c0309..fb75bdc6fe 100644
> --- a/drivers/net/af_packet/rte_eth_af_packet.c
> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
> @@ -839,12 +839,6 @@ open_packet_iface(const char *key __rte_unused,
>   
>   #define PACKET_FANOUT_INVALID -1
>   
> -static int
> -get_fanout_group_id(int if_index)
> -{
> -	return (getpid() ^ if_index) & 0xffff;
> -}
> -
>   static int
>   get_fanout_mode(const char *fanout_mode)
>   {
> @@ -877,11 +871,11 @@ get_fanout_mode(const char *fanout_mode)
>   }
>   
>   static int
> -get_fanout(const char *fanout_mode, int if_index)
> +get_fanout(const char *fanout_mode)
>   {
>   	int load_balance = get_fanout_mode(fanout_mode);
>   	if (load_balance != PACKET_FANOUT_INVALID)
> -		return get_fanout_group_id(if_index) | (load_balance << 16);
> +		return load_balance << 16;
>   	else
>   		return PACKET_FANOUT_INVALID;
>   }
> @@ -996,11 +990,12 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
>   	sockaddr.sll_protocol = htons(ETH_P_ALL);
>   	sockaddr.sll_ifindex = (*internals)->if_index;
>   
> -	fanout_arg = get_fanout(fanout_mode, (*internals)->if_index);
> +	fanout_arg = get_fanout(fanout_mode);
>   	if (fanout_arg == PACKET_FANOUT_INVALID) {
>   		PMD_LOG(ERR, "Invalid fanout mode: %s", fanout_mode);
>   		goto error;
>   	}
> +	fanout_arg |= PACKET_FANOUT_FLAG_UNIQUEID << 16;
>   
>   	/*
>   	 * Set the flag opportunistically if multiple queues are requested.
> @@ -1142,6 +1137,20 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
>   					name, pair->value);
>   				goto error;
>   			}
> +
> +			/* read back the fanout arg so later queues join the same fanout group */
> +			if (q == 0) {
> +				socklen_t fanout_arg_len = sizeof(fanout_arg);
> +				rc = getsockopt(qsockfd, SOL_PACKET, PACKET_FANOUT, &fanout_arg,
> +						&fanout_arg_len);
> +				if (rc == -1) {
> +					PMD_LOG_ERRNO(ERR,
> +						"%s: could not get PACKET_FANOUT "
> +						"on AF_PACKET socket for %s",
> +						name, pair->value);
> +					goto error;
> +				}
> +			}
>   		}
>   	}
>   


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

* Re: [PATCH v2] net/af_packet: fix accidental fanout group ID reuse
  2026-11-11 10:45 ` [PATCH v2] " Frank Dressler
  2026-11-16 14:17   ` Frank Dressler
@ 2026-11-16 17:41   ` Stephen Hemminger
  2026-11-16 18:53     ` Frank Dressler
  1 sibling, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2026-11-16 17:41 UTC (permalink / raw)
  To: Frank Dressler; +Cc: dev, stable

On Wed, 11 Nov 2026 10:45:36 +0000
Frank Dressler <frank@dressler.pro> wrote:

> This fix ensures that the queues of an AF_PACKET vdev do not
> accidentally join an already existing fanout group in the same netns.
> Joining such a group would make each member receive only a fraction of
> the packets.
> 
> It sets the PACKET_FANOUT_FLAG_UNIQUEID flag for the first queue which
> asks the kernel to allocate a new, unique fanout group ID, then asks the
> kernel for that queue's fanout configuration which includes this
> generated ID but not the flag anymore (the flag is ephemeral) and then
> uses it for subsequent queues to make them join the same fanout group.
> 
> The bug exists since the PMD's introduction in 2014:
> 
>   # 2014 DPDK:
>   $ git show 364e08f2bb:lib/librte_pmd_af_packet/rte_eth_af_packet.c |
>       grep getpid
>     fanout_arg = (getpid() ^ (*internals)->if_index) & 0xffff;
> 
>   # v26.07:
>   $ git show v26.07:drivers/net/af_packet/rte_eth_af_packet.c |
>       grep getpid
>     return (getpid() ^ if_index) & 0xffff;
> 
> The chance for a collision might look low initially as it requires PIDs
> to be equal mod 65536. But the chance is high for applications running
> in containers having individual pidns but a shared netns, which can be
> the case in a k8s pod, or also with manually started containers, e.g.
> `--network ns:<path>` in Podman. The individual pidns increase the
> chance of different processes having the same PID.
> 
> To quickly reproduce the issue, you can start multiple AF_PACKET DPDK
> applications with qpairs greater than 1, prefixing them with
> `unshare --fork -p` to have each one get the same PID as if they were
> executed in a container. Each one then only receives a fraction of
> the traffic.
> 
> The used UNIQUEID fanout flag is available since Linux v4.12, while DPDK
> currently requires Linux v5.4 or newer. The change is also compatible
> with RHEL 8.
> 
> Fixes: 364e08f2bbc0 ("af_packet: add PMD for AF_PACKET-based virtual devices")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Frank Dressler <frank@dressler.pro>
> ---

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

The commit message is way to long though. Will chop it during merge.
You need to tell you AI to be concise. I have started using multiple
prompts to tell it to not repeat.

The kernel review prompt includes /kslop skill which has:
https://github.com/masoncl/review-prompts/blob/main/kernel/slop-indicators.md

AI even flagged that:


Logic is correct. The kernel clears PACKET_FANOUT_FLAG_UNIQUEID from
the stored group flags after allocating the id, and PACKET_FANOUT
getsockopt returns id | type << 16 | flags << 24, which is exactly
the encoding fanout_add() needs for the later queues to pass the
match->flags/type checks and join. DEFRAG, ROLLOVER and
IGNORE_OUTGOING survive the round trip unchanged.

Info

The commit message is longer than it needs to be. The two git show
transcripts repeat what the Fixes: tag already says; dropping them
and the "This fix ensures" opener would leave something like:

  The fanout group id was derived from (getpid() ^ ifindex), so
  processes in separate pid namespaces sharing a netns (e.g. a k8s
  pod) can pick the same id. Their queues then join one fanout group
  and each process sees only part of the traffic.

  Use PACKET_FANOUT_FLAG_UNIQUEID on the first queue so the kernel
  allocates an unused id, then read it back with getsockopt and use
  it for the remaining queues.

  PACKET_FANOUT_FLAG_UNIQUEID is available since Linux 4.12.

Worth one sentence: this also fixes two af_packet vdevs on the same
interface in one process, which previously shared a group because
pid and ifindex were identical.

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

* Re: [PATCH v2] net/af_packet: fix accidental fanout group ID reuse
  2026-11-16 17:41   ` Stephen Hemminger
@ 2026-11-16 18:53     ` Frank Dressler
  2026-11-16 19:04       ` Stephen Hemminger
  0 siblings, 1 reply; 6+ messages in thread
From: Frank Dressler @ 2026-11-16 18:53 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, stable

On 11/16/26 17:41, Stephen Hemminger wrote:
> On Wed, 11 Nov 2026 10:45:36 +0000
> Frank Dressler <frank@dressler.pro> wrote:
> 
>> This fix ensures that the queues of an AF_PACKET vdev do not
>> accidentally join an already existing fanout group in the same netns.
>> Joining such a group would make each member receive only a fraction of
>> the packets.
>>
>> It sets the PACKET_FANOUT_FLAG_UNIQUEID flag for the first queue which
>> asks the kernel to allocate a new, unique fanout group ID, then asks the
>> kernel for that queue's fanout configuration which includes this
>> generated ID but not the flag anymore (the flag is ephemeral) and then
>> uses it for subsequent queues to make them join the same fanout group.
>>
>> The bug exists since the PMD's introduction in 2014:
>>
>>    # 2014 DPDK:
>>    $ git show 364e08f2bb:lib/librte_pmd_af_packet/rte_eth_af_packet.c |
>>        grep getpid
>>      fanout_arg = (getpid() ^ (*internals)->if_index) & 0xffff;
>>
>>    # v26.07:
>>    $ git show v26.07:drivers/net/af_packet/rte_eth_af_packet.c |
>>        grep getpid
>>      return (getpid() ^ if_index) & 0xffff;
>>
>> The chance for a collision might look low initially as it requires PIDs
>> to be equal mod 65536. But the chance is high for applications running
>> in containers having individual pidns but a shared netns, which can be
>> the case in a k8s pod, or also with manually started containers, e.g.
>> `--network ns:<path>` in Podman. The individual pidns increase the
>> chance of different processes having the same PID.
>>
>> To quickly reproduce the issue, you can start multiple AF_PACKET DPDK
>> applications with qpairs greater than 1, prefixing them with
>> `unshare --fork -p` to have each one get the same PID as if they were
>> executed in a container. Each one then only receives a fraction of
>> the traffic.
>>
>> The used UNIQUEID fanout flag is available since Linux v4.12, while DPDK
>> currently requires Linux v5.4 or newer. The change is also compatible
>> with RHEL 8.
>>
>> Fixes: 364e08f2bbc0 ("af_packet: add PMD for AF_PACKET-based virtual devices")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Frank Dressler <frank@dressler.pro>
>> ---
> 
> Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
> 
> The commit message is way to long though. Will chop it during merge.

Thank you.

> You need to tell you AI to be concise. I have started using multiple
> prompts to tell it to not repeat.
> 

I did try let AI generate the commit message but it was too short and 
did not give me the impression that a reader without my context could 
easily understand and review the issue. So I wrote my own message.

This is not the first time people think I used AI when I did not. It is 
always very demotivating. 
https://github.com/secdev/scapy/issues/4964#issuecomment-6124262531 But 
I understand when people think things are AI even when they are not 
given the amount of AI generated content.

I'll try writing more concise messages in the future.

> The kernel review prompt includes /kslop skill which has:
> https://github.com/masoncl/review-prompts/blob/main/kernel/slop-indicators.md
> 

It would feel weird applying AI-detection stuff to hand-written commits 
just to make sure people relying on it do not get confused by such 
broken tools that lead to miscategorizations.

> AI even flagged that:
> 

I started to run the AI patch review locally a while ago after noticing 
its horrible quality to prevent sending unnecessary patch versions. When 
I run it with just `./devtools/ai/review-patch.py <patch>` it says

	Error: API error: {'type': 'not_found_error', 'message': 'model: 
claude-sonnet-4-5-20250929'}

So I switched it to claude-sonnet-4-6 and that just outputs some very 
stupid comments that read like "I found a bug. ... Oh, no, it is not a 
bug. Actually, re-reading the logic carefully ... This is correct. There 
is one real issue: ... This is correct. No correctness errors found ... 
Warning: ... No issue. ... No Errors or Warnings found." With 
claude-opus-5-5 it becomes sane or broken because it just says "No 
issues found. Review-Result: CLEAN"

> 
> Logic is correct. The kernel clears PACKET_FANOUT_FLAG_UNIQUEID from
> the stored group flags after allocating the id, and PACKET_FANOUT
> getsockopt returns id | type << 16 | flags << 24, which is exactly
> the encoding fanout_add() needs for the later queues to pass the
> match->flags/type checks and join. DEFRAG, ROLLOVER and
> IGNORE_OUTGOING survive the round trip unchanged.
> 
> Info
> 
> The commit message is longer than it needs to be. The two git show
> transcripts repeat what the Fixes: tag already says; dropping them
> and the "This fix ensures" opener would leave something like:
> 
>    The fanout group id was derived from (getpid() ^ ifindex), so
>    processes in separate pid namespaces sharing a netns (e.g. a k8s
>    pod) can pick the same id. Their queues then join one fanout group
>    and each process sees only part of the traffic.
> 
>    Use PACKET_FANOUT_FLAG_UNIQUEID on the first queue so the kernel
>    allocates an unused id, then read it back with getsockopt and use
>    it for the remaining queues.
> 
>    PACKET_FANOUT_FLAG_UNIQUEID is available since Linux 4.12.
> 
> Worth one sentence: this also fixes two af_packet vdevs on the same
> interface in one process, which previously shared a group because
> pid and ifindex were identical.


How do I reproduce this output? Is it created with the review-patch.py tool?


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

* Re: [PATCH v2] net/af_packet: fix accidental fanout group ID reuse
  2026-11-16 18:53     ` Frank Dressler
@ 2026-11-16 19:04       ` Stephen Hemminger
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2026-11-16 19:04 UTC (permalink / raw)
  To: Frank Dressler; +Cc: dev, stable

On Mon, 16 Nov 2026 18:53:54 +0000
Frank Dressler <frank@dressler.pro> wrote:

> On 11/16/26 17:41, Stephen Hemminger wrote:
> > On Wed, 11 Nov 2026 10:45:36 +0000
> > Frank Dressler <frank@dressler.pro> wrote:
> >   
> >> This fix ensures that the queues of an AF_PACKET vdev do not
> >> accidentally join an already existing fanout group in the same netns.
> >> Joining such a group would make each member receive only a fraction of
> >> the packets.
> >>
> >> It sets the PACKET_FANOUT_FLAG_UNIQUEID flag for the first queue which
> >> asks the kernel to allocate a new, unique fanout group ID, then asks the
> >> kernel for that queue's fanout configuration which includes this
> >> generated ID but not the flag anymore (the flag is ephemeral) and then
> >> uses it for subsequent queues to make them join the same fanout group.
> >>
> >> The bug exists since the PMD's introduction in 2014:
> >>
> >>    # 2014 DPDK:
> >>    $ git show 364e08f2bb:lib/librte_pmd_af_packet/rte_eth_af_packet.c |
> >>        grep getpid
> >>      fanout_arg = (getpid() ^ (*internals)->if_index) & 0xffff;
> >>
> >>    # v26.07:
> >>    $ git show v26.07:drivers/net/af_packet/rte_eth_af_packet.c |
> >>        grep getpid
> >>      return (getpid() ^ if_index) & 0xffff;
> >>
> >> The chance for a collision might look low initially as it requires PIDs
> >> to be equal mod 65536. But the chance is high for applications running
> >> in containers having individual pidns but a shared netns, which can be
> >> the case in a k8s pod, or also with manually started containers, e.g.
> >> `--network ns:<path>` in Podman. The individual pidns increase the
> >> chance of different processes having the same PID.
> >>
> >> To quickly reproduce the issue, you can start multiple AF_PACKET DPDK
> >> applications with qpairs greater than 1, prefixing them with
> >> `unshare --fork -p` to have each one get the same PID as if they were
> >> executed in a container. Each one then only receives a fraction of
> >> the traffic.
> >>
> >> The used UNIQUEID fanout flag is available since Linux v4.12, while DPDK
> >> currently requires Linux v5.4 or newer. The change is also compatible
> >> with RHEL 8.
> >>
> >> Fixes: 364e08f2bbc0 ("af_packet: add PMD for AF_PACKET-based virtual devices")
> >> Cc: stable@dpdk.org
> >>
> >> Signed-off-by: Frank Dressler <frank@dressler.pro>
> >> ---  
> > 
> > Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
> > 
> > The commit message is way to long though. Will chop it during merge.  
> 
> Thank you.
> 
> > You need to tell you AI to be concise. I have started using multiple
> > prompts to tell it to not repeat.
> >   
> 
> I did try let AI generate the commit message but it was too short and 
> did not give me the impression that a reader without my context could 
> easily understand and review the issue. So I wrote my own message.
> 
> This is not the first time people think I used AI when I did not. It is 
> always very demotivating. 
> https://github.com/secdev/scapy/issues/4964#issuecomment-6124262531 But 
> I understand when people think things are AI even when they are not 
> given the amount of AI generated content.
> 
> I'll try writing more concise messages in the future.
> 
> > The kernel review prompt includes /kslop skill which has:
> > https://github.com/masoncl/review-prompts/blob/main/kernel/slop-indicators.md
> >   
> 
> It would feel weird applying AI-detection stuff to hand-written commits 
> just to make sure people relying on it do not get confused by such 
> broken tools that lead to miscategorizations.
> 
> > AI even flagged that:
> >   
> 
> I started to run the AI patch review locally a while ago after noticing 
> its horrible quality to prevent sending unnecessary patch versions. When 
> I run it with just `./devtools/ai/review-patch.py <patch>` it says
> 
> 	Error: API error: {'type': 'not_found_error', 'message': 'model: 
> claude-sonnet-4-5-20250929'}
> 
> So I switched it to claude-sonnet-4-6 and that just outputs some very 
> stupid comments that read like "I found a bug. ... Oh, no, it is not a 
> bug. Actually, re-reading the logic carefully ... This is correct. There 
> is one real issue: ... This is correct. No correctness errors found ... 
> Warning: ... No issue. ... No Errors or Warnings found." With 
> claude-opus-5-5 it becomes sane or broken because it just says "No 
> issues found. Review-Result: CLEAN"
> 
> > 
> > Logic is correct. The kernel clears PACKET_FANOUT_FLAG_UNIQUEID from
> > the stored group flags after allocating the id, and PACKET_FANOUT
> > getsockopt returns id | type << 16 | flags << 24, which is exactly
> > the encoding fanout_add() needs for the later queues to pass the
> > match->flags/type checks and join. DEFRAG, ROLLOVER and
> > IGNORE_OUTGOING survive the round trip unchanged.
> > 
> > Info
> > 
> > The commit message is longer than it needs to be. The two git show
> > transcripts repeat what the Fixes: tag already says; dropping them
> > and the "This fix ensures" opener would leave something like:
> > 
> >    The fanout group id was derived from (getpid() ^ ifindex), so
> >    processes in separate pid namespaces sharing a netns (e.g. a k8s
> >    pod) can pick the same id. Their queues then join one fanout group
> >    and each process sees only part of the traffic.
> > 
> >    Use PACKET_FANOUT_FLAG_UNIQUEID on the first queue so the kernel
> >    allocates an unused id, then read it back with getsockopt and use
> >    it for the remaining queues.
> > 
> >    PACKET_FANOUT_FLAG_UNIQUEID is available since Linux 4.12.
> > 
> > Worth one sentence: this also fixes two af_packet vdevs on the same
> > interface in one process, which previously shared a group because
> > pid and ifindex were identical.  
> 
> 
> How do I reproduce this output? Is it created with the review-patch.py tool?
> 

Mostly I am trying to suppress the over wording AI does.
Especially in comments.
AI seems to generate a PhD thesis for a one line bug report

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

end of thread, other threads:[~2026-11-16 19:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10 19:06 [PATCH 1/1] net/af_packet: fix accidental fanout group ID reuse Frank Dressler
2026-11-11 10:45 ` [PATCH v2] " Frank Dressler
2026-11-16 14:17   ` Frank Dressler
2026-11-16 17:41   ` Stephen Hemminger
2026-11-16 18:53     ` Frank Dressler
2026-11-16 19:04       ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox