2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-19 14:37:21 +00:00

userspace: Switching of L3 packets in L2 pipeline

Ports have a new layer3 attribute if they send/receive L3 packets.

The packet_type included in structs dp_packet and flow is considered in
ofproto-dpif. The classical L2 match fields (dl_src, dl_dst, dl_type, and
vlan_tci, vlan_vid, vlan_pcp) now have Ethernet as pre-requisite.

A dummy ethernet header is pushed to L3 packets received from L3 ports
before the the pipeline processing starts. The ethernet header is popped
before sending a packet to a L3 port.

For datapath ports that can receive L2 or L3 packets, the packet_type
becomes part of the flow key for datapath flows and is handled
appropriately in dpif-netdev.

In the 'else' branch in flow_put_on_pmd() function, the additional check
flow_equal(&match.flow, &netdev_flow->flow) was removed, as a) the dpcls
lookup is sufficient to uniquely identify a flow and b) it caused false
negatives because the flow in netdev->flow may not properly masked.

In dpif_netdev_flow_put() we now use the same method for constructing the
netdev_flow_key as the one used when adding the flow to the dplcs to make sure
these always match. The function netdev_flow_key_from_flow() used so far was
not only inefficient but sometimes caused mismatches and subsequent flow
update failures.

The kernel datapath does not support the packet_type match field.
Instead it encodes the packet type implictly by the presence or absence of
the Ethernet attribute in the flow key and mask.
This patch filters the PACKET_TYPE attribute out of netlink flow key and
mask to be sent to the kernel datapath.

Signed-off-by: Lorand Jakab <lojakab@cisco.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Jan Scheurich
2017-06-02 16:16:17 +00:00
committed by Ben Pfaff
parent 5978c2e315
commit beb75a40fd
23 changed files with 337 additions and 119 deletions

View File

@@ -476,6 +476,13 @@ match_set_ct_ipv6_dst_masked(struct match *match, const struct in6_addr *dst,
match->wc.masks.ct_ipv6_dst = *mask;
}
void
match_set_packet_type(struct match *match, ovs_be32 packet_type)
{
match->flow.packet_type = packet_type;
match->wc.masks.packet_type = OVS_BE32_MAX;
}
void
match_set_dl_type(struct match *match, ovs_be16 dl_type)
{
@@ -1249,6 +1256,22 @@ match_format(const struct match *match,
format_be16_masked(s, "ct_tp_dst", f->ct_tp_dst, wc->masks.ct_tp_dst);
}
if (wc->masks.packet_type) {
if (pt_ns_type_be(wc->masks.packet_type) == 0) {
ds_put_format(s, "packet_type=(%u,*),",
pt_ns(f->packet_type));
} else if (pt_ns_type_be(wc->masks.packet_type) == OVS_BE16_MAX) {
ds_put_format(s, "packet_type=(%u,%#"PRIx16"),",
pt_ns(f->packet_type),
pt_ns_type(f->packet_type));
} else {
ds_put_format(s, "packet_type=(%u,%#"PRIx16"/%#"PRIx16"),",
pt_ns(f->packet_type),
pt_ns_type(f->packet_type),
pt_ns_type(wc->masks.packet_type));
}
}
if (wc->masks.dl_type) {
skip_type = true;
if (f->dl_type == htons(ETH_TYPE_IP)) {
@@ -1361,8 +1384,10 @@ match_format(const struct match *match,
ntohs(wc->masks.vlans[i].tci));
}
}
format_eth_masked(s, "dl_src", f->dl_src, wc->masks.dl_src);
format_eth_masked(s, "dl_dst", f->dl_dst, wc->masks.dl_dst);
if (!skip_type && wc->masks.dl_type) {
ds_put_format(s, "%sdl_type=%s0x%04"PRIx16",",
colors.param, colors.end, ntohs(f->dl_type));