All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] ip: Fix compilation break on old systems
@ 2017-11-13 10:21 Leon Romanovsky
  2017-11-13 15:33 ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2017-11-13 10:21 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, Leon Romanovsky, Cong Wang, Riad Abo Raed

From: Leon Romanovsky <leonro@mellanox.com>

As was reported [1], the iproute2 fails to compile on old systems,
in Cong's case, it was Fedora 19, in our case it was RedHat 7.2, which
failed with the following errors during compilation:

ipxfrm.c: In function ‘xfrm_selector_print’:
ipxfrm.c:479:7: error: ‘IPPROTO_MH’ undeclared (first use in this
function)
  case IPPROTO_MH:
       ^
ipxfrm.c:479:7: note: each undeclared identifier is reported only once
for each function it appears in
ipxfrm.c: In function ‘xfrm_selector_upspec_parse’:
ipxfrm.c:1345:8: error: ‘IPPROTO_MH’ undeclared (first use in this
function)
   case IPPROTO_MH:
        ^                                                                                                                                                            make[1]: *** [ipxfrm.o] Error 1

The reason to it is the order of headers files. The IPPROTO_MH field is
set in kernel's UAPI header file (in6.h), but only in case
__UAPI_DEF_IPPROTO_V6 is set before. That define comes from other kernel's
header file (libc-compat.h) and is set in case there are no previous
libc relevant declarations.

In ip code, the include of <netdb.h> causes to indirect inclusion of
<netinet/in.h> and it sets __UAPI_DEF_IPPROTO_V6 to be zero and prevents from
IPPROTO_MH declaration.

This patch takes the simplest possible approach to fix the compilation
error by checking if IPPROTO_MH was defined before and in case it
wasn't, it defines it to be the same as in the kernel.

[1] https://www.spinics.net/lists/netdev/msg463980.html

Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Riad Abo Raed <riada@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
 ip/xfrm.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ip/xfrm.h b/ip/xfrm.h
index 8566d639..71be574d 100644
--- a/ip/xfrm.h
+++ b/ip/xfrm.h
@@ -30,6 +30,10 @@
 #include <linux/xfrm.h>
 #include <linux/ipsec.h>

+#ifndef IPPROTO_MH
+#define IPPROTO_MH              135
+#endif
+
 #define XFRMS_RTA(x)  ((struct rtattr*)(((char*)(x)) + NLMSG_ALIGN(sizeof(struct xfrm_usersa_info))))
 #define XFRMS_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct xfrm_usersa_info))

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

* Re: [PATCH iproute2] ip: Fix compilation break on old systems
  2017-11-13 10:21 [PATCH iproute2] ip: Fix compilation break on old systems Leon Romanovsky
@ 2017-11-13 15:33 ` Stephen Hemminger
  2017-11-13 16:04   ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2017-11-13 15:33 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: netdev, Leon Romanovsky, Cong Wang, Riad Abo Raed

On Mon, 13 Nov 2017 12:21:19 +0200
Leon Romanovsky <leon@kernel.org> wrote:

> From: Leon Romanovsky <leonro@mellanox.com>
> 
> As was reported [1], the iproute2 fails to compile on old systems,
> in Cong's case, it was Fedora 19, in our case it was RedHat 7.2, which
> failed with the following errors during compilation:
> 
> ipxfrm.c: In function ‘xfrm_selector_print’:
> ipxfrm.c:479:7: error: ‘IPPROTO_MH’ undeclared (first use in this
> function)
>   case IPPROTO_MH:
>        ^
> ipxfrm.c:479:7: note: each undeclared identifier is reported only once
> for each function it appears in
> ipxfrm.c: In function ‘xfrm_selector_upspec_parse’:
> ipxfrm.c:1345:8: error: ‘IPPROTO_MH’ undeclared (first use in this
> function)
>    case IPPROTO_MH:
>         ^                                                                                                                                                            make[1]: *** [ipxfrm.o] Error 1
> 
> The reason to it is the order of headers files. The IPPROTO_MH field is
> set in kernel's UAPI header file (in6.h), but only in case
> __UAPI_DEF_IPPROTO_V6 is set before. That define comes from other kernel's
> header file (libc-compat.h) and is set in case there are no previous
> libc relevant declarations.
> 
> In ip code, the include of <netdb.h> causes to indirect inclusion of
> <netinet/in.h> and it sets __UAPI_DEF_IPPROTO_V6 to be zero and prevents from
> IPPROTO_MH declaration.
> 
> This patch takes the simplest possible approach to fix the compilation
> error by checking if IPPROTO_MH was defined before and in case it
> wasn't, it defines it to be the same as in the kernel.
> 
> [1] https://www.spinics.net/lists/netdev/msg463980.html
> 
> Cc: Cong Wang <xiyou.wangcong@gmail.com>
> Cc: Riad Abo Raed <riada@mellanox.com>
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> ---
>  ip/xfrm.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/ip/xfrm.h b/ip/xfrm.h
> index 8566d639..71be574d 100644
> --- a/ip/xfrm.h
> +++ b/ip/xfrm.h
> @@ -30,6 +30,10 @@
>  #include <linux/xfrm.h>
>  #include <linux/ipsec.h>
> 
> +#ifndef IPPROTO_MH
> +#define IPPROTO_MH              135
> +#endif
> +

Is there some way to add an additional header to the file instead?
Doing local definitions seems like it might cause a future issue.

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

* Re: [PATCH iproute2] ip: Fix compilation break on old systems
  2017-11-13 15:33 ` Stephen Hemminger
