Cannot include "netinet/in.h" with "linux/netfilter/nf_nat.h" and "sys/capability.h"

Bug #1509894 reported by David Renshaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I expect to be able to compile the following program (and indeed I am able to compile it on Ubuntu release before 15.10):

```
// test.c
#include "sys/capability.h"
#include "netinet/in.h"
#include "linux/netfilter/nf_nat.h"

int main() {
  // Program that needs to call capset() and htonl(), and also needs
  // to do some netfilter things with NF_ACCEPT...
}
```

However, on 15.10 I get a bunch of errors:

```
$ gcc test.c
In file included from test.c:3:0:
/usr/include/linux/in.h:28:3: error: redeclaration of enumerator ‘IPPROTO_IP’
   IPPROTO_IP = 0, /* Dummy protocol for TCP */
   ^
/usr/include/netinet/in.h:42:5: note: previous definition of ‘IPPROTO_IP’ was here
     IPPROTO_IP = 0, /* Dummy protocol for TCP. */
     ^
...
```

This bug breaks the build for Sandstorm on Ubuntu 15.10:
https://github.com/sandstorm-io/sandstorm/issues/1049

```
$ lsb_release -rd
Description: Ubuntu 15.10
Release: 15.10

$ apt-cache policy linux-libc-dev
linux-libc-dev:
  Installed: 4.2.0-16.19
  Candidate: 4.2.0-16.19
  Version table:
 *** 4.2.0-16.19 0
        500 http://us.archive.ubuntu.com/ubuntu/ wily/main amd64 Packages
        100 /var/lib/dpkg/status
```
---
AlsaVersion: Advanced Linux Sound Architecture Driver Version k4.2.0-16-generic.
AplayDevices: Error: [Errno 2] No such file or directory
ApportVersion: 2.19.1-0ubuntu3
Architecture: amd64
ArecordDevices: Error: [Errno 2] No such file or directory
AudioDevicesInUse: Error: command ['fuser', '-v', '/dev/snd/by-path', '/dev/snd/pcmC0D1c', '/dev/snd/pcmC0D0c', '/dev/snd/pcmC0D0p', '/dev/snd/controlC0', '/dev/snd/seq', '/dev/snd/timer'] failed with exit code 1:
Card0.Amixer.info: Error: [Errno 2] No such file or directory
Card0.Amixer.values: Error: [Errno 2] No such file or directory
DistroRelease: Ubuntu 15.10
HibernationDevice: RESUME=UUID=875556b7-c0a8-46ab-9060-d2cd1999c0ac
InstallationDate: Installed on 2015-10-19 (6 days ago)
InstallationMedia: Ubuntu-Server 15.10 "Wily Werewolf" - Alpha amd64 (20150924)
IwConfig:
 enp0s8 no wireless extensions.

 enp0s3 no wireless extensions.

 lo no wireless extensions.
Lsusb:
 Bus 001 Device 002: ID 80ee:0021 VirtualBox USB Tablet
 Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
MachineType: innotek GmbH VirtualBox
Package: linux (not installed)
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
ProcFB:

ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-4.2.0-16-generic root=UUID=4ca984fb-5723-4616-8ecb-838c0c1d92a2 ro
ProcVersionSignature: Ubuntu 4.2.0-16.19-generic 4.2.3
RelatedPackageVersions:
 linux-restricted-modules-4.2.0-16-generic N/A
 linux-backports-modules-4.2.0-16-generic N/A
 linux-firmware 1.149
RfKill: Error: [Errno 2] No such file or directory
Tags: wily wily
UdevLog: Error: [Errno 2] No such file or directory: '/var/log/udev'
Uname: Linux 4.2.0-16-generic x86_64
UnreportableReason: The report belongs to a package that is not installed.
UpgradeStatus: No upgrade log present (probably fresh install)
UserGroups: adm cdrom dip lpadmin plugdev sambashare sudo
_MarkForUpload: True
dmi.bios.date: 12/01/2006
dmi.bios.vendor: innotek GmbH
dmi.bios.version: VirtualBox
dmi.board.name: VirtualBox
dmi.board.vendor: Oracle Corporation
dmi.board.version: 1.2
dmi.chassis.type: 1
dmi.chassis.vendor: Oracle Corporation
dmi.modalias: dmi:bvninnotekGmbH:bvrVirtualBox:bd12/01/2006:svninnotekGmbH:pnVirtualBox:pvr1.2:rvnOracleCorporation:rnVirtualBox:rvr1.2:cvnOracleCorporation:ct1:cvr:
dmi.product.name: VirtualBox
dmi.product.version: 1.2
dmi.sys.vendor: innotek GmbH

Revision history for this message
Brad Figg (brad-figg) wrote : Missing required logs.

This bug is missing log files that will aid in diagnosing the problem. From a terminal window please run:

apport-collect 1509894

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
Revision history for this message
David Renshaw (j-davfd-4) wrote : AlsaDevices.txt

apport information

tags: added: apport-collected wily
description: updated
Revision history for this message
David Renshaw (j-davfd-4) wrote : CRDA.txt

apport information

Revision history for this message
David Renshaw (j-davfd-4) wrote : Card0.Codecs.codec97.0.ac97.0.0.txt

apport information

Revision history for this message
David Renshaw (j-davfd-4) wrote : Card0.Codecs.codec97.0.ac97.0.0.regs.txt

apport information

Revision history for this message
David Renshaw (j-davfd-4) wrote : CurrentDmesg.txt

apport information

Revision history for this message
David Renshaw (j-davfd-4) wrote : JournalErrors.txt

apport information

Revision history for this message
David Renshaw (j-davfd-4) wrote : Lspci.txt

apport information

Revision history for this message
David Renshaw (j-davfd-4) wrote : PciMultimedia.txt

apport information

Revision history for this message
David Renshaw (j-davfd-4) wrote : ProcCpuinfo.txt

apport information

Revision history for this message
David Renshaw (j-davfd-4) wrote : ProcInterrupts.txt

apport information

Revision history for this message
David Renshaw (j-davfd-4) wrote : ProcModules.txt

apport information

Revision history for this message
David Renshaw (j-davfd-4) wrote : UdevDb.txt

apport information

Revision history for this message
David Renshaw (j-davfd-4) wrote : WifiSyslog.txt

apport information

Changed in linux (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
David Renshaw (j-davfd-4) wrote :

I've found that I can work around the issue by reordering my includes, like this:

```
// test.c
#include "netinet/in.h"
#include "sys/capability.h"
#include "linux/netfilter/nf_nat.h"

int main() {
  // Program that needs to call capset() and htonl(), and also needs
  // to do some netfilter things with NF_ACCEPT...
}
```

The program now compiles without any errors.

Revision history for this message
David Renshaw (j-davfd-4) wrote :

I now have something that appears to work for me. Please feel free to close this bug or mark it as invalid. Thanks.

Revision history for this message
Alberto Salvia Novella (es20490446e) wrote :

Yeap!

Changed in linux (Ubuntu):
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.