All of lore.kernel.org
 help / color / mirror / Atom feed
* [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets
@ 2014-03-04 10:37 Vladimir V. Kamarzin
  2014-03-04 10:44 ` Vladimir Kamarzin
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Vladimir V. Kamarzin @ 2014-03-04 10:37 UTC (permalink / raw)
  To: openvpn-devel

From: "Vladimir V. Kamarzin" <vvk@...1868...>

When working in TAP mode, openvpn at server side maintains mapping table
"MAC" -> "client". It needs to know what MAC belongs to what client to
be able to forward traffic.

Before this change extraction of MAC addresses was performed only from
ethernet headers of packets, coming from the client. This patch
introduces extraction from ARP packets.

Why extraction only from ethernet header may be not enought? Obviously
in such cases, when MAC in ethernet header differs from ARP message
"Sender Hardware Address" field. For example, one device (A) performs
handling of ARP traffic for other device (B) on the client side (C)
connected to server (S) via TAP (server bridge mode). Unless (B) send
some traffic to server-side network, it will be inaccessible because ARP
handling performed by (A) and not (B) itself.

Signed-off-by: Vladimir V. Kamarzin <vvk@...1868...>
---
 src/openvpn/mroute.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/openvpn/mroute.c b/src/openvpn/mroute.c
index 850e336..608b432 100644
--- a/src/openvpn/mroute.c
+++ b/src/openvpn/mroute.c
@@ -226,7 +226,26 @@ mroute_extract_addr_ether (struct mroute_addr *src,
 	  src->type = MR_ADDR_ETHER;
 	  src->netbits = 0;
 	  src->len = 6;
-	  memcpy (src->addr, eth->source, 6);
+	  struct buffer b = *buf;
+	  if (buf_advance (&b, sizeof (struct openvpn_ethhdr)))
+	    {
+	      if (ntohs (eth->proto) == OPENVPN_ETH_P_ARP
+		  && BLEN (&b) >= (int) sizeof (struct openvpn_arp))
+		{
+		  const struct openvpn_arp *arp = (const struct openvpn_arp *) BPTR (&b);
+		  if (arp->mac_addr_type == htons(0x0001)
+		      && arp->proto_addr_type == htons(0x0800)
+		      && arp->mac_addr_size == 0x06
+		      && arp->proto_addr_size == 0x04)
+		    {
+		      memcpy (src->addr, arp->mac_src, 6);
+		    }
+		}
+	      else
+		{
+		  memcpy (src->addr, eth->source, 6);
+		}
+	    }
 	}
       if (dest)
 	{
-- 
1.8.3.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets
  2014-03-04 10:37 [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets Vladimir V. Kamarzin
@ 2014-03-04 10:44 ` Vladimir Kamarzin
  2014-03-04 19:56 ` Gert Doering
  2014-03-04 20:49 ` Arne Schwabe
  2 siblings, 0 replies; 9+ messages in thread
From: Vladimir Kamarzin @ 2014-03-04 10:44 UTC (permalink / raw)
  To: openvpn-devel@lists.sourceforge.net

Tested on versions 2.2 and 2.3, patch applies to git master branch. I'm not sure this functionality should be wrapped with #ifdef.

Waiting for comments and your opinion regarding this change.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets
  2014-03-04 10:37 [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets Vladimir V. Kamarzin
  2014-03-04 10:44 ` Vladimir Kamarzin
@ 2014-03-04 19:56 ` Gert Doering
  2014-03-04 20:49 ` Arne Schwabe
  2 siblings, 0 replies; 9+ messages in thread
From: Gert Doering @ 2014-03-04 19:56 UTC (permalink / raw)
  To: "Vladimir V. Kamarzin" <vvk@; +Cc: openvpn-devel

[-- Attachment #1: Type: text/plain, Size: 1154 bytes --]

Hi,

On Tue, Mar 04, 2014 at 04:37:29PM +0600, Vladimir V. Kamarzin wrote:
> From: "Vladimir V. Kamarzin" <vvk@...1868...>
> 
> When working in TAP mode, openvpn at server side maintains mapping table
> "MAC" -> "client". It needs to know what MAC belongs to what client to
> be able to forward traffic.
> 
> Before this change extraction of MAC addresses was performed only from
> ethernet headers of packets, coming from the client. This patch
> introduces extraction from ARP packets.

Feature-NAK from me.  If you want to play ARP tricks on the client side,
do it right - keep the ethernet source, or change ethernet source and ARP
source, not change the ethernet source but forward ARP packet unchanged.

There is too much special case code already that nobody is able to 
maintain and properly test(!) for future builds, wo do not want to add more.

gert

-- 
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             gert@...1296...
fax: +49-89-35655025                        gert@...1297...

[-- Attachment #2: Type: application/pgp-signature, Size: 305 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets
  2014-03-04 10:37 [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets Vladimir V. Kamarzin
  2014-03-04 10:44 ` Vladimir Kamarzin
  2014-03-04 19:56 ` Gert Doering
@ 2014-03-04 20:49 ` Arne Schwabe
  2014-03-05  5:53   ` Gert Doering
  2014-03-05 10:37   ` Vladimir Kamarzin
  2 siblings, 2 replies; 9+ messages in thread
From: Arne Schwabe @ 2014-03-04 20:49 UTC (permalink / raw)
  To: "Vladimir V. Kamarzin" <vvk@

[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]

Am 04.03.14 11:37, schrieb Vladimir V. Kamarzin:
> From: "Vladimir V. Kamarzin" <vvk@...1868...>
>
> When working in TAP mode, openvpn at server side maintains mapping table
> "MAC" -> "client". It needs to know what MAC belongs to what client to
> be able to forward traffic.
>
> Before this change extraction of MAC addresses was performed only from
> ethernet headers of packets, coming from the client. This patch
> introduces extraction from ARP packets.
>
> Why extraction only from ethernet header may be not enought? Obviously
> in such cases, when MAC in ethernet header differs from ARP message
> "Sender Hardware Address" field. For example, one device (A) performs
> handling of ARP traffic for other device (B) on the client side (C)
> connected to server (S) via TAP (server bridge mode). Unless (B) send
> some traffic to server-side network, it will be inaccessible because ARP
> handling performed by (A) and not (B) itself.
>
>
OpenVPN basically just emulates a learning switch. Learning switches
also don't need these special logic. If your setup does not work with
OpenVPN then either

a) it won't work with a learning switch either or
b) OpenVPN learning switch implementation has a bug

