Add support functions for 8021.ad push and pop vlan.
authorThomas F. Herbert <thomasfherbert@gmail.com>
Tue, 2 Jun 2015 17:55:28 +0000 (13:55 -0400)
committerBen Pfaff <blp@nicira.com>
Sun, 7 Jun 2015 18:35:21 +0000 (11:35 -0700)
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>
AUTHORS
lib/odp-execute.c
lib/packets.c
lib/packets.h

diff --git a/AUTHORS b/AUTHORS
index 28899a8..24e854d 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -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
index b785104..c676451 100644 (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;
         }
index 016b12b..965754f 100644 (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);
 
index b146a50..e22267e 100644 (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