[ovs-dev] [PATCH V10 1/5] Support functions for 8021.ad push and pop vlan
Thomas F Herbert
thomasfherbert at gmail.com
Tue Jun 2 17:55:28 UTC 2015
From: "Thomas F. Herbert" <thomasfherbert at gmail.com>
Changes to allow the tpid to be specified and all vlan tpid checking to be
generalized.
Signed-off-by: Thomas F Herbert <thomasfherbert at gmail.com>
---
lib/odp-execute.c | 2 +-
lib/packets.c | 8 ++++----
lib/packets.h | 7 +++++++
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index b785104..c676451 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -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;
}
diff --git a/lib/packets.c b/lib/packets.c
index 016b12b..4482b45 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -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);
diff --git a/lib/packets.h b/lib/packets.h
index b146a50..e22267e 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -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
--
2.1.0
More information about the dev
mailing list