I would like to have either a) confirmed or b) fixed than to included a
band aid.

Arne


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets
  2014-03-04 20:49 ` Arne Schwabe
@ 2014-03-05  5:53   ` Gert Doering
  2014-03-05 10:37   ` Vladimir Kamarzin
  1 sibling, 0 replies; 9+ messages in thread
From: Gert Doering @ 2014-03-05  5:53 UTC (permalink / raw)
  To: Arne Schwabe <arne@; +Cc: openvpn-devel

[-- Attachment #1: Type: text/plain, Size: 688 bytes --]

Hi,

On Tue, Mar 04, 2014 at 09:49:49PM +0100, Arne Schwabe wrote:
> a) it won't work with a learning switch either or
> b) OpenVPN learning switch implementation has a bug
> 
> I would like to have either a) confirmed or b) fixed than to included a
> band aid.

It looks like some sort of proxy-ARP where the ARP is *forwarded* instead
of being *bridged* (= new ethernet frame, unchanged payload).

gert
-- 
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             gert@...1296...
fax: +49-89-35655025                        gert@...1297...

[-- Attachment #2: Type: application/pgp-signature, Size: 305 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets
  2014-03-04 20:49 ` Arne Schwabe
  2014-03-05  5:53   ` Gert Doering
@ 2014-03-05 10:37   ` Vladimir Kamarzin
  2014-03-05 12:21     ` Gert Doering
  1 sibling, 1 reply; 9+ messages in thread
From: Vladimir Kamarzin @ 2014-03-05 10:37 UTC (permalink / raw)
  To: Arne Schwabe <arne@

05.03.2014, 02:49, "Arne Schwabe" <arne@...1227...>:

> OpenVPN basically just emulates a learning switch. Learning switches
> also don't need these special logic. If your setup does not work with
> OpenVPN then either
>
> a) it won't work with a learning switch either or
> b) OpenVPN learning switch implementation has a bug
>
> I would like to have either a) confirmed or b) fixed than to included a
> band aid.

My setup does work with learning switches (tested before openvpn). So it looks like openvpn behavior not 100% the same.

Example setup contains following:
- S: switch
- A: generic network host, 192.168.0.1/24
- B: special device which provides access to C, 192.168.0.2/24 and MAC 00:00:00:11:11:11
- C: special device that we want access, 192.168.0.3/24, MAC 00:00:00:22:22:22

Plug scheme: (A) and (B) are plugged to (S). (C) is plugged to (B). ARP handling for (B) is performed by (C).

Here is step-by-step scheme how it works:
1. (A) wants to "ping" (C). So it sends ARP request "who has 192.168.0.3 tell 192.168.0.1" with broadcast destination in ethernet frame. Switch forwards this packet to all ports.
2. (B) receives ARP request and generates reply: "192.168.0.3 is at 00:00:00:22:22:22". Although MAC in ethernet header is 00:00:00:11:11:11!
3. Switch (S) see this reply and learns 00:00:00:11:11:11 to it MAC address table. (A) see this reply and add entry to ARP cache: 192.168.0.3 -> 00:00:00:22:22:22
4. (A) sends unicast packet (ICMP echo request) to 192.168.0.3, with ethernet destination address 00:00:00:22:22:22
5. Switch (S) does not know where is 00:00:00:22:22:22, so it sends this packet to all ports
6. (C) receives ICMP echo request and generates ICMP echo reply. Ethernet header now contains 00:00:00:22:22:22.
7. Switch see frame with src 00:00:00:22:22:22 and learns it. All happy, traffic passes.

In openvpn case, it looks like there is no step 5, so probably it is a bug. So I better should fix this instead of doing tricks with ARP.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets
  2014-03-05 10:37   ` Vladimir Kamarzin
