librelist archives

« back to archive

Compiling with netmap: net/if.h and linux/if.h discrepancy

Compiling with netmap: net/if.h and linux/if.h discrepancy

From:
Lars Bro
Date:
2014-05-13 @ 19:44
Hi,

I am compiling Click with Netmap on Debian Wheezy with kernel 3.10.32.

I have installed Click and Netmap as follows

# Netmap
chroot $IMGDIR << !
cd /usr/local
git clone https://code.google.com/p/netmap netmap
cd /usr/local/netmap/LINUX
make
cd /usr/local/netmap/extra
make
!

# Click
chroot $IMGDIR << !
cd /usr/local/click
./configure --enable-all-elements --with-netmap=/usr/local/netmap/sys
make
make install
!

I get the following type of compilation error, though:
  CXX elements.cc
In file included from ../elements/userlevel/netmapinfo.hh:5:0,
                 from ../elements/userlevel/fromdevice.hh:24,
                 from elements.cc:375:
/usr/include/net/if.h:45:5: error: expected identifier before numeric
constant
/usr/include/net/if.h:45:5: error: expected '}' before numeric constant
/usr/include/net/if.h:45:5: error: expected unqualified-id before numeric
constant
/usr/include/net/if.h:82:3: error: expected declaration before '}' token
make[1]: *** [elements.o] Error 1
make[1]: Leaving directory `/usr/local/click/userlevel'
make: *** [userlevel] Error 2
root@10.10.0.134:/usr/local/click#

It seems as if there is a conflict between net/if.h and linux/if.h, so I
have done as follows:

diff --git a/elements/userlevel/fromdevice.cc
b/elements/userlevel/fromdevice.cc
index 77b92f4..27b1bd3 100644
--- a/elements/userlevel/fromdevice.cc
+++ b/elements/userlevel/fromdevice.cc
@@ -47,7 +47,7 @@

 #if FROMDEVICE_ALLOW_LINUX
 # include <sys/socket.h>
-# include <net/if.h>
+# include <linux/if.h>
 # include <features.h>
 # if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
 #  include <netpacket/packet.h>
diff --git a/elements/userlevel/netmapinfo.hh
b/elements/userlevel/netmapinfo.hh
index 1bcd575..9df89c7 100644
--- a/elements/userlevel/netmapinfo.hh
+++ b/elements/userlevel/netmapinfo.hh
@@ -2,7 +2,7 @@
 #define CLICK_NETMAPINFO_HH 1

 #if HAVE_NET_NETMAP_H
-#include <net/if.h>
+#include <linux/if.h>
 #include <net/netmap.h>
 #include <net/netmap_user.h>

diff --git a/elements/userlevel/todevice.cc b/elements/userlevel/todevice.cc
index 58114e4..047c3bf 100644
--- a/elements/userlevel/todevice.cc
+++ b/elements/userlevel/todevice.cc
@@ -45,7 +45,7 @@
 #if TODEVICE_ALLOW_LINUX
 # include <sys/socket.h>
 # include <sys/ioctl.h>
-# include <net/if.h>
+# include <linux/if.h>
 # include <net/if_packet.h>
 # include <features.h>
 # if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1

I dont know the side effects of using linux/if.h instead of net/if.h, but
it compiles though.

yours,
Lars Bro