Skip to contentSkip to conversation

sctp/sctp_big_chunk.c: Fix compiler error

PATCH New Xiao Yang 3 participants 8 messages Apr 4, 2018

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/1 sctp/sctp_big_chunk.c: Fix compiler error

On old distros(e.g. RHEL5), Compilation failed because of redefinitions from linux/sctp.h(including linux/in.h) and netinet/in.h, as below:
----------------------------------------------------------------------
In file included from /usr/include/linux/sctp.h:54,

                 from ../../../include/lapi/sctp.h:22,
                 from sctp_big_chunk.c:35:

/usr/include/linux/in.h:26: error: redeclaration of enumerator ‘IPPROTO_IP’ /usr/include/netinet/in.h:33: error: previous definition of ‘IPPROTO_IP’ was here
...
----------------------------------------------------------------------

1) There was a existed netinet/sctp.h based on lksctp-tools-devel package in LTP, so we used netinet/sctp.h to fix it as the sctp tests did.
2) We removed lapi/sctp.h and duplicated SOL_SCTP in lapi/socket.h.

---
 configure.ac                            |  1 -
 include/lapi/sctp.h                     | 29 -----------------------------
 include/lapi/socket.h                   |  4 ----
 testcases/network/sctp/Makefile         |  2 ++
 testcases/network/sctp/sctp_big_chunk.c |  2 +-
 5 files changed, 3 insertions(+), 35 deletions(-)
 delete mode 100644 include/lapi/sctp.h
configure.ac +0 -1
index 9358064..1721ff2 100644
@@ -44,7 +44,6 @@ AC_CHECK_HEADERS([ \
     linux/mempolicy.h \
     linux/module.h \
     linux/netlink.h \
-    linux/sctp.h \
     mm.h \
     pthread.h \
     sys/epoll.h \
include/lapi/sctp.h deleted +0 -29
deleted file mode 100644
index 69adc7a..0000000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2018 Oracle and/or its affiliates.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef LAPI_SCTP_H__
-#define LAPI_SCTP_H__
-
-#ifdef HAVE_LINUX_SCTP_H
-# include <linux/sctp.h>
-#endif
-
-#ifndef SCTP_SOCKOPT_BINDX_ADD
-# define SCTP_SOCKOPT_BINDX_ADD	100
-#endif
-
-#endif	/* LAPI_SCTP_H__ */
include/lapi/socket.h +0 -4
index d58c460..426906f 100644
@@ -45,10 +45,6 @@
 # define SOCK_CLOEXEC 02000000
 #endif
 
-#ifndef SOL_SCTP
-# define SOL_SCTP	132
-#endif
-
 #ifndef SOL_UDPLITE
 # define SOL_UDPLITE		136 /* UDP-Lite (RFC 3828) */
 #endif
testcases/network/sctp/Makefile +2 -0
index 0fa9125..ac4a99a 100644
@@ -17,6 +17,8 @@ top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+CPPFLAGS		+= -I$(top_srcdir)/utils/sctp/include
+
 INSTALL_TARGETS		:= sctp01.sh
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/network/sctp/sctp_big_chunk.c +1 -1
index 55a2969..d3288ee 100644
@@ -32,7 +32,7 @@
 #include "tst_safe_stdio.h"
 #include "lapi/netinet_in.h"
 #include "lapi/socket.h"
-#include "lapi/sctp.h"
+#include "netinet/sctp.h"
 
 static int port;
 static int sfd, cfd;
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 sctp/sctp_big_chunk.c: Fix compiler error

Hi Xiao,

Quoted 11 lines

On old distros(e.g. RHEL5), Compilation failed because of redefinitions from linux/sctp.h(including linux/in.h) and netinet/in.h, as below:
----------------------------------------------------------------------
In file included from /usr/include/linux/sctp.h:54,

                 from ../../../include/lapi/sctp.h:22,
                 from sctp_big_chunk.c:35:

/usr/include/linux/in.h:26: error: redeclaration of enumerator ‘IPPROTO_IP’ /usr/include/netinet/in.h:33: error: previous definition of ‘IPPROTO_IP’ was here
...
----------------------------------------------------------------------

Quoted 6 lines

1) There was a existed netinet/sctp.h based on lksctp-tools-devel package in LTP, so we used netinet/sctp.h to fix it as the sctp tests did.
2) We removed lapi/sctp.h and duplicated SOL_SCTP in lapi/socket.h.

---

Thank you for the fix. I'd prefer to remove our utils/sctp/include/netinet/sctp.h (I don't think it's a good idea to copy headers into source code) and fix include/lapi/sctp.h header trying first include <netinet/sctp.h> (with autotools check) and then <linux/sctp.h> if the previous is not available, as Alexey suggested [1].

