VLAN tagging on TAP devices in OpenVPN server mode
cover VLAN tagging on TAP devices in OpenVPN server mode
Hi,
we're currently attempting to use OpenVPN in an environment where potentially several hundred users connect to a cluster of OpenVPN instances and gain access to several different internal networks.
The different networks are internally managed using VLANs (based on IEEE 802.1Q). (The packets are transported in tagged form on the internal backbones and inserted into the actual department networks in untagged form.)
Instead of using one OpenVPN server instance per VLAN (e.g. on a different port or a different load-balanced IP) we would like every instance to provide access to all networks by directly plugging into the "backbone", i.e. by directly handling tagged packets.
The following patch-set is a first draft to implement VLAN tagging on an OpenVPN server running in server mode and using a TAP device.
Each client gets assigned a VLAN identifier (VID) (e.g. through a client-connect script or through ccd files), indicating the network the client may communicate with.
Packets coming in from the TAP device are assumed to be tagged with IEEE 802.1Q headers. OpenVPN removes the tag, remembers the VID and routes the packet to the destination client(s) on the other side of the secure tunnel which have a matching VID.
Packets that OpenVPN pushes onto the device are tagged according to which VID the sending client belonged to.
For high-level illustration, consider the following example network:
|---+---------------------| Untagged internal network A
|
| |---+------| Untagged internal network B
| |
| |
T(*) T(**)
|====+=====+========+======| Backbone with tagged networks A and B
|
| (*) Switch tags/untags with VID 11
| (**) Switch tags/untags with VID 22
tap (***) (***) receives tagged packets from A and B
[ OpenVPN server ]
| | |
| | +---------[ OpenVPN client 1 (server-side: --vlan-tag 11) ]
| | tap
| | |
| | |-----+---------| Untagged network A
| |
| +-----------[ OpenVPN client 2 (server-side: --vlan-tag 11) ]
| tap
| |
| |-----+---------| Untagged network A
|
+-------------[ OpenVPN client 3 (server-side: --vlan-tag 22) ]
tap
|
|-----+---------| Untagged network BThe internal network A is only available to clients 1 and 2, network B is only available to client 3. A and B are seperate broadcast domains and broadcasts on network A only propagate to client 1's and client 2's networks.
The server's tap interface sits on the backbone and inputs/outputs only tagged packets.
The clients receive and send untagged packets and require no explicit VLAN support.
The patch-set is now based on Davide Guerri's --passtos patch, as it directly falls with-in the functionality of my original version and looked like a candidate for integration.
The patches are also available directly via git, see our gitweb at
The last two patches (add debug logging ...) aren't really intended for inclusion. I haven't looked into proper log levels, so currently the debug messages flood at notice priority. I'm not sure whether the messages should be included at all.
Another question would be whether I should turn the feature into a compile-time selectable option.
The patch-set has only received light testing up to now, as it was originally only intended as a proof of concept. At this point I'm very interested in all kinds of feed-back and would like to determine whether you might be interested in integrating something like this in an official OpenVPN release at some point.
Cheers
Fabian
Fabian Knittel (9):
is_ipv4(): add packet length check for 802.1Q packets
vlan: Add global --vlan-tagging option
vlan: Add per-client --vlan-tag option
vlan: Prepend and remove VLAN identifiers on outgoing and incoming
frames
vlan: Add VLAN identifier to mroute_addr for ethernet addresses
vlan: Restrict broadcasts to the sender's VLAN.
vlan: Slightly enhance PF's protocol inspection of 802.1Q packets
vlan: add debug logging to tagging / untagging
vlan: add debug logging to broadcast filter
mroute.c | 20 ++++++++-- mroute.h | 8 +++-- multi.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- multi.h | 5 +++ options.c | 34 +++++++++++++++++ options.h | 3 ++ proto.c | 3 ++ proto.h | 36 ++++++++++++++++-- 8 files changed, 210 insertions(+), 20 deletions(-)
PATCH 1/9 is_ipv4(): add packet length check for 802.1Q packets
This patch adds an additional length check to is_ipv4().
Currently is_ipv4() only checks whether the frame is large enough for struct openvpn_ethhdr. In case of an 802.1Q packet the function now also checks whether the frame is large enough for struct openvpn_8021qhdr, which is 4 bytes larger than struct openvpn_ethhdr.
--- proto.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
proto.c +3 -0
@@ -54,6 +54,9 @@ is_ipv4 (int tunnel_type, struct buffer *buf)return false; eh = (const struct openvpn_ethhdr *)BPTR (buf);if (ntohs (eh->proto) ==OPENVPN_ETH_P_8021Q ) { +if (BLEN (buf) < (int )(sizeof (struct openvpn_8021qhdr ) + +sizeof (struct openvpn_iphdr ))) +return false;const struct openvpn_8021qhdr *evh; evh = (const struct openvpn_8021qhdr *)BPTR (buf);if (ntohs (evh->proto) !=OPENVPN_ETH_P_IPV4 )
Signature · 1 line
1.7.0
PATCH 2/9 vlan: Add global --vlan-tagging option
In reply to Fabian KnittelThis patch adds the new "--vlan-tagging" boolean option. The option is valid in server mode. It is off by default.
The flag indicates whether openvpn should assume the tap device
to be in tagged mode, i.e. packets coming in on the device are tagged via IEEE 802.1Q and packets going out through the device should be tagged likewise.
The option has no immediate effect yet, but will be used by later patches.
--- options.c | 13 +++++++++++++ options.h | 2 ++ 2 files changed, 15 insertions(+), 0 deletions(-)
options.c +13 -0
@@ -651,6 +651,8 @@ static const char usage_message[] ="--show-pkcs11-ids provider [cert_private] : Show PKCS#11 available ids.\n" " --verb option can be added *BEFORE* this.\n"#endif /* ENABLE_PKCS11 */ +"\n" +"--vlan-tagging : Enable VLAN tagging/untagging to/from TAP device.\n" ;#endif /* !ENABLE_SMALL */
@@ -1175,6 +1177,8 @@ show_settings (const struct options *o)SHOW_BOOL (ifconfig_noexec);SHOW_BOOL (ifconfig_nowarn); +SHOW_BOOL (vlan_tagging); +#ifdef HAVE_GETTIMEOFDAY SHOW_INT (shaper);#endif
@@ -1742,6 +1746,8 @@ options_postprocess_verify_ce (const struct options *options, const struct conneif ((options->ssl_flags &SSLF_NO_NAME_REMAPPING ) && script_method ==SM_SYSTEM )msg (M_USAGE ,"--script-security method='system' cannot be combined with --no-name-remapping" ); +if (options->vlan_tagging && dev !=DEV_TYPE_TAP ) +msg (M_USAGE ,"--vlan-tagging only works with --dev tap" ); }else {
@@ -1788,6 +1794,8 @@ options_postprocess_verify_ce (const struct options *options, const struct conneif (options->port_share_host || options->port_share_port)msg (M_USAGE ,"--port-share requires TCP server mode (--mode server --proto tcp-server)" );#endif +if (options->vlan_tagging) + msg (M_USAGE, "--vlan-tagging requires --mode server"); }#endif /* P2MP_SERVER */
@@ -5730,6 +5738,11 @@ add_option (struct options *options, options->persist_mode =1 ; }#endif + else if (streq (p[0], "vlan-tagging")) + { +VERIFY_PERMISSION (OPT_P_GENERAL ); + options->vlan_tagging = true; + } else {if (file)
options.h +2 -0
@@ -509,6 +509,8 @@ struct optionsbool show_net_up;int route_method;#endif + +bool vlan_tagging; };#define streq (x, y) (!strcmp((x), (y)))
Signature · 1 line
1.7.0
PATCH 3/9 vlan: Add per-client --vlan-tag option
In reply to Fabian KnittelThis patch adds the new "--vlan-tag" integer option. The option is valid in server mode and can be set in a client context (e.g. from the client-connect hook). It defaults to 0.
The value indicates which VID (VLAN identifier) to associate with a client. The client will only receive packets which belong to the same VLAN. Packets going out via the tap devie will be marked as belonging to the indicated VID.
The option has no immediate effect yet, but will be used by later patches.
--- options.c | 25 +++++++++++++++++++++++-- options.h | 1 + proto.h | 4 ++++ 3 files changed, 28 insertions(+), 2 deletions(-)
options.c +23 -2
@@ -1178,6 +1178,7 @@ show_settings (const struct options *o)SHOW_BOOL (ifconfig_nowarn);SHOW_BOOL (vlan_tagging); +SHOW_INT (vlan_tag);#ifdef HAVE_GETTIMEOFDAY SHOW_INT (shaper);
@@ -1748,6 +1749,8 @@ options_postprocess_verify_ce (const struct options *options, const struct connemsg (M_USAGE ,"--script-security method='system' cannot be combined with --no-name-remapping" );if (options->vlan_tagging && dev !=DEV_TYPE_TAP )msg (M_USAGE ,"--vlan-tagging only works with --dev tap" ); +if (!options->vlan_tagging && options->vlan_tag) +msg (M_USAGE ,"--vlan-tag must be used with activated --vlan-tagging" ); }else {
@@ -1794,8 +1797,8 @@ options_postprocess_verify_ce (const struct options *options, const struct conneif (options->port_share_host || options->port_share_port)msg (M_USAGE ,"--port-share requires TCP server mode (--mode server --proto tcp-server)" );#endif -if (options->vlan_tagging) - msg (M_USAGE, "--vlan-tagging requires --mode server"); +if (options->vlan_tagging || options->vlan_tag) + msg (M_USAGE, "--vlan-tagging/--vlan-tag requires --mode server"); }#endif /* P2MP_SERVER */
@@ -5743,6 +5746,24 @@ add_option (struct options *options,VERIFY_PERMISSION (OPT_P_GENERAL ); options->vlan_tagging = true; } +else if (streq (p[0 ],"vlan-tag" )) + { +VERIFY_PERMISSION (OPT_P_INSTANCE ); +if (p[1 ]) + { + options->vlan_tag =positive_atoi (p[1 ]); +if (options->vlan_tag <OPENVPN_8021Q_MIN_VID || options->vlan_tag >OPENVPN_8021Q_MAX_VID ) + { +msg (msglevel,"the parameter of --vlan-tag parameters must be >= %d and <= %d" ,OPENVPN_8021Q_MIN_VID ,OPENVPN_8021Q_MAX_VID ); + goto err; + } + } +else + { +msg (msglevel,"error parsing --vlan-tag parameters" ); + goto err; + } + }else {if (file)
options.h +1 -0
@@ -511,6 +511,7 @@ struct options#endif bool vlan_tagging; +int vlan_tag; };#define streq (x, y) (!strcmp((x), (y)))
proto.h +4 -0
@@ -211,4 +211,8 @@ void ipv4_packet_size_verify (const uint8_t *data, counter_type *errors);#endif + +#define OPENVPN_8021Q_MIN_VID 1 +#define OPENVPN_8021Q_MAX_VID 0xFFFE +#endif
Signature · 1 line
1.7.0
Re: [Openvpn-devel] [PATCH 3/9] vlan: Add per-client --vlan-tag option
Quoted 1 line · Fabian Knittel
options.c +1
-0+if (options->vlan_tag <OPENVPN_8021Q_MIN_VID || options->vlan_tag >OPENVPN_8021Q_MAX_VID )
..
Quoted 1 line
+#define
OPENVPN_8021Q_MIN_VID1
This looks like --vlan-tag 0 will not work.
Quoted 1 line
+#define
OPENVPN_8021Q_MAX_VID0xFFFE
The max VID in 802.1q is 4095 = 0xfff.
//Peter
Re: [Openvpn-devel] [PATCH 3/9] vlan: Add per-client --vlan-tag option
Hi Peter,
Quoted 4 lines · Peter Stuge
Quoted 1 line · Fabian Knittel
+#define
OPENVPN_8021Q_MAX_VID0xFFFEThe max VID in 802.1q is 4095 =
0xfff.
You are absolutely correct. Thanks for catching that. I intended it to say 0xFFE, because the standard talks about VID values being valid within the range 0 through 4094 [1]. But OPENVPN_8021Q_MASK_VID should definitely be defined as 0xFFF, as the bit field is 12 bits.
VID == 0xFFF is "Reserved for implementation use." and "shall not be configured as PVID [...] or transmitted in a tag header." [2] But I'm not sure whether it's used in reality and if you'd like that value to be accepted, I have no objections.
Thanks again for reviewing!
Cheers
Fabian
1: IEEE Std 8021.Q-2005, "9.6 VLAN Tag Control Information", p.76 2: IEEE Std 8021.Q-2005, Table 9-2, p.76
Re: [Openvpn-devel] [PATCH 3/9] vlan: Add per-client --vlan-tag option
Hi Fabian,
Quoted 7 lines · Fabian Knittel
Quoted 3 lines
Quoted 1 line
+#define
OPENVPN_8021Q_MAX_VID0xFFFEThe max VID in 802.1q is 4095 =
0xfff.You are absolutely correct. Thanks for catching that. I intended it to say
0xFFE, because the standard talks about VID values being valid within the range 0 through 4094 [1].
Aha!
Quoted 2 lines
But
OPENVPN_8021Q_MASK_VIDshould definitely be defined as0xFFF, as the bit field is 12 bits.
Right.
Quoted 4 lines
VID ==
0xFFFis "Reserved for implementation use." and "shall not be configured as PVID [...] or transmitted in a tag header." [2] But I'm not sure whether it's used in reality and if you'd like that value to be accepted, I have no objections.
I think it's good to play along with the standards, so I like MAX 0xffe too.
Quoted 1 line
Thanks again for reviewing!
You're welcome!
//Peter
PATCH 4/9 vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
In reply to Fabian KnittelThis patch adds parsing of the IEEE 802.1Q headers for incoming and outgoing ethernet frames.
For frames coming in from the tap interface, the 802.1Q header is parsed and translated into a regular Ethernet II header. Note that the Priority Code Point (PCP) and Canonical Format Indicator (CFI) fields contained within the 802.1Q header are ignored. Only the VLAN Identifier (VID) is used.
For frames going out over the tap interface, the Ethernet II header is replaced with a 802.1Q-based header. PCP and CFI are permanently set to 0. The VID is set according to the instance's vlan_tag value (also see patch adding the "--vlan-tag" option).
--- multi.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ multi.h | 5 ++++ proto.h | 34 +++++++++++++++++++++++++---- 3 files changed, 107 insertions(+), 5 deletions(-)
multi.c +73 -0
@@ -2117,6 +2117,73 @@ multi_process_incoming_link (struct multi_context *m, struct multi_instance *ins }/* +* Removes the VLAN tagging of a frame and returns the frame's VID. Frames +* without tagging are dropped. +*/ +static int16_t +remove_vlan_identifier (struct buffer *buf) +{ +struct openvpn_ethhdr eth; +struct openvpn_8021qhdr vlanhdr; +int16_t vid; + +if (BLEN (buf) < (sizeof (struct openvpn_8021qhdr ))) + goto err; + + vlanhdr = *(const struct openvpn_8021qhdr *)BPTR (buf); + +if (ntohs (vlanhdr.tpid) !=OPENVPN_ETH_P_8021Q ) + { +/* Drop untagged frames */ + goto err; + } + +/* Ethernet II frame with 802.1Q */ + vid =ntohs (vlan_get_vid (&vlanhdr)); +memcpy (ð, &vlanhdr,sizeof (eth)); + eth.proto = vlanhdr.proto; + +buf_advance (buf,SIZE_ETH_TO_8021Q_HDR ); +memcpy (BPTR (buf), ð,sizeof eth); + +return vid; +err: +/* Drop the frame. */ + buf->len =0 ; +return -1 ; +} + +/* +* Adds VLAN tagging to a frame. Short frames that can't be tagged are +* dropped. +*/ +void +multi_prepend_vlan_identifier (struct multi_instance *mi,struct buffer *buf) +{ +struct openvpn_ethhdr eth; +struct openvpn_8021qhdr vlanhdr; +uint8_t *p; + +/* Frame too small or not enough head room for VLAN tag? */ +if ((BLEN (buf) < (int )sizeof (struct openvpn_ethhdr )) || + (buf_reverse_capacity (buf) <SIZE_ETH_TO_8021Q_HDR )) + { +/* Drop the frame. */ + buf->len =0 ; +return ; + } + + eth = *(const struct openvpn_ethhdr *)BPTR (buf); +memcpy (&vlanhdr, ð,sizeof eth); + vlanhdr.tpid =htons (OPENVPN_ETH_P_8021Q ); + vlanhdr.proto = eth.proto; +vlan_set_vid (&vlanhdr,htons (mi->context.options.vlan_tag)); + +ASSERT (p =buf_prepend (buf,SIZE_ETH_TO_8021Q_HDR )); +memcpy (p, &vlanhdr,sizeof vlanhdr); +} + +/* * Process packets in the TUN/TAP interface -> TCP/UDP socket direction, * i.e. server -> client direction. */
@@ -2158,6 +2225,12 @@ multi_process_incoming_tun (struct multi_context *m, const unsigned int mpp_flag* the appropriate multi_instance object. */ +if (dev_type ==DEV_TYPE_TAP && m->top.options.vlan_tagging) + { +if (remove_vlan_identifier (&m->top.c2.buf) ==-1 ) +return false; + } + mroute_flags =mroute_extract_addr_from_packet (&src, &dest, #ifdef ENABLE_PF
multi.h +5 -0
@@ -405,6 +405,7 @@ multi_get_timeout (struct multi_context *m, struct timeval *dest)static inline bool multi_process_outgoing_tun (struct multi_context *m,const unsigned int mpp_flags) { +void multi_prepend_vlan_identifier (struct multi_instance *mi,struct buffer *buf);struct multi_instance *mi = m->pending;bool ret = true;
@@ -415,6 +416,10 @@ multi_process_outgoing_tun (struct multi_context *m, const unsigned int mpp_flag mi->context.c2.to_tun.len);#endif set_prefix (mi); +if (mi->context.options.vlan_tag) + { +multi_prepend_vlan_identifier (mi, &mi->context.c2.to_tun); + }process_outgoing_tun (&mi->context); ret =multi_process_post (m, mi, mpp_flags);clear_prefix ();
proto.h +29 -5
@@ -61,20 +61,26 @@ struct openvpn_ethhdr# define OPENVPN_ETH_P_IPV4 0x0800/* IPv4 protocol */ # define OPENVPN_ETH_P_IPV6 0x86DD/* IPv6 protocol */ # define OPENVPN_ETH_P_ARP 0x0806/* ARP protocol */ +# define OPENVPN_ETH_P_8021Q 0x8100/* 802.1Q protocol */ uint16_t proto;/* packet type ID field */ }; -# define OPENVPN_ETH_P_8021Q 0x8100/* 802.1Q protocol */ -struct openvpn_8021qhdr {uint8_t dest[OPENVPN_ETH_ALEN ];/* destination ethernet addr */ uint8_t source[OPENVPN_ETH_ALEN ];/* source ethernet addr */ -uint32_t tag;/* packet 802.1Q Vlan Tag */ -uint16_t proto;/* packet type ID field */ +uint16_t tpid;/* 802.1Q Tag Protocol Identifier */ +# define OPENVPN_8021Q_MASK_VID htons (0xFFFE)/* mask VID out of tag */ +uint16_t tag;/* tag field containing PCP, CFI, VID */ +uint16_t proto;/* contained packet type ID field */ }; +/* +* Size difference between a regular Ethernet II header and an Ethernet II +* header with additional IEEE 802.1Q tagging. +*/ +#define SIZE_ETH_TO_8021Q_HDR (sizeof (struct openvpn_8021qhdr) - sizeof (struct openvpn_ethhdr))struct openvpn_arp {# define ARP_MAC_ADDR_TYPE 0x0001
@@ -213,6 +219,24 @@ void ipv4_packet_size_verify (const uint8_t *data,#define OPENVPN_8021Q_MIN_VID 1 -#define OPENVPN_8021Q_MAX_VID 0xFFFE +#define OPENVPN_8021Q_MAX_VID ntohs (OPENVPN_8021Q_MASK_VID) + +/* +* Retrieve the VLAN Identifier (VID) from the IEEE 802.1Q header. +*/ +static inline int +vlan_get_vid (const struct openvpn_8021qhdr *hdr) +{ +return hdr->tag &OPENVPN_8021Q_MASK_VID ; +} + +/* +* Set the VLAN Identifier (VID) in an IEEE 802.1Q header. +*/ +static inline void +vlan_set_vid (struct openvpn_8021qhdr *hdr,const int vid) +{ + hdr->tag = (hdr->tag & ~OPENVPN_8021Q_MASK_VID ) | (vid &OPENVPN_8021Q_MASK_VID ); +}#endif
Signature · 1 line
1.7.0
Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
multi.c multi_process_incoming_link (struct multi_context *m, struct multi_instance *ins · line 2139
Quoted 5 lines · Fabian Knittel
multi.c +5
-0+if (ntohs (vlanhdr.tpid) !=OPENVPN_ETH_P_8021Q ) + { +/* Drop untagged frames */ + goto err; + }
It would be nice to be able to use VID 0 to mean untagged packets.
//Peter
Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
Quoted 8 lines · Peter Stuge
multi.c multi_process_incoming_link (struct multi_context *m, struct multi_instance *ins · line 2139
Quoted 5 lines · Fabian Knittel
multi.c +5
-0+if (ntohs (vlanhdr.tpid) !=OPENVPN_ETH_P_8021Q ) + { +/* Drop untagged frames */ + goto err; + }It would be nice to be able to use VID 0 to mean untagged packets.
Hm, nice idea. I'll implement it in my next round of patches.
Cheers
Fabian
Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
Quoted 4 lines · Fabian Knittel
Quoted 1 line · Peter Stuge
It would be nice to be able to use VID 0 to mean untagged packets.
Hm, nice idea. I'll implement it in my next round of patches.
I've just noticed a detail that might warrant discussion. To make sure we're talking about the same thing, this is how I intended --vlan-tag 0 to be handled:
Packets coming in from the tap device:
If the packet has no 802.1Q header or the 802.1Q header's VID field is 0, the vid is assumed to be 0 and the packet will be forwarded to all clients who's --vlan-tag is set to 0.
Packets outgoing via the tap device:
Packets originating from clients who's --vlan-tag is set to 0 are passed on to the tap device without change, i.e. no 802.1Q header is attached or removed. A potential 802.1Q header already present within the packet is left untouched. This would allow the Priority Code Point (PCP) field to be used.
Now, to the slight difficulty: What happens with outgoing frames from clients who's --vlan-tag is set to 0, where the frame contains a 802.1Q header with VID field != 0? Pushed onto a network which uses vlan tags, this would allow a client to inject packets into a different network. (For --vlan-tag != 0 this is no problem, because we unconditionally wrap the packets in 802.1Q headers with a new VID.)
Possible solutions:
a) Inspect outgoing packets for --vlan-tag == 0 clients. Drop packets that have a VID != 0.
b) Always wrap outgoing packets with 802.1Q headers and set the VID to
0. (This would make the code-patch uniform for all --vlan-tag values.)
I think I slightly prefer solution a), as it allows the PCP field to be used and doesn't add needless overhead to outgoing packets.
Cheers
Fabian
Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
In reply to Fabian KnittelQuoted 10 lines · Fabian Knittel
Quoted 8 lines · Peter Stuge
Quoted 6 lines · Fabian Knittel
multi.c +5
-0+if (ntohs (vlanhdr.tpid) !=OPENVPN_ETH_P_8021Q ) + { +/* Drop untagged frames */ + goto err; + }
Quoted 5 lines
Quoted 2 lines
It would be nice to be able to use VID 0 to mean untagged packets.
Hm, nice idea. I'll implement it in my next round of patches.
FYI: 802.1Q defines VLAN 1 as the 'native' LAN: all packets on VLAN 1 are *by definition* not encapsulated (according to my CCNA guide ;-)) VID 0 means "priority frames"
Perhaps we need to make sure that VID 1 means untagged ...
For more details, see http://www.javvin.com/protocolVLAN.html
cheers,
JJK
Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
Quoted 2 lines · Jan Just Keijser
FYI: 802.1Q defines VLAN 1 as the 'native' LAN: all packets on VLAN 1 are *by definition* not encapsulated (according to my CCNA guide ;-))
802.1Q != CCNA..
Look at the spec, Table 9-2 on page 86. (100 in PDF)
VID Use
0 "no VLAN identifier is present in the frame"
1 "The default PVID value used for classifying frames on ingress ..
The PVID value of a Port can be changed by management."
FFF "Reserved for implementation use."
Quoted 1 line
Perhaps we need to make sure that VID 1 means untagged ...
Any VID can be untagged. While 1 is the default it can change and OpenVPN shouldn't really care.
One alternative approach to using tag 0 would be to introduce a vlan-pvid (or vlan-default-tag) option to set the PVID.
But explicitly allowing tag 0 can also be useful.
//Peter
Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
Quoted 7 lines · Peter Stuge
Quoted 2 lines · Jan Just Keijser
FYI: 802.1Q defines VLAN 1 as the 'native' LAN: all packets on VLAN 1 are *by definition* not encapsulated (according to my CCNA guide ;-))
802.1Q != CCNA..
Quoted 10 lines
Look at the spec, Table 9-2 on page 86. (100 in PDF)
VID Use
0 "no VLAN identifier is present in the frame"
1 "The default PVID value used for classifying frames on ingress ..
The PVID value of a Port can be changed by management."
FFF "Reserved for implementation use."
be careful here (from table 9.2; I actually have an older copy of the 802.1Q spec):
The null VLAN ID. Indicates that the tag header contains only priority information; no VLAN identifier is present in the frame. This VID value shall not be configured as a PVID or a member of a VID Set, or configured in any Filtering Database entry, or used in any Management operation.
so it *does* have priority info in it and it is *not* the same as no VLAN identifier ...
cheers,
JJK
Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
Quoted 19 lines · Jan Just Keijser
Quoted 7 lines · Peter Stuge
Look at the spec, Table 9-2 on page 86. (100 in PDF)
VID Use
0 "no VLAN identifier is present in the frame"
1 "The default PVID value used for classifying frames on ingress ..
The PVID value of a Port can be changed by management."
FFF "Reserved for implementation use."be careful here (from table 9.2; I actually have an older copy of the 802.1Q spec):
The null VLAN ID. Indicates that the tag header contains only priority information; no VLAN identifier is present in the frame. This VID value shall not
be configured as a PVID or a member of a VID Set, or configured in any Filtering
Database entry, or used in any Management operation.
Quoted 2 lines
so it *does* have priority info in it and it is *not* the same as no VLAN identifier ...
I'm not sure whether you're actually disagreeing with each other... :)
"No VLAN identifier" does not mean "there is no 802.1Q header". It just means, that it doesn't represent a VLAN. A frame without a VLAN identifier (i.e. where VID == 0) represents a priority packet.
Cheers
Fabian
Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
In reply to Peter StugeQuoted 3 lines · Peter Stuge
Quoted 2 lines · Jan Just Keijser
FYI: 802.1Q defines VLAN 1 as the 'native' LAN: all packets on VLAN 1 are *by definition* not encapsulated (according to my CCNA guide ;-))
[...]
Quoted 7 lines
Quoted 1 line
Perhaps we need to make sure that VID 1 means untagged ...
Any VID can be untagged. While 1 is the default it can change and OpenVPN shouldn't really care.
One alternative approach to using tag 0 would be to introduce a vlan-pvid (or vlan-default-tag) option to set the PVID.
So packets coming in on the tap device that aren't tagged would be assumed to have a vid == PVID. And packets going out on the tap device with a vid == PVID would go out untagged. (A vid of 0 would continue to be rejected as configuration option.)
Not specifying --vlan-pvid would mean that only tagged packets are accepted (and sent).
I'm still unsure what to do with incoming frames from clients who's vid matches the pvid and where the frames contain a full 802.1Q header with a non-zero vid. I'll probably just drop those packets. Maybe we should drop such packets regardless of the PVID value while in --vlan-tagging
mode. (Tags in tags are apparently specified by 802.1ad and we don't
support that anyway.)
Quoted 1 line
But explicitly allowing tag 0 can also be useful.
What would be the use-case? Packets with tag 0 are priority packets and we currently completely ignore / drop the priority values. We could of course add an option to specify whether the priority part of 802.1Q packets should be preserved.
Instead of removing the 802.1Q packets when untagging, we would instead change the vid to 0 and leave the priority fields untouched. We'd probably want an option separate from the --vlan-tag option to specify that though ...
And would this be a global setting or per-client? Per-client could make the broadcasting code a tad bit more difficult, as the packets would need to be modified for each client. (Stripping or not stripping the 802.1Q headers...)
Cheers
Fabian
Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
Quoted 20 lines · Fabian Knittel
Quoted 3 lines · Peter Stuge
Quoted 2 lines · Jan Just Keijser
FYI: 802.1Q defines VLAN 1 as the 'native' LAN: all packets on VLAN 1 are *by definition* not encapsulated (according to my CCNA guide ;-))
[...]
Quoted 7 lines
Quoted 1 line
Perhaps we need to make sure that VID 1 means untagged ...
Any VID can be untagged. While 1 is the default it can change and OpenVPN shouldn't really care.
One alternative approach to using tag 0 would be to introduce a vlan-pvid (or vlan-default-tag) option to set the PVID.
So packets coming in on the tap device that aren't tagged would be assumed to have a vid == PVID. And packets going out on the tap device with a vid == PVID would go out untagged. (A vid of 0 would continue to be rejected as configuration option.)
Not specifying --vlan-pvid would mean that only tagged packets are accepted (and sent).
Quoted 7 lines
I'm still unsure what to do with incoming frames from clients who's vid matches the pvid and where the frames contain a full 802.1Q header with a non-zero vid. I'll probably just drop those packets. Maybe we should drop such packets regardless of the PVID value while in --vlan-tagging
mode. (Tags in tags are apparently specified by 802.1ad and we don't
support that anyway.)
Just paying attention to the discussion from the side line. But just a simple question from a VLAN newbie. This discussion here made me think about something, something which probably is not directly connected to vid == PVID.
But what kind traffic does hit the OpenVPN clients? Does the OpenVPN server send only traffic to the corresponding VLAN the OpenVPN client is "assigned" to? Or does it receive packages for all the VLAN's and does the "filtering" on the client side?
From a security and not the least from a performance perspective, the OpenVPN clients should only receive traffic which hits it's own VLAN (ie. the server does the "filtering" before sending data to the client).
I'm not sure if I saw this in code or not ... but if it is in place and
somebody could point me to the patch which does it, I would be happy.
kind regards,
David Sommerseth
Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
Hi,
Quoted 5 lines · David Sommerseth
Quoted 1 line
From a security and not the least from a performance perspective, the
OpenVPN clients should only receive traffic which hits it's own VLAN (ie. the server does the "filtering" before sending data to the client).
I'm not sure if I saw this in code or not ... but if it is in place and
somebody could point me to the patch which does it, I would be happy.
The patch description (part 0) says so:
----------------- snip -------------------
Packets coming in from the TAP device are assumed to be tagged with IEEE 802.1Q headers. OpenVPN removes the tag, remembers the VID and routes the packet to the destination client(s) on the other side of the secure tunnel which have a matching VID.
----------------- snip -------------------
I have not yet reviewed the source to check whether this really takes place.
Something else I need to check: the "standard" mroute code hashes based on ethernet address (in tap mode). What happens if the same MAC address shows up for two different VLAN IDs? (Not very likely for virtual ethernet devices, though, but this can happen in real-world scenarios).
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
Hi Gert,
Quoted 4 lines · Gert Doering
Something else I need to check: the "standard" mroute code hashes based on ethernet address (in tap mode). What happens if the same MAC address shows up for two different VLAN IDs? (Not very likely for virtual ethernet devices, though, but this can happen in real-world scenarios).
Have a look at "vlan: Add VLAN identifier to mroute_addr for ethernet addresses". The VID is appended to the MAC address and forms the new mroute_addr for ethernet frames (in tap mode).
Cheers
Fabian
Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
In reply to David Sommerseth[ I just noticed that I accidentally sent this only to David and not to
the list. It was written and sent on Thu, 01 Apr 2010 15:46:21 +0200 ]
Quoted 4 lines · David Sommerseth
But what kind traffic does hit the OpenVPN clients? Does the OpenVPN server send only traffic to the corresponding VLAN the OpenVPN client is "assigned" to? Or does it receive packages for all the VLAN's and does the "filtering" on the client side?
The client is unmodified and everything is handled on the server-side. VLAN handling is transparent for the clients. They only see packets belonging to their VLAN and packets sent by them are implicitly assigned to the VLAN they belong to.
Quoted 3 lines
From a security and not the least from a performance perspective, the OpenVPN clients should only receive traffic which hits it's own VLAN (ie. the server does the "filtering" before sending data to the client).
I agree. It also has the nice side-effect for us, that clients don't need to be upgraded. :)
Quoted 2 lines
I'm not sure if I saw this in code or not ... but if it is in place and
somebody could point me to the patch which does it, I would be happy.
I attempt to achieve this in patches 5 and 6. Patch 5 takes care of unicast traffic and patch 6 takes care of broadcast traffic.
As far I understand it, packets are generally routed based on struct mroute_addr. As soon as a client sends a packet to the openvpn server, the packet's sending address is learned and stored as an mroute_addr. If a bit-wise comparison of a destination mroute_addr and learned client's mroute_addr match, the packet is routed to that client.
In tap mode, the addresses of interest are the MAC addresses. In patch 5 I extend what is stored in the mroute_addr: Instead of only storing the 6 bytes of the MAC address, I also append the 2 bytes of the VID. So now a destination MAC address of one VLAN will never match the destination MAC address of another VLAN, because the mroute_addr fields never match.
For broadcasting, no mroute_addr comparisons are done, so the change from patch 5 doesn't help. For a broadcast, the packet is simply forwarded to each of the connected clients (unless PF prevents it). Patch 6 adds a check to the broadcast loop to check whether the sender's vid and the intended broadcast recipient have a matching vid. So we now selectively broadcast based on matching vid.
As I'm not fully familiar with OpenVPN's code base, so I can't be absolutely sure that patch 5 and 6 catch all cases, but it's what I've found to be relevant during my tests and code reviews. I agree with Peter, that this part is critical for security and should be thoroughly reviewed.
Cheers
Fabian
Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
In reply to Jan Just KeijserHi,
Quoted 6 lines · Jan Just Keijser
Quoted 2 lines
Hm, nice idea. I'll implement it in my next round of patches.
FYI: 802.1Q defines VLAN 1 as the 'native' LAN: all packets on VLAN 1 are *by definition* not encapsulated (according to my CCNA guide ;-)) VID 0 means "priority frames"
Perhaps we need to make sure that VID 1 means untagged ...
Different vendors handle this differently - on Cisco, for example, you can make vlan 1 tagged and have the "native" VLAN on a port (= untagged transmissions) on a different VID.
So you can't rely on "VID 1 = untagged".
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...Re: [Openvpn-devel] [PATCH 4/9] vlan: Prepend and remove VLAN identifiers on outgoing and incoming frames
Hi,
Quoted 8 lines · Gert Doering
Quoted 6 lines · Jan Just Keijser
Quoted 2 lines
Hm, nice idea. I'll implement it in my next round of patches.
FYI: 802.1Q defines VLAN 1 as the 'native' LAN: all packets on VLAN 1 are *by definition* not encapsulated (according to my CCNA guide ;-)) VID 0 means "priority frames"
Perhaps we need to make sure that VID 1 means untagged ...
Quoted 5 lines
Different vendors handle this differently - on Cisco, for example, you can make vlan 1 tagged and have the "native" VLAN on a port (= untagged transmissions) on a different VID.
So you can't rely on "VID 1 = untagged".
The current patch-set uses VID 1 = untagged as default (in "vlan-accept all" or "vlan-accept untagged" mode). Setting "vlan-pvid VID" in global context allows you to change this though.
Cheers
Fabian
PATCH 5/9 vlan: Add VLAN identifier to mroute_addr for ethernet addresses
In reply to Fabian KnittelThis patch appends the VID to the ethernet address in mroute_addr.
By including the VID in mroute_addr, the routing space is divided by VLAN. This means:
- duplicate MAC addresses on different VLANs no longer conflict and
- all unicast-traffic is constrained to whatever VLAN the traffic came from (i.e. cross-VLAN unicast routing is no longer possible).
(This patch doesn't take care of broadcast traffic. Broadcast traffic across VLANs is still be possible at this point.)
--- mroute.c | 10 +++++++--- mroute.h | 8 +++++--- multi.c | 15 +++++++++++---- 3 files changed, 23 insertions(+), 10 deletions(-)
mroute.c +7 -3
@@ -169,7 +169,8 @@ mroute_extract_addr_ether (struct mroute_addr *src,struct mroute_addr *dest, struct mroute_addr *esrc, struct mroute_addr *edest, - const struct buffer *buf) + const struct buffer *buf, + int16_t vid) { unsigned int ret = 0;if (BLEN (buf) >= (int )sizeof (struct openvpn_ethhdr ))
@@ -179,15 +180,17 @@ mroute_extract_addr_ether (struct mroute_addr *src, { src->type =MR_ADDR_ETHER ; src->netbits =0 ; - src->len =6 ; + src->len =8 ;memcpy (src->addr, eth->source,6 ); +memcpy (src->addr +6 , &vid,2 ); }if (dest) { dest->type =MR_ADDR_ETHER ; dest->netbits =0 ; - dest->len =6 ; + dest->len =8 ;memcpy (dest->addr, eth->dest,6 ); +memcpy (dest->addr +6 , &vid,2 );/* ethernet broadcast/multicast packet? */ if (is_mac_mcast_addr (eth->dest))
@@ -303,6 +306,7 @@ mroute_addr_print_ex (const struct mroute_addr *ma, {case MR_ADDR_ETHER :buf_printf (&out,"%s" ,format_hex_ex (ma->addr,6 ,0 ,1 ,":" , gc)); +buf_printf (&out,"@%d" , *(int16_t *)(ma->addr +6 ));break ;case MR_ADDR_IPV4 : {
mroute.h +5 -3
@@ -139,7 +139,8 @@ mroute_extract_addr_from_packet (struct mroute_addr *src, struct mroute_addr *esrc, struct mroute_addr *edest, const struct buffer *buf, - int tunnel_type) + int tunnel_type, + int16_t bcast_domain) { unsigned int mroute_extract_addr_ipv4 (struct mroute_addr *src, struct mroute_addr *dest,
@@ -149,13 +150,14 @@ mroute_extract_addr_from_packet (struct mroute_addr *src,struct mroute_addr *dest, struct mroute_addr *esrc, struct mroute_addr *edest, - const struct buffer *buf); + const struct buffer *buf, + int16_t vid);unsigned int ret =0 ;verify_align_4 (buf);if (tunnel_type ==DEV_TYPE_TUN ) ret =mroute_extract_addr_ipv4 (src, dest, buf);else if (tunnel_type ==DEV_TYPE_TAP ) - ret =mroute_extract_addr_ether (src, dest, esrc, edest, buf); + ret =mroute_extract_addr_ether (src, dest, esrc, edest, buf, bcast_domain);return ret; }
multi.c +11 -4
@@ -1975,7 +1975,8 @@ multi_process_incoming_link (struct multi_context *m, struct multi_instance *insNULL ,NULL , &c->c2.to_tun, - DEV_TYPE_TUN); +DEV_TYPE_TUN , + 0);/* drop packet if extract failed */ if (!(mroute_flags &MROUTE_EXTRACT_SUCCEEDED ))
@@ -2033,10 +2034,13 @@ multi_process_incoming_link (struct multi_context *m, struct multi_instance *ins }else if (TUNNEL_TYPE (m->top.c1.tuntap) ==DEV_TYPE_TAP ) { +int16_t vid =0 ;#ifdef ENABLE_PF struct mroute_addr edest;mroute_addr_reset (&edest);#endif +if (m->top.options.vlan_tagging) + vid = c->options.vlan_tag;/* extract packet source and dest addresses */ mroute_flags = mroute_extract_addr_from_packet (&src, &dest,
@@ -2047,7 +2051,8 @@ multi_process_incoming_link (struct multi_context *m, struct multi_instance *insNULL , #endif &c->c2.to_tun, - DEV_TYPE_TAP); +DEV_TYPE_TAP , + vid);if (mroute_flags &MROUTE_EXTRACT_SUCCEEDED ) {
@@ -2198,6 +2203,7 @@ multi_process_incoming_tun (struct multi_context *m, const unsigned int mpp_flagunsigned int mroute_flags;struct mroute_addr src, dest;const int dev_type =TUNNEL_TYPE (m->top.c1.tuntap); +int16_t vid =0 ;#ifdef ENABLE_PF struct mroute_addr esrc, *e1, *e2;
@@ -2227,7 +2233,7 @@ multi_process_incoming_tun (struct multi_context *m, const unsigned int mpp_flagif (dev_type ==DEV_TYPE_TAP && m->top.options.vlan_tagging) { -if (remove_vlan_identifier (&m->top.c2.buf) ==-1 ) +if ((vid =remove_vlan_identifier (&m->top.c2.buf)) ==-1 )return false; }
@@ -2240,7 +2246,8 @@ multi_process_incoming_tun (struct multi_context *m, const unsigned int mpp_flag#endif NULL , &m->top.c2.buf, - dev_type); + dev_type, + vid);if (mroute_flags &MROUTE_EXTRACT_SUCCEEDED ) {
Signature · 1 line
1.7.0
PATCH 6/9 vlan: Restrict broadcasts to the sender's VLAN.
In reply to Fabian KnittelThis patch enhances openvpn's internal packet routing to restrict broadcast packets to destinations with a matching VID.
I.e. broadcasts from client to client or from tap interface to clients are now filtered based on whether the client belongs to the correct VLAN id.
--- multi.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-)
multi.c +9 -6
@@ -1759,7 +1759,8 @@ static void multi_bcast (struct multi_context *m, const struct buffer *buf, const struct multi_instance *sender_instance, - const struct mroute_addr *sender_addr) + const struct mroute_addr *sender_addr, + int16_t vid) { struct hash_iterator hi;struct hash_element *he;
@@ -1804,6 +1805,8 @@ multi_bcast (struct multi_context *m, } }#endif +if (vid !=0 && vid != mi->context.options.vlan_tag) +continue ;multi_add_mbuf (m, mi, mb); } }
@@ -1997,7 +2000,7 @@ multi_process_incoming_link (struct multi_context *m, struct multi_instance *insif (mroute_flags &MROUTE_EXTRACT_MCAST ) {/* for now, treat multicast as broadcast */ -multi_bcast (m, &c->c2.to_tun, m->pending,NULL ); +multi_bcast (m, &c->c2.to_tun, m->pending,NULL ,0 ); }else /* possible client to client routing */ {
@@ -2063,7 +2066,7 @@ multi_process_incoming_link (struct multi_context *m, struct multi_instance *ins {if (mroute_flags & (MROUTE_EXTRACT_BCAST |MROUTE_EXTRACT_MCAST )) { -multi_bcast (m, &c->c2.to_tun, m->pending,NULL ); +multi_bcast (m, &c->c2.to_tun, m->pending,NULL , vid); }else /* try client-to-client routing */ {
@@ -2258,9 +2261,9 @@ multi_process_incoming_tun (struct multi_context *m, const unsigned int mpp_flag {/* for now, treat multicast as broadcast */ #ifdef ENABLE_PF -multi_bcast (m, &m->top.c2.buf,NULL , e2); +multi_bcast (m, &m->top.c2.buf,NULL , e2, vid);#else -multi_bcast (m, &m->top.c2.buf,NULL ,NULL ); +multi_bcast (m, &m->top.c2.buf,NULL ,NULL , vid);#endif } else
@@ -2429,7 +2432,7 @@ gremlin_flood_clients (struct multi_context *m)ASSERT (buf_write_u8 (&buf,get_random () &0xFF ));for (i =0 ; i < parm.n_packets; ++i) -multi_bcast (m, &buf,NULL ,NULL ); +multi_bcast (m, &buf,NULL ,NULL ,0 );gc_free (&gc); }
Signature · 1 line
1.7.0
PATCH 7/9 vlan: Slightly enhance PF's protocol inspection of 802.1Q packets
In reply to Fabian KnittelTo allow openvpn's PF code to inspect IP packets contained within 802.1Q packets, this patch enhances mroute_extract_addr_ether() to properly skip over the 802.1Q header.
--- mroute.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
mroute.c +9 -1
@@ -205,7 +205,15 @@ mroute_extract_addr_ether (struct mroute_addr *src,struct buffer b = *buf;if (buf_advance (&b,sizeof (struct openvpn_ethhdr ))) { -switch (ntohs (eth->proto)) +uint16_t proto =ntohs (eth->proto); +if (proto ==OPENVPN_ETH_P_8021Q ) + { +const struct openvpn_8021qhdr *tag = (const struct openvpn_8021qhdr *)BPTR (buf); + proto =ntohs (tag->proto); +buf_advance (&b,SIZE_ETH_TO_8021Q_HDR ); + } + +switch (proto) {case OPENVPN_ETH_P_IPV4 : ret |= (mroute_extract_addr_ipv4 (esrc, edest, &b) <<MROUTE_SEC_SHIFT );
Signature · 1 line
1.7.0
PATCH 8/9 vlan: add debug logging to tagging / untagging
In reply to Fabian Knittel--- multi.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
multi.c +6 -0
@@ -2143,11 +2143,15 @@ remove_vlan_identifier (struct buffer *buf)if (ntohs (vlanhdr.tpid) !=OPENVPN_ETH_P_8021Q ) {/* Drop untagged frames */ +msg (M_INFO ,"dropping untagged ethernet frame (proto/len 0x%04x)" , +ntohs (vlanhdr.tpid)); goto err; }/* Ethernet II frame with 802.1Q */ vid =ntohs (vlan_get_vid (&vlanhdr)); +msg (M_INFO ,"untagging ethernet frame: vid: %u, wrapped proto/len: 0x%04x" , + vid,ntohs (vlanhdr.proto));memcpy (ð, &vlanhdr,sizeof (eth)); eth.proto = vlanhdr.proto;
@@ -2189,6 +2193,8 @@ multi_prepend_vlan_identifier (struct multi_instance *mi, struct buffer *buf)ASSERT (p =buf_prepend (buf,SIZE_ETH_TO_8021Q_HDR ));memcpy (p, &vlanhdr,sizeof vlanhdr); + +msg (M_INFO ,"tagging frame with vid %u, type is %04x" , mi->context.options.vlan_tag, vlanhdr.proto); }/*
Signature · 1 line
1.7.0
PATCH 9/9 vlan: add debug logging to broadcast filter
In reply to Fabian Knittel--- multi.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-)
multi.c +15 -1
@@ -1806,7 +1806,21 @@ multi_bcast (struct multi_context *m, }#endif if (vid !=0 && vid != mi->context.options.vlan_tag) -continue ; + { +struct gc_arena gc =gc_new (); +msg (M_INFO ,"VLAN: addr[%s]@%d -> client[%s]@%d packet dropped by BCAST VLAN filter" , +mroute_addr_print_ex (sender_addr,MAPF_SHOW_ARP , &gc), + vid,mi_prefix (mi), mi->context.options.vlan_tag); +gc_free (&gc); +continue ; + } + { +struct gc_arena gc =gc_new (); +msg (M_INFO ,"BCAST: addr[%s]@%d -> client[%s]@%d" , +mroute_addr_print_ex (sender_addr,MAPF_SHOW_ARP , &gc), + vid,mi_prefix (mi), mi->context.options.vlan_tag); +gc_free (&gc); + }multi_add_mbuf (m, mi, mb); } }
Signature · 1 line
1.7.0
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 6 lines · Fabian Knittel
Hi,
The patch-set is now based on Davide Guerri's --passtos patch, as it directly falls with-in the functionality of my original version and looked like a candidate for integration.
Quoted 8 lines
The patches are also available directly via git, see our gitweb at
The last two patches (add debug logging ...) aren't really intended for inclusion. I haven't looked into proper log levels, so currently the debug messages flood at notice priority. I'm not sure whether the messages should be included at all.
Hi!
Thank you very much for your patches! I'll look into them soon. The patches seems to apply nicely against the feat_passtos branch. I was worried about a conflict here, until I noticed where you had your roots :)
Those two last debug info patches, I'll skip as you seem not to be completely ready with them. So, please clean them up or mark them as "good" for inclusion when you're confident in them.
One thing, it would be good if you would do your commit with -s (--signoff). We've not been strict about this so far, but I would like to see those sign-off messages. (I'll make sure the developers documentation is 'up-to-date' in this matter, as I don't think that's mentioned now).
Quoted 2 lines
Another question would be whether I should turn the feature into a compile-time selectable option.
It's been several discussions about if such features should be #ifdef'ed or not. The general consensus of the discussions is that it will most probably be accepted into a stable tree in the future quicker if it is a compile-time enablement.
The main argument which I find acceptable, is that if a stability and/or security issue is found, it would be possible to easily disable all features and disable them one-by-one to find the offending feature.
Quoted 5 lines
The patch-set has only received light testing up to now, as it was originally only intended as a proof of concept. At this point I'm very interested in all kinds of feed-back and would like to determine whether you might be interested in integrating something like this in an official OpenVPN release at some point.
I'll admit I don't understand too much how the VLAN's really work in core network code. But I understand the concept though. From what I can judge based on a quick first look, the patches looks fine. I'll try to find some time to read through the patches once more.
[* Other reviewers are most welcome to have a look as well! *]
If you could do a bit more testing, also some stress/performance testing with several VLAN's being tested in parallel, that would be beneficial.
Having all this said, the feature itself seems reasonable for me to include into OpenVPN, so the missing step is just to mature the code to be sure we don't cause any regression. And here some stress/performance testing will be helpful. You scare at least me when stating that this code "was originally only intended as a proof of concept", which is why I'm not signing off these patches immediately and giving you a feature branch. But I'm open for full inclusion!
Again, thanks you very much for your patches and I hope we will get these them reviewed properly and soon. And keep us updated on the progress with your patches!
kind regards,
David Sommerseth
Quoted 12 lines
Fabian Knittel (9):
is_ipv4(): add packet length check for 802.1Q packets
vlan: Add global --vlan-tagging option
vlan: Add per-client --vlan-tag option
vlan: Prepend and remove VLAN identifiers on outgoing and incoming
frames
vlan: Add VLAN identifier tomroute_addrfor ethernet addresses
vlan: Restrict broadcasts to the sender's VLAN.
vlan: Slightly enhance PF's protocol inspection of 802.1Q packets
vlan: add debug logging to tagging / untagging
vlan: add debug logging to broadcast filter
Quoted 9 lines
mroute.c | 20 ++++++++-- mroute.h | 8 +++-- multi.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- multi.h | 5 +++ options.c | 34 +++++++++++++++++ options.h | 3 ++ proto.c | 3 ++ proto.h | 36 ++++++++++++++++-- 8 files changed, 210 insertions(+), 20 deletions(-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkuz1qIACgkQDC186MBRfrr+IwCgrG/o46LEEpH9oNOJ9IxTz8Nf kPoAn0T7k5DnJUNyYOneH0hkdUy/7RyR
=EEbK
-----END PGP SIGNATURE-----
Quoted 2 lines · David Sommerseth
I'll admit I don't understand too much how the VLAN's really work in core network code.
There's a prefix, and a wrapper to create virtual interfaces. And there's the vconfig tool to do configuration. NIC drivers need to support oversize frames.
vconfig add eth0 4 # VLAN 4 will be tagged on eth0
So to test this, one could do:
vconfig add tap0 4 # Creates tap9.4 which is VLAN 4 on tap9
Then run openvpn --mode server --vlan-tag 4 on that tap0, and client traffic should then come out of tap0.4 rather than tap0.
Quoted 3 lines
I'll try to find some time to read through the patches once more.
[* Other reviewers are most welcome to have a look as well! *]
I think they looked okey, apart from the things I pointed out already.
Quoted 4 lines
You scare at least me when stating that this code "was originally only intended as a proof of concept", which is why I'm not signing off these patches immediately and giving you a feature branch. But I'm open for full inclusion!
I'm generally in favor too. Although originally PoC I think this looks like good quality now, and VLANs are actually really simple.
I would like to request extra special thorough review of broadcast domain separation though, so that it's certain that nothing will jump VLANs.
//Peter
Hi David,
Quoted 1 line · David Sommerseth
Thank you very much for your patches! I'll look into them soon.
Thanks!
Quoted 3 lines
The
patches seems to apply nicely against thefeat_passtosbranch. I was worried about a conflict here, until I noticed where you had your roots :)
Actually, I was lucky to notice the openvpn-unstable.git repo before submission. My original patch-set was based on the subversion repo branch beta21 and would have conflicted with feat_passtos. I didn't notice the git repo and the Wiki on secure-computing.net until I happened to look at some openvpn-devel mails in the archive. Does openvpn.net link to them from somewhere?
Quoted 5 lines
One thing, it would be good if you would do your commit with -s (--signoff). We've not been strict about this so far, but I would like to see those sign-off messages. (I'll make sure the developers documentation is 'up-to-date' in this matter, as I don't think that's mentioned now).
Will do.
Quoted 11 lines
Quoted 2 lines
Another question would be whether I should turn the feature into a compile-time selectable option.
It's been several discussions about if such features should be #ifdef'ed or not. The general consensus of the discussions is that it will most probably be accepted into a stable tree in the future quicker if it is a compile-time enablement.
The main argument which I find acceptable, is that if a stability and/or security issue is found, it would be possible to easily disable all features and disable them one-by-one to find the offending feature.
I'll add the necessary #ifdefs and such.
Quoted 2 lines
If you could do a bit more testing, also some stress/performance testing with several VLAN's being tested in parallel, that would be beneficial.
We'll definitely be doing that over here. My main concern was whether we would have to patch OpenVPN indefinitely with local enhancements or whether there was a chance to include it upstream. And now that things look quite positive, we can go forward with the chosen approach. :)
Quoted 7 lines
Having all this said, the feature itself seems reasonable for me to include into OpenVPN, so the missing step is just to mature the code to be sure we don't cause any regression. And here some stress/performance testing will be helpful. You scare at least me when stating that this code "was originally only intended as a proof of concept", which is why I'm not signing off these patches immediately and giving you a feature branch. But I'm open for full inclusion!
Sounds great! I'll definitely continue polishing the patch-set and continue hitting the vlan code with more tests.
Quoted 1 line
And keep us updated on the progress with your patches!
Will do. :)
Cheers
Fabian
Quoted 11 lines · Fabian Knittel
Hi David,
Quoted 1 line · David Sommerseth
Thank you very much for your patches! I'll look into them soon.
Thanks!
Quoted 3 lines
The
patches seems to apply nicely against thefeat_passtosbranch. I was worried about a conflict here, until I noticed where you had your roots :)
Quoted 6 lines
Actually, I was lucky to notice the openvpn-unstable.git repo before submission. My original patch-set was based on the subversion repo branch beta21 and would have conflicted with
feat_passtos. I didn't notice the git repo and the Wiki on secure-computing.net until I happened to look at some openvpn-devel mails in the archive. Does openvpn.net link to them from somewhere?
No, I don't think so yet. This git tree got publicly available just a few months ago, and things have gone in quite a quick tempo since then.
We have not discussed this much at all, as far as I remember.
Samuli: Can you look into this? To get some links to the developers doc and the git tree on the official web site?
Quoted 7 lines
Quoted 2 lines
If you could do a bit more testing, also some stress/performance testing with several VLAN's being tested in parallel, that would be beneficial.
We'll definitely be doing that over here. My main concern was whether we would have to patch OpenVPN indefinitely with local enhancements or whether there was a chance to include it upstream. And now that things look quite positive, we can go forward with the chosen approach. :)
Thanks a lot! This really will help us a lot. If you even dare to try a local merge against the 'allmerged' branch when you do some bigger tests, that would also be very much appreciated.
Btw! How is it with IPv6 and your patches? We have quite some patches for that in the tree already. And as I see you patch in the [PATCH 1/9] the is_ipv4() function, you might want to be sure this will also work in the IPv6 world as well.
Gert: is this something you could double check as too?
Quoted 10 lines
Quoted 7 lines
Having all this said, the feature itself seems reasonable for me to include into OpenVPN, so the missing step is just to mature the code to be sure we don't cause any regression. And here some stress/performance testing will be helpful. You scare at least me when stating that this code "was originally only intended as a proof of concept", which is why I'm not signing off these patches immediately and giving you a feature branch. But I'm open for full inclusion!
Sounds great! I'll definitely continue polishing the patch-set and continue hitting the vlan code with more tests.
Cool! Please let me know if you patches will go on top of the current patch-set you sent, or if you come with a new patch-set based upon the feat_passtos branch.
Looking forward to more patches!
Kind regards,
David Sommerseth
Quoted 9 lines · David Sommerseth
Quoted 4 lines · Fabian Knittel
We'll definitely be doing that over here. My main concern was whether we would have to patch OpenVPN indefinitely with local enhancements or whether there was a chance to include it upstream. And now that things look quite positive, we can go forward with the chosen approach. :)
Thanks a lot! This really will help us a lot. If you even dare to try a local merge against the 'allmerged' branch when you do some bigger tests, that would also be very much appreciated.
OK. I assume feat_passtos isn't merged into allmerged yet, right? I'll probably pluck Davide Guerri's patch from feat_passtos and do the testing together with my vlan patches on allmerged. (Assuming things don't explode too badly on allmerged :).)
Quoted 4 lines
Btw! How is it with IPv6 and your patches? We have quite some patches for that in the tree already. And as I see you patch in the [PATCH 1/9] the
is_ipv4()function, you might want to be sure this will also work in the IPv6 world as well.
AFAICS, IPv6 support for tap should only come into the picture when we attempt to inspect the packets for specific purposes, like packet filtering or retrieving the packet's priority (TOS in IPv4). So although the patches don't yet explicitly handle IPv6, I don't expect them to conflict with it either...
I'll have a look when I merge to allmerged. And we'll be testing autoconfigured IPv6 addresses over tap in our setup, so we'll hopefully catch obvious problems.
Quoted 6 lines
Quoted 2 lines
Sounds great! I'll definitely continue polishing the patch-set and continue hitting the vlan code with more tests.
Cool! Please let me know if you patches will go on top of the current patch-set you sent, or if you come with a new patch-set based upon the
feat_passtosbranch.
I'd be fine with whatever you would prefer ... If you have no preferences, I'd probably continue rebasing my internal branch on feat_passtos until all comments have been worked in and we've completed our basic tests. But I can also use a more incremental approach, if that simplifies your reviewing work or you'd like the existing code to be visible on openvpn-testing.git.
Cheers
Fabian
Quoted 7 lines · Fabian Knittel
Quoted 6 lines · David Sommerseth
Quoted 4 lines · Fabian Knittel
We'll definitely be doing that over here. My main concern was whether we would have to patch OpenVPN indefinitely with local enhancements or whether there was a chance to include it upstream. And now that things look quite positive, we can go forward with the chosen approach. :)
Quoted 8 lines
Quoted 3 lines
Thanks a lot! This really will help us a lot. If you even dare to try a local merge against the 'allmerged' branch when you do some bigger tests, that would also be very much appreciated.
OK. I assume
feat_passtosisn't merged into allmerged yet, right? I'll probably pluck Davide Guerri's patch fromfeat_passtosand do the testing together with my vlan patches on allmerged. (Assuming things don't explode too badly on allmerged :).)
No, the feat_passtos is awaiting testing before getting merged into allmerged. So it's just for you to get a glimpse of what I might complain about when I do the main merges. I will always be the one doing the official merges into allmerged, but please test that on your own work as well - or else I'll haunt you afterwards when conflicts appears ;-)
Quoted 10 lines
Quoted 4 lines
Btw! How is it with IPv6 and your patches? We have quite some patches for that in the tree already. And as I see you patch in the [PATCH 1/9] the
is_ipv4()function, you might want to be sure this will also work in the IPv6 world as well.AFAICS, IPv6 support for tap should only come into the picture when we attempt to inspect the packets for specific purposes, like packet filtering or retrieving the packet's priority (TOS in IPv4). So although the patches don't yet explicitly handle IPv6, I don't expect them to conflict with it either...
Yeah, I thought so. As long as your patch-set does treat IPv4 and IPv6 equally and it works as expected, then I'm happy! If the passtos feature fails on IPv6, that's the passtos feature which is faulty - and I won't chase you for those fixes. Unless you want to fix it, of course :)
Quoted 3 lines
I'll have a look when I merge to allmerged. And we'll be testing autoconfigured IPv6 addresses over tap in our setup, so we'll hopefully catch obvious problems.
Perfect!
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
Sounds great! I'll definitely continue polishing the patch-set and continue hitting the vlan code with more tests.
Cool! Please let me know if you patches will go on top of the current patch-set you sent, or if you come with a new patch-set based upon the
feat_passtosbranch.
Quoted 6 lines
I'd be fine with whatever you would prefer ... If you have no preferences, I'd probably continue rebasing my internal branch on
feat_passtosuntil all comments have been worked in and we've completed our basic tests. But I can also use a more incremental approach, if that simplifies your reviewing work or you'd like the existing code to be visible on openvpn-testing.git.
I'm also fine with with this approach. Do what's most easy for you. I'll be able to grab incremental and the completed patch-set, it's no big difference for me at all. Depends if you want to keep the commit logs and progress in the upstream git tree or not. If you have a public git tree available, I could pull that as well. (I tried the git URL the webUI gave me yesterday, without luck).
For the moment I'll just sit "on the fence" wait for things to settle, and I'll grab what you provide me when you're ready. Then I'll give you a feat_vlan_tagging branch and pull it in there.
kind regards,
David Sommerseth
A message that is not in the archive (sent off-list or not yet received): [email protected]...
Quoted 2 lines · David Sommerseth
If you have a public git tree available, I could pull that as well. (I tried the git URL the webUI gave me yesterday, without luck).
Ah, thanks for noticing ... the non-ssh path apparently doesn't get used often. I forgot to fix the URLs since switching to gitosis. I've now verified that
git://fsmi-dev.fsmi.uni-karlsruhe.de/openvpn.git
definitely works. Anyway, I'll mail again when there's something new to pull.
Cheers
Fabian
Quoted 9 lines
Quoted 8 lines
Actually, I was lucky to notice the openvpn-unstable.git repo before submission. My original patch-set was based on the subversion repo branch beta21 and would have conflicted with
feat_passtos. I didn't notice the git repo and the Wiki on secure-computing.net until I happened to look at some openvpn-devel mails in the archive. Does openvpn.net link to them from somewhere?
Quoted 7 lines
No, I don't think so yet. This git tree got publicly available just a few months ago, and things have gone in quite a quick tempo since then.
We have not discussed this much at all, as far as I remember.Samuli: Can you look into this? To get some links to the developers doc and the git tree on the official web site?
Actually I'll try to get the remaining non-technical issues with the community site (Trac) sorted out a.s.a.p. so that it can be opened as "beta" and we can add the necessary information there. Currently it's very hard to find the services we use, unless one follows the -devel mailinglist actively.
Signature · 5 lines
Samuli Seppänen Community Manager OpenVPN Technologies, Inc irc freenode net: mattock
Quoted 8 lines
Actually, I was lucky to notice the openvpn-unstable.git repo before submission. My original patch-set was based on the subversion repo branch beta21 and would have conflicted with
feat_passtos. I didn't notice the git repo and the Wiki on secure-computing.net until I happened to look at some openvpn-devel mails in the archive. Does openvpn.net link to them from somewhere?
Currently there are tons of sites and services related to OpenVPN and only a few of them are linked to from openvpn.net. This will be fixed soonish, when the "official" community site (with Trac tracker/wiki) opens - it's technically ready for beta-testing, but we (=the company) have not yet decided how we bind it together with openvpn.net. Other services are coming out of the pipe after Trac - forums first and foremost.
Signature · 5 lines
Samuli Seppänen Community Manager OpenVPN Technologies, Inc irc freenode net: mattock