lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZqRv2uXUk21uj7Gt@kodidev-ubuntu>
Date: Fri, 26 Jul 2024 20:56:10 -0700
From: Tony Ambardar <tony.ambardar@...il.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: bpf@...r.kernel.org, linux-kselftest@...r.kernel.org,
	netdev@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
	Daniel Borkmann <daniel@...earbox.net>,
	Andrii Nakryiko <andrii@...nel.org>,
	Martin KaFai Lau <martin.lau@...ux.dev>,
	Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>,
	Yonghong Song <yonghong.song@...ux.dev>,
	John Fastabend <john.fastabend@...il.com>,
	KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>,
	Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
	Mykola Lysenko <mykolal@...com>, Shuah Khan <shuah@...nel.org>,
	Björn Töpel <bjorn@...nel.org>,
	Magnus Karlsson <magnus.karlsson@...el.com>,
	Maciej Fijalkowski <maciej.fijalkowski@...el.com>,
	Jonathan Lemon <jonathan.lemon@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Yan Zhai <yan@...udflare.com>
Subject: Re: [PATCH bpf-next v1 5/8] selftests/bpf: Fix order-of-include
 compile errors in lwt_reroute.c

On Thu, Jul 25, 2024 at 01:18:04PM -0700, Andrii Nakryiko wrote:
> On Thu, Jul 25, 2024 at 3:39 AM Tony Ambardar <tony.ambardar@...il.com> wrote:
> >
> > From: Tony Ambardar <tony.ambardar@...il.com>
> >
> > Fix redefinition errors seen compiling lwt_reroute.c for mips64el/musl-libc
> > by adjusting the order of includes in lwt_helpers.h. The ordering required
> > is:
> > <net/if.h>  -->  <arpa/inet.h> (from "test_progs.h")  -->  <linux/icmp.h>.
> >
> > Because of the complexity and large number of includes, ordering appears to
> > be fragile however. Previously, with "test_progs.h" at the end of this
> > sequence, compiling with GCC 12.3 for mips64el/musl-libc yields errors:
> >
> > In file included from .../include/arpa/inet.h:9,
> >                  from ./test_progs.h:18,
> >                  from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:11,
> >                  from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52:
> > .../include/netinet/in.h:23:8: error: redefinition of 'struct in6_addr'
> >    23 | struct in6_addr {
> >       |        ^~~~~~~~
> > In file included from .../include/linux/icmp.h:24,
> >                  from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:9:
> > .../include/linux/in6.h:33:8: note: originally defined here
> >    33 | struct in6_addr {
> >       |        ^~~~~~~~
> > .../include/netinet/in.h:34:8: error: redefinition of 'struct sockaddr_in6'
> >    34 | struct sockaddr_in6 {
> >       |        ^~~~~~~~~~~~
> > .../include/linux/in6.h:50:8: note: originally defined here
> >    50 | struct sockaddr_in6 {
> >       |        ^~~~~~~~~~~~
> > .../include/netinet/in.h:42:8: error: redefinition of 'struct ipv6_mreq'
> >    42 | struct ipv6_mreq {
> >       |        ^~~~~~~~~
> > .../include/linux/in6.h:60:8: note: originally defined here
> >    60 | struct ipv6_mreq {
> >       |        ^~~~~~~~~
> >
> > Similarly, with "test_progs.h" at the beginning of this sequence, compiling
> > with GCC 12.3 for x86_64 using glibc would fail like this:
> >
> > In file included from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:8,
> >                  from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52:
> > /usr/include/linux/if.h:83:9: error: redeclaration of enumerator ‘IFF_UP’
> >    83 |         IFF_UP                          = 1<<0,  /* sysfs */
> >       |         ^~~~~~
> > /usr/include/net/if.h:44:5: note: previous definition of ‘IFF_UP’ with type ‘enum <anonymous>’
> >    44 |     IFF_UP = 0x1,               /* Interface is up.  */
> >       |     ^~~~~~
> > /usr/include/linux/if.h:84:9: error: redeclaration of enumerator ‘IFF_BROADCAST’
> >    84 |         IFF_BROADCAST                   = 1<<1,  /* __volatile__ */
> >       |         ^~~~~~~~~~~~~
> > /usr/include/net/if.h:46:5: note: previous definition of ‘IFF_BROADCAST’ with type ‘enum <anonymous>’
> >    46 |     IFF_BROADCAST = 0x2,        /* Broadcast address valid.  */
> >       |     ^~~~~~~~~~~~~
> >
> > ...
> >
> > In file included from /usr/include/linux/icmp.h:23,
> >                  from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:10,
> >                  from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52:
> > /usr/include/linux/if.h:194:8: error: redefinition of ‘struct ifmap’
> >   194 | struct ifmap {
> >       |        ^~~~~
> > In file included from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:8,
> >                  from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52:
> > /usr/include/net/if.h:111:8: note: originally defined here
> >   111 | struct ifmap
> >       |        ^~~~~
> > In file included from /usr/include/linux/icmp.h:23,
> >                  from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:10,
> >                  from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52:
> > /usr/include/linux/if.h:232:8: error: redefinition of ‘struct ifreq’
> >   232 | struct ifreq {
> >       |        ^~~~~
> > In file included from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:8,
> >                  from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52:
> > /usr/include/net/if.h:126:8: note: originally defined here
> >   126 | struct ifreq
> >       |        ^~~~~
> >
> > Fixes: 43a7c3ef8a15 ("selftests/bpf: Add lwt_xmit tests for BPF_REDIRECT")
> > Signed-off-by: Tony Ambardar <tony.ambardar@...il.com>
> > ---
> >  tools/testing/selftests/bpf/prog_tests/lwt_helpers.h | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h b/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h
> > index fb1eb8c67361..8e5e28af03c5 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h
> > +++ b/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h
> > @@ -6,10 +6,9 @@
> >  #include <time.h>
> >  #include <net/if.h>
> >  #include <linux/if_tun.h>
> > +#include "test_progs.h" /* between <net/if.h> and <linux/icmp.h> or errors */
> 
> Now we'll be papering over the real issue. Can you see if you can
> untangle this mess and ensure that we consistently use either net/if.h
> or linux/if.h headers?
> 

Well, "untangle this mess" is certainly the right phrase, so I'll give it
another go and see what I can find.

> pw-bot: cr
> 
> >  #include <linux/icmp.h>
> >
> > -#include "test_progs.h"
> > -
> >  #define log_err(MSG, ...) \
> >         fprintf(stderr, "(%s:%d: errno: %s) " MSG "\n", \
> >                 __FILE__, __LINE__, strerror(errno), ##__VA_ARGS__)
> > --
> > 2.34.1
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