Skip to contentSkip to conversation

Patch: Admin interface shows server IP when connected

Openvpn-devel Rolf Fokkens 4 participants 23 messages Oct 2, 2005 – Nov 7, 2005 Kbuild

lore
Share & tools
lore
#0 lore raw

Hi,

I created an OpenVPN admin interface, which I want to show the actual connected server of a client. The normal "state" command in the admin interface does not provide the information. The attached patch adds an extra argument to the "state" result which shows the server's IP. Like this:

[[email protected]... ~]# echo state | nc 0.0.0.0 5000

Quoted 1 line

INFO:OpenVPN Management Interface Version 1 -- type 'help' for

more info
1128286300,CONNECTED,SUCCESS,,145.66.1.1
END
[[email protected]... ~]#

James Yonan once told me that this actualy changes the admin API, so it may break some admin interfaces. For those however who can use it I attached the patch.

Rolf

forward.c +1 -0
diff -ruN openvpn-2.0.1.orig/forward.c openvpn-2.0.1/forward.c
@@ -194,6 +194,7 @@
 		  management_set_state (management,
 					OPENVPN_STATE_GET_CONFIG,
 					NULL,
+					0,
 					0);
 		}
 #endif
init.c +5 -1
diff -ruN openvpn-2.0.1.orig/init.c openvpn-2.0.1/init.c
@@ -594,15 +594,18 @@
   if (management)
     {
       in_addr_t tun_local = 0;
+      in_addr_t tun_remote = 0; /* FKS */
       const char *detail = "SUCCESS";
       if (c->c1.tuntap)
 	tun_local = c->c1.tuntap->local;
+      tun_remote = htonl (c->c1.link_socket_addr.actual.sin_addr.s_addr);
       if (flags & ISC_ERRORS)
 	detail = "ERROR";
       management_set_state (management,
 			    OPENVPN_STATE_CONNECTED,
 			    detail,
-			    tun_local);
+			    tun_local,
+			    tun_remote);
       if (tun_local)
 	management_post_tunnel_open (management, tun_local);
     }
@@ -2190,6 +2193,7 @@
 	      management_set_state (management,
 				    OPENVPN_STATE_CONNECTING,
 				    NULL,
+				    (in_addr_t)0,
 				    (in_addr_t)0);
 	    }
 
manage.c +8 -2
diff -ruN openvpn-2.0.1.orig/manage.c openvpn-2.0.1/manage.c
@@ -440,7 +440,8 @@
 	       "state",
 	       man->persist.state,
 	       &man->connection.state_realtime,
-	       LOG_PRINT_INT_DATE|LOG_PRINT_STATE|LOG_PRINT_LOCAL_IP);
+	       LOG_PRINT_INT_DATE|LOG_PRINT_STATE|
+	       LOG_PRINT_LOCAL_IP|LOG_PRINT_REMOTE_IP);
 }
 
 static void
@@ -1329,7 +1330,8 @@
 management_set_state (struct management *man,
 		      const int state,
 		      const char *detail,
-		      const in_addr_t tun_local_ip)
+		      const in_addr_t tun_local_ip,
+		      const in_addr_t tun_remote_ip)
 {
   if (man->persist.state && (!man->settings.server || state < OPENVPN_STATE_CLIENT_BASE))
     {
@@ -1343,6 +1345,7 @@
       e.u.state = state;
       e.string = detail;
       e.local_ip = tun_local_ip;
+      e.remote_ip = tun_remote_ip;
       
       log_history_add (man->persist.state, &e);
 
@@ -1351,6 +1354,7 @@
 			       |   LOG_PRINT_INT_DATE
                                |   LOG_PRINT_STATE
 			       |   LOG_PRINT_LOCAL_IP
+			       |   LOG_PRINT_REMOTE_IP
                                |   LOG_PRINT_CRLF, &gc);
 
       if (out)
@@ -2032,6 +2036,8 @@
     buf_printf (&out, "%s", e->string);
   if (flags & LOG_PRINT_LOCAL_IP)
     buf_printf (&out, ",%s", print_in_addr_t (e->local_ip, IA_EMPTY_IF_UNDEF, gc));
+  if (flags & LOG_PRINT_REMOTE_IP)
+    buf_printf (&out, ",%s", print_in_addr_t (e->remote_ip, IA_EMPTY_IF_UNDEF, gc));
   if (flags & LOG_PRINT_CRLF)
     buf_printf (&out, "\r\n");
   return BSTR (&out);
manage.h +5 -1
diff -ruN openvpn-2.0.1.orig/manage.h openvpn-2.0.1/manage.h
@@ -96,6 +96,7 @@
   time_t timestamp;
   const char *string;
   in_addr_t local_ip;
+  in_addr_t remote_ip;
   union log_entry_union u;
 };
 
@@ -111,6 +112,8 @@
 #define LOG_PRINT_CRLF         (1<<7)
 #define LOG_FATAL_NOTIFY       (1<<8)
 
+#define LOG_PRINT_REMOTE_IP    (1<<9)
+
 const char *log_entry_print (const struct log_entry *e, unsigned int flags, struct gc_arena *gc);
 
 struct log_history