What do you think, Alexey?

Kind regards,
Petr

[1] http://lists.linux.it/pipermail/ltp/2018-March/007517.html

author
#2 lore raw

PATCH 1/1 sctp/sctp_big_chunk.c: Fix compiler error

Quoted 17 lines · Petr Vorel

Hi Xiao,

Quoted 13 lines

On old distros(e.g. RHEL5), Compilation failed because of redefinitions from linux/sctp.h(including linux/in.h) and netinet/in.h, as below:
----------------------------------------------------------------------
In file included from /usr/include/linux/sctp.h:54,

                  from ../../../include/lapi/sctp.h:22,
                  from sctp_big_chunk.c:35:

/usr/include/linux/in.h:26: error: redeclaration of enumerator ‘IPPROTO_IP’ /usr/include/netinet/in.h:33: error: previous definition of ‘IPPROTO_IP’ was here
...
----------------------------------------------------------------------
1) There was a existed netinet/sctp.h based on lksctp-tools-devel package in LTP, so we used netinet/sctp.h to fix it as the sctp tests did.
2) We removed lapi/sctp.h and duplicated SOL_SCTP in lapi/socket.h.

Quoted 2 lines

---

Quoted 4 lines

Thank you for the fix. I'd prefer to remove our utils/sctp/include/netinet/sctp.h (I don't think it's a good idea to copy headers into source code) and fix include/lapi/sctp.h header trying first include<netinet/sctp.h> (with autotools check) and then <linux/sctp.h> if the previous is not available, as Alexey suggested [1].

Hi Petr,

If only<linux/sctp.h> is provided on RHEL5, it seems that the redefinition problem still exists.

Thanks,
Xiao Yang.

Quoted 11 lines

What do you think, Alexey?

Kind regards,
Petr

[1] http://lists.linux.it/pipermail/ltp/2018-March/007517.html

.

#3 lore raw

PATCH 1/1 sctp/sctp_big_chunk.c: Fix compiler error

Quoted 18 lines · Xiao Yang
Quoted 17 lines · Petr Vorel

Hi Xiao,

Quoted 15 lines

On old distros(e.g. RHEL5), Compilation failed because of redefinitions from linux/sctp.h(including linux/in.h) and netinet/in.h, as below:
----------------------------------------------------------------------
In file included from /usr/include/linux/sctp.h:54,

                  from ../../../include/lapi/sctp.h:22,
                  from sctp_big_chunk.c:35:

/usr/include/linux/in.h:26: error: redeclaration of enumerator ‘IPPROTO_IP’ /usr/include/netinet/in.h:33: error: previous definition of ‘IPPROTO_IP’ was here
...
----------------------------------------------------------------------
1) There was a existed netinet/sctp.h based on lksctp-tools-devel package in LTP, so we used netinet/sctp.h to fix it as the sctp tests did.
2) We removed lapi/sctp.h and duplicated SOL_SCTP in lapi/socket.h.

---

Quoted 7 lines
Quoted 4 lines

Thank you for the fix. I'd prefer to remove our utils/sctp/include/netinet/sctp.h (I don't think it's a good idea to copy headers into source code) and fix include/lapi/sctp.h header trying first include<netinet/sctp.h> (with autotools check) and then <linux/sctp.h> if the previous is not available, as Alexey suggested [1].

Hi Petr,

If only<linux/sctp.h> is provided on RHEL5, it seems that the redefinition problem still exists.

I think it would be better to just remove the include of linux/sctp.h for now, to fix this issue. lapi/ has the needed definitions to compile the test without it.

Optionally,
we could include netinet/sctp.h, if it was installed, in lapi/sctp.h, or substitute it with the one from utils and support it from there, including utils/sctp which is lksctp-tools.

Thanks,
Alexey

author
#4 lore raw

PATCH v2 1/1 sctp/sctp_big_chunk.c: Fix compiler error

On old distros(e.g. RHEL5), Compilation failed because of redefinitions from linux/sctp.h(including linux/in.h) and netinet/in.h, as below:
----------------------------------------------------------------------
In file included from /usr/include/linux/sctp.h:54,

                 from ../../../include/lapi/sctp.h:22,
                 from sctp_big_chunk.c:35:

/usr/include/linux/in.h:26: error: redeclaration of enumerator ‘IPPROTO_IP’ /usr/include/netinet/in.h:33: error: previous definition of ‘IPPROTO_IP’ was here
...
----------------------------------------------------------------------

1) Remove the include of linux/sctp.h to fix it.
2) Include netinet/sctp.h, if it was available.

---
 configure.ac        | 2 +-
 include/lapi/sctp.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
