Re: [LTP] [lxc-dev] Re: [PATCH 5/9] Network NS patch , lib to create the netns

2008-08-13 Thread Veerendra
Serge E. Hallyn wrote:
   
   
 If I remove the above entries, and if I have only this entry now in my  
 libclone.h

 #ifndef SYS_unshare
 #ifdef __NR_unshare
 #define SYS_unshare __NR_unshare
 #elif __i386__
 #define SYS_unshare 310
 #elif __ia64__
 #define SYS_unshare 1296
 #elif __x86_64__
 #define SYS_unshare 272
 #elif __s390x__ || __s390__
 #define SYS_unshare 303
 #elif __powerpc__
 #define SYS_unshare 282
 #else
 #error unshare not supported on this architecure.
 #endif
 #endif
 

 Ah, ok, try adding the following  right below the above block:

 #ifndef __NR_unshare
 #define __NR_unshare SYS_unshare
 #endif

 That way at least we don't have 310 listed twice in the file.

 What distro are you using, btw?

 thanks,
 -serge

   
This worked fine, thanks Serge.
I am using the SLES10-SP2 (x86_64)

Regards
Veerendra C

-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK  win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100url=/
___
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


Re: [LTP] [lxc-dev] Re: [PATCH 5/9] Network NS patch , lib to create the netns

2008-08-11 Thread Serge E. Hallyn
Quoting Veerendra ([EMAIL PROTECTED]):
 Veerendra wrote:
  Signed-off-by: Veerendra C [EMAIL PROTECTED]
 
  This patch consists of the files..
 
  containers/libclone/libclone.h
  containers/libclone/libnetns.c
  containers/libclone/Makefile
 
 
  Regards
  Veerendra C
 
  
 

 Attaching the patch..
 
 
 --~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
 lxc-dev group.
 To post to this group, send email to [EMAIL PROTECTED]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
 http://groups.google.com/group/lxc-dev?hl=en
 -~--~~~~--~~--~--~---
 

 Index: containers/libclone/libclone.h
 ===
 --- containers.orig/libclone/libclone.h
 +++ containers/libclone/libclone.h
 @@ -58,6 +58,46 @@ extern int  __clone2(int (*fn) (void *ar
  pid_t *parent_tid, void *tls, pid_t *child_tid);
  #endif
 
 +#ifndef HAVE_UNSHARE
 +
 +#if __i386__
 +#define __NR_unshare 310
 +#elif __x86_64__
 +#define __NR_unshare 272
 +#elif __ia64__
 +#define __NR_unshare 1296
 +#elif __s390x__
 +#define __NR_unshare 303
 +#elif __powerpc__
 +#define __NR_unshare 282
 +#else
 +#error Architecture not supported
 +#endif

The existing libclone.h already tries to define these for arches that
need them.  I certainly believe that there are distributions which
are still funky, but let's understand why.

Do you have a machine of your own on which you needed this?  Can you
remove this bit and let me know what happens?

 +
 +static inline int unshare(unsigned long flags)
 +{
 +return syscall(__NR_unshare, flags);
 +}
 +
 +#endif /* HAVE_UNSHARE */
 +
 +#if __i386__
 +#define __NR_clone64   333
 +#define __NR_unshare64 334

What on earth are you using clone64 and unshare64 for?  They don't
actually exist, and you certainly don't need them for network
namespaces.

 +#elif __powerpc__
 +#define __NR_clone64   313
 +#define __NR_unshare64 314
 +#elif __s390x__ || __s390__
 +#define __NR_clone64   322
 +#define __NR_unshare64 323
 +#elif __x86_64__
 +#define __NR_clone64   295
 +#define __NR_unshare64 296
 +#else
 +#error Architecture not supported
 +#endif
 +
 +
  #ifndef CLONE_NEWUTS
  #define CLONE_NEWUTS 0x0400
  #endif
 @@ -74,6 +114,10 @@ extern int  __clone2(int (*fn) (void *ar
  #define CLONE_NEWPID0x2000
  #endif
 
 +#ifndef CLONE_NEWNET
 +#define CLONE_NEWNET 0x4000
 +#endif
 +
  /*
   * Run fn1 in a unshared environmnent, and fn2 in the original context
   * Fn2 may be NULL.
 @@ -97,4 +141,10 @@ int do_clone_unshare_tests(int use_clone
   int (*fn1)(void *arg), void *arg1,
   int (*fn2)(void *arg), void *arg2);
 
 +static inline int unshare64(unsigned long long int flags)
 +{
 +   return syscall(__NR_unshare64, (unsigned long) (flags  32), 
 +  (unsigned long) (flags  0x));
 +}
 +

Again, you shouldn't need the above.

  #endif
 Index: containers/libclone/libnetns.c
 ===
 --- /dev/null
 +++ containers/libclone/libnetns.c
 @@ -0,0 +1,105 @@
 +/*
 +* Copyright (c) International Business Machines Corp., 2007
 +* This program is free software; you can redistribute it and/or modify
 +* it under the terms of the GNU General Public License as published by
 +* the Free Software Foundation; either version 2 of the License, or
 +* (at your option) any later version.
 +*
 +* This program is distributed in the hope that it will be useful,
 +* but WITHOUT ANY WARRANTY; without even the implied warranty of
 +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
 +* the GNU General Public License for more details.
 +* You should have received a copy of the GNU General Public License
 +* along with this program; if not, write to the Free Software
 +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 +*
 +***/
 +/*=
 +* This testcase creates the network namespace. 
 +* It creates veth pair veth8  veth9. Also assigns IP addresses to the 
 childNS.
 +* Also it starts the sshd daemon @ port 7890
 +*
 +* Scripts Used: parentns.sh childns.sh
 +=*/
 +
 +#include sys/utsname.h
 +#include sched.h
 +#include stdio.h
 +#include stdlib.h
 +#include libclone.h
 +#include sched.h
 +#include sys/syscall.h
 +#include unistd.h
 +#include signal.h
 +#include string.h
 +#include errno.h
 +#include libgen.h
 +#include fcntl.h
 +#include sys/types.h
 +#include sys/wait.h
 + 
 +extern pid_t getpgid(pid_t pid);
 +extern pid_t