This directory has been moved to vsys-scripts.
authorSapan Bhatia <sapanb@cs.princeton.edu>
Fri, 25 Jun 2010 14:36:31 +0000 (14:36 +0000)
committerSapan Bhatia <sapanb@cs.princeton.edu>
Fri, 25 Jun 2010 14:36:31 +0000 (14:36 +0000)
12 files changed:
Makefile
factory/comon_exec [deleted file]
factory/hide_netif [deleted file]
factory/nfsmount [deleted file]
factory/pfmount [deleted file]
factory/pl-ps [deleted file]
factory/portsummary [deleted file]
factory/setup-link [deleted file]
factory/setup-nat [deleted file]
factory/vtop [deleted file]
globals.ml
tests/vsys_conctest.c

index cbed53d..ad1fc19 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -34,7 +34,7 @@ splice_stub.o: splice_stub.c
        gcc -c -I /usr/lib/ocaml -I /usr/lib64/ocaml splice_stub.c -o splice_stub.o
 
 vsys: ocaml_inotify-0.4/inotify.cmxa globals.cmx fdwatcher.cmx conffile.cmx splice_stub.o splice.cmx dirwatcher.cmx fifowatcher.cmx frontend.cmx unixsocketwatcher.cmx backend.cmx main.cmx docs 
        gcc -c -I /usr/lib/ocaml -I /usr/lib64/ocaml splice_stub.c -o splice_stub.o
 
 vsys: ocaml_inotify-0.4/inotify.cmxa globals.cmx fdwatcher.cmx conffile.cmx splice_stub.o splice.cmx dirwatcher.cmx fifowatcher.cmx frontend.cmx unixsocketwatcher.cmx backend.cmx main.cmx docs 
-       ocamlopt -I ocaml_inotify-0.4 str.cmxa unix.cmxa inotify.cmxa globals.cmx fdwatcher.cmx dirwatcher.cmx splice.cmx splice_stub.o directfifowatcher.cmx unixsocketwatcher.cmx  frontend.cmx backend.cmx str.cmxa conffile.cmx main.cmx -o vsys
+       ocamlopt -I ocaml_inotify-0.4 str.cmxa unix.cmxa inotify.cmxa globals.cmx fdwatcher.cmx dirwatcher.cmx splice.cmx splice_stub.o directfifowatcher.cmx unixsocketwatcher.cmx  frontend.cmx backend.cmx conffile.cmx main.cmx -o vsys
 
 vsys.b: ocaml_inotify-0.4/inotify.cma inotify.cmi globals.ml fdwatcher.ml dirwatcher.ml directfifowatcher.ml frontend.ml backend.ml main.ml
        ocamlc -g str.cma unix.cma ocaml_inotify-0.4/inotify.cma globals.cmo fdwatcher.cmo dirwatcher.cmo directfifowatcher.cmo frontend.cmo backend.cmo str.cma conffile.cmo main.cmo -o vsys.b
 
 vsys.b: ocaml_inotify-0.4/inotify.cma inotify.cmi globals.ml fdwatcher.ml dirwatcher.ml directfifowatcher.ml frontend.ml backend.ml main.ml
        ocamlc -g str.cma unix.cma ocaml_inotify-0.4/inotify.cma globals.cmo fdwatcher.cmo dirwatcher.cmo directfifowatcher.cmo frontend.cmo backend.cmo str.cma conffile.cmo main.cmo -o vsys.b
