Hi,
I've been experimenting with adding another vlan header in the last few
days.
my end goal is to be able to use the push_vlan and strip_vlan commands from
ovs-ofctl.
I added the following code to packets.c but the patch doesn't work. any
ideas?
/* Checks if a header is of type vlan */
bool
is_vlan_header(struct ofpbuf *packet)
{
struct vlan_eth_header *veh = packet->l2;
if (packet->size >= sizeof *veh
&& veh->veth_type == htons(ETH_TYPE_VLAN))
{
return true;
}
return false;
}
void
eth_push_vlan(struct ofpbuf *packet, ovs_be16 tci)
{
// new code, will beautify once it works.
if (is_vlan_header(packet))
{
struct vlan_eth_header *veh = packet->l2;
struct vlan_eth_header *veh2;
/* Insert new 802.1Q header. */
struct vlan_eth_header tmp;
memcpy(tmp.veth_dst, veh->veth_dst, ETH_ADDR_LEN);
memcpy(tmp.veth_src, veh->veth_src, ETH_ADDR_LEN);
tmp.veth_type = htons(ETH_TYPE_VLAN);
tmp.veth_tci = tci & htons(~VLAN_CFI);
tmp.veth_next_type = veh->veth_type;
veh2 = ofpbuf_push_uninit(packet, VLAN_HEADER_LEN);
memcpy(veh2, &tmp, sizeof tmp);
packet->l2 = packet->data;
}
else
{
struct eth_header *eh = packet->data;
struct vlan_eth_header *veh;
/* Insert new 802.1Q header. */
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_tci = tci & htons(~VLAN_CFI);
tmp.veth_next_type = eh->eth_type;
veh = ofpbuf_push_uninit(packet, VLAN_HEADER_LEN);
memcpy(veh, &tmp, sizeof tmp);
packet->l2 = packet->data;
}
}
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev