support VLANs in TAP mode
cover support VLANs in TAP mode
This patchset is the restyled, adjusted and (partly) re-worked version of the patchset that can be found in this GitHub PR
https://github.com/OpenVPN/openvpn/pull/76
originally authored by Fabian Knittel.
The status of this new patchset is tracked here:
https://community.openvpn.net/openvpn/ticket/6#comment:5
These new patches have already gone through a first round of review by Gert and are now being posted on the mailing list for broader scrutinity.
In a nutshell, this new feature allows to assign each client to a VLAN (like if it was a host plugged into a switch, with OpenVPN server being the switch). This will ensure proper isolation between clients on different VLANs.
On top of that, depending on the configuration, clients can be bridged with different networks on the server side, thanks to the VLAN tagging applied to their outgoing packets (more is explained in the additional manpage content).
A specific document explaining more in details how this feature can be useful in common setups is planned to be drafted after the patchset has been merged.
Feedback is welcome!
Regards,
Antonio Quartulli (9):
maddr: create helper function to populate maddr object from eth_addr
VLAN: add basic VLAN tagging support
maddr: export VLAN ID from client context to maddr object
VLAN: filter multicast and client-to-client unicast traffic
is_ipv_X: add support for parsing IP header inside a 802.1q frame
VLAN: implement support for forwarding only pre-tagged VLAN packets
VLAN: allow forwarding tagged and untagged packets on the server TAP
device
VLAN: add documentation to manpage
VLAN: allow user to avoid compiling VLAN handling code
configure.ac | 12 ++ doc/openvpn.8 | 99 +++++++++++- src/openvpn/Makefile.am | 4 + src/openvpn/errlevel.h | 2 + src/openvpn/mroute.c | 66 +++++--- src/openvpn/mroute.h | 13 +- src/openvpn/multi.c | 47 +++++- src/openvpn/multi.h | 2 + src/openvpn/options.c | 99 ++++++++++++ src/openvpn/options.h | 13 ++ src/openvpn/proto.c | 42 +++-- src/openvpn/proto.h | 25 +++ src/openvpn/vlan.c | 337 ++++++++++++++++++++++++++++++++++++++++ src/openvpn/vlan.h | 131 ++++++++++++++++ 14 files changed, 852 insertions(+), 40 deletions(-) create mode 100644 src/openvpn/vlan.c create mode 100644 src/openvpn/vlan.h
Signature · 1 line
2.23.0
PATCH 1/9 maddr: create helper function to populate maddr object from eth_addr
--- src/openvpn/mroute.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
src/openvpn/mroute.c +12 -8
@@ -247,6 +247,16 @@ mroute_extract_addr_ip(struct mroute_addr *src, struct mroute_addr *dest,return ret; } +static void +mroute_copy_ether_to_addr (struct mroute_addr *maddr, +const uint8_t *ether_addr) +{ + maddr->type =MR_ADDR_ETHER ; + maddr->netbits =0 ; + maddr->len =OPENVPN_ETH_ALEN ; +memcpy (maddr->eth_addr, ether_addr,OPENVPN_ETH_ALEN ); +} + unsigned int mroute_extract_addr_ether(struct mroute_addr *src, struct mroute_addr *dest,
@@ -260,17 +270,11 @@ mroute_extract_addr_ether(struct mroute_addr *src,const struct openvpn_ethhdr *eth = (const struct openvpn_ethhdr *)BPTR (buf);if (src) { - src->type =MR_ADDR_ETHER ; - src->netbits =0 ; - src->len =6 ; -memcpy (src->eth_addr, eth->source,sizeof (dest->eth_addr)); +mroute_copy_ether_to_addr (src, eth->source); }if (dest) { - dest->type =MR_ADDR_ETHER ; - dest->netbits =0 ; - dest->len =6 ; -memcpy (dest->eth_addr, eth->dest,sizeof (dest->eth_addr)); +mroute_copy_ether_to_addr (dest, eth->dest);/* ethernet broadcast/multicast packet? */ if (is_mac_mcast_addr (eth->dest))
Signature · 1 line
2.23.0
PATCH 2/9 VLAN: add basic VLAN tagging support
In reply to Antonio QuartulliThis patch introduces basic support for VLAN tagging on the server side. The introduced functionality consists in allowing the user to assign a VID to the server TAP device and a VID to each client port.
Client specific VID are assigned by means of files in CCD (like for other client specific settings).
Once VIDs have been assigned, everything works as before, except that communications are allowed only between hosts having the same VID.
With this patch all broadcast and client-to-client traffic is yet separated by VLAN: only client-to-server unicasts are affected.
--- src/openvpn/Makefile.am | 1 + src/openvpn/errlevel.h | 2 + src/openvpn/multi.c | 27 +++++++--- src/openvpn/multi.h | 2 + src/openvpn/options.c | 54 ++++++++++++++++++++ src/openvpn/options.h | 9 ++++ src/openvpn/proto.h | 25 +++++++++ src/openvpn/vlan.c | 110 ++++++++++++++++++++++++++++++++++++++++ src/openvpn/vlan.h | 44 ++++++++++++++++ 9 files changed, 268 insertions(+), 6 deletions(-) create mode 100644 src/openvpn/vlan.c create mode 100644 src/openvpn/vlan.h
src/openvpn/Makefile.am +1 -0
@@ -123,6 +123,7 @@ openvpn_SOURCES = \ syshead.h \ tls_crypt.c tls_crypt.h \ tun.c tun.h \ + vlan.c vlan.h \ win32.h win32.c \ cryptoapi.h cryptoapi.c openvpn_LDADD = \
src/openvpn/errlevel.h +2 -0
@@ -148,6 +148,8 @@#define D_PF_DEBUG LOGLEV(7, 72, M_DEBUG)/* packet filter debugging, must also define PF_DEBUG in pf.h */ #define D_PUSH_DEBUG LOGLEV(7, 73, M_DEBUG)/* show push/pull debugging info */ +#define D_VLAN_DEBUG LOGLEV(7, 74, M_DEBUG)/* show VLAN tagging/untagging debug info */ +#define D_HANDSHAKE_VERBOSE LOGLEV(8, 70, M_DEBUG)/* show detailed description of each handshake */ #define D_TLS_DEBUG_MED LOGLEV(8, 70, M_DEBUG)/* limited info from tls_session routines */ #define D_INTERVAL LOGLEV(8, 70, M_DEBUG)/* show interval.h debugging info */
src/openvpn/multi.c +21 -6
@@ -45,6 +45,7 @@#include "gremlin.h" #include "mstats.h" #include "ssl_verify.h" +#include "vlan.h" #include <inttypes.h> #include "memdbg.h"
@@ -2208,7 +2209,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, + uint16_t vid) { struct hash_iterator hi;struct hash_element *he;
@@ -2258,6 +2260,10 @@ multi_bcast(struct multi_context *m, } }#endif /* ifdef ENABLE_PF */ +if (vid !=0 && vid != mi->context.options.vlan_pvid) + { +continue ; + }multi_add_mbuf (m, mi, mb); } }
@@ -2595,7 +2601,7 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *instif (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 */ {
@@ -2640,6 +2646,15 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inststruct mroute_addr edest;mroute_addr_reset (&edest);#endif +if (m->top.options.vlan_tagging) + { +if (vlan_is_tagged (&c->c2.to_tun)) + { +/* Drop VLAN-tagged frame. */ +msg (D_VLAN_DEBUG ,"dropping incoming VLAN-tagged frame" ); + c->c2.to_tun.len =0 ; + } + }/* extract packet source and dest addresses */ mroute_flags = mroute_extract_addr_from_packet(&src, &dest,
@@ -2661,7 +2676,7 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inst {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 ,0 ); }else /* try client-to-client routing */ {
@@ -2788,9 +2803,9 @@ multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flags {/* 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,0 );#else -multi_bcast (m, &m->top.c2.buf,NULL ,NULL ); +multi_bcast (m, &m->top.c2.buf,NULL ,NULL ,0 );#endif } else
@@ -2972,7 +2987,7 @@ gremlin_flood_clients(struct multi_context *m)for (i =0 ; i < parm.n_packets; ++i) { -multi_bcast (m, &buf,NULL ,NULL ); +multi_bcast (m, &buf,NULL ,NULL ,0 ); }gc_free (&gc);
src/openvpn/multi.h +2 -0
@@ -40,6 +40,7 @@#include "mudp.h" #include "mtcp.h" #include "perf.h" +#include "vlan.h" #define MULTI_PREFIX_MAX_LENGTH 256
@@ -620,6 +621,7 @@ multi_process_outgoing_tun(struct multi_context *m, const unsigned int mpp_flags mi->context.c2.to_tun.len);#endif set_prefix (mi); +vlan_process_outgoing_tun (m, mi);process_outgoing_tun (&mi->context); ret =multi_process_post (m, mi, mpp_flags);clear_prefix ();
src/openvpn/options.c +54 -0
102 lines not on this page · raw message
src/openvpn/options.h +9 -0
@@ -169,6 +169,11 @@ struct remote_liststruct remote_entry *array[CONNECTION_LIST_SIZE ]; }; +enum vlan_acceptable_frames +{ +VLAN_ONLY_UNTAGGED_OR_PRIORITY , +}; +struct remote_host_store {#define RH_HOST_LEN 80
@@ -632,6 +637,10 @@ struct optionsint keying_material_exporter_length;#endif +bool vlan_tagging; +enum vlan_acceptable_frames vlan_accept; +uint16_t vlan_pvid; +struct pull_filter_list *pull_filter_list;/* Useful when packets sent by openvpn itself are not subject
src/openvpn/proto.h +25 -0
@@ -60,9 +60,31 @@ 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 */ }; +struct openvpn_8021qhdr +{ +uint8_t dest[OPENVPN_ETH_ALEN ];/* destination ethernet addr */ +uint8_t source[OPENVPN_ETH_ALEN ];/* source ethernet addr */ + +uint16_t tpid;/* 802.1Q Tag Protocol Identifier */ +#define OPENVPN_8021Q_MASK_PCP htons(0xE000)/* mask PCP out of pcp_cfi_vid */ +#define OPENVPN_8021Q_MASK_CFI htons(0x1000)/* mask CFI out of pcp_cfi_vid */ +#define OPENVPN_8021Q_MASK_VID htons(0x0FFF)/* mask VID out of pcp_cfi_vid */ +uint16_t pcp_cfi_vid;/* bit fields, see IEEE 802.1Q */ +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 0x0001uint16_t mac_addr_type;/* 0x0001 */
@@ -311,4 +333,7 @@ void ipv4_packet_size_verify(const uint8_t *data,#endif +#define OPENVPN_8021Q_MIN_VID 1 +#define OPENVPN_8021Q_MAX_VID 4094 +#endif /* ifndef PROTO_H */
src/openvpn/vlan.c new file +110 -0
110 lines not on this page · raw message
src/openvpn/vlan.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH 3/9 maddr: export VLAN ID from client context to maddr object
In reply to Antonio QuartulliWhen receiving a packet from a client, the associated maddr needs to carry also the VID associated with that client. This way the VID can be appended to the packet later, if needed.
This patch adds support for exporting the VID from the client context to the related per-packet maddr object.
--- src/openvpn/mroute.c | 54 +++++++++++++++++++++++++++++++------------- src/openvpn/mroute.h | 11 ++++++--- src/openvpn/multi.c | 3 +++ 3 files changed, 49 insertions(+), 19 deletions(-)
src/openvpn/mroute.c +38 -16
@@ -58,7 +58,7 @@ static inline bool is_mac_mcast_maddr(const struct mroute_addr *addr) {return (addr->type &MR_ADDR_MASK ) ==MR_ADDR_ETHER - &&is_mac_mcast_addr (addr->eth_addr); + &&is_mac_mcast_addr (addr->ether.addr); }/*
@@ -249,12 +249,15 @@ mroute_extract_addr_ip(struct mroute_addr *src, struct mroute_addr *dest,static void mroute_copy_ether_to_addr (struct mroute_addr *maddr, -const uint8_t *ether_addr) +const uint8_t *ether_addr, +uint16_t vid) { maddr->type =MR_ADDR_ETHER ; maddr->netbits =0 ; maddr->len =OPENVPN_ETH_ALEN ; -memcpy (maddr->eth_addr, ether_addr,OPENVPN_ETH_ALEN ); +memcpy (maddr->ether.addr, ether_addr,OPENVPN_ETH_ALEN ); + maddr->len +=sizeof (vid); + maddr->ether.vid = vid; }unsigned int
@@ -262,6 +265,7 @@ mroute_extract_addr_ether(struct mroute_addr *src,struct mroute_addr *dest, struct mroute_addr *esrc, struct mroute_addr *edest, + uint16_t vid, const struct buffer *buf) { unsigned int ret = 0;
@@ -270,11 +274,11 @@ mroute_extract_addr_ether(struct mroute_addr *src,const struct openvpn_ethhdr *eth = (const struct openvpn_ethhdr *)BPTR (buf);if (src) { -mroute_copy_ether_to_addr (src, eth->source); +mroute_copy_ether_to_addr (src, eth->source, vid); }if (dest) { -mroute_copy_ether_to_addr (dest, eth->dest); +mroute_copy_ether_to_addr (dest, eth->dest, vid);/* ethernet broadcast/multicast packet? */ if (is_mac_mcast_addr (eth->dest))
@@ -289,18 +293,35 @@ mroute_extract_addr_ether(struct mroute_addr *src,if (esrc || edest) {struct buffer b = *buf; -if (buf_advance (&b,sizeof (struct openvpn_ethhdr ))) +if (!buf_advance (&b,sizeof (struct openvpn_ethhdr ))) { -switch (ntohs (eth->proto)) - { -case OPENVPN_ETH_P_IPV4 : - ret |= (mroute_extract_addr_ip (esrc, edest, &b) <<MROUTE_SEC_SHIFT ); -break ; +return 0 ; + } -case OPENVPN_ETH_P_ARP : - ret |= (mroute_extract_addr_arp (esrc, edest, &b) <<MROUTE_SEC_SHIFT ); -break ; +uint16_t proto = eth->proto; +if (proto ==htons (OPENVPN_ETH_P_8021Q )) + { +if (!buf_advance (&b,SIZE_ETH_TO_8021Q_HDR )) + { +/* It's an 802.1Q packet, but doesn't have a full header, +* so something went wrong */ +return 0 ; } + +const struct openvpn_8021qhdr *tag; + tag = (const struct openvpn_8021qhdr *)BPTR (buf); + proto = tag->proto; + } + +switch (ntohs (proto)) + { +case OPENVPN_ETH_P_IPV4 : + ret |= (mroute_extract_addr_ip (esrc, edest, &b) <<MROUTE_SEC_SHIFT ); +break ; + +case OPENVPN_ETH_P_ARP : + ret |= (mroute_extract_addr_arp (esrc, edest, &b) <<MROUTE_SEC_SHIFT ); +break ; } }#endif
@@ -444,8 +465,9 @@ mroute_addr_print_ex(const struct mroute_addr *ma,switch (maddr.type &MR_ADDR_MASK ) {case MR_ADDR_ETHER : -buf_printf (&out,"%s" ,format_hex_ex (ma->eth_addr, -sizeof (ma->eth_addr),0 ,1 ,":" , gc)); +buf_printf (&out,"%s" ,format_hex_ex (ma->ether.addr, +sizeof (ma->ether.addr),0 ,1 ,":" , gc)); +buf_printf (&out,"@%hu" , ma->ether.vid);break ;case MR_ADDR_IPV4 :
src/openvpn/mroute.h +8 -3
@@ -82,7 +82,10 @@ struct mroute_addr {* valid if MR_WITH_NETBITS is set */ union {uint8_t raw_addr[MR_MAX_ADDR_LEN ];/* actual address */ -uint8_t eth_addr[OPENVPN_ETH_ALEN ]; +struct { +uint8_t addr[OPENVPN_ETH_ALEN ]; +uint16_t vid; + } ether;struct {in_addr_t addr;/* _network order_ IPv4 address */ in_port_t port;/* _network order_ TCP/UDP port */
@@ -100,7 +103,7 @@ struct mroute_addr {/* Wrappers to support compilers that do not grok anonymous unions */ mroute_union#define raw_addr mroute_union.raw_addr -#define eth_addr mroute_union.eth_addr +#define ether mroute_union.ether#define v4 mroute_union.v4#define v6 mroute_union.v6#define v4mappedv6 mroute_union.v4mappedv6
@@ -178,6 +181,7 @@ unsigned int mroute_extract_addr_ether(struct mroute_addr *src,struct mroute_addr *dest, struct mroute_addr *esrc, struct mroute_addr *edest, + uint16_t vid, const struct buffer *buf);/*
@@ -189,6 +193,7 @@ mroute_extract_addr_from_packet(struct mroute_addr *src,struct mroute_addr *dest, struct mroute_addr *esrc, struct mroute_addr *edest, + uint16_t vid, const struct buffer *buf, int tunnel_type) {
@@ -200,7 +205,7 @@ mroute_extract_addr_from_packet(struct mroute_addr *src, }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, vid, buf); }return ret; }
src/openvpn/multi.c +3 -0
@@ -2570,6 +2570,7 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inst &dest,NULL ,NULL , +0 , &c->c2.to_tun, DEV_TYPE_TUN);
@@ -2664,6 +2665,7 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inst#else NULL , #endif +0 , &c->c2.to_tun, DEV_TYPE_TAP);
@@ -2791,6 +2793,7 @@ multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flagsNULL , #endifNULL , +0 , &m->top.c2.buf, dev_type);
Signature · 1 line
2.23.0
PATCH 4/9 VLAN: filter multicast and client-to-client unicast traffic
In reply to Antonio QuartulliWith this change, client-to-client communications are possible only if clients were configured with the same PVID.
At the same time also broadcast packets are now forwarded only to hosts belonging to the originator VLAN.
--- src/openvpn/multi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
src/openvpn/multi.c +9 -2
@@ -2643,10 +2643,12 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inst }else if (TUNNEL_TYPE (m->top.c1.tuntap) ==DEV_TYPE_TAP ) { +uint16_t vid =0 ;#ifdef ENABLE_PF struct mroute_addr edest;mroute_addr_reset (&edest);#endif +if (m->top.options.vlan_tagging) {if (vlan_is_tagged (&c->c2.to_tun))
@@ -2655,6 +2657,10 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *instmsg (D_VLAN_DEBUG ,"dropping incoming VLAN-tagged frame" ); c->c2.to_tun.len =0 ; } +else + { + vid = c->options.vlan_pvid; + } }/* extract packet source and dest addresses */ mroute_flags = mroute_extract_addr_from_packet(&src,
@@ -2665,7 +2671,7 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inst#else NULL , #endif -0 , + vid, &c->c2.to_tun, DEV_TYPE_TAP);
@@ -2678,7 +2684,8 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inst {if (mroute_flags & (MROUTE_EXTRACT_BCAST |MROUTE_EXTRACT_MCAST )) { -multi_bcast (m, &c->c2.to_tun, m->pending,NULL ,0 ); +multi_bcast (m, &c->c2.to_tun, m->pending,NULL , + vid); }else /* try client-to-client routing */ {
Signature · 1 line
2.23.0
PATCH 5/9 is_ipv_X: add support for parsing IP header inside a 802.1q frame
In reply to Antonio QuartulliExtend is_ipv_X() routine by properly parsing 802.1q frame rather than dropping them.
This change is required in order to allow OpenVPN to accept VLAN tagged frames, which otherwise would be dropped when trying to access the inner IP header.
While at it, slightly fix the function style.
--- src/openvpn/proto.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-)
src/openvpn/proto.c +32 -10
@@ -38,17 +38,17 @@* If raw tunnel packet is IPv<X>, return true and increment * buffer offset to start of IP header. */ -static -bool -is_ipv_X (int tunnel_type,struct buffer *buf,int ip_ver ) +static bool +is_ipv_X (int tunnel_type,struct buffer *buf,int ip_ver) {int offset; +uint16_t proto;const struct openvpn_iphdr *ih;verify_align_4 (buf);if (tunnel_type ==DEV_TYPE_TUN ) { -if (BLEN (buf) < (int )sizeof (struct openvpn_iphdr )) +if (BLEN (buf) <sizeof (struct openvpn_iphdr )) {return false; }
@@ -57,24 +57,46 @@ is_ipv_X( int tunnel_type, struct buffer *buf, int ip_ver )else if (tunnel_type ==DEV_TYPE_TAP ) {const struct openvpn_ethhdr *eh; -if (BLEN (buf) < (int )(sizeof (struct openvpn_ethhdr ) - +sizeof (struct openvpn_iphdr ))) +if (BLEN (buf) < (sizeof (struct openvpn_ethhdr ) + +sizeof (struct openvpn_iphdr ))) {return false; } - eh = (const struct openvpn_ethhdr *)BPTR (buf); -if (ntohs (eh->proto) != (ip_ver ==6 ?OPENVPN_ETH_P_IPV6 :OPENVPN_ETH_P_IPV4 )) + eh = (const struct openvpn_ethhdr *)BPTR (buf); + +/* start by assuming this is a standard Eth fram */ + proto = eh->proto; + offset =sizeof (struct openvpn_ethhdr ); + +/* if this is a 802.1q frame, parse the header using the according +* format +*/ +if (proto ==htons (OPENVPN_ETH_P_8021Q )) + { +const struct openvpn_8021qhdr *evh; +if (BLEN (buf) < (sizeof (struct openvpn_ethhdr ) + +sizeof (struct openvpn_iphdr ))) + { +return false; + } + + evh = (const struct openvpn_8021qhdr *)BPTR (buf); + + proto = evh->proto; + offset =sizeof (struct openvpn_8021qhdr ); + } + +if (ntohs (proto) != (ip_ver ==6 ?OPENVPN_ETH_P_IPV6 :OPENVPN_ETH_P_IPV4 )) {return false; } - offset =sizeof (struct openvpn_ethhdr ); }else {return false; } - ih = (const struct openvpn_iphdr *) (BPTR (buf) + offset); + ih = (const struct openvpn_iphdr *)(BPTR (buf) + offset);/* IP version is stored in the same bits for IPv4 or IPv6 header */ if (OPENVPN_IPH_GET_VER (ih->version_len) == ip_ver)
Signature · 1 line
2.23.0
PATCH 6/9 VLAN: implement support for forwarding only pre-tagged VLAN packets
In reply to Antonio QuartulliBy building on top of the VLAN basic support, allow the user to configure the server in VLAN_TAGGED-only mode. This way, only packets that reach the TAP interface with an 802.1Q header are considered for forwarding - untagged packets are all dropped.
A VLAN-tagged packet is then treated like any other packet by the OpenVPN routing engine, with the exception of being allowed to reach only clients configured with the same VID.
The logic applies to all server-to-client and client-to-client traffic.
--- src/openvpn/multi.c | 16 +++- src/openvpn/options.c | 24 +++++ src/openvpn/options.h | 1 + src/openvpn/vlan.c | 210 ++++++++++++++++++++++++++++++++++++++++++ src/openvpn/vlan.h | 4 + 5 files changed, 252 insertions(+), 3 deletions(-)
src/openvpn/multi.c +13 -3
@@ -2763,6 +2763,7 @@ multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flagsunsigned 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;
@@ -2787,6 +2788,15 @@ multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flagsreturn true; } +if (dev_type ==DEV_TYPE_TAP && m->top.options.vlan_tagging) + { + vid =vlan_decapsulate (&m->top, &m->top.c2.buf); +if (vid <0 ) + { +return false; + } + } +/* * Route an incoming tun/tap packet to * the appropriate multi_instance object.
@@ -2800,7 +2810,7 @@ multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flagsNULL , #endifNULL , -0 , + vid, &m->top.c2.buf, dev_type);
@@ -2813,9 +2823,9 @@ multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flags {/* for now, treat multicast as broadcast */ #ifdef ENABLE_PF -multi_bcast (m, &m->top.c2.buf,NULL , e2,0 ); +multi_bcast (m, &m->top.c2.buf,NULL , e2, vid);#else -multi_bcast (m, &m->top.c2.buf,NULL ,NULL ,0 ); +multi_bcast (m, &m->top.c2.buf,NULL ,NULL , vid);#endif } else
src/openvpn/options.c +24 -0
@@ -406,6 +406,7 @@ static const char usage_message[] =" to its initialization function.\n" #endif"--vlan-tagging : Enable 802.1Q-based VLAN tagging.\n" +"--vlan-accept tagged|untagged : Set VLAN tagging mode.\n" "--vlan-pvid v : Sets the Port VLAN Identifier. Defaults to 1.\n"#if P2MP #if P2MP_SERVER
@@ -1234,6 +1235,8 @@ print_vlan_accept(enum vlan_acceptable_frames mode) {switch (mode) { +case VLAN_ONLY_TAGGED : +return "tagged" ;case VLAN_ONLY_UNTAGGED_OR_PRIORITY :return "untagged" ; }
@@ -2381,6 +2384,10 @@ options_postprocess_verify_ce(const struct options *options, const struct connec }if (!options->vlan_tagging) { +if (options->vlan_accept != defaults.vlan_accept) + { +msg (M_USAGE ,"--vlan-accept requires --vlan-tagging" ); + }if (options->vlan_pvid != defaults.vlan_pvid) {msg (M_USAGE ,"--vlan-pvid requires --vlan-tagging" );
@@ -8400,6 +8407,23 @@ add_option(struct options *options,VERIFY_PERMISSION (OPT_P_GENERAL ); options->vlan_tagging = true; } +else if (streq (p[0 ],"vlan-accept" ) && p[1 ] && !p[2 ]) + { +VERIFY_PERMISSION (OPT_P_GENERAL ); +if (streq (p[1 ],"tagged" )) + { + options->vlan_accept =VLAN_ONLY_TAGGED ; + } +else if (streq (p[1 ],"untagged" )) + { + options->vlan_accept =VLAN_ONLY_UNTAGGED_OR_PRIORITY ; + } +else + { +msg (msglevel,"--vlan-accept must be 'tagged', 'untagged'" ); + goto err; + } + }else if (streq (p[0 ],"vlan-pvid" ) && p[1 ] && !p[2 ]) {VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_INSTANCE );
src/openvpn/options.h +1 -0
@@ -171,6 +171,7 @@ struct remote_listenum vlan_acceptable_frames { +VLAN_ONLY_TAGGED ,VLAN_ONLY_UNTAGGED_OR_PRIORITY , };
src/openvpn/vlan.c +210 -0
222 lines not on this page · raw message
src/openvpn/vlan.h +4 -0
@@ -29,10 +29,14 @@#include "buffer.h" #include "mroute.h" +#include "openvpn.h" struct multi_context ;struct multi_instance ; +int16_t +vlan_decapsulate (const struct context *c,struct buffer *buf); +bool vlan_is_tagged (const struct buffer *buf);
Signature · 1 line
2.23.0
PATCH 7/9 VLAN: allow forwarding tagged and untagged packets on the server TAP device
In reply to Antonio QuartulliThis changes allows the user to configure the server TAP interface to forward both VLAN tagged and untagged packets (i.e. vlan_accept == VLAN_ALL).
Untagged packets are marked with the VID configured in the server configuration file, while tagged packets will keep their header as it is.
Forwarding is then performed following the standard rules, while ensuring that pakcets do not leave the VLAN they belong to.
--- src/openvpn/options.c | 12 +++++++++--- src/openvpn/options.h | 1 + src/openvpn/vlan.c | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-)
src/openvpn/options.c +9 -3
@@ -406,7 +406,7 @@ static const char usage_message[] =" to its initialization function.\n" #endif"--vlan-tagging : Enable 802.1Q-based VLAN tagging.\n" -"--vlan-accept tagged|untagged : Set VLAN tagging mode.\n" +"--vlan-accept tagged|untagged|all : Set VLAN tagging mode. Default is 'all'.\n" "--vlan-pvid v : Sets the Port VLAN Identifier. Defaults to 1.\n"#if P2MP #if P2MP_SERVER
@@ -853,7 +853,7 @@ init_options(struct options *o, const bool init_gc) o->route_method =ROUTE_METHOD_ADAPTIVE ; o->block_outside_dns = false;#endif - o->vlan_accept =VLAN_ONLY_UNTAGGED_OR_PRIORITY ; + o->vlan_accept =VLAN_ALL ; o->vlan_pvid =1 ;#if P2MP_SERVER o->real_hash_size =256 ;
@@ -1239,6 +1239,8 @@ print_vlan_accept(enum vlan_acceptable_frames mode)return "tagged" ;case VLAN_ONLY_UNTAGGED_OR_PRIORITY :return "untagged" ; +case VLAN_ALL : +return "all" ; }return NULL ; }
@@ -8418,9 +8420,13 @@ add_option(struct options *options, { options->vlan_accept =VLAN_ONLY_UNTAGGED_OR_PRIORITY ; } + else if (streq(p[1], "all")) + { + options->vlan_accept =VLAN_ALL ; + } else { -msg (msglevel,"--vlan-accept must be 'tagged', 'untagged'" ); +msg (msglevel,"--vlan-accept must be 'tagged', 'untagged' or 'all'" ); goto err; } }
src/openvpn/options.h +1 -0
@@ -173,6 +173,7 @@ enum vlan_acceptable_frames {VLAN_ONLY_TAGGED ,VLAN_ONLY_UNTAGGED_OR_PRIORITY , + VLAN_ALL, };struct remote_host_store
src/openvpn/vlan.c +17 -0
@@ -74,6 +74,10 @@ vlanhdr_set_vid(struct openvpn_8021qhdr *hdr, const uint16_t vid)* returned. Any included priority information is lost. * If a frame isn't VLAN-tagged, the frame is dropped. * +* For vlan_accept == VLAN_ALL: +* Accepts both VLAN-tagged and untagged (or priority-tagged) frames and +* and handles them as described above. +* * @param c The global context. * @param buf The ethernet frame. * @return Returns -1 if the frame is dropped or the VID if it is accepted.
@@ -133,6 +137,7 @@ vlan_decapsulate(const struct context *c, struct buffer *buf)/* vid == 0 means prio-tagged packet: don't drop and fall-through */ case VLAN_ONLY_TAGGED : +case VLAN_ALL :/* tagged frame can be accepted: extract vid and strip encapsulation */ /* in case of prio-tagged frame (vid == 0), assume the sender
@@ -310,6 +315,18 @@ vlan_process_outgoing_tun(struct multi_context *m, struct multi_instance *mi) mi->context.c2.to_tun.len =0 ; } } +else if (m->top.options.vlan_accept ==VLAN_ALL ) + { +/* Packets either need to be VLAN-tagged or not, depending on the +* packet's originating VID and the port's native VID (PVID). */ + +if (m->top.options.vlan_pvid != mi->context.options.vlan_pvid) + { +/* Packets need to be VLAN-tagged, because the packet's VID does not +* match the port's PVID. */ +vlan_encapsulate (&mi->context, &mi->context.c2.to_tun); + } + }else if (m->top.options.vlan_accept ==VLAN_ONLY_TAGGED ) {/* All packets on the port (the tap device) need to be VLAN-tagged. */
Signature · 1 line
2.23.0
PATCH 8/9 VLAN: add documentation to manpage
In reply to Antonio QuartulliThis patch adds documentation for all the VLAN related knobs.
--- doc/openvpn.8 | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-)
doc/openvpn.8 +98 -1
@@ -3440,7 +3440,8 @@ without needing to restart the server. The following options are legal in a client\-specific context: -.B \-\-push, \-\-push\-reset, \-\-push\-remove, \-\-iroute, \-\-ifconfig\-push, +.B \-\-push, \-\-push\-reset, \-\-push\-remove, \-\-iroute, +.B \-\-ifconfig\-push, \-\-vlan\-pvid and .B \-\-config. .\"*********************************************************
@@ -3860,6 +3861,102 @@ connection is torn down. Not implemented on Windows. .\"********************************************************* +.TP +.B \-\-vlan\-tagging +Server-only option. Turns the OpenVPN server instance into a switch that +understands VLAN\-tagging, based on IEEE 802.1Q. + +The server TAP device and each of the connecting clients is seen as a port of the +switch. All client ports are in untagged mode and the server TAP device is +VLAN-tagged, untagged or accepts both, depending on the +.B \-\-vlan\-accept setting. + +Ethernet frames with a prepended 802.1Q tag are called "tagged". If the VLAN +Identifier (VID) field in such a tag is non-zero, the frame is called +"VLAN\-tagged". If the VID is zero, but the Priority Control Point (PCP) field +is non\-zero, the frame is called "prio\-tagged". If there is no 802.1Q tag, the +frame is "untagged". + +Using the +.B \-\-vlan\-pvid v +option once per client (see \-\-client\-config\-dir), each port can be associated +with a certain VID. Packets +can only be forwarded between ports having the same VID. Therefore, clients +with differing VIDs are completely separated from one\-another, even if +.B \-\-client\-to\-client +is activated. + +The packet filtering takes place in the OpenVPN server. Clients do not +need to have any VLAN tagging configuration. + +The +.B \-\-vlan\-tagging +option is off by default. While turned off, OpenVPN +accepts any Ethernet frame and does not perform any special processing +for VLAN\-tagged packets. + +The option can only be activated in +.B \-\-dev tap mode. + +.\"********************************************************* +.TP +.B \-\-vlan\-accept all | tagged | untagged +Configure the VLAN tagging policy for the server TAP device. The following modes +are available: + +.B tagged +\-\- Admit only VLAN\-tagged frames. +Only VLAN\-tagged packets are accepted, while untagged or priority\-tagged +packets are dropped when entering the server TAP device. + +.br +.B untagged +\-\- Admit only untagged and prio\-tagged frames. +.br +VLAN\-tagged packets are not accepted, while untagged or priority\-tagged +packets entering the server TAP device are tagged with the value configured +for the global +.B \-\-vlan\-pvid +setting. +.br +.B all +(default) \-\- Admit all frames. +.br +All packets are admitted and then treated like untagged or tagged mode +respectively. + +(Note: Some vendors refer to switch ports running in +.B tagged +mode as "trunk ports" and switch ports running in +.B untagged +mode as "access ports".) + +Packets forwarded from clients to the server are VLAN\-tagged +with the originating client's PVID, unless the VID matches the +global \-\-vlan\-pvid, in which case the tag is removed. + +If no PVID is configured for a given client (see \-\-vlan\-pvid) packets +are tagged with 1 by default. +.\"********************************************************* +.TP +.B \-\-vlan\-pvid v +Specifies which VLAN identifier a "port" is associated with. Only valid when +\fB\-\-vlan\-tagging\fR is speficied. + +In the client context, the setting specifies which VLAN ID a client is +associated with. In the global context, the VLAN ID of the server TAP device is set. +The latter only makes sense for +.B \-\-vlan\-accept untagged +and +.B \-\-vlan\-accept all +modes. + +Valid values for +.B v +go from 1 through to 4094. Defaults to 1. + +In some switch implementations, the PVID is also referred to as "Native VLAN". +.\"********************************************************* .SS Client Mode Use client mode when connecting to an OpenVPN server which has
Signature · 1 line
2.23.0
PATCH 9/9 VLAN: allow user to avoid compiling VLAN handling code
In reply to Antonio QuartulliTo handle VLANs a whole lot of code has been introduced. However, there are a number of users who may not need this feature and would rather preserve disk space.
Implement a configure knob (--disable-vlan-tagging) to conditionally take the entire VLAN code out.
This patch introduces the conditional by keeping all the logic/ifdefs in vlan.h and avoid polluting the rest of code (exception made for options.h/c which is really troublesome to deal with).
--- configure.ac | 12 ++++++ src/openvpn/Makefile.am | 5 ++- src/openvpn/mroute.c | 6 +-- src/openvpn/mroute.h | 2 + src/openvpn/multi.c | 10 ++--- src/openvpn/options.c | 15 ++++++++ src/openvpn/options.h | 2 + src/openvpn/vlan.h | 83 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 126 insertions(+), 9 deletions(-)
configure.ac +12 -0
@@ -256,6 +256,13 @@ AC_ARG_ENABLE( [enable_async_push="no"] ) +AC_ARG_ENABLE( + [vlan-tagging], + [AS_HELP_STRING([--disable-vlan-tagging], [Disble support for 802.1Q-based VLAN tagging])], + , + [enable_vlan="yes"] +) + AC_ARG_WITH( [special-build], [AS_HELP_STRING([--with-special-build=STRING], [specify special build string])],
@@ -1321,6 +1328,10 @@ if test "${enable_async_push}" = "yes"; then ) fi +if test "${enable_vlan}" = "yes"; then + AC_DEFINE(ENABLE_VLAN_TAGGING, 1, [Enable 802.1Q-based VLAN tagging/untagging]) +fi + CONFIGURE_DEFINES="`set | grep '^enable_.*=' ; set | grep '^with_.*='`" AC_DEFINE_UNQUOTED([CONFIGURE_DEFINES], ["`echo ${CONFIGURE_DEFINES}`"], [Configuration settings])
@@ -1349,6 +1360,7 @@ AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS]) AC_SUBST([PLUGIN_AUTH_PAM_CFLAGS]) AC_SUBST([PLUGIN_AUTH_PAM_LIBS]) +AM_CONDITIONAL([VLAN_TAGGING], [test "${enable_vlan}" = "yes"]) AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"]) AM_CONDITIONAL([GIT_CHECKOUT], [test "${GIT_CHECKOUT}" = "yes"]) AM_CONDITIONAL([ENABLE_PLUGIN_AUTH_PAM], [test "${enable_plugin_auth_pam}" = "yes"])
src/openvpn/Makefile.am +4 -1
@@ -123,7 +123,7 @@ openvpn_SOURCES = \ syshead.h \ tls_crypt.c tls_crypt.h \ tun.c tun.h \ - vlan.c vlan.h \ + vlan.h \ win32.h win32.c \ cryptoapi.h cryptoapi.c openvpn_LDADD = \
@@ -136,6 +136,9 @@ openvpn_LDADD = \ $(OPTIONAL_SELINUX_LIBS) \ $(OPTIONAL_SYSTEMD_LIBS) \ $(OPTIONAL_DL_LIBS) +if VLAN_TAGGING +openvpn_SOURCES += vlan.c +endif if WIN32 openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt
src/openvpn/mroute.c +3 -3
@@ -35,6 +35,7 @@#include "proto.h" #include "error.h" #include "socket.h" +#include "vlan.h" #include "memdbg.h"
@@ -256,8 +257,7 @@ mroute_copy_ether_to_addr(struct mroute_addr *maddr, maddr->netbits =0 ; maddr->len =OPENVPN_ETH_ALEN ;memcpy (maddr->ether.addr, ether_addr,OPENVPN_ETH_ALEN ); - maddr->len +=sizeof (vid); - maddr->ether.vid = vid; +vlan_maddr_copy_vid (maddr, vid); }unsigned int
@@ -467,7 +467,7 @@ mroute_addr_print_ex(const struct mroute_addr *ma,case MR_ADDR_ETHER :buf_printf (&out,"%s" ,format_hex_ex (ma->ether.addr,sizeof (ma->ether.addr),0 ,1 ,":" , gc)); -buf_printf (&out,"@%hu" , ma->ether.vid); +vlan_maddr_print_vid (&out, ma);break ;case MR_ADDR_IPV4 :
src/openvpn/mroute.h +2 -0
@@ -84,7 +84,9 @@ struct mroute_addr {uint8_t raw_addr[MR_MAX_ADDR_LEN ];/* actual address */ struct {uint8_t addr[OPENVPN_ETH_ALEN ]; +#ifdef ENABLE_VLAN_TAGGING uint16_t vid; +#endif } ether;struct {in_addr_t addr;/* _network order_ IPv4 address */
src/openvpn/multi.c +5 -5
@@ -2260,11 +2260,12 @@ multi_bcast(struct multi_context *m, } }#endif /* ifdef ENABLE_PF */ -if (vid !=0 && vid != mi->context.options.vlan_pvid) +if (!vlan_match_pvid (vid, &mi->context.options)) {continue ; }multi_add_mbuf (m, mi, mb); + } }
@@ -2648,8 +2649,7 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inststruct mroute_addr edest;mroute_addr_reset (&edest);#endif - -if (m->top.options.vlan_tagging) +if (vlan_is_enabled (&m->top.options)) {if (vlan_is_tagged (&c->c2.to_tun)) {
@@ -2659,7 +2659,7 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inst }else { - vid = c->options.vlan_pvid; + vid =vlan_get_pvid (&c->options); } }/* extract packet source and dest addresses */
@@ -2788,7 +2788,7 @@ multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flagsreturn true; } -if (dev_type ==DEV_TYPE_TAP && m->top.options.vlan_tagging) +if (dev_type ==DEV_TYPE_TAP &&vlan_is_enabled (&m->top.options)) { vid =vlan_decapsulate (&m->top, &m->top.c2.buf);if (vid <0 )
src/openvpn/options.c +15 -0
@@ -405,9 +405,11 @@ static const char usage_message[] ="--plugin m [str]: Load plug-in module m passing str as an argument\n" " to its initialization function.\n"#endif +#ifdef ENABLE_VLAN_TAGGING "--vlan-tagging : Enable 802.1Q-based VLAN tagging.\n" "--vlan-accept tagged|untagged|all : Set VLAN tagging mode. Default is 'all'.\n" "--vlan-pvid v : Sets the Port VLAN Identifier. Defaults to 1.\n" +#endif /* ifdef ENABLE_VLAN_TAGGING */ #if P2MP #if P2MP_SERVER "\n"
@@ -853,8 +855,10 @@ init_options(struct options *o, const bool init_gc) o->route_method =ROUTE_METHOD_ADAPTIVE ; o->block_outside_dns = false;#endif +#ifdef ENABLE_VLAN_TAGGING o->vlan_accept =VLAN_ALL ; o->vlan_pvid =1 ; +#endif /* ifdef ENABLE_VLAN_TAGGING */ #if P2MP_SERVER o->real_hash_size =256 ; o->virtual_hash_size =256 ;
@@ -1230,6 +1234,7 @@ dhcp_option_address_parse(const char *name, const char *parm, in_addr_t *array,#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ +#ifdef ENABLE_VLAN_TAGGING static const char *print_vlan_accept (enum vlan_acceptable_frames mode) {
@@ -1244,6 +1249,7 @@ print_vlan_accept(enum vlan_acceptable_frames mode) }return NULL ; } +#endif /* ifdef ENABLE_VLAN_TAGGING */ #if P2MP
@@ -1314,9 +1320,11 @@ show_p2mp_parms(const struct options *o)SHOW_STR (port_share_host);SHOW_STR (port_share_port);#endif +#ifdef ENABLE_VLAN_TAGGING SHOW_BOOL (vlan_tagging);msg (D_SHOW_PARMS ," vlan_accept = %s" ,print_vlan_accept (o->vlan_accept));SHOW_INT (vlan_pvid); +#endif /* ifdef ENABLE_VLAN_TAGGING */ #endif /* P2MP_SERVER */ SHOW_BOOL (client);
@@ -2380,6 +2388,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec } } +#ifdef ENABLE_VLAN_TAGGING if (options->vlan_tagging && dev !=DEV_TYPE_TAP ) {msg (M_USAGE ,"--vlan-tagging must be used with --dev tap" );
@@ -2395,6 +2404,8 @@ options_postprocess_verify_ce(const struct options *options, const struct connec msg(M_USAGE, "--vlan-pvid requires --vlan-tagging"); } } +#endif /* ifdef ENABLE_VLAN_TAGGING */ + }else {
@@ -2485,10 +2496,12 @@ options_postprocess_verify_ce(const struct options *options, const struct connec msg(M_USAGE, "--stale-routes-check requires --mode server"); } +#ifdef ENABLE_VLAN_TAGGING if (options->vlan_tagging) {msg (M_USAGE ,"--vlan-tagging requires --mode server" ); } +#endif /* ifdef ENABLE_VLAN_TAGGING */ }#endif /* P2MP_SERVER */
@@ -8404,6 +8417,7 @@ add_option(struct options *options,VERIFY_PERMISSION (OPT_P_GENERAL ); options->allow_recursive_routing = true; } +#ifdef ENABLE_VLAN_TAGGING else if (streq(p[0], "vlan-tagging") && !p[1]) {VERIFY_PERMISSION (OPT_P_GENERAL );
@@ -8443,6 +8457,7 @@ add_option(struct options *options, goto err; } } +#endif /* ifdef ENABLE_VLAN_TAGGING */ else {int i;
src/openvpn/options.h +2 -0
@@ -639,9 +639,11 @@ struct optionsint keying_material_exporter_length;#endif +#ifdef ENABLE_VLAN_TAGGING bool vlan_tagging;enum vlan_acceptable_frames vlan_accept;uint16_t vlan_pvid; +#endif /* ifdef ENABLE_VLAN_TAGGING */ struct pull_filter_list *pull_filter_list;
src/openvpn/vlan.h +83 -0
100 lines not on this page · raw message
Signature · 1 line
2.23.0
[Openvpn-devel] [PATCH applied] Re: maddr: create helper function to populate maddr object from eth_addr
In reply to Antonio QuartulliThis is one of the easy ones, and very "obviously correct". Client side tested on Linux and FreeBSD with t_client / TAP tests (which do not really excercise this code, unfortunately, but my test server is still down).
While I do prefer memcpy()'s using "sizeof(dest)" to "OPENVPN_ETH_ALEN", mroute.eth_addr is "uint8_t[OPENVPN_ETH_ALEN]" so this is safe enough.
Your patch has been applied to the master branch.
commit 5e27e47d631f61ee3f9234dd076389232495e714
Author: Antonio Quartulli Date: Wed Oct 9 16:34:14 2019 +0200
maddr: create helper function to populate maddr object from eth_addr
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg18921.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: VLAN: add basic VLAN tagging support
In reply to Antonio QuartulliStared at the code (twice now), run t_client and t_server tests.
This patch does not really *do* much yet, but it lays the groundwork for future work - the "broadcast only to clients in the same vlan" part is there, but it's always called with "0" (= all clients). As far as I can see, the only notable behavioural change we have so far is "if a client is assigned a pvid (!= the global pvid), it will not be able to communicate with the TAP interface" (check in vlan.c, vlan_process_outgoing_tun()), but client-to-client is still allowed, and there is no per-vlan MAC learning yet either.
(Most notably, it only adds options and code relevant for TAP mode)
Your patch has been applied to the master branch.
commit 99f28081477ca325a14b13c38abec2c9b619eb01
Author: Antonio Quartulli Date: Wed Oct 9 16:34:15 2019 +0200
VLAN: add basic VLAN tagging support
Signed-off-by: Fabian Knittel <[email protected]...>
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg18924.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: maddr: export VLAN ID from client context to maddr object
In reply to Antonio QuartulliStared at the code, ran client side tests, full set of server side tests, and compiled (+client tested) on FreeBSD 7.4 to give the "anonymous union explosion" bits a good checking :-) (it does not explode anymore, thanks for fixing that).
Similar to 2/9, this patch does not actually change behaviour yet - it adds the 2-byte vid to the hashed ethernet address for per-client learning, but as all callers set it to "0", there is no "vlan separation" effect yet (I know it's coming in a future patch, just pointing out why this patch does not change visible behaviour yet).
It shows up in the "MULTI: Learn" lines already, though
Nov 6 22:04:51 gentoo tap-udp-p2mp[11510]: freebsd-11-amd64/2001:608:0:814::f000:16 MULTI: Learn: 00:bd:b5:63:b5:[email protected]... -> freebsd-11-amd64/2001:608:0:814::f000:16
.. the "@0" bit after the MAC address is the PVID.
As a side note: it seems that whoever did the IPv6 payload patches was a bit sloppy (it was me, so I am allowed to say that). MAC learning is only done on IPv4 and ARP packets, but not on IPv6 packets - so I expect "ipv6 only mode on tap" to be a bit wacky... this needs re-testing before we can declare "ipv6-only works reliably".
Your patch has been applied to the master branch.
commit a2b7230712dbc8cfab85d5bd59605f58fc5fe5f8
Author: Antonio Quartulli Date: Wed Oct 9 16:34:16 2019 +0200
maddr: export VLAN ID from client context to maddr object
Signed-off-by: Fabian Knittel <[email protected]...>
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg18917.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Re: [Openvpn-devel] [PATCH applied] Re: maddr: export VLAN ID from client context to maddr object
Hi,
Quoted 5 lines · Gert Doering
As a side note: it seems that whoever did the IPv6 payload patches was a bit sloppy (it was me, so I am allowed to say that). MAC learning is only done on IPv4 and ARP packets, but not on IPv6 packets - so I expect "ipv6 only mode on tap" to be a bit wacky... this needs re-testing before we can declare "ipv6-only works reliably".
I was wrong here. This part is only for the extraction of the "inner" addresses in an tap/ethernet packet, which are then subsequently used for ENABLE_PF filtering.
Since *that* only has IPv4 (because nobody reviewed and ACKed Antonio's "make PF support IPv6" patches yet) it makes sense that the code only extract IPv4 addresses.
Now, I see a slight merge conflict with the PF/IPv6 patch set... :-)
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...Re: [Openvpn-devel] [PATCH applied] Re: VLAN: add basic VLAN tagging support
In reply to Gert DoeringThis broke (again) Visual Studio build:
Quoted 1 line
error LNK2019: unresolved external symbol
vlan_process_outgoing_tun
referenced in function multi_process_outgoing_tun
Can we please ack and merge this patch
https://patchwork.openvpn.net/patch/868/ to catch these things earlier?
ke 6. marrask. 2019 klo 22.42 Gert Doering ([email protected]...) kirjoitti:
Quoted 44 lines
Acked-by Gert Doering <[email protected]...>Stared at the code (twice now), run
t_clientandt_servertests.This patch does not really *do* much yet, but it lays the groundwork for future work - the "broadcast only to clients in the same vlan" part is there, but it's always called with "0" (= all clients). As far as I can see, the only notable behavioural change we have so far is "if a client is assigned a pvid (!= the global pvid), it will not be able to communicate with the TAP interface" (check in
vlan.c,vlan_process_outgoing_tun()), but client-to-client is still allowed, and there is no per-vlan MAC learning yet either.(Most notably, it only adds options and code relevant for TAP mode)
Your patch has been applied to the master branch.
commit
99f28081477ca325a14b13c38abec2c9b619eb01Author: Antonio Quartulli Date: Wed Oct 9 16:34:15 2019 +0200VLAN: add basic VLAN tagging support Signed-off-by: Fabian Knittel <[email protected]...> Signed-off-by: Antonio Quartulli <[email protected]...> Acked-by: Gert Doering <[email protected]...> Message-Id: <[email protected]...> URL: https://www.mail-archive.com/[email protected]/msg18924.html Signed-off-by: Gert Doering <[email protected]...>--
kind regards,Gert Doering
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Signature · 1 line
-Lev
Re: [Openvpn-devel] [PATCH applied] Re: VLAN: add basic VLAN tagging support
Hi,
Quoted 4 lines · Lev Stipakov
This broke (again) Visual Studio build:
Quoted 1 line
error LNK2019: unresolved external symbol
vlan_process_outgoing_tunreferenced in function
multi_process_outgoing_tun
Can you please send a patch that adds vlan.c to the list of source code modules to be compiled and linked?
Quoted 2 lines
Can we please ack and merge this patch
https://patchwork.openvpn.net/patch/868/ to catch these things earlier?
I'm a bit unhappy with that one, as it changes behaviour for all non-windows builds (including all the openssl build output even if it succeeds).
Besides this, we need to fix this whole MSVC mess - all other platforms are just done with "add new source file to the Makefile.ac" and done (including mingw builds), and then MSVC is broken again, and this will happen again and again.
Is there no reasonable way to build these project files from Makefile.ac?
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...Re: [Openvpn-devel] [PATCH applied] Re: VLAN: add basic VLAN tagging support
Hi,
Quoted 4 lines
I'm a bit unhappy with that one, as it changes behaviour for all non-windows
builds (including all the openssl build output even if it succeeds).
The only place it changes behavior is this
install:
- if [ ! -z "${CHOST}" ]; then unset CC; fi
- - .travis/build-deps.sh > build-deps.log 2>&1 || (cat build-deps.log && exit 1)
+ - .travis/build-deps.sh
I don't see it as an issue to print output when building dependencies. The reason why
it is done is that travis aborts build if there is no output for more than 10 minutes.
Quoted 8 lines
Besides this, we need to fix this whole MSVC mess - all other platforms are just done with "add new source file to the Makefile.ac" and done (including mingw builds), and then MSVC is broken again, and this will happen again and again.
Is there no reasonable way to build these project files from Makefile.ac?
I see no reasonable way. Selva, Simon - opinions?
We could probably have a templatized project file and script which inserts source files to there
based on content of Makefile.ac, but I don't like it. I consider necessity of modifying VS project
a lesser evil.
(you open it and it just works)
-Lev
Re: [Openvpn-devel] [PATCH applied] Re: VLAN: add basic VLAN tagging support
Hi,
Quoted 12 lines · Lev Stipakov
Quoted 3 lines
I'm a bit unhappy with that one, as it changes behaviour for all non-windows
builds (including all the openssl build output even if it succeeds).The only place it changes behavior is this
install:
- if [ ! -z "${CHOST}" ]; then unset CC; fi
- -.travis/build-deps.sh> build-deps.log 2>&1 || (cat build-deps.log && exit 1)
+ -.travis/build-deps.sh
Quoted 4 lines
I don't see it as an issue to print output when building dependencies. The reason why
it is done is that travis aborts build if there is no output for more than 10 minutes.
It's lots of text that is totally uninteresting if it succeeds, but that you need to scroll over when looking for the reason why a build fails - which is the reason why it is the way it is today.
[..]
Quoted 6 lines
We could probably have a templatized project file and script which inserts source files to there
based on content of Makefile.ac, but I don't like it. I consider necessity of modifying VS project a lesser evil.(you open it and it just works)
I'm not taking responsibility for not breaking MSVC builds. This is a world alien to me - if you want me to not break things, it needs to be "without fiddling XML files".
If you volunteer to update MSVC every time we add or change a source file, I'm happy to send you a HEADS UP notice. But I am not doing it, and I will not request it from any contributor who is not using windows.
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...Re: [Openvpn-devel] [PATCH applied] Re: VLAN: add basic VLAN tagging support
In reply to Lev StipakovWe could introduce a master.c file which would include:
#include "argv.c"
#include "auth_token.c"
#include "base64.c"
#include "block_dns.c"
#include "buffer.c"
.
.
.
#include "status.c"
#include "tls_crypt.c"
#include "tun.c"
#include "win32.c"
And then have Makefile.ac and MSVC project files compile the master.c only.
Best regards,
Simon
Besides this, we need to fix this whole MSVC mess - all other platforms are just done with "add new source file to the Makefile.ac" and done (including mingw builds), and then MSVC is broken again, and this will happen again and again.
Is there no reasonable way to build these project files from Makefile.ac?
I see no reasonable way. Selva, Simon - opinions?
We could probably have a templatized project file and script which inserts source files to there
based on content of Makefile.ac, but I don't like it. I consider necessity of modifying VS project
a lesser evil.
(you open it and it just works)
-Lev
PATCH 1/1 msvc: Add vlan.c/h
In reply to Gert DoeringThis upgrades 99f28081477ca325a14b13c38abec2c9b619eb01 to support MSVC building.
--- src/openvpn/openvpn.vcxproj | 2 ++ src/openvpn/openvpn.vcxproj.filters | 6 ++++++ 2 files changed, 8 insertions(+)
src/openvpn/openvpn.vcxproj +2 -0
@@ -196,6 +196,7 @@ <ClCompile Include="status.c" /> <ClCompile Include="tls_crypt.c" /> <ClCompile Include="tun.c" /> + <ClCompile Include="vlan.c" /> <ClCompile Include="win32.c" /> </ItemGroup> <ItemGroup>
@@ -283,6 +284,7 @@ <ClInclude Include="syshead.h" /> <ClInclude Include="tls_crypt.h" /> <ClInclude Include="tun.h" /> + <ClInclude Include="vlan.h" /> <ClInclude Include="win32.h" /> </ItemGroup> <ItemGroup>
src/openvpn/openvpn.vcxproj.filters +6 -0
@@ -237,6 +237,9 @@ <ClCompile Include="auth_token.c"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="vlan.c"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="base64.h">
@@ -494,6 +497,9 @@ <ClInclude Include="auth_token.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="vlan.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ResourceCompile Include="openvpn_win32_resources.rc">
Signature · 1 line
2.23.0.windows.1
Re: [Openvpn-devel] [PATCH applied] Re: VLAN: add basic VLAN tagging support
In reply to Lev StipakovHi,
Quoted 16 lines · Lev Stipakov
Hi,
Quoted 4 lines
I'm a bit unhappy with that one, as it changes behaviour for all non-windows
builds (including all the openssl build output even if it succeeds).The only place it changes behavior is this
install:
- if [ ! -z "${CHOST}" ]; then unset CC; fi
- -.travis/build-deps.sh> build-deps.log 2>&1 || (cat build-deps.log && exit 1)
+ -.travis/build-deps.sh
Quoted 5 lines
I don't see it as an issue to print output when building dependencies. The reason why
it is done is that travis aborts build if there is no output for more than 10 minutes.
Can travis be instructed to wait longer ?
Re: [Openvpn-devel] [PATCH] msvc: Add vlan.c/h
In reply to Simon Rozmanto 7. marrask. 2019 klo 15.30 Simon Rozman ([email protected]...) kirjoitti:
Quoted 64 lines
This upgrades
99f28081477ca325a14b13c38abec2c9b619eb01to support MSVC building.Signed-off-by Simon Rozman <[email protected]...>--- src/openvpn/openvpn.vcxproj | 2 ++ src/openvpn/openvpn.vcxproj.filters | 6 ++++++ 2 files changed, 8 insertions(+)src/openvpn/openvpn.vcxproj +2
-0@@ -196,6 +196,7 @@ <ClCompile Include="status.c" /> <ClCompile Include="tls_crypt.c" /> <ClCompile Include="tun.c" /> + <ClCompile Include="vlan.c" /> <ClCompile Include="win32.c" /> </ItemGroup> <ItemGroup>@@ -283,6 +284,7 @@ <ClInclude Include="syshead.h" /> <ClInclude Include="tls_crypt.h" /> <ClInclude Include="tun.h" /> + <ClInclude Include="vlan.h" /> <ClInclude Include="win32.h" /> </ItemGroup> <ItemGroup>src/openvpn/openvpn.vcxproj.filters +6
-1@@ -237,6 +237,9 @@ <ClCompile Include="auth_token.c"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="vlan.c"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="base64.h">@@ -494,6 +497,9 @@ <ClInclude Include="auth_token.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="vlan.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ResourceCompile Include="openvpn_win32_resources.rc"> --2.23.0.windows.1
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Signature · 1 line
-Lev
Re: [Openvpn-devel] [PATCH applied] Re: VLAN: add basic VLAN tagging support
In reply to Simon RozmanI revoke this “master.c” idea. It makes incremental compiling ridiculously slow. It might work for production builds, but definitely not for development.
Best regards,
Simon
From: Simon Rozman [mailto:[email protected]...]
Sent: Thursday, November 7, 2019 2:06 PM
To: 'Lev Stipakov' <[email protected]...>; 'Gert Doering' <[email protected]...>
Cc: 'Antonio Quartulli' <[email protected]...>; 'openvpn-devel' <[email protected]>
Subject: Re: [Openvpn-devel] [PATCH applied] Re: VLAN: add basic VLAN tagging support
We could introduce a master.c file which would include:
#include "argv.c"
#include "auth_token.c"
#include "base64.c"
#include "block_dns.c"
#include "buffer.c"
.
.
.
#include "status.c"
#include "tls_crypt.c"
#include "tun.c"
#include "win32.c"
And then have Makefile.ac and MSVC project files compile the master.c only.
Best regards,
Simon
Besides this, we need to fix this whole MSVC mess - all other platforms are just done with "add new source file to the Makefile.ac" and done (including mingw builds), and then MSVC is broken again, and this will happen again and again.
Is there no reasonable way to build these project files from Makefile.ac?
I see no reasonable way. Selva, Simon - opinions?
We could probably have a templatized project file and script which inserts source files to there
based on content of Makefile.ac, but I don't like it. I consider necessity of modifying VS project
a lesser evil.
(you open it and it just works)
-Lev
Re: [Openvpn-devel] [PATCH applied] Re: VLAN: add basic VLAN tagging support
Hi,
Quoted 1 line · Simon Rozman
I revoke this “master.c” idea. It makes incremental compiling ridiculously slow. It might work for production builds, but definitely not for development.
It also breaks scoping of variables/function. So, I am glad you found your own reason to reject that :-)
Signature · 1 line
Antonio Quartulli
[Openvpn-devel] [PATCH applied] Re: msvc: Add vlan.c/h
In reply to Simon RozmanThanks!
Your patch has been applied to the master branch.
commit 2b11e57c02b2d21e384a2fc860feeeeea1209f55
Author: Simon Rozman Date: Thu Nov 7 14:29:01 2019 +0100
msvc: Add vlan.c/h
Signed-off-by: Simon Rozman <[email protected]...>
Acked-by: Lev Stipakov <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg19015.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Re: [Openvpn-devel] [PATCH applied] Re: VLAN: add basic VLAN tagging support
In reply to Lev StipakovHi
Quoted 28 lines · Lev Stipakov
Hi,
Quoted 4 lines
I'm a bit unhappy with that one, as it changes behaviour for all non-windows
builds (including all the openssl build output even if it succeeds).The only place it changes behavior is this
install:
- if [ ! -z "${CHOST}" ]; then unset CC; fi
- -.travis/build-deps.sh> build-deps.log 2>&1 || (cat build-deps.log && exit 1)
+ -.travis/build-deps.shI don't see it as an issue to print output when building dependencies. The reason why
it is done is that travis aborts build if there is no output for more than 10 minutes.Quoted 4 lines
Besides this, we need to fix this whole MSVC mess - all other platforms are just done with "add new source file to the Makefile.ac" and done (including mingw builds), and then MSVC is broken again, and this will happen again and again.
Quoted 5 lines
Quoted 2 lines
Is there no reasonable way to build these project files from Makefile.ac?
I see no reasonable way. Selva, Simon - opinions?
Personally, I come from the Unix world, work on Windows only out of necessity, and either avoid MSVC or leave it to others to figure out as far as possible. So my opinion may not count for much.
That said, short of moving to a more Windows-friendly build system such as CMake, I see no good options. But the status quo looks good enough to me -- i.e., just do a patch to fix the project files when you notice a missing entry.
Selva
[Openvpn-devel] [PATCH applied] Re: VLAN: filter multicast and client-to-client unicast traffic
In reply to Antonio QuartulliYour patch has been applied to the master branch.
Stared at the code, did quite a bit of testing, found interesting effects.
What this patch does is "client-to-client isolation according to pvid" (so if you have clients with "vlan-pvid 200" in their ccd/ file, and other clients with "vlan-pvid 207", only those with the same ID can talk to each other). This is as desired.
What it also does is completely break TAP-to-client communication if "--vlan-tagging" is enabled - broadcasts ("...incoming_tun()") are broadcasted everywhere, but unicast packets are never delivered as they are looked up with a dst PVID of "0" while the "...incoming_link()" part has learned then with the correct per-client pvid (defaulting to "@1"). The necessary adjustments for this are coming in a later patch in the series, but it makes testing individual bits a bit more complex (I hacked multi.c to use a non-0 server pvid and that made tap<->client work again, so the basics are sound).
If --vlan-tagging is disabled, all tests pass. So this is not breaking existing functionality, just not adding all required new bits yet.
(And it's not touching any non-TAP code paths anyway)
commit 1c57ea76a256330314d53999bce3e09644b420f9
Author: Antonio Quartulli Date: Wed Oct 9 16:34:17 2019 +0200
VLAN: filter multicast and client-to-client unicast traffic
Signed-off-by: Fabian Knittel <[email protected]...>
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg18922.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Re: [Openvpn-devel] [PATCH applied] Re: VLAN: add basic VLAN tagging support
In reply to Gert DoeringHi,
It's lots of text that is totally uninteresting if it succeeds, but that
Quoted 3 lines
you need to scroll over when looking for the reason why a build fails - which is the reason why it is the way it is today.
I have sent v2 which doesn't change the behavior for non-Windows builds.
If you volunteer to update MSVC every time we add or change a source file,
Quoted 3 lines
I'm happy to send you a HEADS UP notice. But I am not doing it, and I will not request it from any contributor who is not using windows.
All right, that would work for me. We don't add C files that often, I could take care
of fixing Visual Studio build after getting a mail from travis / buildbot (when we'll have MSVC there).
v2: https://patchwork.openvpn.net/patch/886/
happy travis: https://travis-ci.org/lstipakov/openvpn/builds/608949725
Signature · 1 line
-Lev
[Openvpn-devel] [PATCH applied] Re: is_ipv_X: add support for parsing IP header inside a 802.1q frame
In reply to Antonio QuartulliStared at code, and ran the full t_client/t_server test suite, but mostly for completeness. Since we do not have tagged packets yet (with the appropriate ether type), this code does not change anything.
Again, only TAP code paths are touched.
Your patch has been applied to the master branch.
commit def3f32d216d16c3bf5a203a2162256203686a34
Author: Antonio Quartulli Date: Wed Oct 9 16:34:18 2019 +0200
is_ipv_X: add support for parsing IP header inside a 802.1q frame
Signed-off-by: Fabian Knittel <[email protected]...>
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg18916.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH v2 8/9 VLAN: add documentation to manpage
In reply to Antonio QuartulliThis patch adds documentation for all the VLAN related knobs.
---
Changes from v1:
- slight rewording of some sentences, as suggested by Arne
doc/openvpn.8 | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-)
doc/openvpn.8 +98 -1
@@ -3440,7 +3440,8 @@ without needing to restart the server. The following options are legal in a client\-specific context: -.B \-\-push, \-\-push\-reset, \-\-push\-remove, \-\-iroute, \-\-ifconfig\-push, +.B \-\-push, \-\-push\-reset, \-\-push\-remove, \-\-iroute, +.B \-\-ifconfig\-push, \-\-vlan\-pvid and .B \-\-config. .\"*********************************************************
@@ -3908,6 +3909,102 @@ connection is torn down. Not implemented on Windows. .\"********************************************************* +.TP +.B \-\-vlan\-tagging +Server-only option. Turns the OpenVPN server instance into a switch that +understands VLAN\-tagging, based on IEEE 802.1Q. + +The server TAP device and each of the connecting clients is seen as a port of the +switch. All client ports are in untagged mode and the server TAP device is +VLAN-tagged, untagged or accepts both, depending on the +.B \-\-vlan\-accept setting. + +Ethernet frames with a prepended 802.1Q tag are called "tagged". If the VLAN +Identifier (VID) field in such a tag is non-zero, the frame is called +"VLAN\-tagged". If the VID is zero, but the Priority Control Point (PCP) field +is non\-zero, the frame is called "prio\-tagged". If there is no 802.1Q tag, the +frame is "untagged". + +Using the +.B \-\-vlan\-pvid v +option once per client (see \-\-client\-config\-dir), each port can be associated +with a certain VID. Packets +can only be forwarded between ports having the same VID. Therefore, clients +with differing VIDs are completely separated from one\-another, even if +.B \-\-client\-to\-client +is activated. + +The packet filtering takes place in the OpenVPN server. Clients should not +have any VLAN tagging configuration applied. + +The +.B \-\-vlan\-tagging +option is off by default. While turned off, OpenVPN +accepts any Ethernet frame and does not perform any special processing +for VLAN\-tagged packets. + +The option can only be activated in +.B \-\-dev tap mode. + +.\"********************************************************* +.TP +.B \-\-vlan\-accept all | tagged | untagged +Configure the VLAN tagging policy for the server TAP device. The following modes +are available: + +.B tagged +\-\- Admit only VLAN\-tagged frames. +Only VLAN\-tagged packets are accepted, while untagged or priority\-tagged +packets are dropped when entering the server TAP device. + +.br +.B untagged +\-\- Admit only untagged and prio\-tagged frames. +.br +VLAN\-tagged packets are not accepted, while untagged or priority\-tagged +packets entering the server TAP device are tagged with the value configured +for the global +.B \-\-vlan\-pvid +setting. +.br +.B all +(default) \-\- Admit all frames. +.br +All packets are admitted and then treated like untagged or tagged mode +respectively. + +(Note: Some vendors refer to switch ports running in +.B tagged +mode as "trunk ports" and switch ports running in +.B untagged +mode as "access ports".) + +Packets forwarded from clients to the server are VLAN\-tagged +with the originating client's PVID, unless the VID matches the +global \-\-vlan\-pvid, in which case the tag is removed. + +If no PVID is configured for a given client (see \-\-vlan\-pvid) packets +are tagged with 1 by default. +.\"********************************************************* +.TP +.B \-\-vlan\-pvid v +Specifies which VLAN identifier a "port" is associated with. Only valid when +\fB\-\-vlan\-tagging\fR is speficied. + +In the client context, the setting specifies which VLAN ID a client is +associated with. In the global context, the VLAN ID of the server TAP device is set. +The latter only makes sense for +.B \-\-vlan\-accept untagged +and +.B \-\-vlan\-accept all +modes. + +Valid values for +.B v +go from 1 through to 4094. Defaults to 1. + +In some switch implementations, the PVID is also referred to as "Native VLAN". +.\"********************************************************* .SS Client Mode Use client mode when connecting to an OpenVPN server which has
Signature · 1 line
2.24.0
[Openvpn-devel] [PATCH applied] Re: VLAN: implement support for forwarding only pre-tagged VLAN packets
In reply to Antonio QuartulliStared at the code. Ran a full set of t_client/t_server tests with disabled VLAN tagging (no change, no brokenness).
With enabled VLAN tagging and using "untagged mode" it now correctly sorts out packets tap <-> client and client1 <-> client2 according to PVID - if PVIDs match, devices can talk and broadcasts are seen, and if they do not match, no communication happens. Great.
One bug for the upcoming documentation: if there is *no* "vlan-pvid" setting in a ccd/ file, it will not use "1" but the "global vlan-pvid" setting. Which, as we just agreed on, makes sense, just needs to be documented.
If enabling "tagging only" ("vlan-accept tagged") half the openvpn server config stops having a meaning - like "ifconfig" or "ifconfig-pool" - so you really want tap devices that are setup outside of OpenVPN or by means of a --up script (setting up dot1q subinterfaces, ifconfig, set up routes, etc.). Just pointing this out for the sake of the archives.
For reference: this is what you'd do on Linux to set up VLAN subinterfaces (vlan 200 on tap9)
# modprobe 8021q # ip link add link tap9 name tap9.200 type vlan id 200 # ip addr add 10.204.4.1/24 dev tap9.200 # ip addr add fd00:abcd:204:4::1/64 dev tap9.200 # ip link set up dev tap9.200
(openvpn running on "--dev tap9")
That said, tagged mode works nicely - client packets are sent to tap0 with "vlan 207" visible in tcpdump, and linux "tap9.207" picks them up correctly and clients can talk. Clients in a different VLAN show up with a different vlan tag, etc. - as one would expect. If you want "clients in vlan 200" to talk to "clients in vlan 207", it needs to be done with linux routing between "tap9.200" and "tap9.207" - which I did test, and it also works as expected.
Full set of t_server test passed with enabled vlan tagging (rearranging tap clients into different vlans and adding IP forwarding etc)
Your patch has been applied to the master branch.
commit e375a5ce555a66c8b6b2ac2869977e723a65982f
Author: Antonio Quartulli Date: Wed Oct 9 16:34:19 2019 +0200
VLAN: implement support for forwarding only pre-tagged VLAN packets
Signed-off-by: Fabian Knittel <[email protected]...>
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg18918.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
PATCH v3 8/9 VLAN: add documentation to manpage
In reply to Antonio QuartulliThis patch adds documentation for all the VLAN related knobs.
---
Changes from v1:
- slight rewording of some sentences, as suggested by Arne
Changes from v2:
- slight rewording of some sentences, as suggested by Gert
doc/openvpn.8 | 100 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-)
doc/openvpn.8 +99 -1
@@ -3440,7 +3440,8 @@ without needing to restart the server. The following options are legal in a client\-specific context: -.B \-\-push, \-\-push\-reset, \-\-push\-remove, \-\-iroute, \-\-ifconfig\-push, +.B \-\-push, \-\-push\-reset, \-\-push\-remove, \-\-iroute, +.B \-\-ifconfig\-push, \-\-vlan\-pvid and .B \-\-config. .\"*********************************************************
@@ -3908,6 +3909,103 @@ connection is torn down. Not implemented on Windows. .\"********************************************************* +.TP +.B \-\-vlan\-tagging +Server-only option. Turns the OpenVPN server instance into a switch that +understands VLAN\-tagging, based on IEEE 802.1Q. + +The server TAP device and each of the connecting clients is seen as a port of the +switch. All client ports are in untagged mode and the server TAP device is +VLAN-tagged, untagged or accepts both, depending on the +.B \-\-vlan\-accept setting. + +Ethernet frames with a prepended 802.1Q tag are called "tagged". If the VLAN +Identifier (VID) field in such a tag is non-zero, the frame is called +"VLAN\-tagged". If the VID is zero, but the Priority Control Point (PCP) field +is non\-zero, the frame is called "prio\-tagged". If there is no 802.1Q tag, the +frame is "untagged". + +Using the +.B \-\-vlan\-pvid v +option once per client (see \-\-client\-config\-dir), each port can be associated +with a certain VID. Packets +can only be forwarded between ports having the same VID. Therefore, clients +with differing VIDs are completely separated from one\-another, even if +.B \-\-client\-to\-client +is activated. + +The packet filtering takes place in the OpenVPN server. Clients should not +have any VLAN tagging configuration applied. + +The +.B \-\-vlan\-tagging +option is off by default. While turned off, OpenVPN +accepts any Ethernet frame and does not perform any special processing +for VLAN\-tagged packets. + +The option can only be activated in +.B \-\-dev tap mode. + +.\"********************************************************* +.TP +.B \-\-vlan\-accept all | tagged | untagged +Configure the VLAN tagging policy for the server TAP device. The following modes +are available: + +.B tagged +\-\- Admit only VLAN\-tagged frames. +Only VLAN\-tagged packets are accepted, while untagged or priority\-tagged +packets are dropped when entering the server TAP device. + +.br +.B untagged +\-\- Admit only untagged and prio\-tagged frames. +.br +VLAN\-tagged packets are not accepted, while untagged or priority\-tagged +packets entering the server TAP device are tagged with the value configured +for the global +.B \-\-vlan\-pvid +setting. +.br +.B all +(default) \-\- Admit all frames. +.br +All packets are admitted and then treated like untagged or tagged mode +respectively. + +(Note: Some vendors refer to switch ports running in +.B tagged +mode as "trunk ports" and switch ports running in +.B untagged +mode as "access ports".) + +Packets forwarded from clients to the server are VLAN\-tagged +with the originating client's PVID, unless the VID matches the +global \-\-vlan\-pvid, in which case the tag is removed. + +If no PVID is configured for a given client (see \-\-vlan\-pvid) packets +are tagged with 1 by default. +.\"********************************************************* +.TP +.B \-\-vlan\-pvid v +Specifies which VLAN identifier a "port" is associated with. Only valid when +\fB\-\-vlan\-tagging\fR is speficied. + +In the client context, the setting specifies which VLAN ID a client is +associated with. In the global context, the VLAN ID of the server TAP device is set. +The latter only makes sense for +.B \-\-vlan\-accept untagged +and +.B \-\-vlan\-accept all +modes. + +Valid values for +.B v +go from 1 through to 4094. The global value defaults to 1. If no \-\-vlan\-pvid +is specified in the client context, the global value is inherited. + +In some switch implementations, the PVID is also referred to as "Native VLAN". +.\"********************************************************* .SS Client Mode Use client mode when connecting to an OpenVPN server which has
Signature · 1 line
2.24.0
[Openvpn-devel] [PATCH applied] Re: VLAN: allow forwarding tagged and untagged packets on the server TAP device
In reply to Antonio QuartulliStared at code, ran full t_client/t_server tests.
In my test I had a "vlan 200" which was the native/untagged VLAN on the tap interface now (so ipv4/v6 config goes to "tap9") and a "vlan 207" which was tagged (-> tap9.207), and clients in "pvid 200" could nicely talk to clients in "pvid 207" by means of linux routing between tap9 and tap9.207. Shutting down tap9.207 stopped communication (= proof that it really went out of openvpn and in again).
Your patch has been applied to the master branch.
commit d626fa179b215a12398051ffca25b43ecfc0ad60
Author: Antonio Quartulli Date: Wed Oct 9 16:34:20 2019 +0200
VLAN: allow forwarding tagged and untagged packets on the server TAP device
Signed-off-by: Fabian Knittel <[email protected]...>
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg18919.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: VLAN: add documentation to manpage
In reply to Antonio QuartulliDocumentation is good :-) and it matches observed behaviour, so that's even better. Can the wording be improved? Surely, always, but this is a continuous process by letting "untainted" people read the docs and come up with questions that we find obvious...
Your patch has been applied to the master branch.
commit 0328003b0e987de0b7b91c3e53c84604188d9421
Author: Antonio Quartulli Date: Sat Nov 9 10:58:36 2019 +0100
VLAN: add documentation to manpage
Signed-off-by: Fabian Knittel <[email protected]...>
Signed-off-by: Antonio Quartulli <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Re: [Openvpn-devel] [PATCH 9/9] VLAN: allow user to avoid compiling VLAN handling code
In reply to Antonio QuartulliHi all,
today, during the hackathon, we discussed whether it makes sense to
allow a user to compile out the VLAN tagging code.
The only reason we could came up with is "binary size". A non-negligible difference between the openvpn binary with and without VLAN code might be a meaningful reason for introducing a compile time option.
The following are the output of the 'size' tool on the openvpn binary without and with VLAN code:
$ size src/openvpn/openvpn text data bss dec hex filename 787428 7224 2136 796788 c2874 src/openvpn/openvpn
$ size src/openvpn/openvpn text data bss dec hex filename 791598 7224 2136 800958 c38be src/openvpn/openvpn
The difference is around 4KB and none of us believes that this is enough to justify having yet another compile time option.
For the reason explained above, we decided to NACK this patch.
Cheers,
Quoted 398 lines · Antonio Quartulli
To handle VLANs a whole lot of code has been introduced. However, there are a number of users who may not need this feature and would rather preserve disk space.
Implement a configure knob (--disable-vlan-tagging) to conditionally take the entire VLAN code out.
This patch introduces the conditional by keeping all the logic/ifdefs in
vlan.hand avoid polluting the rest of code (exception made for options.h/c which is really troublesome to deal with).Signed-off-by Antonio Quartulli <[email protected]...>--- configure.ac | 12 ++++++ src/openvpn/Makefile.am | 5 ++- src/openvpn/mroute.c | 6 +-- src/openvpn/mroute.h | 2 + src/openvpn/multi.c | 10 ++--- src/openvpn/options.c | 15 ++++++++ src/openvpn/options.h | 2 + src/openvpn/vlan.h | 83 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 126 insertions(+), 9 deletions(-)configure.ac +12
-0@@ -256,6 +256,13 @@ AC_ARG_ENABLE( [enable_async_push="no"] ) +AC_ARG_ENABLE( + [vlan-tagging], + [AS_HELP_STRING([--disable-vlan-tagging], [Disble support for 802.1Q-based VLAN tagging])], + , + [enable_vlan="yes"] +) + AC_ARG_WITH( [special-build], [AS_HELP_STRING([--with-special-build=STRING], [specify special build string])],@@ -1321,6 +1328,10 @@ if test "${enable_async_push}" = "yes"; then ) fi +if test "${enable_vlan}" = "yes"; then + AC_DEFINE(ENABLE_VLAN_TAGGING, 1, [Enable 802.1Q-based VLAN tagging/untagging]) +fi + CONFIGURE_DEFINES="`set | grep '^enable_.*=' ; set | grep '^with_.*='`" AC_DEFINE_UNQUOTED([CONFIGURE_DEFINES], ["`echo ${CONFIGURE_DEFINES}`"], [Configuration settings])@@ -1349,6 +1360,7 @@ AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS]) AC_SUBST([PLUGIN_AUTH_PAM_CFLAGS]) AC_SUBST([PLUGIN_AUTH_PAM_LIBS]) +AM_CONDITIONAL([VLAN_TAGGING], [test "${enable_vlan}" = "yes"]) AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"]) AM_CONDITIONAL([GIT_CHECKOUT], [test "${GIT_CHECKOUT}" = "yes"]) AM_CONDITIONAL([ENABLE_PLUGIN_AUTH_PAM], [test "${enable_plugin_auth_pam}" = "yes"])src/openvpn/Makefile.am +4
-1@@ -123,7 +123,7 @@ openvpn_SOURCES = \ syshead.h \ tls_crypt.c tls_crypt.h \ tun.c tun.h \ - vlan.c vlan.h \ + vlan.h \ win32.h win32.c \ cryptoapi.h cryptoapi.c openvpn_LDADD = \@@ -136,6 +136,9 @@ openvpn_LDADD = \ $(OPTIONAL_SELINUX_LIBS) \ $(OPTIONAL_SYSTEMD_LIBS) \ $(OPTIONAL_DL_LIBS) +if VLAN_TAGGING +openvpn_SOURCES += vlan.c +endif if WIN32 openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncryptsrc/openvpn/mroute.c +3
-3@@ -35,6 +35,7 @@#include "proto.h" #include "error.h" #include "socket.h" +#include "vlan.h" #include "memdbg.h" @@ -256,8 +257,7 @@ mroute_copy_ether_to_addr(struct mroute_addr *maddr, maddr->netbits =0 ; maddr->len =OPENVPN_ETH_ALEN ;memcpy (maddr->ether.addr, ether_addr,OPENVPN_ETH_ALEN ); - maddr->len +=sizeof (vid); - maddr->ether.vid = vid; +vlan_maddr_copy_vid (maddr, vid); }unsigned int @@ -467,7 +467,7 @@ mroute_addr_print_ex(const struct mroute_addr *ma,case MR_ADDR_ETHER :buf_printf (&out,"%s" ,format_hex_ex (ma->ether.addr,sizeof (ma->ether.addr),0 ,1 ,":" , gc)); -buf_printf (&out,"@%hu" , ma->ether.vid); +vlan_maddr_print_vid (&out, ma);break ;case MR_ADDR_IPV4 :src/openvpn/mroute.h +2
-0@@ -84,7 +84,9 @@ struct mroute_addr {uint8_t raw_addr[MR_MAX_ADDR_LEN ];/* actual address */ struct {uint8_t addr[OPENVPN_ETH_ALEN ]; +#ifdef ENABLE_VLAN_TAGGING uint16_t vid; +#endif } ether;struct {in_addr_t addr;/* _network order_ IPv4 address */ src/openvpn/multi.c +5
-5@@ -2260,11 +2260,12 @@ multi_bcast(struct multi_context *m, } }#endif /* ifdef ENABLE_PF */ -if (vid !=0 && vid != mi->context.options.vlan_pvid) +if (!vlan_match_pvid (vid, &mi->context.options)) {continue ; }multi_add_mbuf (m, mi, mb); + } }@@ -2648,8 +2649,7 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inststruct mroute_addr edest;mroute_addr_reset (&edest);#endif - -if (m->top.options.vlan_tagging) +if (vlan_is_enabled (&m->top.options)) {if (vlan_is_tagged (&c->c2.to_tun)) {@@ -2659,7 +2659,7 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inst }else { - vid = c->options.vlan_pvid; + vid =vlan_get_pvid (&c->options); } }/* extract packet source and dest addresses */ @@ -2788,7 +2788,7 @@ multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flagsreturn true; } -if (dev_type ==DEV_TYPE_TAP && m->top.options.vlan_tagging) +if (dev_type ==DEV_TYPE_TAP &&vlan_is_enabled (&m->top.options)) { vid =vlan_decapsulate (&m->top, &m->top.c2.buf);if (vid <0 )src/openvpn/options.c +15
-0@@ -405,9 +405,11 @@ static const char usage_message[] ="--plugin m [str]: Load plug-in module m passing str as an argument\n" " to its initialization function.\n"#endif +#ifdef ENABLE_VLAN_TAGGING "--vlan-tagging : Enable 802.1Q-based VLAN tagging.\n" "--vlan-accept tagged|untagged|all : Set VLAN tagging mode. Default is 'all'.\n" "--vlan-pvid v : Sets the Port VLAN Identifier. Defaults to 1.\n" +#endif /* ifdef ENABLE_VLAN_TAGGING */ #if P2MP #if P2MP_SERVER "\n" @@ -853,8 +855,10 @@ init_options(struct options *o, const bool init_gc) o->route_method =ROUTE_METHOD_ADAPTIVE ; o->block_outside_dns = false;#endif +#ifdef ENABLE_VLAN_TAGGING o->vlan_accept =VLAN_ALL ; o->vlan_pvid =1 ; +#endif /* ifdef ENABLE_VLAN_TAGGING */ #if P2MP_SERVER o->real_hash_size =256 ; o->virtual_hash_size =256 ;@@ -1230,6 +1234,7 @@ dhcp_option_address_parse(const char *name, const char *parm, in_addr_t *array,#endif /* if defined(_WIN32) || defined(TARGET_ANDROID) */ +#ifdef ENABLE_VLAN_TAGGING static const char *print_vlan_accept (enum vlan_acceptable_frames mode) {@@ -1244,6 +1249,7 @@ print_vlan_accept(enum vlan_acceptable_frames mode) }return NULL ; } +#endif /* ifdef ENABLE_VLAN_TAGGING */ #if P2MP @@ -1314,9 +1320,11 @@ show_p2mp_parms(const struct options *o)SHOW_STR (port_share_host);SHOW_STR (port_share_port);#endif +#ifdef ENABLE_VLAN_TAGGING SHOW_BOOL (vlan_tagging);msg (D_SHOW_PARMS ," vlan_accept = %s" ,print_vlan_accept (o->vlan_accept));SHOW_INT (vlan_pvid); +#endif /* ifdef ENABLE_VLAN_TAGGING */ #endif /* P2MP_SERVER */ SHOW_BOOL (client);@@ -2380,6 +2388,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec } } +#ifdef ENABLE_VLAN_TAGGING if (options->vlan_tagging && dev !=DEV_TYPE_TAP ) {msg (M_USAGE ,"--vlan-tagging must be used with --dev tap" );@@ -2395,6 +2404,8 @@ options_postprocess_verify_ce(const struct options *options, const struct connec msg(M_USAGE, "--vlan-pvid requires --vlan-tagging"); } } +#endif /* ifdef ENABLE_VLAN_TAGGING */ + }else {@@ -2485,10 +2496,12 @@ options_postprocess_verify_ce(const struct options *options, const struct connec msg(M_USAGE, "--stale-routes-check requires --mode server"); } +#ifdef ENABLE_VLAN_TAGGING if (options->vlan_tagging) {msg (M_USAGE ,"--vlan-tagging requires --mode server" ); } +#endif /* ifdef ENABLE_VLAN_TAGGING */ }#endif /* P2MP_SERVER */ @@ -8404,6 +8417,7 @@ add_option(struct options *options,VERIFY_PERMISSION (OPT_P_GENERAL ); options->allow_recursive_routing = true; } +#ifdef ENABLE_VLAN_TAGGING else if (streq(p[0], "vlan-tagging") && !p[1]) {VERIFY_PERMISSION (OPT_P_GENERAL );@@ -8443,6 +8457,7 @@ add_option(struct options *options, goto err; } } +#endif /* ifdef ENABLE_VLAN_TAGGING */ else {int i;src/openvpn/options.h +2
-0@@ -639,9 +639,11 @@ struct optionsint keying_material_exporter_length;#endif +#ifdef ENABLE_VLAN_TAGGING bool vlan_tagging;enum vlan_acceptable_frames vlan_accept;uint16_t vlan_pvid; +#endif /* ifdef ENABLE_VLAN_TAGGING */ struct pull_filter_list *pull_filter_list;src/openvpn/vlan.h +83
-0@@ -29,11 +29,14 @@#include "buffer.h" #include "mroute.h" +#include "options.h" #include "openvpn.h" struct multi_context ;struct multi_instance ; +#ifdef ENABLE_VLAN_TAGGING +int16_t vlan_decapsulate (const struct context *c,struct buffer *buf);@@ -43,6 +46,86 @@ vlan_is_tagged(const struct buffer *buf);void vlan_process_outgoing_tun (struct multi_context *m,struct multi_instance *mi); +static inline bool +vlan_is_enabled (struct options *opt) +{ +return opt->vlan_tagging; +} + +static inline bool +vlan_match_pvid (uint16_t vid,struct options *opt) +{ +return vid !=0 && vid == opt->vlan_pvid; +} + +static inline uint16_t +vlan_get_pvid (struct options *opt) +{ +return opt->vlan_pvid; +} + +static inline void +vlan_maddr_copy_vid (struct mroute_addr *maddr,uint16_t vid) +{ + maddr->len +=sizeof (vid); + maddr->ether.vid = vid; +} + +static inline void +vlan_maddr_print_vid (struct buffer *out,const struct mroute_addr *maddr) +{ +buf_printf (out,"@%hu" , maddr->ether.vid); +} + +#else + +static inline int16_t +vlan_decapsulate (const struct context *c,struct buffer *buf) +{ +return 1 ; +} + +static inline bool +vlan_tagged_drop (const struct buffer *buf) +{ +return false; +} + +static inline void +vlan_process_outgoing_tun (struct multi_context *m,struct multi_instance *mi) +{ +} + +static inline bool +vlan_is_enabled (struct options *opt) +{ +return false; +} + +static inline bool +vlan_match_pvid (uint16_t vid,struct options *opt) +{ +return true; +} + +static inline uint16_t +vlan_get_pvid (struct options *opt) +{ +return 0 ; +} + +static inline void +vlan_maddr_copy_vid (struct mroute_addr *maddr,uint16_t vid) +{ +} + +static inline void +vlan_maddr_print_vid (struct buffer *out,const struct mroute_addr *maddr) +{ +} + +#endif +#endif /* P2MP_SERVER */ #endif /* VLAN_H */
Signature · 1 line
Antonio Quartulli