netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Rename static setns() function
@ 2011-07-15 18:38 Dan McGee
  2011-07-15 22:58 ` David Miller
  2011-07-15 23:41 ` Eric W. Biederman
  0 siblings, 2 replies; 4+ messages in thread
From: Dan McGee @ 2011-07-15 18:38 UTC (permalink / raw)
  To: netdev; +Cc: Dan McGee, Eric W. Biederman

Fixes the following error:

    gcc -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -I../include
    -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib/\"   -c -o ipnetns.o ipnetns.c
    ipnetns.c:31:12: error: static declaration of ‘setns’ follows non-static
    declaration
    /usr/include/bits/sched.h:93:12: note: previous declaration of ‘setns’
    was here
    make[1]: *** [ipnetns.o] Error 1

Fixes issue introduced in commit 0dc34c7713bb7055.

Signed-off-by: Dan McGee <dan@archlinux.org>
---
 ip/ipnetns.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index db7007c..46230ad 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -28,7 +28,7 @@
 #define MNT_DETACH	0x00000002	/* Just detach from the tree */
 #endif /* MNT_DETACH */
 
-static int setns(int fd, int nstype)
+static int do_setns(int fd, int nstype)
 {
 #ifdef __NR_setns
 	return syscall(__NR_setns, fd, nstype);
@@ -150,7 +150,7 @@ static int netns_exec(int argc, char **argv)
 			strerror(errno));
 		return -1;
 	}
-	if (setns(netns, CLONE_NEWNET) < 0) {
+	if (do_setns(netns, CLONE_NEWNET) < 0) {
 		fprintf(stderr, "seting the network namespace failed: %s\n",
 			strerror(errno));
 		return -1;
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Rename static setns() function
  2011-07-15 18:38 [PATCH] Rename static setns() function Dan McGee
@ 2011-07-15 22:58 ` David Miller
  2011-07-15 23:41 ` Eric W. Biederman
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2011-07-15 22:58 UTC (permalink / raw)
  To: dan; +Cc: netdev, ebiederm

From: Dan McGee <dan@archlinux.org>
Date: Fri, 15 Jul 2011 13:38:19 -0500

> Fixes the following error:
> 
>     gcc -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -I../include
>     -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib/\"   -c -o ipnetns.o ipnetns.c
>     ipnetns.c:31:12: error: static declaration of ‘setns’ follows non-static
>     declaration
>     /usr/include/bits/sched.h:93:12: note: previous declaration of ‘setns’
>     was here
>     make[1]: *** [ipnetns.o] Error 1
> 
> Fixes issue introduced in commit 0dc34c7713bb7055.
> 
> Signed-off-by: Dan McGee <dan@archlinux.org>

Thanks for fixing this:

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Rename static setns() function
  2011-07-15 18:38 [PATCH] Rename static setns() function Dan McGee
  2011-07-15 22:58 ` David Miller
@ 2011-07-15 23:41 ` Eric W. Biederman
  2011-07-16  0:02   ` Dan McGee
  1 sibling, 1 reply; 4+ messages in thread
From: Eric W. Biederman @ 2011-07-15 23:41 UTC (permalink / raw)
  To: Dan McGee; +Cc: netdev


Dan can you try this patch I think it does a better job at dealing
with libc defining setns but I don't have a brand new libc handy
to test with.

Eric

From: "Eric W. Biederman" <ebiederm@xmission.com>
Date: Fri, 15 Jul 2011 16:36:33 -0700
Subject: [PATCH] iproute2: Auto-detect the presence of setns in libc

If libc has setns present use that version instead of
rolling the syscall wrapper by hand.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
 configure    |   24 ++++++++++++++++++++++++
 ip/Makefile  |    6 ++++++
 ip/ipnetns.c |    2 ++
 3 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 69797ab..cfcc82a 100755
--- a/configure
+++ b/configure
@@ -163,6 +163,27 @@ check_ipt_lib_dir()
 	echo "not found!"
 }
 
+check_setns()
+{
+cat >/tmp/setnstest.c <<EOF
+#include <sched.h>
+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"
@@ -178,3 +199,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 2ee4e7c..8d03993 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 db7007c..dff3497 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)
-- 
1.7.5.1.217.g4e3aa


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Rename static setns() function
  2011-07-15 23:41 ` Eric W. Biederman
@ 2011-07-16  0:02   ` Dan McGee
  0 siblings, 0 replies; 4+ messages in thread
From: Dan McGee @ 2011-07-16  0:02 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: netdev

On Fri, Jul 15, 2011 at 6:41 PM, Eric W. Biederman
<ebiederm@xmission.com> wrote:
>
> Dan can you try this patch I think it does a better job at dealing
> with libc defining setns but I don't have a brand new libc handy
> to test with.

Works perfectly (as long as one remembers to rerun ./configure first).
It also works fine with my other configure patch I sent to the list.

-Dan

> From: "Eric W. Biederman" <ebiederm@xmission.com>
> Date: Fri, 15 Jul 2011 16:36:33 -0700
> Subject: [PATCH] iproute2: Auto-detect the presence of setns in libc
>
> If libc has setns present use that version instead of
> rolling the syscall wrapper by hand.
>
> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
> ---
>  configure    |   24 ++++++++++++++++++++++++
>  ip/Makefile  |    6 ++++++
>  ip/ipnetns.c |    2 ++
>  3 files changed, 32 insertions(+), 0 deletions(-)
>
> diff --git a/configure b/configure
> index 69797ab..cfcc82a 100755
> --- a/configure
> +++ b/configure
> @@ -163,6 +163,27 @@ check_ipt_lib_dir()
>        echo "not found!"
>  }
>
> +check_setns()
> +{
> +cat >/tmp/setnstest.c <<EOF
> +#include <sched.h>
> +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"
> @@ -178,3 +199,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 2ee4e7c..8d03993 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 db7007c..dff3497 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)
> --
> 1.7.5.1.217.g4e3aa
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-07-16  0:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-15 18:38 [PATCH] Rename static setns() function Dan McGee
2011-07-15 22:58 ` David Miller
2011-07-15 23:41 ` Eric W. Biederman
2011-07-16  0:02   ` Dan McGee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).