Revision: 579
          http://sourceforge.net/p/vde/svn/579
Author:   rd235
Date:     2014-03-08 12:08:39 +0000 (Sat, 08 Mar 2014)
Log Message:
-----------
vxvde bugfix (IPv4 self broadcasts) and optimizations

Modified Paths:
--------------
    branches/rd235/vde-2/src/lib/libvdeplug/libvdeplug_vxvde.c
    branches/rd235/vde-2/src/vde_plug.c

Modified: branches/rd235/vde-2/src/lib/libvdeplug/libvdeplug_vxvde.c
===================================================================
--- branches/rd235/vde-2/src/lib/libvdeplug/libvdeplug_vxvde.c  2014-02-10 
21:41:41 UTC (rev 578)
+++ branches/rd235/vde-2/src/lib/libvdeplug/libvdeplug_vxvde.c  2014-03-08 
12:08:39 UTC (rev 579)
@@ -196,7 +196,6 @@
        return retval;
 }
 
-
 #ifdef DEBUGADDR
 static inline void printaddr(char *msg, void *sockaddr)
 {
@@ -255,7 +254,6 @@
        for (rp = result; rp != NULL; rp = rp->ai_next) {
                switch (rp->ai_family) {
                        case AF_INET6: {
-                               // currently unsupported
                                                                                
         struct sockaddr_in6 *addr=(struct sockaddr_in6 *)(rp->ai_addr);
                                                                                
         struct ipv6_mreq mc_req;
                                                                                
         struct sockaddr_in6 bindaddr;
@@ -309,8 +307,8 @@
                                                                                
                                 &bindaddrlen) < 0)
                                                                                
                 goto error;
                                                                                
         uniport=bindaddr.sin6_port;
-                                                                               
         break;
                                                                                
 }
+                                                                               
 break;
                        case AF_INET: {
                                                                                
        struct sockaddr_in *addr=(struct sockaddr_in *)(rp->ai_addr);
                                                                                
        struct ip_mreqn mc_req;
@@ -370,6 +368,7 @@
                                                                                
        uniport=bindaddr.sin_port;
                                                                                
        //fprintf(stderr,"local port %d\n",ntohs(bindaddr.sin_port));
                                                                                
}
+                                                                               
break;
                        default:
                                                                                
uniport=0;
                }

Modified: branches/rd235/vde-2/src/vde_plug.c
===================================================================
--- branches/rd235/vde-2/src/vde_plug.c 2014-02-10 21:41:41 UTC (rev 578)
+++ branches/rd235/vde-2/src/vde_plug.c 2014-03-08 12:08:39 UTC (rev 579)
@@ -42,6 +42,7 @@
 
 #define BUFSIZE 4096
 #define ETH_ALEN 6
+#define ETH_HDRLEN (ETH_ALEN+ETH_ALEN+2)
 
 VDECONN *conn;
 VDECONN *conn2;
@@ -300,15 +301,19 @@
                        break;
                if (pollv[0].revents & POLLIN) {
                        nx=vde_recv(conn, bufin, BUFSIZE,0);
-                       if (nx==0)
+                       if (__builtin_expect((nx >= ETH_HDRLEN),1)) {
+                               vde_send(conn2, bufin, nx, 0);
+                               /*fprintf(stderr,"0->1 %d ",nx);*/
+                       } else if (nx<0)
                                break;
-                       vde_send(conn2, bufin, nx, 0);
                }
                if (pollv[1].revents & POLLIN) {
                        nx=vde_recv(conn2,bufin,BUFSIZE,0);
-                       if (nx<0)
+                       if (__builtin_expect((nx >= ETH_HDRLEN),1)) {
+                               vde_send(conn, bufin, nx, 0);
+                               /*fprintf(stderr,"1->0 %d ",nx);*/
+                       } else if (nx<0)
                                break;
-                       vde_send(conn, bufin, nx, 0);
                }
        }
        return(0);
@@ -465,8 +470,8 @@
 
        for(;;) {
                poll(pollv,3,-1);
-               if ((pollv[0].revents | pollv[1].revents | pollv[2].revents) & 
POLLHUP ||
-                               pollv[2].revents & POLLIN)
+               if (__builtin_expect(((pollv[0].revents | pollv[1].revents | 
pollv[2].revents) & POLLHUP ||
+                               pollv[2].revents & POLLIN),0))
                        break;
                if (pollv[0].revents & POLLIN) {
                        nx=read(STDIN_FILENO,bufin,sizeof(bufin));
@@ -475,17 +480,16 @@
                        /*fprintf(stderr,"%s: RECV %d %x %x 
\n",myname,nx,bufin[0],bufin[1]);*/
                        if (nx==0)
                                break;
-                       vdestream_recv(vdestream, bufin, nx);
+                               vdestream_recv(vdestream, bufin, nx);
                }
                if (pollv[1].revents & POLLIN) {
                        nx=vde_recv(conn,bufin,BUFSIZE-2,0);
-                       if (nx<0)
-                               perror("vde_plug: recvfrom ");
-                       else
+                       if (__builtin_expect((nx >= ETH_HDRLEN),1))
                        {
                                vdestream_send(vdestream, bufin, nx);
                                /*fprintf(stderr,"%s: SENT %d %x %x 
\n",myname,nx,bufin[0],bufin[1]);*/
-                       }
+                       } else if (nx<0)
+                               perror("vde_plug: recvfrom ");
                }
        }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
vde-users mailing list
vde-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vde-users

Reply via email to