From: Simon Horman Date: Wed, 15 Jan 2014 08:17:01 +0000 (+0900) Subject: lib: Add tpid parameter to eth_push_vlan() X-Git-Tag: sliver-openvswitch-2.1.90-1~10^2~5 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=1bf02876a46e3e86a59f959fdac57db7f6b0a4ad;p=sliver-openvswitch.git lib: Add tpid parameter to eth_push_vlan() This is in preparation for pushing vlan tags using the TPID provided by the kernel via auxdata. Signed-off-by: Simon Horman Signed-off-by: Ben Pfaff --- diff --git a/lib/cfm.c b/lib/cfm.c index bd2f6ea19..583df1ded 100644 --- a/lib/cfm.c +++ b/lib/cfm.c @@ -554,7 +554,7 @@ cfm_compose_ccm(struct cfm *cfm, struct ofpbuf *packet, if (ccm_vlan || cfm->ccm_pcp) { uint16_t tci = ccm_vlan | (cfm->ccm_pcp << VLAN_PCP_SHIFT); - eth_push_vlan(packet, htons(tci)); + eth_push_vlan(packet, htons(ETH_TYPE_VLAN), htons(tci)); } ccm = packet->l3; diff --git a/lib/flow.c b/lib/flow.c index f1d2cad29..b1b9f989a 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -1168,7 +1168,7 @@ flow_compose(struct ofpbuf *b, const struct flow *flow) } if (flow->vlan_tci & htons(VLAN_CFI)) { - eth_push_vlan(b, flow->vlan_tci); + eth_push_vlan(b, htons(ETH_TYPE_VLAN), flow->vlan_tci); } if (flow->dl_type == htons(ETH_TYPE_IP)) { diff --git a/lib/odp-execute.c b/lib/odp-execute.c index 5b77fa9a9..096c113fa 100644 --- a/lib/odp-execute.c +++ b/lib/odp-execute.c @@ -205,7 +205,7 @@ odp_execute_actions__(void *dp, struct ofpbuf *packet, struct pkt_metadata *md, case OVS_ACTION_ATTR_PUSH_VLAN: { const struct ovs_action_push_vlan *vlan = nl_attr_get(a); - eth_push_vlan(packet, vlan->vlan_tci); + eth_push_vlan(packet, htons(ETH_TYPE_VLAN), vlan->vlan_tci); break; } diff --git a/lib/packets.c b/lib/packets.c index d87aa8eb3..0d63841ac 100644 --- a/lib/packets.c +++ b/lib/packets.c @@ -176,7 +176,7 @@ compose_rarp(struct ofpbuf *b, const uint8_t eth_src[ETH_ADDR_LEN]) * * Also sets 'packet->l2' to point to the new Ethernet header. */ void -eth_push_vlan(struct ofpbuf *packet, ovs_be16 tci) +eth_push_vlan(struct ofpbuf *packet, ovs_be16 tpid, ovs_be16 tci) { struct eth_header *eh = packet->data; struct vlan_eth_header *veh; @@ -185,7 +185,7 @@ eth_push_vlan(struct ofpbuf *packet, ovs_be16 tci) struct vlan_eth_header tmp; memcpy(tmp.veth_dst, eh->eth_dst, ETH_ADDR_LEN); memcpy(tmp.veth_src, eh->eth_src, ETH_ADDR_LEN); - tmp.veth_type = htons(ETH_TYPE_VLAN); + tmp.veth_type = tpid; tmp.veth_tci = tci & htons(~VLAN_CFI); tmp.veth_next_type = eh->eth_type; diff --git a/lib/packets.h b/lib/packets.h index 63873b036..8e21fa89b 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -151,7 +151,7 @@ bool eth_addr_from_string(const char *, uint8_t ea[ETH_ADDR_LEN]); void compose_rarp(struct ofpbuf *, const uint8_t eth_src[ETH_ADDR_LEN]); -void eth_push_vlan(struct ofpbuf *, ovs_be16 tci); +void eth_push_vlan(struct ofpbuf *, ovs_be16 tpid, ovs_be16 tci); void eth_pop_vlan(struct ofpbuf *); void set_ethertype(struct ofpbuf *packet, ovs_be16 eth_type); diff --git a/ofproto/bond.c b/ofproto/bond.c index a651d8d2d..b4d9487b3 100644 --- a/ofproto/bond.c +++ b/ofproto/bond.c @@ -541,7 +541,7 @@ bond_compose_learning_packet(struct bond *bond, packet = ofpbuf_new(0); compose_rarp(packet, eth_src); if (vlan) { - eth_push_vlan(packet, htons(vlan)); + eth_push_vlan(packet, htons(ETH_TYPE_VLAN), htons(vlan)); } *port_aux = slave->aux; diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index b5b6171dc..c5e660093 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -581,7 +581,7 @@ xlate_receive(const struct dpif_backer *backer, struct ofpbuf *packet, * an OpenFlow controller properly, so that it looks correct * for sFlow, and so that flow_extract() will get the correct * vlan_tci if it is called on 'packet'. */ - eth_push_vlan(packet, flow->vlan_tci); + eth_push_vlan(packet, htons(ETH_TYPE_VLAN), flow->vlan_tci); } /* We can't reproduce 'key' from 'flow'. */ fitness = fitness == ODP_FIT_PERFECT ? ODP_FIT_TOO_MUCH : fitness;