@ 2017-11-13 16:04   ` Leon Romanovsky
  0 siblings, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2017-11-13 16:04 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, Cong Wang, Riad Abo Raed

[-- Attachment #1: Type: text/plain, Size: 2759 bytes --]

On Mon, Nov 13, 2017 at 07:33:37AM -0800, Stephen Hemminger wrote:
> On Mon, 13 Nov 2017 12:21:19 +0200
> Leon Romanovsky <leon@kernel.org> wrote:
>
> > From: Leon Romanovsky <leonro@mellanox.com>
> >
> > As was reported [1], the iproute2 fails to compile on old systems,
> > in Cong's case, it was Fedora 19, in our case it was RedHat 7.2, which
> > failed with the following errors during compilation:
> >
> > ipxfrm.c: In function ‘xfrm_selector_print’:
> > ipxfrm.c:479:7: error: ‘IPPROTO_MH’ undeclared (first use in this
> > function)
> >   case IPPROTO_MH:
> >        ^
> > ipxfrm.c:479:7: note: each undeclared identifier is reported only once
> > for each function it appears in
> > ipxfrm.c: In function ‘xfrm_selector_upspec_parse’:
> > ipxfrm.c:1345:8: error: ‘IPPROTO_MH’ undeclared (first use in this
> > function)
> >    case IPPROTO_MH:
> >         ^                                                                                                                                                            make[1]: *** [ipxfrm.o] Error 1
> >
> > The reason to it is the order of headers files. The IPPROTO_MH field is
> > set in kernel's UAPI header file (in6.h), but only in case
> > __UAPI_DEF_IPPROTO_V6 is set before. That define comes from other kernel's
> > header file (libc-compat.h) and is set in case there are no previous
> > libc relevant declarations.
> >
> > In ip code, the include of <netdb.h> causes to indirect inclusion of
> > <netinet/in.h> and it sets __UAPI_DEF_IPPROTO_V6 to be zero and prevents from
> > IPPROTO_MH declaration.
> >
> > This patch takes the simplest possible approach to fix the compilation
> > error by checking if IPPROTO_MH was defined before and in case it
> > wasn't, it defines it to be the same as in the kernel.
> >
> > [1] https://www.spinics.net/lists/netdev/msg463980.html
> >
> > Cc: Cong Wang <xiyou.wangcong@gmail.com>
> > Cc: Riad Abo Raed <riada@mellanox.com>
> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> > ---
> >  ip/xfrm.h | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/ip/xfrm.h b/ip/xfrm.h
> > index 8566d639..71be574d 100644
> > --- a/ip/xfrm.h
> > +++ b/ip/xfrm.h
> > @@ -30,6 +30,10 @@
> >  #include <linux/xfrm.h>
> >  #include <linux/ipsec.h>
> >
> > +#ifndef IPPROTO_MH
> > +#define IPPROTO_MH              135
> > +#endif
> > +
>
> Is there some way to add an additional header to the file instead?
> Doing local definitions seems like it might cause a future issue.

I tried various combinations of includes and didn't find working solution.

In this specific case, the value of IPPROTO_MH is defined in kernel UAPI and it
will be with us forever.

Thanks

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-13 10:21 [PATCH iproute2] ip: Fix compilation break on old systems Leon Romanovsky
2017-11-13 15:33 ` Stephen Hemminger
2017-11-13 16:04   ` Leon Romanovsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.