@@ -321,7 +324,8 @@
 void management_set_state (struct management *man,
 			   const int state,
 			   const char *detail,
-			   const in_addr_t tun_local_ip);
+			   const in_addr_t tun_local_ip,
+			   const in_addr_t tun_remote_ip);
 
 /*
  * The management object keeps track of OpenVPN --echo

Binary files openvpn-2.0.1.orig/openvpn and openvpn-2.0.1/openvpn differ

route.c +1 -0
diff -ruN openvpn-2.0.1.orig/route.c openvpn-2.0.1/route.c
@@ -527,6 +527,7 @@
 	  management_set_state (management,
 				OPENVPN_STATE_ADD_ROUTES,
 				NULL,
+				0,
 				0);
 	}
 #endif
sig.c +1 -0
diff -ruN openvpn-2.0.1.orig/sig.c openvpn-2.0.1/sig.c
@@ -167,6 +167,7 @@
 	management_set_state (management,
 			      state,
 			      si->signal_text ? si->signal_text : signal_name (si->signal_received, true),
+			      (in_addr_t)0,
 			      (in_addr_t)0);
     }
 #endif
ssl.c +2 -0
diff -ruN openvpn-2.0.1.orig/ssl.c openvpn-2.0.1/ssl.c
@@ -2841,6 +2841,7 @@
 		      management_set_state (management,
 					    OPENVPN_STATE_WAIT,
 					    NULL,
+					    0,
 					    0);
 		    }
 #endif
@@ -3512,6 +3513,7 @@
 		      management_set_state (management,
 					    OPENVPN_STATE_AUTH,
 					    NULL,
+					    0,
 					    0);
 		    }
 #endif
stamp-h1 +1 -0
diff -ruN openvpn-2.0.1.orig/stamp-h1 openvpn-2.0.1/stamp-h1
@@ -0,0 +1 @@
+timestamp for config.h
tun.c +2 -1
diff -ruN openvpn-2.0.1.orig/tun.c openvpn-2.0.1/tun.c
@@ -536,7 +536,8 @@
       management_set_state (management,
 			    OPENVPN_STATE_ASSIGN_IP,
 			    NULL,
-			    tt->local);
+			    tt->local,
+			    0);
     }
 #endif
 
#1 lore raw

[Openvpn-devel] Re: Patch: TAP non ARP dependent

Hi,

Using OpenVPN to build a WAN, I noticed a disturbing thing: After failing over to secondary OpenVPN server it takes a long time until a ping to a client side IP works again. I think I know what's happening:

An OpenVPN server learns client-side MAC addresses based on the source MAC addresses of received packets, just like an ethernet switch. When an ethernet packet has to be sent to a client, the OpenVPN server selects the client based on previously learnt MAC addresses. When a packet has an unknown destination MAC address it's dropped - this is very unlike a switch which broadcasts a packet to all interfaces. There's only one exception for OpenVPN: when the destination MAC address is a broadcast / multicast address the packet is sent to all clients.

The above makes clear why ICMP (or other IP) packets normaly arrive. It's because they're preceeded by an ARP request..... which is a broadcast. The ARP request is delivered to all clients, including the right one. The ARP reply that's sent back to the server contains a source MAC address which is learnt by the server, after which the ICMP packets are delivered properly.

The attached patch makes OpenVPN do the switch-like thing: broadcast a packet with an unknow destination to all clients instead of dropping it.

It helps me a lot, so it may help others as well.

Cheers,

Rolf

multi.c renamed from multi.c.orig +10 -2
@@ -1756,9 +1756,17 @@
 	    }
 	  else
 	    {
-	      multi_set_pending (m, multi_get_instance_by_virtual_addr (m, &dest, dev_type == DEV_TYPE_TUN));
+              struct multi_instance *mi;
 
-	      if (m->pending)
+	      mi = multi_get_instance_by_virtual_addr (m, &dest, dev_type == DEV_TYPE_TUN);
+	      multi_set_pending (m, mi);
+
+	      if (!mi)
+                {
+	          /* No known instance? Do like a switch: broadcast */
+	          if (dev_type == DEV_TYPE_TAP) multi_bcast (m, &m->top.c2.buf, NULL);
+                }
+              else
 		{
 		  /* get instance context */
 		  c = &m->pending->context;
#2 lore raw
In reply to Rolf Fokkens
Quoted 14 lines · Rolf Fokkens

Hi,

I created an OpenVPN admin interface, which I want to show the actual connected server of a client. The normal "state" command in the admin interface does not provide the information. The attached patch adds an extra argument to the "state" result which shows the server's IP. Like this:

    [[email protected]... ~]# echo state | nc 0.0.0.0 5000
     >INFO:OpenVPN Management Interface Version 1 -- type 'help' for
    more info
    1128286300,CONNECTED,SUCCESS,,145.66.1.1
    END
    [[email protected]... ~]#
Quoted 5 lines

James Yonan once told me that this actualy changes the admin API, so it may break some admin interfaces. For those however who can use it I attached the patch.

Rolf

Rolf,

Thanks for the patch -- I see this as being a 2.1 thing, mostly so as not to change the the management API mid-stream in 2.0.x.

What I would like to do is collect all of the managment interface changes which affect the API and release them simultaneously as "Management Interface Version 2".

James

#3 lore raw

[Openvpn-devel] Patch: TAP usage made non ARP dependent

In reply to Rolf Fokkens

Hi,

Using OpenVPN to build a WAN, I noticed a disturbing thing: After failing over to secondary OpenVPN server it takes a long time until a ping to a client side IP works again. I think I know what's happening:

An OpenVPN server learns client-side MAC addresses based on the source MAC addresses of received packets, just like an ethernet switch. When an ethernet packet has to be sent to a client, the OpenVPN server selects the client based on previously learnt MAC addresses. When a packet has an unknown destination MAC address it's dropped - this is very unlike a switch which broadcasts a packet to all interfaces. There's only one exception for OpenVPN: when the destination MAC address is a broadcast / multicast address the packet is sent to all clients.

The above makes clear why ICMP (or other IP) packets normaly arrive. It's because they're preceeded by an ARP request..... which is a broadcast. The ARP request is delivered to all clients, including the right one. The ARP reply that's sent back to the server contains a source MAC address which is learnt by the server, after which the ICMP packets are delivered properly.

The attached patch makes OpenVPN do the switch-like thing: broadcast a packet with an unknow destination to all clients instead of dropping it.

It helps me a lot, so it may help others as well.

Cheers,

Rolf

multi.c renamed from multi.c.orig +10 -2
@@ -1756,9 +1756,17 @@
 	    }
 	  else
 	    {
-	      multi_set_pending (m, multi_get_instance_by_virtual_addr (m, &dest, dev_type == DEV_TYPE_TUN));
+              struct multi_instance *mi;
 
-	      if (m->pending)
+	      mi = multi_get_instance_by_virtual_addr (m, &dest, dev_type == DEV_TYPE_TUN);
+	      multi_set_pending (m, mi);
+
+	      if (!mi)
+                {
+	          /* No known instance? Do like a switch: broadcast */
+	          if (dev_type == DEV_TYPE_TAP) multi_bcast (m, &m->top.c2.buf, NULL);
+                }
+              else
 		{
 		  /* get instance context */
 		  c = &m->pending->context;
#4 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Em Seg, 2005-10-03 às 21:43 +0200, Rolf Fokkens escreveu:

Quoted 7 lines

Hi,

Using OpenVPN to build a WAN, I noticed a disturbing thing: After failing over to secondary OpenVPN server it takes a long time until a ping to a client side IP works again. I think I know what's happening:

...

great to read it! We're going to test your patch. Thanks a lot.

Signature · 1 line
Marcelo Toledo <[email protected]...>
#5 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Quoted 3 lines · Marcelo Toledo

great to read it! We're going to test your patch. Thanks a lot.

Wonderful, beware however there's another issue te be resolved: MAC aging. Switches require their mac-table te be refreshed regularly, otherwise the MAC entries are aged out (on cisco in 300 sec). OpenVPN doesn't seem to do aging like that, so a MAC entry learnt won't be forgotten.

This is problematic if another client (because of a failover) will be routing the traffic. In this case traffic will be sent to the wrong client until an ARP request + reply corrects the MAC entry on the server.

So another thing that should be implemented probably is aging.

#6 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Em Ter, 2005-10-04 às 14:06 +0200, Rolf Fokkens escreveu:

Quoted 2 lines

So another thing that should be implemented probably is aging.

Alright, I am aware. Are you planning working on this?

Signature · 1 line
Marcelo Toledo <[email protected]...>
#7 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Quoted 10 lines · Marcelo Toledo

Em Ter, 2005-10-04 às 14:06 +0200, Rolf Fokkens escreveu:

Quoted 3 lines

So another thing that should be implemented probably is aging.

Alright, I am aware. Are you planning working on this?

Attached you'll find find a new patch which includes aging. Could you try?

multi.c +21 -7
diff -ruN openvpn-2.0.2.orig/multi.c openvpn-2.0.2/multi.c
@@ -675,12 +675,13 @@
 
 		  if (route->flags & MULTI_ROUTE_CACHE)
 		    flags[0] = 'C';
-		  status_printf (so, "%s%s,%s,%s,%s",
+		  status_printf (so, "%s%s,%s,%s,%s,%d",
 				 mroute_addr_print (ma, &gc),
 				 flags,
 				 tls_common_name (mi->context.c2.tls_multi, false),
 				 mroute_addr_print (&mi->real, &gc),
-				 time_string (route->last_reference, 0, false, &gc));
+				 time_string (route->last_reference, 0, false, &gc),
+				 now - route->last_update);
 		}
 	      gc_free (&gc);
 	    }
