Revision: 545
http://vde.svn.sourceforge.net/vde/?rev=545&view=rev
Author: rd235
Date: 2012-03-16 17:58:07 +0000 (Fri, 16 Mar 2012)
Log Message:
-----------
Align rd235 branch to vde-2 mainstream 2.3.2
Modified Paths:
--------------
branches/rd235/vde-2/configure.ac
branches/rd235/vde-2/src/lib/libvdeplug.c
branches/rd235/vde-2/src/lib/python/vdeplug_python.c
branches/rd235/vde-2/src/vde_autolink.c
branches/rd235/vde-2/src/vde_pcapplug.c
branches/rd235/vde-2/src/vde_plug.c
branches/rd235/vde-2/src/vde_plug2tap.c
branches/rd235/vde-2/src/vde_switch/Makefile.am
branches/rd235/vde-2/src/vde_switch/consmgmt.c
branches/rd235/vde-2/src/vde_switch/datasock.c
branches/rd235/vde-2/src/vde_switch/vde_switch.c
branches/rd235/vde-2/src/vde_tunctl.c
branches/rd235/vde-2/src/vdetaplib/vdetap.c
Modified: branches/rd235/vde-2/configure.ac
===================================================================
--- branches/rd235/vde-2/configure.ac 2012-02-02 14:59:34 UTC (rev 544)
+++ branches/rd235/vde-2/configure.ac 2012-03-16 17:58:07 UTC (rev 545)
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT([vde2],[2.3.1],[[email protected]])
+AC_INIT([vde2],[2.3.2],[[email protected]])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
Modified: branches/rd235/vde-2/src/lib/libvdeplug.c
===================================================================
--- branches/rd235/vde-2/src/lib/libvdeplug.c 2012-02-02 14:59:34 UTC (rev
544)
+++ branches/rd235/vde-2/src/lib/libvdeplug.c 2012-03-16 17:58:07 UTC (rev
545)
@@ -46,6 +46,8 @@
/* Per-User standard switch definition */
/* This will be prefixed by getenv("HOME") */
/* it can be a symbolic link to the switch dir */
+#define STDSWITCH "/.vde2/default.switch"
+/* deprecated old name */
#define STDSOCK "/.vde2/stdsock"
#ifdef USE_IPN
@@ -176,9 +178,14 @@
given_sockname = NULL;
if (homedir) {
struct stat statbuf;
- snprintf(std_sockname, PATH_MAX, "%s%s", homedir,
STDSOCK);
+ snprintf(std_sockname, PATH_MAX, "%s%s", homedir,
STDSWITCH);
if (lstat(std_sockname,&statbuf)==0)
given_sockname = std_sockname;
+ else {
+ snprintf(std_sockname, PATH_MAX, "%s%s",
homedir, STDSOCK);
+ if (lstat(std_sockname,&statbuf)==0)
+ given_sockname = std_sockname;
+ }
}
} else {
char *split;
Modified: branches/rd235/vde-2/src/lib/python/vdeplug_python.c
===================================================================
--- branches/rd235/vde-2/src/lib/python/vdeplug_python.c 2012-02-02
14:59:34 UTC (rev 544)
+++ branches/rd235/vde-2/src/lib/python/vdeplug_python.c 2012-03-16
17:58:07 UTC (rev 545)
@@ -13,7 +13,7 @@
static PyObject *vdeplug_open(PyObject *self, PyObject *args)
{
- struct vde_open_args vde_args = {0,NULL,0};
+ struct vde_open_args vde_args = {0,NULL,0777};
char *vde_sock = NULL, *vde_descr = NULL;
VDECONN *ret;
int e;
Modified: branches/rd235/vde-2/src/vde_autolink.c
===================================================================
--- branches/rd235/vde-2/src/vde_autolink.c 2012-02-02 14:59:34 UTC (rev
544)
+++ branches/rd235/vde-2/src/vde_autolink.c 2012-03-16 17:58:07 UTC (rev
545)
@@ -1316,7 +1316,7 @@
int main(int argc,char **argv)
{
- int n, npfd=0, option_index;
+ int npfd=0, option_index;
int mgmtfd, mgmtindex=-1, vdemgindex=-1, consoleindex=-1;
struct job *j; time_t now;
@@ -1433,7 +1433,7 @@
while(1){
- n=poll(pfd,npfd,polltimeout);
+ poll(pfd,npfd,polltimeout);
/* Handle async output from switch */
if(pfd[vdemgindex].revents & POLLHUP){
Modified: branches/rd235/vde-2/src/vde_pcapplug.c
===================================================================
--- branches/rd235/vde-2/src/vde_pcapplug.c 2012-02-02 14:59:34 UTC (rev
544)
+++ branches/rd235/vde-2/src/vde_pcapplug.c 2012-03-16 17:58:07 UTC (rev
545)
@@ -259,7 +259,6 @@
static char *sockname=NULL;
static char *ifname=NULL;
int daemonize=0;
- int result;
char errbuf[PCAP_ERRBUF_SIZE];
int pcapfd;
register ssize_t nx;
@@ -332,6 +331,13 @@
exit(1);
}
strcat(pidfile_path, "/");
+
+ conn=vde_open(sockname,"vde_pcapplug:",&open_args);
+ if (conn == NULL) {
+ printlog(LOG_ERR,"vde_open %s:
%s",sockname?sockname:"DEF_SWITCH",strerror(errno));
+ exit(1);
+ }
+
if (daemonize && daemon(0, 0)) {
printlog(LOG_ERR,"daemon: %s",strerror(errno));
exit(1);
@@ -365,16 +371,12 @@
}
setup_fd(pcapfd);
- conn=vde_open(sockname,"vde_pcapplug:",&open_args);
- if (conn == NULL)
- exit(1);
-
pollv[0].fd=pcapfd;
pollv[1].fd=vde_datafd(conn);
pollv[2].fd=vde_ctlfd(conn);
for(;;) {
- result=poll(pollv,3,-1);
+ poll(pollv,3,-1);
if ((pollv[0].revents | pollv[1].revents | pollv[2].revents) &
POLLHUP ||
pollv[2].revents & POLLIN)
break;
Modified: branches/rd235/vde-2/src/vde_plug.c
===================================================================
--- branches/rd235/vde-2/src/vde_plug.c 2012-02-02 14:59:34 UTC (rev 544)
+++ branches/rd235/vde-2/src/vde_plug.c 2012-03-16 17:58:07 UTC (rev 545)
@@ -286,7 +286,6 @@
int main(int argc, char **argv)
{
static char *sockname=NULL;
- int result;
register ssize_t nx;
struct vde_open_args open_args={.port=0,.group=NULL,.mode=0700};
@@ -374,8 +373,10 @@
atexit(cleanup);
setsighandlers();
conn=vde_open(sockname,"vde_plug:",&open_args);
- if (conn == NULL)
+ if (conn == NULL) {
+ fprintf(stderr,"vde_open %s:
%s\n",sockname?sockname:"DEF_SWITCH",strerror(errno));
exit(1);
+ }
vdestream=vdestream_open(conn,STDOUT_FILENO,vdeplug_recv,vdeplug_err);
@@ -383,7 +384,7 @@
pollv[2].fd=vde_ctlfd(conn);
for(;;) {
- result=poll(pollv,3,-1);
+ poll(pollv,3,-1);
if ((pollv[0].revents | pollv[1].revents | pollv[2].revents) &
POLLHUP ||
pollv[2].revents & POLLIN)
break;
Modified: branches/rd235/vde-2/src/vde_plug2tap.c
===================================================================
--- branches/rd235/vde-2/src/vde_plug2tap.c 2012-02-02 14:59:34 UTC (rev
544)
+++ branches/rd235/vde-2/src/vde_plug2tap.c 2012-03-16 17:58:07 UTC (rev
545)
@@ -245,7 +245,6 @@
static char *sockname=NULL;
static char *tapname=NULL;
int daemonize=0;
- int result;
int tapfd;
register ssize_t nx;
struct vde_open_args open_args={.port=0,.group=NULL,.mode=0700};
@@ -345,9 +344,11 @@
pollv[0].fd=tapfd;
if (sockname==NULL || strcmp(sockname,"-") != 0) {
- conn=vde_open(sockname,"vde_plug:",&open_args);
- if (conn == NULL)
+ conn=vde_open(sockname,"vde_plug2tap:",&open_args);
+ if (conn == NULL) {
+ printlog(LOG_ERR,"vde_open %s:
%s",sockname?sockname:"DEF_SWITCH",strerror(errno));
exit(1);
+ }
pollv[1].fd=vde_datafd(conn);
pollv[2].fd=vde_ctlfd(conn);
npollv=3;
@@ -360,7 +361,7 @@
}
for(;;) {
- result=poll(pollv,3,-1);
+ poll(pollv,3,-1);
if ((pollv[0].revents | pollv[1].revents | pollv[2].revents) &
POLLHUP ||
(npollv > 2 && pollv[2].revents & POLLIN))
break;
Modified: branches/rd235/vde-2/src/vde_switch/Makefile.am
===================================================================
--- branches/rd235/vde-2/src/vde_switch/Makefile.am 2012-02-02 14:59:34 UTC
(rev 544)
+++ branches/rd235/vde-2/src/vde_switch/Makefile.am 2012-03-16 17:58:07 UTC
(rev 545)
@@ -22,7 +22,7 @@
tuntap.c \
tuntap.h
-vde_switch_LDADD = $(top_builddir)/src/common/libvdecommon.la -lrt
+vde_switch_LDADD = $(top_builddir)/src/common/libvdecommon.la
AM_CPPFLAGS = -I$(top_srcdir)/include
AM_CFLAGS = -Wall
Modified: branches/rd235/vde-2/src/vde_switch/consmgmt.c
===================================================================
--- branches/rd235/vde-2/src/vde_switch/consmgmt.c 2012-02-02 14:59:34 UTC
(rev 544)
+++ branches/rd235/vde-2/src/vde_switch/consmgmt.c 2012-03-16 17:58:07 UTC
(rev 545)
@@ -391,6 +391,7 @@
n = read(fd, buf, sizeof(buf));
if(n < 0){
printlog(LOG_WARNING,"Reading from mgmt
%s",strerror(errno));
+ return;
}
}
if (n==0) { /*EOF || POLLHUP*/
Modified: branches/rd235/vde-2/src/vde_switch/datasock.c
===================================================================
--- branches/rd235/vde-2/src/vde_switch/datasock.c 2012-02-02 14:59:34 UTC
(rev 544)
+++ branches/rd235/vde-2/src/vde_switch/datasock.c 2012-03-16 17:58:07 UTC
(rev 545)
@@ -115,6 +115,8 @@
int optsize = sizeof(sockbufsize);
#endif
struct sockaddr_un sun_in;
+ // init sun_in memory
+ memset(&sun_in,0,sizeof(sun_in));
switch(type){
case REQ_NEW_PORT0:
port_request= -1;
Modified: branches/rd235/vde-2/src/vde_switch/vde_switch.c
===================================================================
--- branches/rd235/vde-2/src/vde_switch/vde_switch.c 2012-02-02 14:59:34 UTC
(rev 544)
+++ branches/rd235/vde-2/src/vde_switch/vde_switch.c 2012-03-16 17:58:07 UTC
(rev 545)
@@ -184,6 +184,7 @@
p->events = POLLIN | POLLHUP;
fdpp[index]->type=type;
fdpp[index]->private_data=private_data;
+ fdpp[index]->timestamp=0;
nfds++;
}
Modified: branches/rd235/vde-2/src/vde_tunctl.c
===================================================================
--- branches/rd235/vde-2/src/vde_tunctl.c 2012-02-02 14:59:34 UTC (rev
544)
+++ branches/rd235/vde-2/src/vde_tunctl.c 2012-03-16 17:58:07 UTC (rev
545)
@@ -9,23 +9,26 @@
#include <fcntl.h>
#include <unistd.h>
#include <pwd.h>
+#include <grp.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <linux/if_tun.h>
-#include <config.h>
-#include <vde.h>
-#include <vdecommon.h>
+/* TUNSETGROUP appeared in 2.6.23 */
+#ifndef TUNSETGROUP
+#define TUNSETGROUP _IOW('T', 206, int)
+#endif
static void Usage(char *name)
{
- fprintf(stderr, "Create: %s [-b] [-u owner] [-t device-name] "
+ fprintf(stderr, "Create: %s [-b] [-u owner] [-g group] [-n] [-t device-name]
"
"[-f tun-clone-device]\n", name);
fprintf(stderr, "Delete: %s -d device-name [-f tun-clone-device]\n\n",
name);
fprintf(stderr, "The default tun clone device is /dev/net/tun - some systems"
" use\n/dev/misc/net/tun instead\n\n");
fprintf(stderr, "-b will result in brief output (just the device name)\n");
+ fprintf(stderr, "-n create a tun interface (not needed if the device name
prefix is tun\n");
exit(1);
}
@@ -33,38 +36,58 @@
{
struct ifreq ifr;
struct passwd *pw;
- long owner = geteuid();
+ struct group *gr;
+ uid_t owner = -1;
+ gid_t group = -1;
int tap_fd, opt, delete = 0, brief = 0;
+ int type=IFF_TAP;
+
char *tun = "", *file = "/dev/net/tun", *name = argv[0], *end;
- while((opt = getopt(argc, argv, "bd:f:t:u:")) > 0){
+ while((opt = getopt(argc, argv, "bd:f:t:u:in")) > 0){
switch(opt) {
case 'b':
brief = 1;
break;
case 'd':
delete = 1;
- tun = optarg;
+ tun = optarg;
break;
case 'f':
- file = optarg;
- break;
+ file = optarg;
+ break;
case 'u':
- pw = getpwnam(optarg);
- if(pw != NULL){
- owner = pw->pw_uid;
- break;
- }
- owner = strtol(optarg, &end, 0);
- if(*end != '\0'){
- fprintf(stderr, "'%s' is neither a username nor a numeric uid.\n",
- optarg);
- Usage(name);
- }
- break;
- case 't':
+ pw = getpwnam(optarg);
+ if(pw != NULL){
+ owner = pw->pw_uid;
+ break;
+ }
+ owner = strtol(optarg, &end, 0);
+ if(*end != '\0'){
+ fprintf(stderr, "'%s' is neither a
username nor a numeric uid.\n",
+ optarg);
+ Usage(name);
+ }
+ break;
+ case 'g':
+ gr = getgrnam(optarg);
+ if(gr != NULL){
+ group = gr->gr_gid;
+ break;
+ }
+ group = strtol(optarg, &end, 0);
+ if(*end != '\0'){
+ fprintf(stderr, "'%s' is neither a
groupname nor a numeric group.\n",
+ optarg);
+ Usage(name);
+ }
+ break;
+ case 't':
tun = optarg;
break;
+ case 'n':
+ type = IFF_TUN;
+ break;
case 'h':
default:
Usage(name);
@@ -85,7 +108,8 @@
memset(&ifr, 0, sizeof(ifr));
- ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
+ if (strncmp(tun,"tun",3)==0) type=IFF_TUN;
+ ifr.ifr_flags = type | IFF_NO_PI;
strncpy(ifr.ifr_name, tun, sizeof(ifr.ifr_name) - 1);
if(ioctl(tap_fd, TUNSETIFF, (void *) &ifr) < 0){
perror("TUNSETIFF");
@@ -100,18 +124,38 @@
printf("Set '%s' nonpersistent\n", ifr.ifr_name);
}
else {
+ /* emulate behaviour prior to TUNSETGROUP */
+ if(owner == -1 && group == -1) {
+ owner = geteuid();
+ }
+
+ if(owner != -1) {
+ if(ioctl(tap_fd, TUNSETOWNER, owner) < 0){
+ perror("TUNSETOWNER");
+ exit(1);
+ }
+ }
+ if(group != -1) {
+ if(ioctl(tap_fd, TUNSETGROUP, group) < 0){
+ perror("TUNSETGROUP");
+ exit(1);
+ }
+ }
+
if(ioctl(tap_fd, TUNSETPERSIST, 1) < 0){
perror("TUNSETPERSIST");
exit(1);
}
- if(ioctl(tap_fd, TUNSETOWNER, owner) < 0){
- perror("TUNSETPERSIST");
- exit(1);
- }
if(brief)
printf("%s\n", ifr.ifr_name);
- else printf("Set '%s' persistent and owned by uid %ld\n", ifr.ifr_name,
- owner);
- }
- return(0);
+ else {
+ printf("Set '%s' persistent and owned by",
ifr.ifr_name);
+ if(owner != -1)
+ printf(" uid %d", owner);
+ if(group != -1)
+ printf(" gid %d", group);
+ printf("\n");
+ }
+ }
+ return(0);
}
Modified: branches/rd235/vde-2/src/vdetaplib/vdetap.c
===================================================================
--- branches/rd235/vde-2/src/vdetaplib/vdetap.c 2012-02-02 14:59:34 UTC (rev
544)
+++ branches/rd235/vde-2/src/vdetaplib/vdetap.c 2012-03-16 17:58:07 UTC (rev
545)
@@ -29,10 +29,7 @@
int main(int argc,char *argv[])
{
int fd,fddata;
- struct sockaddr_un datain;
- /*struct sockaddr_un dataout;*/
- socklen_t datainsize;
- int result,nx;
+ int nx;
register int i;
struct vde_open_args open_args={.port=0,.group=NULL,.mode=0700};
char *descr;
@@ -66,17 +63,15 @@
pollv[0].fd=fd;
pollv[1].fd=vde_datafd(conn);
for(;;) {
- result=poll(pollv,2,-1);
+ poll(pollv,2,-1);
if (pollv[0].revents & POLLHUP || pollv[1].revents & POLLHUP)
break;
if (pollv[0].revents & POLLIN) {
nx=read(fd,bufin,sizeof(bufin));
/*fprintf(stderr,"RX from pgm %d\n",nx);*/
- //send(connected_fd,bufin,nx,0);
vde_send(conn,bufin,nx,0);
}
if (pollv[1].revents & POLLIN) {
- datainsize=sizeof(datain);
nx=vde_recv(conn,bufin,BUFSIZE,0);
/*fprintf(stderr,"TX to pgm %d\n",nx);*/
write(fd,bufin,nx);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
vde-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vde-users