[dpdk-dev] [PATCH] llib/ibrte_net: workaround to avoid macro conflict

Matthew Hall mhall at mhcomputing.net
Thu Oct 9 07:37:28 CEST 2014


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.
-- 
Sent from my mobile device.

On October 8, 2014 10:20:31 PM PDT, "Wu, Jingjing" <jingjing.wu at intel.com> wrote:
>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:nhorman at tuxdriver.com] 
>Sent: Tuesday, September 30, 2014 9:10 PM
>To: Wu, Jingjing
>Cc: dev at dpdk.org
>Subject: Re: [dpdk-dev] [PATCH] llib/ibrte_net: workaround to avoid
>macro conflict
>
>On Tue, Sep 30, 2014 at 10:49:08AM +0800, Jingjing Wu wrote:
>> 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. 
>> 
>> Signed-off-by: Jingjing Wu <jingjing.wu at intel.com>
>> ---
>>  lib/librte_net/rte_ip.h | 5 +++++
>>  1 file changed, 5 insertions(+)
>> 
>> diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index 
>> e3f65c1..2bcb479 100644
>> --- a/lib/librte_net/rte_ip.h
>> +++ b/lib/librte_net/rte_ip.h
>> @@ -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
>>   */
>> --
>> 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



More information about the dev mailing list