@@ -737,12 +738,13 @@
 
 		  if (route->flags & MULTI_ROUTE_CACHE)
 		    flags[0] = 'C';
-		  status_printf (so, "ROUTING_TABLE,%s%s,%s,%s,%s,%u",
+		  status_printf (so, "ROUTING_TABLE,%s%s,%s,%s,%s,%d,%u",
 				 mroute_addr_print (ma, &gc),
 				 flags,
 				 tls_common_name (mi->context.c2.tls_multi, false),
 				 mroute_addr_print (&mi->real, &gc),
 				 time_string (route->last_reference, 0, false, &gc),
+				 now - route->last_update,
 				 (unsigned int)route->last_reference);
 		}
 	      gc_free (&gc);
@@ -791,7 +793,10 @@
   if (he)
     oldroute = (struct multi_route *) he->value;
   if (oldroute && multi_route_defined (m, oldroute))
-    owner = oldroute->instance;
+    {
+      owner = oldroute->instance;
+      oldroute->last_update = now;
+    }
 
   /* do we need to add address to hash table? */
   if ((!owner || owner != mi)
@@ -807,6 +812,7 @@
       newroute->instance = mi;
       newroute->flags = flags;
       newroute->last_reference = now;
+      newroute->last_update = now;
       newroute->cache_generation = 0;
 
       /* The cache is invalidated when cache_generation is incremented */
@@ -1665,7 +1671,7 @@
 
 	      if (mroute_flags & MROUTE_EXTRACT_SUCCEEDED)
 		{
-		  if (multi_learn_addr (m, m->pending, &src, 0) == m->pending)
+		  if (multi_learn_addr (m, m->pending, &src, MULTI_ROUTE_AGEABLE) == m->pending)
 		    {
 		      /* check for broadcast */
 		      if (m->enable_c2c)
@@ -1756,9 +1762,17 @@
 	    }
 	  else
 	    {
-	      multi_set_pending (m, multi_get_instance_by_virtual_addr (m, &dest, dev_type == DEV_TYPE_TUN));
+              struct multi_instance *mi;
+
+	      mi = multi_get_instance_by_virtual_addr (m, &dest, dev_type == DEV_TYPE_TUN);
+	      multi_set_pending (m, mi);
 
-	      if (m->pending)
+	      if (!mi)
+                {
+	          /* No known instance? Do like a switch: broadcast */
+	          if (dev_type == DEV_TYPE_TAP) multi_bcast (m, &m->top.c2.buf, NULL);
+                }
+              else
 		{
 		  /* get instance context */
 		  c = &m->pending->context;
multi.h +2 -1
diff -ruN openvpn-2.0.2.orig/multi.h openvpn-2.0.2/multi.h
@@ -134,6 +134,7 @@
 
   unsigned int cache_generation;
   time_t last_reference;
+  time_t last_update;
 };
 
 /*
@@ -291,7 +292,7 @@
 	   && r->cache_generation != m->route_helper->cache_generation)
     return false;
   else if ((r->flags & MULTI_ROUTE_AGEABLE)
-	   && r->last_reference + m->route_helper->ageable_ttl_secs < now)
+	   && r->last_update + m->route_helper->ageable_ttl_secs < now)
     return false;
   else
     return true;
#8 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Em Ter, 2005-10-04 às 20:57 +0200, Rolf Fokkens escreveu:

Quoted 10 lines
Quoted 7 lines · Marcelo Toledo

Em Ter, 2005-10-04 às 14:06 +0200, Rolf Fokkens escreveu:

Quoted 2 lines

So another thing that should be implemented probably is aging.

Alright, I am aware. Are you planning working on this?

Attached you'll find find a new patch which includes aging. Could you try?

that's great! I will try it, thanks.

Signature · 1 line
Marcelo Toledo <[email protected]...>
#9 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

In reply to Rolf Fokkens

Em Ter, 2005-10-04 às 20:57 +0200, Rolf Fokkens escreveu:

Quoted 10 lines
Quoted 7 lines · Marcelo Toledo

Em Ter, 2005-10-04 às 14:06 +0200, Rolf Fokkens escreveu:

Quoted 2 lines

So another thing that should be implemented probably is aging.

Alright, I am aware. Are you planning working on this?

Attached you'll find find a new patch which includes aging. Could you try?

We have tested it in two ways:

1. Applied only in the server, worked perfectly with 3 clients. Right now we're going to try few hundreds.

2. Applied the patch only in the client, worked well but they couldn't see each other.

Should I apply in both or only in the server is enough?

Signature · 1 line
Marcelo Toledo <[email protected]...>
#10 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Quoted 11 lines · Marcelo Toledo

We have tested it in two ways:

1. Applied only in the server, worked perfectly with 3 clients. Right now we're going to try few hundreds.

2. Applied the patch only in the client, worked well but they couldn't see each other.

Should I apply in both or only in the server is enough?

Could be a silly question, but to be sure: you had the client-to-client option enabled on the server side?

The patch should work both on the client and the server, but for clients it hardly does anything at all.

#11 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Em Sex, 2005-10-07 às 18:19 +0200, Rolf Fokkens escreveu:

Quoted 3 lines

Could be a silly question, but to be sure: you had the client-to-client option enabled on the server side?

Yes we do.

Quoted 2 lines

The patch should work both on the client and the server, but for clients it hardly does anything at all.

alright, here what we have done.

In the main server we installed the patch. We have ~400 clients connected to it, 3 of them we also installed the patch, here is the result.

All these 3 clients couldn't see each other but they could see the remaining 397 clients. The 397 couldn't see the 3 clients.

I think that's it, any idea?

Signature · 1 line
Marcelo Toledo <[email protected]...>
#12 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Quoted 17 lines · Marcelo Toledo

Em Sex, 2005-10-07 às 18:19 +0200, Rolf Fokkens escreveu:

Quoted 3 lines

Could be a silly question, but to be sure: you had the client-to-client option enabled on the server side?

Yes we do.

Quoted 3 lines

The patch should work both on the client and the server, but for clients it hardly does anything at all.

alright, here what we have done.

Quoted 10 lines

In the main server we installed the patch. We have ~400 clients connected to it, 3 of them we also installed the patch, here is the result.

All these 3 clients couldn't see each other but they could see the remaining 397 clients. The 397 couldn't see the 3 clients.

I think that's it, any idea?

What do you mean with "see each other"? I tried to reproduce, but no success. Both the clients could ping each other:

Server:

./openvpn --writepid /var/run/openvpn/nocompress.pid --cd /etc/openvpn/ --client-to-client --status /tmp/nocompress.status 1 cipher aes-128-cbc --keepalive 10 30 --port 5000 --dev tap0 --fragment 1300 --mtu-disc yes --mode server --tls-server --dh /etc/openvpn/plaza/dh1024.pem --ca /etc/openvpn/plaza/openvpn-ca.crt --cert /etc/openvpn/plaza/openvpn-N004.crt --key /etc/openvpn/plaza/openvpn-N004.key --verb 2 -- management 127.0.0.1 5000

Client 1:

/opt/openvpn --writepid /var/run/openvpn-vvpn-0.pid --cipher aes-128-cbc --engine padlock --dev tap0 --keepalive 3 30 --tls-client --port 5000 --passtos --syslog --fragment 1300 --mtu-disc yes --management 127.0.0.1 5000 --ca /etc/openvpn/vvpn/ca.crt --cert /etc/openvpn/vvpn/vvpn.crt --key /etc/openvpn/vvpn/vvpn.key --verb 2 --remote 145.66.1.1

Client 2:

/opt/openvpn --writepid /var/run/openvpn-vvpn-0.pid --cipher aes-128-cbc --engine padlock --dev tap0 --keepalive 3 30 --tls-client --port 5000 --passtos --syslog --fragment 1300 --mtu-disc yes --management 127.0.0.1 5000 --ca /etc/openvpn/vvpn/ca.crt --cert /etc/openvpn/vvpn/vvpn.crt --key /etc/openvpn/vvpn/vvpn.key --verb 2 --remote 145.66.1.1

Any obvious difference to your configs?

#13 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

In reply to Marcelo Toledo
Quoted 12 lines · Marcelo Toledo

Em Sex, 2005-10-07 às 18:19 +0200, Rolf Fokkens escreveu:

Quoted 3 lines

Could be a silly question, but to be sure: you had the client-to-client option enabled on the server side?

Yes we do.

Quoted 2 lines

The patch should work both on the client and the server, but for clients it hardly does anything at all.

alright, here what we have done.

Quoted 8 lines

In the main server we installed the patch. We have ~400 clients connected to it, 3 of them we also installed the patch, here is the result.

All these 3 clients couldn't see each other but they could see the remaining 397 clients. The 397 couldn't see the 3 clients.

I think that's it, any idea?

What is common amonng the three that is different from the rest?

Maybe subnetting issue? Does client-to-client work across subnets?

--
Leonard Isham, CISSP
Ostendo non ostento.

#14 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

In reply to Marcelo Toledo
Quoted 10 lines · Marcelo Toledo

In the main server we installed the patch. We have ~400 clients connected to it, 3 of them we also installed the patch, here is the result.

All these 3 clients couldn't see each other but they could see the remaining 397 clients. The 397 couldn't see the 3 clients.

I think that's it, any idea?

Oh dear, I'm starting to get a notion what's happening: the broadcast that happens when an unknow client is addressed, is handled by the patch in multi_process_incoming_tun. The same thing should happen in multi_process_incoming_link as well, which is not the case. This may be related to your problem.

So I tried to fix that. But here comes the catch: OpenVPN only keeps track of MAC addresses on remote clients, not of the ones behind the TAP interface. Now suppose some machine behind the TAP interface of the server sends an ICMP echo request to a machine behind one of the clients, the following happens:
* The ICMP echo request will be unicast to the right client once the MAC address is in de MAC table of the server.
* The ICMP echo reply will be unicast back to the server.
* The server looks up the destination MAC address of the destination of the ICMP echo reply, but this fails because the mac address is behind the TAP interface.
* Because the server can't find the MAC address the ICMP echo reply is broadcast to all clients. Ouch! Marcelo, this is no option for you as you have 400 clients!!

The problem is caused by the fact that the MAC table only keeps track of MAC's behind clients, no MAC's behind the TAP interface are registered. This can easily be fixed by registering them as well. I'll get back on that as well.

And once I have this working "kinda prototypically" I guess I need James help to finish it.

Rolf

#15 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Quoted 1 line · Rolf Fokkens

The problem is caused by the fact that the MAC table only keeps track of MAC's behind clients, no MAC's behind the TAP interface are registered. This can easily be fixed by registering them as well. I'll get back on that as well.

Well, another patch. It contains a new MAC table implementation:

* The MAC table has 1024 entries
I tested it with 2 entries, it still worked fine.

* It's a kind of FIFO table:
MAC addresses are only learnt based on the src MAC of incoming packets, Lookups have nothing to do with learning (as it does in the existing code)
o Newly learnt MAC entries are inserted at the head
o Old MAC entries are removed from the tail when the table is full
o Known MAC entries are moved to the head when being refreshed
o Lookups don't change the order of entries in the FIFO

* Each entry has a Time To Live of 60 sec.
After 60 sec. an entry is no longer returned when lookup up. It remains in the FIFO however, and may be refreshed.

The MAC table code is in the mac_table.c and mac_table.h files.

At several places multi.c is changed to use the new MAC table for TAP devices, TUN devices still use the existing code though I haven't tested that.

I tested with 1 server and 2 clients, and TCP dump shows proper behaviour. For debugging I also modified the Admin interface to reflect the MAC table contents (including TTL) when using the "status" command, alle works like predicted.

Marcelo, you have a uniqe testbed with ~400 clients, could you test this patch as well?

Rolf

mac_table.c +309 -0
diff -ruN openvpn-2.0.2.orig/mac_table.c openvpn-2.0.2/mac_table.c
@@ -0,0 +1,309 @@
+#include "mac_table.h"
+#include <stdio.h>
+
+#define mix(a,b,c)               \
+{                                \
+  a -= b; a -= c; a ^= (c>>13);  \
+  b -= c; b -= a; b ^= (a<<8);   \
+  c -= a; c -= b; c ^= (b>>13);  \
+  a -= b; a -= c; a ^= (c>>12);  \
+  b -= c; b -= a; b ^= (a<<16);  \
+  c -= a; c -= b; c ^= (b>>5);   \
+  a -= b; a -= c; a ^= (c>>3);   \
+  b -= c; b -= a; b ^= (a<<10);  \
+  c -= a; c -= b; c ^= (b>>15);  \
+}
+
+static uint32_t mactab_hash_func (const uint8_t *k, uint32_t mask)
+{
+  uint32_t a, b, c;
+
+  /* Set up the internal state */
+  a = b = 0x9e3779b9;        /* the golden ratio; an arbitrary value */
+
+  c = 6;
+  b  = (uint32_t)*k++;
+  b += (uint32_t)*k++ + (a << 8);
+  b += 0x9e3779b9;
+
+
+  a  = (uint32_t)*k++;
+  a += (uint32_t)*k++ + (a << 8);
+  a += (uint32_t)*k++ + (a << 8);
+  a += (uint32_t)*k++ + (a << 8);
+
+  mix (a, b, c);
+
+  return c & mask;
+}
+
+struct mentry
+{
+  char mac[6];
+  short hval;
+  short active;
+
+  time_t expire;
+
+  struct multi_instance *mi;
+
+  struct mentry *hprev, *hnext; /* Hash Link  */
+  struct mentry *cprev, *cnext; /* Cache link */
+};
+
+struct mactab
+{
+  int bucketmask;
+  int nentries;
+  struct mentry **buckets;
+  struct mentry *entries, *free, *head, *tail;
+};
+
+struct mactab *mactab_init (int nentries)
+{
+  struct mactab *mh;
+  struct mentry *me;
+  uint32_t i, j, nbuckets;
+
+  for (i = nentries, j = 1; i != 0; i >>= 1, j++);
+
+  nbuckets = (1 << j);
+
+  mh = malloc (sizeof (struct mactab));
+
+  mh->bucketmask = nbuckets - 1;
+  mh->buckets    = (struct mentry **) calloc (nbuckets, sizeof (void *));
+
+  mh->nentries   = nentries;
+  mh->entries    = (struct mentry *) calloc (nentries, sizeof (struct mentry));
+
+  mh->head       = NULL;
+  mh->tail       = NULL;
+
+  me             = mh->entries;
+  me->cprev      = NULL;
+  me->cnext      = me + 1;
+  mh->free       = me++;
+  nentries      -= 2;
+
+  while (nentries--) {
+    me->cprev = me - 1;
+    me->cnext = me + 1;
+    me++;
+  }
+  me->cprev = me - 1;
+  me->cnext = NULL;
+
+  return mh;
+};
+
+void mactab_uninit (struct mactab *mh)
+{
+  if (!mh) return;
+
+  free (mh->entries);
+  free (mh->buckets);
+};
+
+static void mactab_unlink_entry (struct mactab *mh, struct mentry *me)
+{
+  struct mentry *mn, *mp;
+
+  mp = me->cprev;
+  mn = me->cnext;
+
+  if (mp) {
+    mp->cnext = mn;
+  } else {
+    mh->head  = mn;
+  }
+  if (mn) {
+    mn->cprev = mp;
+  } else {
+    mh->tail  = mp;
+  }
+}
+
+static void mactab_unhash_entry (struct mactab *mh, struct mentry *me)
+{
+  struct mentry *mn, *mp;
+
+  mp = me->hprev;
+  mn = me->hnext;
+
+  if (mp) {
+    mp->hnext             = mn;
+  } else {
+    mh->buckets[me->hval] = mn;
+  }
+  if (mn) {
+    mn->hprev = mp;
+  }
+};
+
+static void mactab_free_entry (struct mactab *mh, struct mentry *me)
+{
+  struct mentry *mn;
+
+  mactab_unlink_entry (mh, me);
+  mactab_unhash_entry (mh, me);
+
+  mn = mh->free;
+  mn->cprev = me;
+  me->cnext = mn;
+  me->cprev = NULL;
+  mh->free  = me;
+
+  me->active = 0;
+};
+
+static void mactab_link_entry (struct mactab *mh, struct mentry *me)
+{
+  struct mentry *mn;
+
+  mn = mh->head;
+  mh->head  = me;
+
+  me->cnext = mn;
+  me->cprev = NULL;
+
+  if (mn) {
+    mn->cprev = me;
+  } else {
+    mh->tail  = me;
+  }
+};
+
+static void mactab_hash_entry (struct mactab *mh, struct mentry *me)
+{
+  struct mentry *mn;
+
+  me->hval = mactab_hash_func (me->mac, mh->bucketmask);
+
+  mn = mh->buckets[me->hval];
+  mh->buckets[me->hval] = me;
+
+  me->hnext = mn;
+  me->hprev = NULL;
+
+  if (mn) {
+    mn->hprev = me;
+  }
+};
+
+static void mactab_refresh_entry (struct mactab *mh, struct mentry *me)
+{
+  struct mentry *mn, *mp;
+
+  if (mh->head == me) return;
+
+  mactab_unlink_entry (mh, me);
+  mactab_link_entry (mh, me);
+};
+
+static struct mentry *mactab_find_entry (struct mactab *mh, const uint8_t *mac)
+{
+  int hval;
+  struct mentry *me;
+
+  hval = mactab_hash_func (mac, mh->bucketmask);
+  me = mh->buckets[hval];
+  while (me) {
+    if (memcmp (me->mac, mac, 6) == 0) return me;
+    me = me->hnext;
+  }
+  return NULL;
+};
+
+static struct mentry *mactab_get_entry (struct mactab *mh)
+{
+  struct mentry *me;
+
+  if (mh->free) {
+    me = mh->free;
+    mh->free = me->cnext;
+    return me;
+  }
+  me = mh->tail;
+  mactab_unlink_entry (mh, me);
+  mactab_unhash_entry (mh, me);
+
+  return me;
+};
+
+void mactab_learn_mac
+  ( struct mactab *mh, const uint8_t *mac, time_t expire
+  , struct multi_instance *mi)
+{
+  struct mentry *me;
+
+  me = mactab_find_entry (mh, mac);
+  if (me) {
+    mactab_refresh_entry (mh, me);
+  } else {
+    me = mactab_get_entry (mh);
+    memcpy (me->mac, mac, 6);
+    me->mi     = mi;
+    me->active = 1;
+    mactab_hash_entry (mh, me);
+    mactab_link_entry (mh, me);
+  }
+  me->expire = expire;
+};
+
+struct multi_instance *mactab_lookup_mac
+  (struct mactab *mh, const uint8_t *mac, time_t now)
+{
+  struct mentry *me;
+
+  me = mactab_find_entry (mh, mac);
+
+  if (!me)              return NULL;
+  if (!me->active)      return NULL;
+  if (me->expire < now) return NULL;
+
+  return me->mi;
+};
+
+void mactab_remove_mi (struct mactab *mh, struct multi_instance *mi)
+{
+  struct mentry *me, *ml;
+
+  me = mh->entries;
+  ml = me + mh->nentries;
+
+  while (me < ml) me++->active = NULL;
+};
+
+int mactab_getnext
+  ( struct mactab *mh, int cur, time_t now
+  , char *mac, int *ttl, struct multi_instance **mi)
+{
+  struct mentry *me;
+
+  while (cur < mh->nentries)
+    {
+      me = mh->entries + cur++;
+      if (me->mi && me->expire > now && me->active)
+        {
+          memcpy (mac, me->mac, 6);
+          *ttl = me->expire - now;
+          *mi  = me->mi;
+          return cur;
+        }
+    }
+  return 0;
+};
+
+char *mactab_print (uint8_t *mac)
+{
+  static char buf[19];
+  char *cp = buf;
+  int i;
+
+  for (i = 0; i < 6; i++)
+    {
+      cp += sprintf (cp, ":%02X", (int)*mac++);
+    }
+  return buf + 1;
+};
mac_table.h +31 -0
diff -ruN openvpn-2.0.2.orig/mac_table.h openvpn-2.0.2/mac_table.h
@@ -0,0 +1,31 @@
+#ifndef H_MHASH
+#define H_MHASH
+
+#include <time.h>
+
+typedef unsigned int uint32_t;
+typedef unsigned char uint8_t;
+
+struct multi_instance;
+struct mactab;
+struct mactab_entry;
+
+extern struct mactab *mactab_init   (int nentries);
+extern void           mactab_uninit (struct mactab *mh);
+
+extern void mactab_learn_mac
+  ( struct mactab *mh, const uint8_t *mac, time_t expire
+  , struct multi_instance *mi);
+
+extern struct multi_instance *mactab_lookup_mac
+  (struct mactab *mh, const uint8_t *mac, time_t now);
+
+extern void mactab_remove_mi (struct mactab *mh, struct multi_instance *mi);
+
+extern int mactab_getnext
+  ( struct mactab *mh, int cur, time_t now
+  , char *mac, int *ttl, struct multi_instance **mi);
+
+extern char *mactab_print (uint8_t *mac);
+
+#endif
Makefile.in +5 -3
diff -ruN openvpn-2.0.2.orig/Makefile.in openvpn-2.0.2/Makefile.in
@@ -102,7 +102,7 @@
 	route.$(OBJEXT) schedule.$(OBJEXT) session_id.$(OBJEXT) \
 	shaper.$(OBJEXT) sig.$(OBJEXT) socket.$(OBJEXT) \
 	socks.$(OBJEXT) ssl.$(OBJEXT) status.$(OBJEXT) \
-	thread.$(OBJEXT) tun.$(OBJEXT)
+	thread.$(OBJEXT) tun.$(OBJEXT) mac_table.$(OBJEXT)
 nodist_openvpn_OBJECTS =
 openvpn_OBJECTS = $(am_openvpn_OBJECTS) $(nodist_openvpn_OBJECTS)
 openvpn_LDADD = $(LDADD)
@@ -135,7 +135,7 @@
 @AMDEP_TRUE@	./$(DEPDIR)/sig.Po ./$(DEPDIR)/socket.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/socks.Po ./$(DEPDIR)/ssl.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/status.Po ./$(DEPDIR)/thread.Po \
[email protected]...@	./$(DEPDIR)/tun.Po
+@AMDEP_TRUE@	./$(DEPDIR)/tun.Po ./$(DEPDIR)/mac_table.Po
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
@@ -308,7 +308,8 @@
 	status.c status.h \
 	syshead.h \
 	thread.c thread.h \
-	tun.c tun.h
+	tun.c tun.h \
+	mac_table.c mac_table.h
 
 LDADD = @LIBOBJS@
 man_MANS = openvpn.8
@@ -484,6 +485,7 @@
 @AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
 @AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
 @AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
+@AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
 
 .c.o:
 @am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
multi.c +110 -20

263 lines not on this page · raw message

multi.h +4 -1
diff -ruN openvpn-2.0.2.orig/multi.h openvpn-2.0.2/multi.h
@@ -37,6 +37,7 @@
 #include "mudp.h"
 #include "mtcp.h"
 #include "perf.h"
+#include "mac_table.h"
 
 /*
  * Walk (don't run) through the routing table,
@@ -97,6 +98,7 @@
 
   struct hash *hash;   /* client instances indexed by real address */
   struct hash *vhash;  /* client instances indexed by virtual address */
+  struct mactab *mtab; /* client instances indexed by virtual MAC address */
   struct hash *iter;   /* like real address hash but optimized for iteration */
   struct schedule *schedule;
   struct mbuf_set *mbuf;
@@ -134,6 +136,7 @@
 
   unsigned int cache_generation;
   time_t last_reference;
+  time_t last_update;
 };
 
 /*
@@ -291,7 +294,7 @@
 	   && r->cache_generation != m->route_helper->cache_generation)
     return false;
   else if ((r->flags & MULTI_ROUTE_AGEABLE)
-	   && r->last_reference + m->route_helper->ageable_ttl_secs < now)
+	   && r->last_update + m->route_helper->ageable_ttl_secs < now)
     return false;
   else
     return true;
#16 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Quoted 31 lines · Rolf Fokkens
Quoted 4 lines · Rolf Fokkens

The problem is caused by the fact that the MAC table only keeps track of MAC's behind clients, no MAC's behind the TAP interface are registered. This can easily be fixed by registering them as well. I'll get back on that as well.

Well, another patch. It contains a new MAC table implementation:

* The MAC table has 1024 entries
I tested it with 2 entries, it still worked fine.

* It's a kind of FIFO table:
MAC addresses are only learnt based on the src MAC of incoming packets, Lookups have nothing to do with learning (as it does in the existing code)
o Newly learnt MAC entries are inserted at the head
o Old MAC entries are removed from the tail when the table is full
o Known MAC entries are moved to the head when being refreshed
o Lookups don't change the order of entries in the FIFO

* Each entry has a Time To Live of 60 sec.
After 60 sec. an entry is no longer returned when lookup up. It remains in the FIFO however, and may be refreshed.

The MAC table code is in the mac_table.c and mac_table.h files.

At several places multi.c is changed to use the new MAC table for TAP devices, TUN devices still use the existing code though I haven't tested that.

Quoted 7 lines

I tested with 1 server and 2 clients, and TCP dump shows proper behaviour. For debugging I also modified the Admin interface to reflect the MAC table contents (including TTL) when using the "status" command, alle works like predicted.

Marcelo, you have a uniqe testbed with ~400 clients, could you test this patch as well?

A couple points:

Why don't you use the existing multi_context::vhash hash to keep track of the server-side MAC table? I know that this hash is usually used to associate MAC or IP addresses with a given client instance, but it seems ideally suited for this. Maybe you could add a flag to struct multi_route to indicate that the MAC is server-side and set multi_route::instance to NULL.

Also, it would be great if you could #ifdef this code so that we can turn it on or off.

James

#17 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Quoted 8 lines · James Yonan

Why don't you use the existing multi_context::vhash hash to keep track of the server-side MAC table? I know that this hash is usually used to associate MAC or IP addresses with a given client instance, but it seems ideally suited for this. Maybe you could add a flag to struct multi_route to indicate that the MAC is server-side and set multi_route::instance to NULL.

I considered that, but after trying that for an hour I realized that I had a hard time getting an accurate overview of the code. For example: there are 24 function definitions in lists.h, what do they all do and how do they affect each other? Two major issues needed to be resolved:

* A FIFO list through all hash elements to easily remove the oldest element.
* The bucket bases locking can no longer exist if there's a FIFO structure through all entries (and buckets).

So I had to consider code at many places, including the locking (for multi threading I assume), which requires a lot of testing to make sure it all works well.

As I need this functionality quite soon (I expect several hundreds of MAC entries behind one of the clients, so there should be no MAC quotum for clients), so I decided to create a prototype based on a separate MAC table. The coding of the mac_table.[ch] files took me about 2 hours, including a stand alone program (without OpenVPN) to test it. As the API is small (5 function prototypes in mac_table.h) it was realy easy to integrate it into multi.c (another 2 hours, including testing).

Bottomline: I needed a (working) prototype without to much effort, to see if this solves the problems I'm experiencing.

Though I'm sure it's possible to integrate the mac_table features in lists.c, It would take me a long time to do so, because lists.c has a generic structure that is uses in several ways and testing may be hard. The mac_table.c file is just over 300 lines and has a simple API (5 functions in mac_table.h) which made both debugging and testing easy. Because MAC tables operate different from route caches you may consider different implementations, but of course that's up to you.

Quoted 3 lines

Also, it would be great if you could #ifdef this code so that we can turn it on or off.

Sure, I'll do that. I'll do it based on mac_table.[ch], to save time. OK? If you want we can integrate mac_table functionality into lists.[ch], but it may require a lot of your help.

Quoted 3 lines

James

#18 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Quoted 6 lines · Rolf Fokkens
Quoted 3 lines · James Yonan

Also, it would be great if you could #ifdef this code so that we can turn it on or off.

Sure, I'll do that. I'll do it based on mac_table.[ch], to save time. OK? If you want we can integrate mac_table functionality into lists.[ch], but it may require a lot of your help.

Attached the patch with #ifdefs. I added a #define MACTAB in config.h.in, though that may not be the proper way to do it.

I tested it with and without the #define MACTAB, both ways it compiles and runs OK with a TAP interface. I didn't test TUN.

Rolf

config.h.in +4 -0
diff -ruN openvpn-2.0.2.orig/config.h.in openvpn-2.0.2/config.h.in
@@ -511,3 +511,7 @@
 /* Define to empty if the keyword `volatile' does not work. Warning: valid
    code using `volatile' can become incorrect without. Disable with care. */
 #undef volatile
+
+/* Define to integrate new MAC table handling for TAP devices.
+   */
+#define MACTAB
mac_table.c +319 -0

319 lines not on this page · raw message

mac_table.h +35 -0
diff -ruN openvpn-2.0.2.orig/mac_table.h openvpn-2.0.2/mac_table.h
@@ -0,0 +1,35 @@
+#ifndef H_MHASH
+#define H_MHASH
+
+#ifdef MACTAB
+
+#include <time.h>
+
+typedef unsigned int uint32_t;
+typedef unsigned char uint8_t;
+
+struct multi_instance;
+struct mactab;
+struct mactab_entry;
+
+extern struct mactab *mactab_init   (int nentries);
+extern void           mactab_uninit (struct mactab *mh);
+
+extern void mactab_learn_mac
+  ( struct mactab *mh, const uint8_t *mac, time_t expire
+  , struct multi_instance *mi);
+
+extern struct multi_instance *mactab_lookup_mac
+  (struct mactab *mh, const uint8_t *mac, time_t now);
+
+extern void mactab_remove_mi (struct mactab *mh, struct multi_instance *mi);
+
+extern int mactab_getnext
+  ( struct mactab *mh, int cur, time_t now
+  , char *mac, int *ttl, struct multi_instance **mi);
+
+extern char *mactab_print (uint8_t *mac);
+
+#endif /* MACTAB */
+
+#endif
Makefile.in +5 -3
diff -ruN openvpn-2.0.2.orig/Makefile.in openvpn-2.0.2/Makefile.in
@@ -102,7 +102,7 @@
 	route.$(OBJEXT) schedule.$(OBJEXT) session_id.$(OBJEXT) \
 	shaper.$(OBJEXT) sig.$(OBJEXT) socket.$(OBJEXT) \
 	socks.$(OBJEXT) ssl.$(OBJEXT) status.$(OBJEXT) \
-	thread.$(OBJEXT) tun.$(OBJEXT)
+	thread.$(OBJEXT) tun.$(OBJEXT) mac_table.$(OBJEXT)
 nodist_openvpn_OBJECTS =
 openvpn_OBJECTS = $(am_openvpn_OBJECTS) $(nodist_openvpn_OBJECTS)
 openvpn_LDADD = $(LDADD)
@@ -135,7 +135,7 @@
 @AMDEP_TRUE@	./$(DEPDIR)/sig.Po ./$(DEPDIR)/socket.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/socks.Po ./$(DEPDIR)/ssl.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/status.Po ./$(DEPDIR)/thread.Po \
[email protected]...@	./$(DEPDIR)/tun.Po
+@AMDEP_TRUE@	./$(DEPDIR)/tun.Po ./$(DEPDIR)/mac_table.Po
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
@@ -308,7 +308,8 @@
 	status.c status.h \
 	syshead.h \
 	thread.c thread.h \
-	tun.c tun.h
+	tun.c tun.h \
+	mac_table.c mac_table.h
 
 LDADD = @LIBOBJS@
 man_MANS = openvpn.8
@@ -484,6 +485,7 @@
 @AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
 @AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
 @AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
+@AMDEP_TRUE@@am__include@ @[email protected].../$(DEPDIR)/[email protected]...@
 
 .c.o:
 @am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
multi.c +141 -14

273 lines not on this page · raw message

multi.h +4 -0
diff -ruN openvpn-2.0.2.orig/multi.h openvpn-2.0.2/multi.h
@@ -37,6 +37,7 @@
 #include "mudp.h"
 #include "mtcp.h"
 #include "perf.h"
+#include "mac_table.h"
 
 /*
  * Walk (don't run) through the routing table,
@@ -97,6 +98,9 @@
 
   struct hash *hash;   /* client instances indexed by real address */
   struct hash *vhash;  /* client instances indexed by virtual address */
+#ifdef MACTAB
+  struct mactab *mtab; /* client instances indexed by virtual MAC address */
+#endif /* MACTAB */
   struct hash *iter;   /* like real address hash but optimized for iteration */
   struct schedule *schedule;
   struct mbuf_set *mbuf;
#19 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Em Dom, 2005-10-09 às 13:22 +0200, Rolf Fokkens escreveu:

Quoted 5 lines

Attached the patch with #ifdefs. I added a #define MACTAB in config.h.in, though that may not be the proper way to do it.

I tested it with and without the #define MACTAB, both ways it compiles and runs OK with a TAP interface. I didn't test TUN.

Hi Rolf,

I've tested your old patch and here is the result.

Compiling we had a few warnings:

In file included from multi.h:40,
from mtcp.c:35:
mac_table.h:6: warning: redefinition of uint32_t' /usr/include/stdint.h:52: warning: uint32_t' previously
declared here
mac_table.h:7: warning: redefinition of uint8_t' /usr/include/stdint.h:49: warning: uint8_t' previously
declared here

mac_table.c: In function `mactab_init':
mac_table.c:72: warning: assignment makes pointer from integer without a cast
mac_table.c: In function `mactab_remove_mi':
mac_table.c:275: warning: assignment makes integer from pointer without a cast
gcc -g -O2 -o openvpn base64.o buffer.o crypto.o error.o event.o
fdmisc.o forward.o fragment.o gremlin.o helper.o init.o interval.o list.o lzo.o manage.o mbuf.o misc.o mroute.o mss.o mtcp.o mtu.o mudp.o multi.o ntlm.o occ.o openvpn.o options.o otime.o packet_id.o perf.o ping.o plugin.o pool.o proto.o proxy.o push.o reliable.o route.o schedule.o session_id.o shaper.o sig.o socket.o socks.o ssl.o status.o
thread.o tun.o mac_table.o -lssl -lcrypto -llzo -ldl

And this error appeared in the server when trying to stabilish a connection.

Sat Oct 8 14:28:25 2005 Data Channel MTU parms [ L:1576 D:1450 EF:44 EB:135 ET:32 EL:0 AF:3/1 ]
Sat Oct 8 14:28:25 2005 Listening for incoming TCP connection on [undef]:1194

Sat Oct  8 14:28:25 2005 TCPv4_SERVER link local (bound): [undef]:1194
Sat Oct  8 14:28:25 2005 TCPv4_SERVER link remote: [undef]
Sat Oct  8 14:28:25 2005 Initialization Sequence Completed
Sat Oct  8 14:30:16 2005 Assertion failed at multi.c:1815
Sat Oct  8 14:30:16 2005 Exiting
Signature · 1 line
Marcelo Toledo <[email protected]...>
#20 lore raw

Re: [Openvpn-devel] Patch: TAP usage made non ARP dependent

Quoted 11 lines · Marcelo Toledo

Sat Oct 8 14:28:25 2005 Data Channel MTU parms [ L:1576 D:1450 EF:44 EB:135 ET:32 EL:0 AF:3/1 ]
Sat Oct 8 14:28:25 2005 Listening for incoming TCP connection on [undef]:1194

Sat Oct  8 14:28:25 2005 TCPv4_SERVER link local (bound): [undef]:1194
Sat Oct  8 14:28:25 2005 TCPv4_SERVER link remote: [undef]
Sat Oct  8 14:28:25 2005 Initialization Sequence Completed
Sat Oct  8 14:30:16 2005 Assertion failed at multi.c:1815
Sat Oct  8 14:30:16 2005 Exiting

I tried to reproduce, but no problems at all:

Mon Oct 10 20:31:05 2005 Listening for incoming TCP connection on [undef]:5000 Mon Oct 10 20:31:05 2005 TCPv4_SERVER link local (bound): [undef]:5000
Mon Oct 10 20:31:05 2005 TCPv4_SERVER link remote: [undef]
Mon Oct 10 20:31:05 2005 Initialization Sequence Completed
Mon Oct 10 20:32:18 2005 Re-using SSL/TLS context
Mon Oct 10 20:32:18 2005 Control Channel MTU parms [ L:1591 D:140 EF:40 EB:0 ET:0 EL:0 ] Mon Oct 10 20:32:18 2005 Data Channel MTU parms [ L:1591 D:1450 EF:59 EB:4 ET:32 EL:0 ]

I need more info,:

* What server params do you use?
Apparently you use TCP , and the default 1194 port. I need more I'm afraid.
* What OS are you using?
I'm running Fedora Core 3 and Fedora Core 4.

#21 lore raw

[Openvpn-devel] Re: Patch: TAP & True MAC aging

In reply to Rolf Fokkens

Hi,

Attached the latest version of the MAC table patch. This patch allowes OpenVPN to learn (and importantly forget!) MAC addresses like ethernet switches. Also (like ethernet switches), OpenVPN now broadcasts packets with unknown MAC addresses (without the patch these packets are dropped).

The command line has two new options:

--mac-ttl n : Time To Live for MAC entries (default: 300)
--mac-table-size n : The number of MAC entries that can be stored (default: 1024)

The Admin interface command now shows the TTL (Time To Live) of each learnt packet, this is for debugging purposes. It may however conflict with adminfrontends!

This patch is work in progess, so testing is needed. I've tested it with UDP and TCP using certificates. I'm using it now in our production situation. Special testing however is needed for shared keys, as I received a report which suggests this may not work.

For those who are interrested, the patch can be downloaded here: http://adsl-dc-4dd05.adsl.wanadoo.nl/dinges/openvpn-2.0.2-fks-mac7.patch

Rolf

#22 lore raw

Re: [Openvpn-devel] Re: Patch: TAP & True MAC aging

Em Ter, 2005-10-11 às 21:29 +0200, Rolf Fokkens escreveu:

Quoted 6 lines

Hi,

Attached the latest version of the MAC table patch. This patch allowes OpenVPN to learn (and importantly forget!) MAC addresses like ethernet switches. Also (like ethernet switches), OpenVPN now broadcasts packets with unknown MAC addresses (without the patch these packets are dropped).

Hello,

sorry the long delay, but we now have tested this new patch. No error appeared but the same situation still persist. Rolf if you would like to schedule we could talk in private to solve this problem, I can even call you if you would like to perform tests, maybe I can try to let you work directly in our environment. Just let me know.

Signature · 1 line
Marcelo Toledo <[email protected]...>