Quoting Veerendra ([EMAIL PROTECTED]):
> Veerendra wrote:
> >
> > Signed-off-by: Veerendra C <[EMAIL PROTECTED]>
> >
> > This patch consists of the files..
> >
> > containers/netns/childipv6.sh
> > containers/netns/par_chld_ipv6.c
> > containers/netns/paripv6.sh
> >
> >
> >
> > Regards
> > Veerendra C
> >
> > -
> Attaching the patch again..
>
>
> --~--~---------~--~----~------------~-------~--~----~
> 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/netns/childipv6.sh
> ===================================================================
> --- /dev/null
> +++ containers/netns/childipv6.sh
> @@ -0,0 +1,58 @@
> +#!/bin/bash
> +################################################################################
> +# This test scripts passes the PID of the child NS to the parent NS.
> +# Also it assigns the device address and starts the sshd daemon
> +# It checks for basic network connection between parent and child.
> +# It renames the network device of the child
> +
> +# Arguments: Accepts an argument 'script' and executes on top of this
> +################################################################################
> +#set -x
> +# The test case ID, the test case count and the total number of test case
> +TCID=${TCID:-childipv6.sh}
> +TST_TOTAL=1
> +TST_COUNT=1
> +export TCID
> +export TST_COUNT
> +export TST_TOTAL
> +
> +source initialize.sh
> +
> +# Passing the PID of child
> +echo $$ > /tmp/FIFO1
> +
> +# waiting for the virt-eth devname and IPv6 addr from parent
> +vnet1=`cat /tmp/FIFO2`
> +parIPv6=`cat /tmp/FIFO4`;
> +tst_resm TINFO "Received the Ipv6 addr $parIPv6";
> +# Assigning the dev addresses
> +ifconfig $vnet1 $IP2/24 up
> +ifconfig lo up ;
> +sleep 2
> +
> +#starting the sshd inside the child NS
> +/usr/sbin/sshd -p $PORT ;
> +if [ $? == 0 ]; then
> + tst_resm TINFO "started the sshd @ port no $PORT"
> + sshpid=`ps -ef | grep "sshd -p $PORT" | awk '{ print $2 ; exit 0} ' `
> +else
> + tst_resm TFAIL "Failed in starting ssh @ port $PORT"
> + status=-1
> +fi
> +
> +childIPv6=`ip -6 addr show dev $vnet1 | awk ' /inet6/ { print $2 } ' | awk
> -F"/" ' { print $1 } '`
> +echo $childIPv6 >> /tmp/FIFO3
> +
> +# checking if parent ns responding
> +ping6 -c 10 $parIPv6 >/dev/null 2>&1 &
$? returns the status of the most recently executed *foreground*
pipeline.
Since you're backgrounding ping6, you are not checking its return value
in the next line.
> +
> + if [ $? == 0 ] ; then
> + tst_resm TINFO "IPv6: Pinging Parent from Child: PASS"
> + status=0
> + else
> + tst_resm TFAIL "IPv6: Pinging Parent from Child: FAIL"
> + status=-1
> + fi
> +#cleanup $sshpid $vnet1
> +tst_resm TINFO " Done with executing child script $0"
> +exit $status
> Index: containers/netns/par_chld_ipv6.c
> ===================================================================
> --- /dev/null
> +++ containers/netns/par_chld_ipv6.c
> @@ -0,0 +1,125 @@
> +/*
> +* 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 . Also assigns IP addresses to the childNS.
> +* Also it starts the sshd daemon @ port 7890
> +*
> +* Scripts Used: paripv6.sh childipv6.sh
> +*
> +* Author: Veerendra C <[EMAIL PROTECTED]>
> +* 31/07/2008
> +=========================================================================*/
> +
> +#include <sys/utsname.h>
> +#include <sched.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include "../libclone/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>
> +#include <test.h>
> +
> +#ifdef NO_LTP
> +#define TFAIL "FAILURE: "
> +#define TPASS "PASS: "
> +#define TINFO "INFO: "
> +#define TWARN "WARN: "
> +#define tst_resm(x, format, arg...) printf("%s:" format, x, ## arg)
> +#define tst_exit() exit(1)
> +#endif
> +
> +char *TCID = "netns_ipv6";
> +int TST_TOTAL=1;
> +
> +extern pid_t getpgid(pid_t pid);
> +extern pid_t getsid(pid_t pid);
> +
> +int crtchild(char *s1)
> +{
> + char *cmd[] = { "/bin/bash", s1, (char *)0 };
> + execve("/bin/bash", cmd, __environ);
> + tst_resm(TFAIL, "The code would not reach here on success\n");
> + perror("execve");
> + return 1;
> +}
> +
> +int main()
> +{
> + int pid, status=0, len, ret ;
> + long int flags = 0;
> + char *ltproot, *par, *child;
> +
> + flags |= CLONE_NEWNS;
> + flags |= CLONE_NEWNET;
> +
> +
> + if (tst_kvercmp(2,6,19) < 0)
> + return 1;
> +
> + ltproot = getenv("LTPROOT");
> +
> + if ( ! ltproot) {
> + tst_resm(TINFO,"LTPROOT env variable is not set\n");
> + tst_resm(TINFO,"Please set LTPROOT and re-run the test..
> Thankyou\n");
> + return -1;
> + }
> +
> + len = strlen(ltproot);
> + par = malloc (len + 60);
> + child = malloc (len + 60);
> +
> + sprintf(par, "%s/testcases/kernel/containers/netns/paripv6.sh" ,
> ltproot);
> + sprintf(child, "%s/testcases/kernel/containers/netns/childipv6.sh" ,
> ltproot);
> +
> + if ((pid = fork()) == 0) {
> +
> + // Child.
> + ret = unshare64(flags);
> + if (ret < 0) {
> + perror("unshare");
> + return 1;
> + }
> + return crtchild(child);
> + }
> + else{
> +
> + //parent
> + ret = system(par);
> + if (ret != 0) {
> + tst_resm(TFAIL, "Error: While running the IPv6 tests between
> parent \
> +& child NS\n");
> + fflush(stdout);
> + exit(1);
> + }
> + fflush(stdout);
> +
> + if ((ret = waitpid(pid, &status, __WALL)) < 0){
> + tst_resm(TFAIL, "waitpid() returns %d, errno %d\n", ret, errno);
> + status = errno;
> + }
> + return status;
> + }
> +}
> Index: containers/netns/paripv6.sh
> ===================================================================
> --- /dev/null
> +++ containers/netns/paripv6.sh
> @@ -0,0 +1,65 @@
> +#!/bin/bash
> +################################################################################
> +# This script creates 2 veth devices $vnet0 and $vnet1.
> +# It will assign $IP1 to $vnet0 .
> +# And defines the $IP2 as route to $vnet1
> +# Also it assigns the $vnet1 to child network-NS
> +#
> +################################################################################
> +
> +#set -x
> +
> +# The test case ID, the test case count and the total number of test case
> +TCID=${TCID:-paripv6.sh}
> +TST_TOTAL=1
> +TST_COUNT=1
> +export TCID
> +export TST_COUNT
> +export TST_TOTAL
> +
> +source initialize.sh
> +status=0
> +
> +# Sets up the infrastructure for creating network NS
> +# By defining the veth pair $vnet0 and $vnet1
> + echo 1 > /proc/sys/net/ipv4/ip_forward
> + echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
> + create_veth
> + vnet0=$dev0
> + vnet1=$dev1
> + if [[ -z $vnet0 || -z $vnet1 ]] ; then
> + tst_resm TFAIL "Error: unable to create veth pair"
> + exit -1
> + else
> + tst_resm TINFO "vnet0 = $vnet0 , vnet1 = $vnet1"
> + fi
> +
> +
> + ifconfig $vnet0 $IP1/24 up
> + route add -host $IP2 dev $vnet0
> + echo 1 > /proc/sys/net/ipv4/conf/$vnet0/proxy_arp
> +
> + # Waits for the Child-NS to get created and reads the PID
> + pid=`cat /tmp/FIFO1`
> + tst_resm TINFO "the pid of child is $pid"
> + ip link set $vnet1 netns $pid
> +
> + echo $vnet1 > /tmp/FIFO2
> +
> + # Passes the IPv6 addr to Child NS
> + parIPv6=`ip -6 addr show dev $vnet0 | awk ' /inet6/ { print $2 } ' |
> awk -F"/" ' { print $1 } '`
> +
> + echo $parIPv6 > /tmp/FIFO4
> + childIPv6=`cat /tmp/FIFO3`
> + ping6 -c 10 $childIPv6 >/dev/null 2>&1 &
Same here.
> + if [ $? == 0 ] ; then
> + tst_resm TINFO "IPv6: Pinging child from parent: PASS"
> + status=0
> + else
> + tst_resm TFAIL "IPv6: Pinging child from parent: FAIL"
> + status=-1
> + fi
> +
> +tst_resm TINFO " Done with executing parent script $0 "
> +exit $status
-------------------------------------------------------------------------
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=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list