2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

userspace: Add OXM field MFF_PACKET_TYPE

Allow packet type namespace OFPHTN_ETHERTYPE as alternative pre-requisite
for matching L3 protocols (MPLS, IP, IPv6, ARP etc).

Change the meta-flow definition of packet_type field to use the new
custom format MFS_PACKET_TYPE representing "(NS,NS_TYPE)".

Parsing routine for MFS_PACKET_TYPE added to meta-flow.c. Formatting
routine for field packet_type extracted from match_format() and moved to
flow.c to be used from meta-flow.c for formatting MFS_PACKET_TYPE.

Updated the ovs-fields man page source meta-flow.xml with documentation
for packet-type-aware bridges and added documentation for field packet_type.

Added packet_type to the matching properties in tests/ofproto.at.

If dl_type is unwildcarded due to later packet modification, make sure it
is cleared again if the original packet_type was not PT_ETH.

Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Jan Scheurich
2017-06-23 16:47:57 +00:00
committed by Ben Pfaff
parent be7ac2f3c1
commit 3d4b2e6eb7
24 changed files with 657 additions and 285 deletions

View File

@@ -2983,23 +2983,18 @@ format_odp_key_attr(const struct nlattr *a, const struct nlattr *ma,
break;
case OVS_KEY_ATTR_PACKET_TYPE: {
ovs_be32 packet_type = nl_attr_get_be32(a);
uint16_t ns = pt_ns(packet_type);
uint16_t ns_type = pt_ns_type(packet_type);
ovs_be32 value = nl_attr_get_be32(a);
ovs_be32 mask = ma ? nl_attr_get_be32(ma) : OVS_BE32_MAX;
if (!is_exact) {
ovs_be32 mask = nl_attr_get_be32(ma);
uint16_t mask_ns_type = pt_ns_type(mask);
ovs_be16 ns = htons(pt_ns(value));
ovs_be16 ns_mask = htons(pt_ns(mask));
format_be16(ds, "ns", ns, &ns_mask, verbose);
if (mask == 0) {
ds_put_format(ds, "ns=%u,id=*", ns);
} else {
ds_put_format(ds, "ns=%u,id=%#"PRIx16"/%#"PRIx16,
ns, ns_type, mask_ns_type);
}
} else {
ds_put_format(ds, "ns=%u,id=%#"PRIx16, ns, ns_type);
}
ovs_be16 ns_type = pt_ns_type_be(value);
ovs_be16 ns_type_mask = pt_ns_type_be(mask);
format_be16x(ds, "id", ns_type, &ns_type_mask, verbose);
ds_chomp(ds, ',');
break;
}
@@ -4340,6 +4335,15 @@ parse_odp_key_mask_attr(const char *s, const struct simap *port_names,
SCAN_FIELD("tll=", eth, nd_tll);
} SCAN_END(OVS_KEY_ATTR_ND);
struct packet_type {
ovs_be16 ns;
ovs_be16 id;
};
SCAN_BEGIN("packet_type(", struct packet_type) {
SCAN_FIELD("ns=", be16, ns);
SCAN_FIELD("id=", be16, id);
} SCAN_END(OVS_KEY_ATTR_PACKET_TYPE);
/* Encap open-coded. */
if (!strncmp(s, "encap(", 6)) {
const char *start = s;
@@ -4527,9 +4531,7 @@ odp_flow_key_from_flow__(const struct odp_flow_key_parms *parms,
nl_msg_put_odp_port(buf, OVS_KEY_ATTR_IN_PORT, data->in_port.odp_port);
}
if (export_mask || flow->packet_type != htonl(PT_ETH)) {
nl_msg_put_be32(buf, OVS_KEY_ATTR_PACKET_TYPE, data->packet_type);
}
nl_msg_put_be32(buf, OVS_KEY_ATTR_PACKET_TYPE, data->packet_type);
if (OVS_UNLIKELY(parms->probe)) {
max_vlans = FLOW_MAX_VLAN_HEADERS;