[PATCH] ethdev: fix strict aliasing lead to link cannot be up

Stephen Hemminger stephen at networkplumber.org
Thu Apr 11 17:05:30 CEST 2024


On Thu, 11 Apr 2024 03:07:49 +0000
Chengwen Feng <fengchengwen at huawei.com> wrote:

> Fix a problem introduced by a compiler upgrade (from gcc10 to gcc12.3),
> which will lead the hns3 NIC can't link up. The root cause is strict
> aliasing violation in rte_eth_linkstatus_set() with hns3 driver, see
> [1] for more details.
> 
> This commit use union to avoid such aliasing violation.
> 
> [1] Strict aliasing problem with rte_eth_linkstatus_set()
>     https://marc.info/?l=dpdk-dev&m=171274148514777&w=3
> 
> Cc: stable at dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
> Signed-off-by: Dengdui Huang <huangdengdui at huawei.com>
> ---

The patch to use union is correct.
Examining the link status fuller raises a couple of pre-existing issues.

1. Why is this an inline function, there is no way this is in the
   fast path of any driver or application?

2. Why is it marked sequential consistent and not relaxed? How could there be a visible
   relationship between link status and other variables. Drivers would
   not be using the link status state as internal variable.



More information about the dev mailing list