diff --git a/configure b/configure index 0795df85..f5c3d405 100755 --- a/configure +++ b/configure @@ -158,6 +158,27 @@ check_ipt_lib_dir() echo "not found!" } +check_setns() +{ +cat >/tmp/setnstest.c < +int main(int argc, char **argv) +{ + (void)setns(0,0); + return 0; +} +EOF +gcc -I$INCLUDE -o /tmp/setnstest /tmp/setnstest.c >/dev/null 2>&1 +if [ $? -eq 0 ] +then + echo "IP_CONFIG_SETNS:=y" >>Config + echo "yes" +else + echo "no" +fi +rm -f /tmp/setnstest.c /tmp/setnstest +} + echo "# Generated config based on" $INCLUDE >Config echo "TC schedulers" @@ -173,3 +194,6 @@ check_ipt echo -n "iptables modules directory: " check_ipt_lib_dir + +echo -n "libc has setns: " +check_setns diff --git a/ip/Makefile b/ip/Makefile index 2ee4e7c0..8d039934 100644 --- a/ip/Makefile +++ b/ip/Makefile @@ -7,6 +7,12 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \ RTMONOBJ=rtmon.o +include ../Config + +ifeq ($(IP_CONFIG_SETNS),y) + CFLAGS += -DHAVE_SETNS +endif + ALLOBJ=$(IPOBJ) $(RTMONOBJ) SCRIPTS=ifcfg rtpr routel routef TARGETS=ip rtmon diff --git a/ip/ipnetns.c b/ip/ipnetns.c index db7007cf..dff3497a 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -28,6 +28,7 @@ #define MNT_DETACH 0x00000002 /* Just detach from the tree */ #endif /* MNT_DETACH */ +#ifndef HAVE_SETNS static int setns(int fd, int nstype) { #ifdef __NR_setns @@ -37,6 +38,7 @@ static int setns(int fd, int nstype) return -1; #endif } +#endif /* HAVE_SETNS */ static int touch(const char *path, mode_t mode)