netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] ipv4: Fix user space build failure due to header change
@ 2024-09-03 13:35 Ido Schimmel
  2024-09-03 14:39 ` David Ahern
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ido Schimmel @ 2024-09-03 13:35 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, pabeni, edumazet, dsahern, gnault, Ido Schimmel

RT_TOS() from include/uapi/linux/in_route.h is defined using
IPTOS_TOS_MASK from include/uapi/linux/ip.h. This is problematic for
files such as include/net/ip_fib.h that want to use RT_TOS() as without
including both header files kernel compilation fails:

In file included from ./include/net/ip_fib.h:25,
                 from ./include/net/route.h:27,
                 from ./include/net/lwtunnel.h:9,
                 from net/core/dst.c:24:
./include/net/ip_fib.h: In function ‘fib_dscp_masked_match’:
./include/uapi/linux/in_route.h:31:32: error: ‘IPTOS_TOS_MASK’ undeclared (first use in this function)
   31 | #define RT_TOS(tos)     ((tos)&IPTOS_TOS_MASK)
      |                                ^~~~~~~~~~~~~~
./include/net/ip_fib.h:440:45: note: in expansion of macro ‘RT_TOS’
  440 |         return dscp == inet_dsfield_to_dscp(RT_TOS(fl4->flowi4_tos));

Therefore, cited commit changed linux/in_route.h to include linux/ip.h.
However, as reported by David, this breaks iproute2 compilation due
overlapping definitions between linux/ip.h and
/usr/include/netinet/ip.h:

In file included from ../include/uapi/linux/in_route.h:5,
                 from iproute.c:19:
../include/uapi/linux/ip.h:25:9: warning: "IPTOS_TOS" redefined
   25 | #define IPTOS_TOS(tos)          ((tos)&IPTOS_TOS_MASK)
      |         ^~~~~~~~~
In file included from iproute.c:17:
/usr/include/netinet/ip.h:222:9: note: this is the location of the previous definition
  222 | #define IPTOS_TOS(tos)          ((tos) & IPTOS_TOS_MASK)

Fix by changing include/net/ip_fib.h to include linux/ip.h. Note that
usage of RT_TOS() should not spread further in the kernel due to recent
work in this area.

Fixes: 1fa3314c14c6 ("ipv4: Centralize TOS matching")
Reported-by: David Ahern <dsahern@kernel.org>
Closes: https://lore.kernel.org/netdev/2f5146ff-507d-4cab-a195-b28c0c9e654e@kernel.org/
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 include/net/ip_fib.h          | 1 +
 include/uapi/linux/in_route.h | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 269ec10f63e4..967e4dc555fa 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -22,6 +22,7 @@
 #include <linux/percpu.h>
 #include <linux/notifier.h>
 #include <linux/refcount.h>
+#include <linux/ip.h>
 #include <linux/in_route.h>
 
 struct fib_config {
diff --git a/include/uapi/linux/in_route.h b/include/uapi/linux/in_route.h
index 10bdd7e7107f..0cc2c23b47f8 100644
--- a/include/uapi/linux/in_route.h
+++ b/include/uapi/linux/in_route.h
@@ -2,8 +2,6 @@
 #ifndef _LINUX_IN_ROUTE_H
 #define _LINUX_IN_ROUTE_H
 
-#include <linux/ip.h>
-
 /* IPv4 routing cache flags */
 
 #define RTCF_DEAD	RTNH_F_DEAD
-- 
2.46.0


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

* Re: [PATCH net-next] ipv4: Fix user space build failure due to header change
  2024-09-03 13:35 [PATCH net-next] ipv4: Fix user space build failure due to header change Ido Schimmel
@ 2024-09-03 14:39 ` David Ahern
  2024-09-03 15:30 ` Guillaume Nault
  2024-09-05  0:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2024-09-03 14:39 UTC (permalink / raw)
  To: Ido Schimmel, netdev; +Cc: davem, kuba, pabeni, edumazet, gnault

On 9/3/24 7:35 AM, Ido Schimmel wrote:
> RT_TOS() from include/uapi/linux/in_route.h is defined using
> IPTOS_TOS_MASK from include/uapi/linux/ip.h. This is problematic for
> files such as include/net/ip_fib.h that want to use RT_TOS() as without
> including both header files kernel compilation fails:
> 

...

> 
> Fix by changing include/net/ip_fib.h to include linux/ip.h. Note that
> usage of RT_TOS() should not spread further in the kernel due to recent
> work in this area.
> 
> Fixes: 1fa3314c14c6 ("ipv4: Centralize TOS matching")
> Reported-by: David Ahern <dsahern@kernel.org>
> Closes: https://lore.kernel.org/netdev/2f5146ff-507d-4cab-a195-b28c0c9e654e@kernel.org/
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> ---
>  include/net/ip_fib.h          | 1 +
>  include/uapi/linux/in_route.h | 2 --
>  2 files changed, 1 insertion(+), 2 deletions(-)
> 

Reviewed-by: David Ahern <dsahern@kernel.org>


Thanks, Ido.


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

* Re: [PATCH net-next] ipv4: Fix user space build failure due to header change
  2024-09-03 13:35 [PATCH net-next] ipv4: Fix user space build failure due to header change Ido Schimmel
  2024-09-03 14:39 ` David Ahern
@ 2024-09-03 15:30 ` Guillaume Nault
  2024-09-05  0:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Guillaume Nault @ 2024-09-03 15:30 UTC (permalink / raw)
  To: Ido Schimmel; +Cc: netdev, davem, kuba, pabeni, edumazet, dsahern

On Tue, Sep 03, 2024 at 04:35:54PM +0300, Ido Schimmel wrote:
> RT_TOS() from include/uapi/linux/in_route.h is defined using
> IPTOS_TOS_MASK from include/uapi/linux/ip.h. This is problematic for
> files such as include/net/ip_fib.h that want to use RT_TOS() as without
> including both header files kernel compilation fails:
> 
> In file included from ./include/net/ip_fib.h:25,
>                  from ./include/net/route.h:27,
>                  from ./include/net/lwtunnel.h:9,
>                  from net/core/dst.c:24:
> ./include/net/ip_fib.h: In function ‘fib_dscp_masked_match’:
> ./include/uapi/linux/in_route.h:31:32: error: ‘IPTOS_TOS_MASK’ undeclared (first use in this function)
>    31 | #define RT_TOS(tos)     ((tos)&IPTOS_TOS_MASK)
>       |                                ^~~~~~~~~~~~~~
> ./include/net/ip_fib.h:440:45: note: in expansion of macro ‘RT_TOS’
>   440 |         return dscp == inet_dsfield_to_dscp(RT_TOS(fl4->flowi4_tos));
> 
> Therefore, cited commit changed linux/in_route.h to include linux/ip.h.
> However, as reported by David, this breaks iproute2 compilation due
> overlapping definitions between linux/ip.h and
> /usr/include/netinet/ip.h:
> 
> In file included from ../include/uapi/linux/in_route.h:5,
>                  from iproute.c:19:
> ../include/uapi/linux/ip.h:25:9: warning: "IPTOS_TOS" redefined
>    25 | #define IPTOS_TOS(tos)          ((tos)&IPTOS_TOS_MASK)
>       |         ^~~~~~~~~
> In file included from iproute.c:17:
> /usr/include/netinet/ip.h:222:9: note: this is the location of the previous definition
>   222 | #define IPTOS_TOS(tos)          ((tos) & IPTOS_TOS_MASK)
> 
> Fix by changing include/net/ip_fib.h to include linux/ip.h. Note that
> usage of RT_TOS() should not spread further in the kernel due to recent
> work in this area.

Reviewed-by: Guillaume Nault <gnault@redhat.com>


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

* Re: [PATCH net-next] ipv4: Fix user space build failure due to header change
  2024-09-03 13:35 [PATCH net-next] ipv4: Fix user space build failure due to header change Ido Schimmel
  2024-09-03 14:39 ` David Ahern
  2024-09-03 15:30 ` Guillaume Nault
@ 2024-09-05  0:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-05  0:00 UTC (permalink / raw)
  To: Ido Schimmel; +Cc: netdev, davem, kuba, pabeni, edumazet, dsahern, gnault

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 3 Sep 2024 16:35:54 +0300 you wrote:
> RT_TOS() from include/uapi/linux/in_route.h is defined using
> IPTOS_TOS_MASK from include/uapi/linux/ip.h. This is problematic for
> files such as include/net/ip_fib.h that want to use RT_TOS() as without
> including both header files kernel compilation fails:
> 
> In file included from ./include/net/ip_fib.h:25,
>                  from ./include/net/route.h:27,
>                  from ./include/net/lwtunnel.h:9,
>                  from net/core/dst.c:24:
> ./include/net/ip_fib.h: In function ‘fib_dscp_masked_match’:
> ./include/uapi/linux/in_route.h:31:32: error: ‘IPTOS_TOS_MASK’ undeclared (first use in this function)
>    31 | #define RT_TOS(tos)     ((tos)&IPTOS_TOS_MASK)
>       |                                ^~~~~~~~~~~~~~
> ./include/net/ip_fib.h:440:45: note: in expansion of macro ‘RT_TOS’
>   440 |         return dscp == inet_dsfield_to_dscp(RT_TOS(fl4->flowi4_tos));
> 
> [...]

Here is the summary with links:
  - [net-next] ipv4: Fix user space build failure due to header change
    https://git.kernel.org/netdev/net-next/c/1083d733eb26

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-09-05  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-03 13:35 [PATCH net-next] ipv4: Fix user space build failure due to header change Ido Schimmel
2024-09-03 14:39 ` David Ahern
2024-09-03 15:30 ` Guillaume Nault
2024-09-05  0:00 ` patchwork-bot+netdevbpf

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