2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-29 15:28:56 +00:00

Add support functions for 8021.ad push and pop vlan.

Changes to allow the tpid to be specified and all vlan tpid checking to be
generalized.

Signed-off-by: Thomas F Herbert <thomasfherbert@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Thomas F. Herbert
2015-06-02 13:55:28 -04:00
committed by Ben Pfaff
parent 3da29e3294
commit d694339457
4 changed files with 13 additions and 5 deletions

View File

@@ -166,6 +166,7 @@ SUGYO Kazushi sugyo.org@gmail.com
Tadaaki Nagao nagao@stratosphere.co.jp
Terry Wilson twilson@redhat.com
Tetsuo NAKAGAWA nakagawa@mxc.nes.nec.co.jp
Thomas F. Herbert thomasfherbert@gmail.com
Thomas Goirand zigo@debian.org
Thomas Graf tgraf@noironetworks.com
Thomas Lacroix thomas.lacroix@citrix.com

View File

@@ -555,7 +555,7 @@ odp_execute_actions(void *dp, struct dp_packet **packets, int cnt, bool steal,
const struct ovs_action_push_vlan *vlan = nl_attr_get(a);
for (i = 0; i < cnt; i++) {
eth_push_vlan(packets[i], htons(ETH_TYPE_VLAN), vlan->vlan_tci);
eth_push_vlan(packets[i], vlan->vlan_tpid, vlan->vlan_tci);
}
break;
}

View File

@@ -192,15 +192,15 @@ eth_push_vlan(struct dp_packet *packet, ovs_be16 tpid, ovs_be16 tci)
/* Removes outermost VLAN header (if any is present) from 'packet'.
*
* 'packet->l2_5' should initially point to 'packet''s outer-most MPLS header
* or may be NULL if there are no MPLS headers. */
* 'packet->l2_5' should initially point to 'packet''s outer-most VLAN header
* or may be NULL if there are no VLAN headers. */
void
eth_pop_vlan(struct dp_packet *packet)
{
struct vlan_eth_header *veh = dp_packet_l2(packet);
if (veh && dp_packet_size(packet) >= sizeof *veh
&& veh->veth_type == htons(ETH_TYPE_VLAN)) {
&& eth_type_vlan(veh->veth_type)) {
memmove((char *)veh + VLAN_HEADER_LEN, veh, 2 * ETH_ADDR_LEN);
dp_packet_resize_l2(packet, -VLAN_HEADER_LEN);
@@ -217,7 +217,7 @@ set_ethertype(struct dp_packet *packet, ovs_be16 eth_type)
return;
}
if (eh->eth_type == htons(ETH_TYPE_VLAN)) {
if (eth_type_vlan(eh->eth_type)) {
ovs_be16 *p;
char *l2_5 = dp_packet_l2_5(packet);

View File

@@ -255,6 +255,13 @@ static inline bool eth_type_mpls(ovs_be16 eth_type)
eth_type == htons(ETH_TYPE_MPLS_MCAST);
}
static inline bool eth_type_vlan(ovs_be16 eth_type)
{
return eth_type == htons(ETH_TYPE_VLAN_8021Q) ||
eth_type == htons(ETH_TYPE_VLAN_8021AD);
}
/* Minimum value for an Ethernet type. Values below this are IEEE 802.2 frame
* lengths. */
#define ETH_TYPE_MIN 0x600