@@ -27,7 +27,7 @@ ADDLIB+=dnet_ntop.o dnet_pton.o
#options for ipx
ADDLIB+=ipx_ntop.o ipx_pton.o
-CC = gcc
+CC ?= gcc
HOSTCC = gcc
CCOPTS = -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall
CFLAGS = $(CCOPTS) -I../include $(DEFINES)
@@ -3,6 +3,11 @@
#
INCLUDE=${1:-"$PWD/include"}
+if [ "_$CC" == "_" ]
+then
+ CC=gcc
+fi
+
check_atm()
{
cat >/tmp/atmtest.c <<EOF
@@ -13,7 +18,7 @@ int main(int argc, char **argv) {
return 0;
}
EOF
-gcc -I$INCLUDE -o /tmp/atmtest /tmp/atmtest.c -latm >/dev/null 2>&1
+${CC} -I$INCLUDE -o /tmp/atmtest /tmp/atmtest.c -latm >/dev/null 2>&1
if [ $? -eq 0 ]
then
echo "TC_CONFIG_ATM:=y" >>Config
@@ -47,7 +52,7 @@ int main(int argc, char **argv)
EOF
-if gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl -lxtables >/dev/null 2>&1
+if ${CC} -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl -lxtables >/dev/null 2>&1
then
echo "TC_CONFIG_XT:=y" >>Config
echo "using xtables"
@@ -84,7 +89,7 @@ int main(int argc, char **argv) {
}
EOF
-gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1
+${CC} -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1
if [ $? -eq 0 ]
then
@@ -124,7 +129,7 @@ int main(int argc, char **argv) {
}
EOF
-gcc -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1
+${CC} -I$INCLUDE $IPTC -o /tmp/ipttest /tmp/ipttest.c $IPTL -ldl >/dev/null 2>&1
if [ $? -eq 0 ]
then
@@ -168,7 +173,7 @@ int main(int argc, char **argv)
return 0;
}
EOF
-gcc -I$INCLUDE -o /tmp/setnstest /tmp/setnstest.c >/dev/null 2>&1
+${CC} -I$INCLUDE -o /tmp/setnstest /tmp/setnstest.c >/dev/null 2>&1
if [ $? -eq 0 ]
then
echo "IP_CONFIG_SETNS:=y" >>Config
@@ -179,6 +184,70 @@ fi
rm -f /tmp/setnstest.c /tmp/setnstest
}
+check_inotify()
+{
+cat >/tmp/inotify_test.c <<EOF
+#include <sys/inotify.h>
+int main(int argc, char **argv)
+{
+ return 0;
+}
+EOF
+${CC} -I$INCLUDE -o /tmp/inotify_test /tmp/inotify_test.c >/dev/null 2>&1
+if [ $? -eq 0 ]
+then
+ echo "yes"
+else
+ echo "IP_CONFIG_DISABLE_INOTIFY:=y" >>Config
+ echo "no"
+fi
+rm -f /tmp/inotify_test.c /tmp/inotify_test
+}
+
+
+check_unshare()
+{
+cat >/tmp/unshare_test.c <<EOF
+#define _GNU_SOURCE /* See feature_test_macros(7) */
+#include <sched.h>
+int main(int argc, char **argv)
+{
+ return unshare(0); /* 0 == no op */
+}
+EOF
+${CC} -I$INCLUDE -o /tmp/unshare_test /tmp/unshare_test.c >/dev/null 2>&1
+if [ $? -eq 0 ]
+then
+ echo "yes"
+else
+ echo "IP_CONFIG_DISABLE_UNSHARE:=y" >>Config
+ echo "no"
+fi
+rm -f /tmp/unshare_test.c /tmp/unshare_test
+}
+
+
+check_db185()
+{
+cat >/tmp/db185_test.c <<EOF
+#include <db_185.h>
+int main(int argc, char **argv)
+{
+ return 0;
+}
+EOF
+${CC} -I$INCLUDE -o /tmp/db185_test /tmp/db185_test.c >/dev/null 2>&1
+if [ $? -eq 0 ]
+then
+ echo "yes"
+else
+ echo "IP_CONFIG_DISABLE_DB185:=y" >>Config
+ echo "no"
+fi
+rm -f /tmp/db185_test.c /tmp/db185_test
+}
+
+
echo "# Generated config based on" $INCLUDE >Config
echo "TC schedulers"
@@ -197,3 +266,12 @@ check_ipt_lib_dir
echo -n "libc has setns: "
check_setns
+
+echo -n "libc has inotify support: "
+check_inotify
+
+echo -n "libc has unshare support: "
+check_unshare
+
+echo -n "libc has db_185 support: "
+check_db185
@@ -13,6 +13,14 @@ ifeq ($(IP_CONFIG_SETNS),y)
CFLAGS += -DHAVE_SETNS
endif
+ifeq ($(IP_CONFIG_DISABLE_INOTIFY),y)
+ CFLAGS += -DDISABLE_INOTIFY
+endif
+
+ifeq ($(IP_CONFIG_DISABLE_UNSHARE),y)
+ CFLAGS += -DCONFIG_IP_NO_UNSHARE
+endif
+
ALLOBJ=$(IPOBJ) $(RTMONOBJ)
SCRIPTS=ifcfg rtpr routel routef
TARGETS=ip rtmon
@@ -2,7 +2,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
+#ifndef DISABLE_INOTIFY
#include <sys/inotify.h>
+#endif
#include <sys/mount.h>
#include <sys/param.h>
#include <sys/syscall.h>
@@ -118,6 +120,10 @@ static void bind_etc(const char *name)
static int netns_exec(int argc, char **argv)
{
+#ifdef CONFIG_IP_NO_UNSHARE
+ fprintf(stderr, "No unshare on this platform, cannod do netns_exec\n");
+ return -1;
+#else
/* Setup the proper environment for apps that are not netns
* aware, and execute a program in that environment.
*/
@@ -169,6 +175,7 @@ static int netns_exec(int argc, char **argv)
fprintf(stderr, "exec of %s failed: %s\n",
cmd, strerror(errno));
exit(-1);
+#endif
}
static int netns_delete(int argc, char **argv)
@@ -194,6 +201,10 @@ static int netns_delete(int argc, char **argv)
static int netns_add(int argc, char **argv)
{
+#ifdef CONFIG_IP_NO_UNSHARE
+ fprintf(stderr, "No unshare on this platform, cannod do netns_add\n");
+ return -1;
+#else
/* This function creates a new network namespace and
* a new mount namespace and bind them into a well known
* location in the filesystem based on the name provided.
@@ -242,11 +253,16 @@ out_delete:
netns_delete(argc, argv);
exit(-1);
return -1;
+#endif
}
static int netns_monitor(int argc, char **argv)
{
+#ifdef DISABLE_INOTIFY
+ fprintf(stderr, "inotify not supported (compiled out)\n");
+ return -1;
+#else
char buf[4096];
struct inotify_event *event;
int fd;
@@ -278,6 +294,7 @@ static int netns_monitor(int argc, char **argv)
}
}
return 0;
+#endif
}
int do_netns(int argc, char **argv)
@@ -18,8 +18,13 @@ ifstat: ifstat.c
rtacct: rtacct.c
$(CC) $(CFLAGS) $(LDFLAGS) -o rtacct rtacct.c $(LIBNETLINK) -lm
+ifeq ($(IP_CONFIG_DISABLE_DB185),y)
+arpd:
+ @echo "Cannot build arpd on this system, no db_185.h file."
+else
arpd: arpd.c
$(CC) $(CFLAGS) -I$(DBM_INCLUDE) $(LDFLAGS) -o arpd arpd.c $(LIBNETLINK) -ldb -lpthread
+endif
ssfilter.c: ssfilter.y
bison ssfilter.y -o ssfilter.c