llib/ibrte_net: workaround to avoid macro conflict
PATCH 1/1 llib/ibrte_net: workaround to avoid macro conflict
Macros such as IPPROTO_TCP, IPPROTO_UDP are already defined in <netinet/in.h>. If user's application includes <netinet/in.h> and rte_ip.h at the same time, there will be conflict error.
This patch uses the way "#ifndef #endif" to avoid the conflict.
--- lib/librte_net/rte_ip.h | 5 +++++ 1 file changed, 5 insertions(+)
lib/librte_net/rte_ip.h +5 -0
@@ -116,6 +116,8 @@ struct ipv4_hdr {#define IPV4_HDR_OFFSET_UNITS 8 +#ifndef _NETINET_IN_H +#ifndef _NETINET_IN_H_/* IPv4 protocols */ #define IPPROTO_IP 0/**< dummy for IP */ #define IPPROTO_HOPOPTS 0/**< IP6 hop-by-hop options */
@@ -227,6 +229,9 @@ struct ipv4_hdr {#define IPPROTO_RAW 255/**< raw IP packet */ #define IPPROTO_MAX 256/**< maximum protocol number */ +#endif /*_NETINET_IN_H_*/ +#endif /*_NETINET_IN_H*/ +/* * IPv4 address types */
Signature · 1 line
1.8.1.4
Hi Jingjing,
2014-09-30 10:49, Jingjing Wu:
Quoted 5 lines
Macros such as
IPPROTO_TCP,IPPROTO_UDPare already defined in <netinet/in.h>. If user's application includes <netinet/in.h> andrte_ip.hat the same time, there will be conflict error.This patch uses the way "#ifndef #endif" to avoid the conflict.
I still think it is not the good approach.
see http://dpdk.org/ml/archives/dev/2014-August/005006.html and http://dpdk.org/ml/archives/dev/2014-August/005026.html
Why not simply remove these definitions?
Signature · 1 line
Thomas
Quoted 38 lines · Jingjing Wu
Macros such as
IPPROTO_TCP,IPPROTO_UDPare already defined in <netinet/in.h>. If user's application includes <netinet/in.h> andrte_ip.hat the same time, there will be conflict error.This patch uses the way "#ifndef #endif" to avoid the conflict.
Signed-off-by Jingjing Wu <[email protected]>--- lib/librte_net/rte_ip.h | 5 +++++ 1 file changed, 5 insertions(+)lib/librte_net/rte_ip.h +5
-0@@ -116,6 +116,8 @@ struct ipv4_hdr {#define IPV4_HDR_OFFSET_UNITS 8 +#ifndef _NETINET_IN_H +#ifndef _NETINET_IN_H_/* IPv4 protocols */ #define IPPROTO_IP 0/**< dummy for IP */ #define IPPROTO_HOPOPTS 0/**< IP6 hop-by-hop options */ @@ -227,6 +229,9 @@ struct ipv4_hdr {#define IPPROTO_RAW 255/**< raw IP packet */ #define IPPROTO_MAX 256/**< maximum protocol number */ +#endif /*_NETINET_IN_H_*/ +#endif /*_NETINET_IN_H*/ +/* * IPv4 address types */ Signature · 1 line
1.8.1.4
Why define them at all? Why not just have rte_ip.h include netinet/in.h directly? Its a standard include file in a standard location for both bsd and linux IIRC.
Neil
Hi, Thomas
The reason why I didn't remover all the macros in rte_ip.h is:
netinet/in.h contains a lot of extra references to the sockets definitions, some external functions declarations, etc. These are useless some DPDK applications, such as classification. rte_ip.h provides a more simplify way for the IP protocol layer.
Quoted 23 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Tuesday, September 30, 2014 1:08 PM
To: Wu, Jingjing
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] llib/ibrte_net: workaround to avoid macro conflictHi Jingjing,
2014-09-30 10:49, Jingjing Wu:
Quoted 5 lines
Macros such as
IPPROTO_TCP,IPPROTO_UDPare already defined in <netinet/in.h>. If user's application includes <netinet/in.h> andrte_ip.hat the same time, there will be conflict error.This patch uses the way "#ifndef #endif" to avoid the conflict.
I still think it is not the good approach.
see http://dpdk.org/ml/archives/dev/2014-August/005006.html and http://dpdk.org/ml/archives/dev/2014-August/005026.htmlWhy not simply remove these definitions?
--
Thomas
Hi, Neil
To have rte_ip.h include netinet/in.h directly is also a choice.
But netinet/in.h contains a lot of extra stuff, and these may be useless some DPDK applications, such as classification. rte_ip.h provides a more simplify way for the IP protocol layer.
-----Original Message-----
From: Neil Horman [mailto:[email protected]]
Sent: Tuesday, September 30, 2014 9:10 PM
To: Wu, Jingjing
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] llib/ibrte_net: workaround to avoid macro conflict
Quoted 35 lines · Jingjing Wu
Macros such as
IPPROTO_TCP,IPPROTO_UDPare already defined in <netinet/in.h>. If user's application includes <netinet/in.h> andrte_ip.hat the same time, there will be conflict error.This patch uses the way "#ifndef #endif" to avoid the conflict.
Signed-off-by Jingjing Wu <[email protected]>--- lib/librte_net/rte_ip.h | 5 +++++ 1 file changed, 5 insertions(+)lib/librte_net/rte_ip.h index renamed from lib/librte_net/rte_ip.h +0
-0e3f65c1..2bcb479 100644
lib/librte_net/rte_ip.h +5
-1@@ -116,6 +116,8 @@ struct ipv4_hdr {#define IPV4_HDR_OFFSET_UNITS 8 +#ifndef _NETINET_IN_H +#ifndef _NETINET_IN_H_/* IPv4 protocols */ #define IPPROTO_IP 0/**< dummy for IP */ #define IPPROTO_HOPOPTS 0/**< IP6 hop-by-hop options */ @@ -227,6 +229,9 @@ struct ipv4_hdr {#define IPPROTO_RAW 255/**< raw IP packet */ #define IPPROTO_MAX 256/**< maximum protocol number */ +#endif /*_NETINET_IN_H_*/ +#endif /*_NETINET_IN_H*/ +/* * IPv4 address types */ --
Quoted 3 lines
1.8.1.4
Why define them at all? Why not just have rte_ip.h include netinet/in.h directly? Its a standard include file in a standard location for both bsd and linux IIRC. Neil
If the DPDK wants to conflict with all those system headers it means they also have to provide working replacement for inet_pton, inet_ntop, and every other important socket function which depends upon in.h or depends upon code depending upon in.h. Clearly this doesn't represent a sustainable path for software development... I had to reimplement a number of these in my app to get around the header conflict and I'm sure I'm not the only one who ran into this issue either.
Matthew.
Signature · 1 line
Sent from my mobile device.
Quoted 61 lines · Jingjing
Hi, Neil
To have
rte_ip.hincludenetinet/in.hdirectly is also a choice.But
netinet/in.hcontains a lot of extra stuff, and these may be useless some DPDK applications, such as classification.rte_ip.hprovides a more simplify way for the IP protocol layer.-----Original Message-----
From: Neil Horman [mailto:[email protected]]
Sent: Tuesday, September 30, 2014 9:10 PM
To: Wu, Jingjing
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] llib/ibrte_net: workaround to avoid macro conflictQuoted 1 line · Jingjing Wu
Macros such as
IPPROTO_TCP,IPPROTO_UDPare already defined in<
netinet/in.h>.Quoted 1 line
If user's application includes <
netinet/in.h> andrte_ip.hat thesame
Quoted 33 lines
time, there will be conflict error.
This patch uses the way "#ifndef #endif" to avoid the conflict.
Signed-off-by Jingjing Wu <[email protected]>--- lib/librte_net/rte_ip.h | 5 +++++ 1 file changed, 5 insertions(+)lib/librte_net/rte_ip.h index renamed from lib/librte_net/rte_ip.h +0
-0e3f65c1..2bcb479 100644
lib/librte_net/rte_ip.h +5
-1@@ -116,6 +116,8 @@ struct ipv4_hdr {#define IPV4_HDR_OFFSET_UNITS 8 +#ifndef _NETINET_IN_H +#ifndef _NETINET_IN_H_/* IPv4 protocols */ #define IPPROTO_IP 0/**< dummy for IP */ #define IPPROTO_HOPOPTS 0/**< IP6 hop-by-hop options */ @@ -227,6 +229,9 @@ struct ipv4_hdr {#define IPPROTO_RAW 255/**< raw IP packet */ #define IPPROTO_MAX 256/**< maximum protocol number */ +#endif /*_NETINET_IN_H_*/ +#endif /*_NETINET_IN_H*/ +/* * IPv4 address types */ --Quoted 3 lines
1.8.1.4
Why define them at all? Why not just have
rte_ip.hincludenetinet/in.hdirectly? Its a standard include file in a standard location for both bsd and linux IIRC.
Neil
Quoted 7 lines · Jingjing
Hi, Neil
To have
rte_ip.hincludenetinet/in.hdirectly is also a choice.But
netinet/in.hcontains a lot of extra stuff, and these may be useless some DPDK applications, such as classification.rte_ip.hprovides a more simplify way for the IP protocol layer.
Not sure what the relevance there is. The definitions you want are standardized, theres no need for the dpdk to re-invent that wheel. Get them from the system include file. The fact that extra macros are available in netinet.h is neither relevant or true (as you can't really say for certain what an application will need).
Neil
Quoted 50 lines
-----Original Message-----
From: Neil Horman [mailto:[email protected]]
Sent: Tuesday, September 30, 2014 9:10 PM
To: Wu, Jingjing
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH] llib/ibrte_net: workaround to avoid macro conflictQuoted 35 lines · Jingjing Wu
Macros such as
IPPROTO_TCP,IPPROTO_UDPare already defined in <netinet/in.h>. If user's application includes <netinet/in.h> andrte_ip.hat the same time, there will be conflict error.This patch uses the way "#ifndef #endif" to avoid the conflict.
Signed-off-by Jingjing Wu <[email protected]>--- lib/librte_net/rte_ip.h | 5 +++++ 1 file changed, 5 insertions(+)lib/librte_net/rte_ip.h index renamed from lib/librte_net/rte_ip.h +0
-0e3f65c1..2bcb479 100644
lib/librte_net/rte_ip.h +5
-1@@ -116,6 +116,8 @@ struct ipv4_hdr {#define IPV4_HDR_OFFSET_UNITS 8 +#ifndef _NETINET_IN_H +#ifndef _NETINET_IN_H_/* IPv4 protocols */ #define IPPROTO_IP 0/**< dummy for IP */ #define IPPROTO_HOPOPTS 0/**< IP6 hop-by-hop options */ @@ -227,6 +229,9 @@ struct ipv4_hdr {#define IPPROTO_RAW 255/**< raw IP packet */ #define IPPROTO_MAX 256/**< maximum protocol number */ +#endif /*_NETINET_IN_H_*/ +#endif /*_NETINET_IN_H*/ +/* * IPv4 address types */ --Quoted 3 lines
1.8.1.4
Why define them at all? Why not just have
rte_ip.hincludenetinet/in.hdirectly? Its a standard include file in a standard location for both bsd and linux IIRC. Neil
2014-10-09 07:29, Neil Horman:
Quoted 5 lines · Jingjing
Quoted 4 lines
Hi, Neil
To have
rte_ip.hincludenetinet/in.hdirectly is also a choice.
Quoted 8 lines
Quoted 3 lines
But
netinet/in.hcontains a lot of extra stuff, and these may be useless some DPDK applications, such as classification.rte_ip.hprovides a more simplify way for the IP protocol layer.Not sure what the relevance there is. The definitions you want are standardized, theres no need for the dpdk to re-invent that wheel. Get them from the system include file. The fact that extra macros are available in
netinet.his neither relevant or true (as you can't really say for certain what an application will need).
Neil, Matthew,
I totally agree with your point of view. Please, could you propose a patch to fix this issue?
Thanks
Signature · 1 line
Thomas
Quoted 15 lines · Thomas Monjalon
2014-10-09 07:29, Neil Horman:
Quoted 5 lines · Jingjing
Quoted 4 lines
Hi, Neil
To have
rte_ip.hincludenetinet/in.hdirectly is also a choice.Quoted 8 lines
Quoted 3 lines
But
netinet/in.hcontains a lot of extra stuff, and these may be useless some DPDK applications, such as classification.rte_ip.hprovides a more simplify way for the IP protocol layer.Not sure what the relevance there is. The definitions you want are standardized, theres no need for the dpdk to re-invent that wheel. Get them from the system include file. The fact that extra macros are available in
netinet.his neither relevant or true (as you can't really say for certain what an application will need).
Quoted 5 lines
Neil, Matthew,
I totally agree with your point of view. Please, could you propose a patch to fix this issue?
Matthew, can you handle this please, I've got too much going on right now. Neil
Quoted 4 lines
Thanks
Signature · 1 line
Thomas
PATCH 1/1 net: fix conflict with libc
In reply to a message not in the archiveIt was impossible to include netinet/in.h and rte_ip.h because the IP protocols were redefined.
It is removed because useless.
--- app/test-pmd/icmpecho.c | 4 ++ lib/librte_net/rte_ip.h | 112 +----------------------------------------------- 2 files changed, 5 insertions(+), 111 deletions(-)
app/test-pmd/icmpecho.c +4 -0
@@ -221,12 +221,16 @@ ip_proto_name(uint8_t ip_proto)if (ip_proto <sizeof (ip_proto_names) /sizeof (ip_proto_names[0 ]))return ip_proto_names[ip_proto];switch (ip_proto) { +#ifdef IPPROTO_PGM case IPPROTO_PGM :/**< PGM */ return "PGM" ; +#endif case IPPROTO_SCTP :/**< Stream Control Transport Protocol */ return "SCTP" ; +#ifdef IPPROTO_DIVERT case IPPROTO_DIVERT :/**< divert pseudo-protocol */ return "DIVERT" ; +#endif case IPPROTO_RAW :/**< raw IP packet */ return "RAW" ;default :
lib/librte_net/rte_ip.h +1 -111
124 lines not on this page · raw message
Signature · 1 line
2.1.3
Re: [PATCH] net: fix conflict with libc
In reply to a message not in the archiveQuoted 5 lines · Thomas Monjalon
It was impossible to include
netinet/in.handrte_ip.hbecause the IP protocols were redefined.
It is removed because useless.Signed-off-by Thomas Monjalon <[email protected]>
Acked by Ivan Boule <[email protected]>
Signature · 2 lines
Ivan Boule 6WIND Development Engineer
Thomas Monjalon
AppliedRe: [PATCH] net: fix conflict with libc
In reply to a message not in the archiveQuoted 7 lines
Quoted 5 lines
It was impossible to include
netinet/in.handrte_ip.hbecause the IP protocols were redefined.
It is removed because useless.Signed-off-by Thomas Monjalon <[email protected]>Acked by Ivan Boule <[email protected]>
Applied
Signature · 1 line
Thomas