@ 2014-03-05 12:21     ` Gert Doering
  2014-03-05 12:44       ` Vladimir Kamarzin
  0 siblings, 1 reply; 9+ messages in thread
From: Gert Doering @ 2014-03-05 12:21 UTC (permalink / raw)
  To: Vladimir Kamarzin <vvk@; +Cc: openvpn-devel@lists.sourceforge.net

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

Hi,

On Wed, Mar 05, 2014 at 04:37:09PM +0600, Vladimir Kamarzin wrote:
> 5. Switch (S) does not know where is 00:00:00:22:22:22, so it sends this packet to all ports

Yeah, I think that's the difference.  We don't do unicast flooding ("send
frames to unknown unicast destinations to every single port") because
bandwidth on the VPN is limited & more expensive.

Adding it would solve the issue at hand, but I'm not convinced that you'll
be happy with the end - it might actually end up saturating VPN links and
making users unhappy if you have "much flooded traffic" (which happens in
some of the networks).

gert
-- 
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             gert@...1296...
fax: +49-89-35655025                        gert@...1297...

[-- Attachment #2: Type: application/pgp-signature, Size: 305 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets
  2014-03-05 12:21     ` Gert Doering
@ 2014-03-05 12:44       ` Vladimir Kamarzin
  2014-03-05 14:55         ` Gert Doering
  0 siblings, 1 reply; 9+ messages in thread
From: Vladimir Kamarzin @ 2014-03-05 12:44 UTC (permalink / raw)
  To: Gert Doering <gert@; +Cc: openvpn-devel@lists.sourceforge.net

> Adding it would solve the issue at hand, but I'm not convinced that you'll
> be happy with the end - it might actually end up saturating VPN links and
> making users unhappy if you have "much flooded traffic" (which happens in
> some of the networks).

I've patched openvpn this way and testing this setup right now, it working well for now. I think it may be implemented as an option (config or ifdef). What do you think?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets
  2014-03-05 12:44       ` Vladimir Kamarzin
@ 2014-03-05 14:55         ` Gert Doering
  0 siblings, 0 replies; 9+ messages in thread
From: Gert Doering @ 2014-03-05 14:55 UTC (permalink / raw)
  To: Vladimir Kamarzin <vvk@; +Cc: openvpn-devel@lists.sourceforge.net

[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]

Hi,

On Wed, Mar 05, 2014 at 06:44:31PM +0600, Vladimir Kamarzin wrote:
> > Adding it would solve the issue at hand, but I'm not convinced that you'll
> > be happy with the end - it might actually end up saturating VPN links and
> > making users unhappy if you have "much flooded traffic" (which happens in
> > some of the networks).
> 
> I've patched openvpn this way and testing this setup right now, it 
> working well for now. I think it may be implemented as an option 
> (config or ifdef). What do you think?

I'm torn.  

We do not want more options, we really have enough - but that *should* be 
configurable, and not the default, so if we integrate it, it needs to have 
an option ("tap-flood-unknown-unicast" or something like that).

So on the feature itself, if it has an option, I'd stay neutral in regards
to ACK/NAKing, and focus on the code review.

gert

-- 
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             gert@...1296...
fax: +49-89-35655025                        gert@...1297...

[-- Attachment #2: Type: application/pgp-signature, Size: 305 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-03-05 14:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-04 10:37 [Openvpn-devel] [PATCH] Extract MAC addresses from ARP packets Vladimir V. Kamarzin
2014-03-04 10:44 ` Vladimir Kamarzin
2014-03-04 19:56 ` Gert Doering
2014-03-04 20:49 ` Arne Schwabe
2014-03-05  5:53   ` Gert Doering
2014-03-05 10:37   ` Vladimir Kamarzin
2014-03-05 12:21     ` Gert Doering
2014-03-05 12:44       ` Vladimir Kamarzin
2014-03-05 14:55         ` Gert Doering

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.