Skip to content

Commit

Permalink
Add support functions for 8021.ad push and pop vlan.
Browse files Browse the repository at this point in the history
Changes to allow the tpid to be specified and all vlan tpid checking to be
generalized.

Signed-off-by: Thomas F Herbert <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
tfherbert authored and blp committed Jun 7, 2015
1 parent 3da29e3 commit d694339
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ SUGYO Kazushi [email protected]
Tadaaki Nagao [email protected]
Terry Wilson [email protected]
Tetsuo NAKAGAWA [email protected]
Thomas F. Herbert [email protected]
Thomas Goirand [email protected]
Thomas Graf [email protected]
Thomas Lacroix [email protected]
Expand Down
2 changes: 1 addition & 1 deletion lib/odp-execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/packets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
7 changes: 7 additions & 0 deletions lib/packets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d694339

Please sign in to comment.