configure.ac +1 -1
index 9358064..9208f1c 100644
@@ -44,8 +44,8 @@ AC_CHECK_HEADERS([ \
     linux/mempolicy.h \
     linux/module.h \
     linux/netlink.h \
-    linux/sctp.h \
     mm.h \
+    netinet/sctp.h \
     pthread.h \
     sys/epoll.h \
     sys/fanotify.h \
include/lapi/sctp.h +2 -2
index 69adc7a..647052b 100644
@@ -18,8 +18,8 @@
 #ifndef LAPI_SCTP_H__
 #define LAPI_SCTP_H__
 
-#ifdef HAVE_LINUX_SCTP_H
-# include <linux/sctp.h>
+#ifdef HAVE_NETINET_SCTP_H
+# include <netinet/sctp.h>
 #endif
 
 #ifndef SCTP_SOCKOPT_BINDX_ADD
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v2 1/1 sctp/sctp_big_chunk.c: Fix compiler error

Quoted 6 lines · Xiao Yang

On old distros(e.g. RHEL5), Compilation failed because of redefinitions from linux/sctp.h(including linux/in.h) and netinet/in.h, as below:
----------------------------------------------------------------------
In file included from /usr/include/linux/sctp.h:54,

                 from ../../../include/lapi/sctp.h:22,
                 from sctp_big_chunk.c:35:
Quoted 8 lines

/usr/include/linux/in.h:26: error: redeclaration of enumerator ‘IPPROTO_IP’ /usr/include/netinet/in.h:33: error: previous definition of ‘IPPROTO_IP’ was here
...
----------------------------------------------------------------------

1) Remove the include of linux/sctp.h to fix it.
2) Include netinet/sctp.h, if it was available.

Applied, thanks!

author
#6 lore raw

PATCH 1/1 sctp/sctp_big_chunk.c: Fix compiler error

In reply to Alexey Kodanev
Quoted 23 lines · Alexey Kodanev
Quoted 22 lines · Xiao Yang
Quoted 21 lines · Petr Vorel

Hi Xiao,

Quoted 13 lines

On old distros(e.g. RHEL5), Compilation failed because of redefinitions from linux/sctp.h(including linux/in.h) and netinet/in.h, as below:
----------------------------------------------------------------------
In file included from /usr/include/linux/sctp.h:54,

                   from ../../../include/lapi/sctp.h:22,
                   from sctp_big_chunk.c:35:

/usr/include/linux/in.h:26: error: redeclaration of enumerator ‘IPPROTO_IP’ /usr/include/netinet/in.h:33: error: previous definition of ‘IPPROTO_IP’ was here
...
----------------------------------------------------------------------
1) There was a existed netinet/sctp.h based on lksctp-tools-devel package in LTP, so we used netinet/sctp.h to fix it as the sctp tests did.
2) We removed lapi/sctp.h and duplicated SOL_SCTP in lapi/socket.h.

Quoted 2 lines

---

Thank you for the fix. I'd prefer to remove our utils/sctp/include/netinet/sctp.h (I don't think it's a good idea to copy headers into source code) and fix include/lapi/sctp.h
header trying first include<netinet/sctp.h> (with autotools check) and then
<linux/sctp.h> if the previous is not available, as Alexey suggested [1].

Quoted 7 lines
Quoted 3 lines

Hi Petr,

If only<linux/sctp.h> is provided on RHEL5, it seems that the redefinition problem still exists.

I think it would be better to just remove the include of linux/sctp.h for now, to fix this issue. lapi/ has the needed definitions to compile the test without it.

Hi Alexey and Petr,

Thanks for your reply.

I will remove linux/sctp.h and check netinet/sctp.h as you suggested in v2 patch.

Thanks,
Xiao Yang

Quoted 10 lines

Optionally,
we could include netinet/sctp.h, if it was installed, in lapi/sctp.h, or substitute it with the one from utils and support it from there, including utils/sctp which is lksctp-tools.

Thanks,
Alexey

#7 lore raw

PATCH 1/1 sctp/sctp_big_chunk.c: Fix compiler error

In reply to Xiao Yang
Quoted 8 lines

On old distros(e.g. RHEL5), Compilation failed because of redefinitions from linux/sctp.h(including linux/in.h) and netinet/in.h, as below:
----------------------------------------------------------------------
In file included from /usr/include/linux/sctp.h:54,

                 from ../../../include/lapi/sctp.h:22,
                 from sctp_big_chunk.c:35:

/usr/include/linux/in.h:26: error: redeclaration of enumerator ‘IPPROTO_IP’ /usr/include/netinet/in.h:33: error: previous definition of ‘IPPROTO_IP’ was here

And obviously we need to find a way, how to check these old distros. IMHO it's not feasible with travis, it'd be great to add another CI (docker based) to test these distros.

Kind regards,
Petr