Re: [PATCH v06 30/36] uapi rdma/rdma_user_rxe.h: include in.h and in6.h

Jason Gunthorpe
2017-08-09T15:52:41Z

On Wed, Aug 09, 2017 at 04:48:08PM +0300, Moni Shoua wrote:
> >
> > I'm not sure this is a good idea, linux/in.h should not be included in
> > userspace users of this file, 'sockaddr_in' needs to come from glibc's
> > 'netinet/in.h' instead..

> Is it wrong to include include/uapi/linux/in.h from userspace?

Generally speaking userspace should always use the glibc version of
the headers and not headers from under linux/

Even if it is OK to include both today, that may not be true as glibc
or the kernel changes, and we end up with broken builds.

For instance look at this commit for a real problem caused by mixing
net/if.h and linux/if.h:

commit dc386fcf4a6d5dc0cc0052437c1cb161b7781592
Author: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Date: Fri Oct 14 12:04:42 2016 -0600

verbs: Use cmake to detect if net/if.h vs netling/route/link.h is broken

If not then just use the header directly, otherwise use the work around.

The issue is that old libnl libraries include linux/if.h and the
declarations there conflict with net/if.h. New libraries do not
do this.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>