diff --git a/factory/comon_exec b/factory/comon_exec
deleted file mode 100755 (executable)
index df6e7c0..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/perl
-use strict;
-
-#######################################################
-#
-# run any (allowed) progam in the root context
-#
-#######################################################
-
-my @allowed = ("/bin/df"); # allowed commands
-my $cmdline;
-my $path;
-my $p;
-
-# read command line
-$cmdline = <STDIN>;
-chomp($cmdline);
-
-# identify the path
-if ($cmdline =~ /\s*(.+)\s+/) {
-   $path = $1;
-} else {
-   $path = $cmdline;
-}
-
-# run the program if it's executable and allowed to run
-if (-x $path) {
-   foreach $p (@allowed) {
-       if ($p eq $path) {
-           system($cmdline);
-           exit(0);
-       }
-   }
-   print "fatal: '$cmdline' is not allowed to run\n";
-} else {
-   print "fatal: $path either does not exist or is not executable\n";
-}
-
-# some error occurred
-exit(-1);
diff --git a/factory/hide_netif b/factory/hide_netif
deleted file mode 100755 (executable)
index c7ae234..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-# Remove hide_netif network attribute.  Attribute is used to hide interfaces that don't have an IP attached. 
-
-# $Id$
-
-nattribute --set --nid $1 --flag ~hide_netif
diff --git a/factory/nfsmount b/factory/nfsmount
deleted file mode 100755 (executable)
index 04115dc..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-
-my $slicename=$ARGV[0];
-my $already_mounted_testfile = "/tmp/$slicename"."_nfsmounted";
-
-my $slice_dir="/vservers/$slicename/";
-
-if (-f $already_mounted_testfile) {
-       die("Sorry, only one successful NFS mount allowed per slice!");
-}
-
-my $remotepath = <STDIN>;
-my $localpath = <STDIN>;
-chomp($localpath);
-chomp($remotepath);
-$localpath=~s/\.\.//g;
-
-$localpath=$slice_dir.$localpath;
-
-unless (-d $localpath) {
-       die("Localpath does not exist, please create it first.");
-}
-
-my $hostexpr="(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(?<!-)\.?)+(?:[a-zA-Z]{2,})$)";
-my $pathexpr="\/?[\w\d]+\/[\w\d]*\/?";
-my $nfshost;
-my $nfspath;
-
-($nfshost,$nfspath)=split ':',$remotepath;
-
-if ($nfshost!~/(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(?<!-)\.?)+(?:[a-zA-Z]{2,})$)/) {
-       die("The hostname $nfshost does not seem to be right.");
-}
-
-if ($nfspath!~/^(((\.\.){1}\/)*|(\/){1})?(([a-zA-Z0-9]*)\/)*([a-zA-Z0-9]*)+$/) {
-       die("The remote path $nfspath does not seem to be right.");
-} 
-
-my $mntcmd="/bin/mount $remotepath $localpath";
-system($mntcmd);
-
-if ($?) {
-    print "Mount failed: $?";
-}
-else {
-    open FIL, ">$already_mounted_testfile";
-    print FIL "$remotepath $localpath";
-    close FIL;
-}
diff --git a/factory/pfmount b/factory/pfmount
deleted file mode 100755 (executable)
index 0282c76..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-# Mount the planetflow directory in a slice
-
-#mount --bind /usr/local/fprobe /vservers/$1/pf
-# changed from request of Faiyaz
-DEST="/vservers/$1/pf"
-mount | grep "on $DEST type" > /dev/null
-if [ $? -eq 1 ]; then
-    mount --bind /var/local/fprobe -o ro $DEST
-fi
diff --git a/factory/pl-ps b/factory/pl-ps
deleted file mode 100755 (executable)
index eafdf5b..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/perl
-use strict;
-
-###############################################
-# pl-ps for slicestat by KyoungSoo Park
-###############################################
-
-my %slice_id;
-my %slice;
-
-open THIS_PIPE, "/bin/awk -F: \'{print \$1, \$3}\' /etc/passwd |";
-while(<THIS_PIPE>) {
-   if (/(.+)\s+(\d+)/) {
-       $slice_id{$1} = $2;
-       $slice{$2} = $1;
-   }
-}
-close THIS_PIPE;
-
-open THIS_PIPE, "/usr/sbin/vps -eo pid,user | sed 1d | awk \'{print \$1, \$2}\' | sort -k 2 |";
-while(<THIS_PIPE>) {
-   if (/(\d+)\s+(.+)$/) {
-       my $pid = $1;
-       my ($id, $sl);
-
-       if (defined($slice_id{$2})) {
-           $id = $slice_id{$2};
-           $sl = $2;
-       } else {
-           $id = $2;
-           $sl = $slice{$2};
-       }
-       print sprintf("%s %s %s\n", $id, $sl, $pid);
-   }
-}
-close THIS_PIPE;
diff --git a/factory/portsummary b/factory/portsummary
deleted file mode 100755 (executable)
index f800632..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/python
-
-import os
-import sys
-
-# NOTE: '--inet' lists only ipv4 addresses.
-ns = os.popen("ncontext --nid 1 --migrate -- vcontext --xid 1 --migrate -- netstat -apnlut --inet", 'r')
-port_summary = {}
-for line in ns:
-       try:
-               ns_fields = line.split()
-               if ns_fields[0] == "tcp" or ns_fields[0] == "udp":
-                       (src_ip, src_port) = ns_fields[3].split(':')
-                       (dst_ip, dst_port) = ns_fields[4].split(':')
-
-                       port_key='%s-%s' % (src_port, dst_port)
-
-                       if src_ip is not "0.0.0.0" and port_key in port_summary:
-                               # skip INADDR_ANY addresses and ports we've already seen.
-                               continue
-
-                       conn_state = ns_fields[5]
-                       if ns_fields[0] == "tcp":
-                               proc_field = ns_fields[6]
-                       else:
-                               if conn_state == "ESTABLISHED":
-                                       proc_field = ns_fields[6]
-                               else:
-                                       proc_field = ns_fields[5]
-
-                       if proc_field != "-":
-                               (pid,procname)= proc_field.split('/')
-                       else:
-                               # NOTE: without a PID there is no way to associate with an XID
-                               continue
-
-                       if ( ns_fields[0] == "tcp" and src_ip == "0.0.0.0" and conn_state == "LISTEN" ) or \
-                          ( ns_fields[0] == "udp" and src_ip == "0.0.0.0" ):
-                               type='C'
-                       elif src_ip == "127.0.0.1":
-                               type='l'
-                       elif src_ip != "0.0.0.0" and src_ip != "127.0.0.1":
-                               type='c'
-                       else:
-                               type='?'
-
-                       xid_stream = os.popen("vserver-info %s XID" % pid)
-                       xid = xid_stream.read()
-
-                       port_summary[port_key] = {'prot' : ns_fields[0], 
-                                                                         'src_port' : src_port, 
-                                                                         'dst_port' : dst_port, 
-                                                                         'slice' : xid[:-1], 
-                                                                         'type': type}
-       except:
-               import traceback; traceback.print_exc()
-               print line
-
-ports = port_summary.keys()
-ports.sort()
-for port in ports:
-       print "%(prot)4s\t%(src_port)6s\t%(dst_port)6s\t%(slice)5s\t%(type)s" % port_summary[port]
-               
diff --git a/factory/setup-link b/factory/setup-link
deleted file mode 100755 (executable)
index cc800ce..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/bin/sh +x
-
-SLICE=$1
-SLICEID=`id -u $SLICE`
-read INDEX
-read REMOTE
-read KEY
-
-LINK=${KEY}if${INDEX}
-
-modprobe ip_gre
-
-### Setup EGRE tunnel
-EGRE=d$LINK
-ip tunnel add $EGRE  mode gre type eth remote $REMOTE key $KEY ttl 64
-ip link set $EGRE up
-
-### Setup etun
-ETUN0=a$LINK
-ETUN1=b$LINK
-ip link add name $ETUN0 type veth peer name $ETUN1
-ifconfig $ETUN0 mtu 1458 up
-ifconfig $ETUN1 up
-
-### Setup bridge
-BRIDGE=c$LINK
-brctl addbr $BRIDGE
-brctl addif $BRIDGE $EGRE 
-brctl addif $BRIDGE $ETUN1
-ifconfig $BRIDGE up
-
-### Setup iptables so that packets are visible in the vserver
-iptables -t mangle -A FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
-
-### Create "grab link" script
-GRAB=/vsys/local_grab-$ETUN0
-echo $SLICE > $GRAB.acl 
-rm -f $GRAB
-cat > $GRAB <<EOF
-#!/bin/sh
-
-read PID
-
-ip link set $ETUN0 netns \$PID
-EOF
-chmod +x $GRAB
-
-### Create script for setting link rate
-BIND=/vsys/local_rate-$ETUN0
-echo $SLICE > $BIND.acl 
-rm -f $BIND
-cat > $BIND <<EOF
-#!/bin/sh
-
-read rt
-
-tc qdisc add dev $EGRE root handle 1: htb default 10
-tc class add dev $EGRE parent 1: classid 1:10 htb rate \$rt ceil \$rt
-
-rm -rf $BIND.acl 
-touch $BIND.acl 
-
-EOF
-chmod +x $BIND
-
-### Create "delete link" script
-DELETE=/vsys/local_delete-$ETUN0
-echo $SLICE > $DELETE.acl 
-rm -f $DELETE
-cat > $DELETE <<EOF
-#!/bin/sh
-
-read NULL
-
-# Remove iptables rule
-iptables -t mangle -D FORWARD -o $BRIDGE -j MARK --set-mark $SLICEID
-
-# Get rid of etun devices, only need name of one of them
-ip link delete dev $ETUN1 
-
-# Get rid of bridge
-ifconfig $BRIDGE down
-brctl delbr $BRIDGE
-
-# Get rid of EGRE tunnel
-ip tunnel del $EGRE
-
-# Clean up files
-rm -f $GRAB $GRAB.acl
-rm -f $DELETE $DELETE.acl
-rm -f $BIND $BIND.acl
-EOF
-chmod +x $DELETE
diff --git a/factory/setup-nat b/factory/setup-nat
deleted file mode 100755 (executable)
index 9a0c4f5..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/sh +x
-
-SLICE=$1
-SLICEID=`id -u $SLICE`
-read KEY
-
-### Setup etun
-ETUN0=nat$KEY
-ETUN1=natx$KEY
-ip link add name $ETUN0 type veth peer name $ETUN1
-ifconfig $ETUN1 10.0.$KEY.1/24 up
-
-iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
-iptables -A FORWARD -i eth0 -o $ETUN1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-iptables -A FORWARD -i $ETUN1 -o eth0 -j ACCEPT
-
-### Create "grab link" script
-GRAB=/vsys/local_grab-$ETUN0
-echo $SLICE > $GRAB.acl 
-rm -f $GRAB
-cat > $GRAB <<EOF
-#!/bin/sh
-
-read PID
-
-ip link set $ETUN0 netns \$PID 
-EOF
-chmod +x $GRAB
-
-### Create "delete link" script
-DELETE=/vsys/local_delete-$ETUN0
-echo $SLICE > $DELETE.acl 
-rm -f $DELETE
-cat > $DELETE <<EOF
-#!/bin/sh
-
-read NULL
-
-# Remove iptables rules
-iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
-iptables -D FORWARD -i eth0 -o $ETUN1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-iptables -D FORWARD -i $ETUN1 -o eth0 -j ACCEPT
-
-# Get rid of etun devices, only need name of one of them
-ip link delete dev $ETUN1 
-
-# Clean up files
-rm -f $GRAB $GRAB.acl
-rm -f $DELETE $DELETE.acl
-
-EOF
-chmod +x $DELETE
-
diff --git a/factory/vtop b/factory/vtop
deleted file mode 100755 (executable)
index 00e44c0..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/perl
-use strict;
-
-###############################################
-# vtop for slicestat by KyoungSoo Park
-###############################################
-
-open THIS_PIPE, "/usr/sbin/vtop bn1 |";
-while(<THIS_PIPE>) {
-    print;
-}
-close THIS_PIPE;
index fde6ffc..93dd803 100644 (file)
@@ -9,7 +9,7 @@ let log_filepath = ref "/var/log/vsys"
 let failsafe = ref false
 
 let logfd = ref Pervasives.stdout
 let failsafe = ref false
 
 let logfd = ref Pervasives.stdout
-let logprint fmt = Printf.fprintf !logfd (fmt ^^ "%!")
+let logprint fmt = Printf.printf fmt
 let debprint fmt = if (!debug) then Printf.fprintf !logfd (fmt ^^ "%!")
 let print fmt = Printf.printf (fmt ^^ "%!")
 
 let debprint fmt = if (!debug) then Printf.fprintf !logfd (fmt ^^ "%!")
 let print fmt = Printf.printf (fmt ^^ "%!")
 
index 2d174a0..daca830 100644 (file)
@@ -11,8 +11,8 @@ int main()
 {
   FILE *fp = NULL, *fp_in = NULL;
   FILE *out_fp = NULL, *diff_fp = NULL;
 {
   FILE *fp = NULL, *fp_in = NULL;
   FILE *out_fp = NULL, *diff_fp = NULL;
-  const char* topcmd = "fe/test.out";
-  const char* top_in_file = "fe/test.in";
+  const char* topcmd = "frontend/test.out";
+  const char* top_in_file = "frontend/test.in";
   char buf[4096];
   int fd_in = -1, fd_out;
   int res;
   char buf[4096];
   int fd_in = -1, fd_out;
   int res;