summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJan Scheurich <jan.scheurich@ericsson.com>2017-04-25 16:29:59 +0000
committerBen Pfaff <blp@ovn.org>2017-05-03 16:56:40 -0700
commit2482b0b0c8c4ceae1f7e4620cd8620ce144e1bf3 (patch)
treedca094fdddf67d6e24e686ecaf96485e48ffcb59 /include
parentc2f4c39be4e288e7a08974aea53b18627a1ef9ef (diff)
downloadopenvswitch-2482b0b0c8c4ceae1f7e4620cd8620ce144e1bf3.tar.gz
userspace: Add packet_type in dp_packet and flow
This commit adds a packet_type attribute to the structs dp_packet and flow to explicitly carry the type of the packet as prepration for the introduction of the so-called packet type-aware pipeline (PTAP) in OVS. The packet_type is a big-endian 32 bit integer with the encoding as specified in OpenFlow verion 1.5. The upper 16 bits contain the packet type name space. Pre-defined values are defined in openflow-common.h: enum ofp_header_type_namespaces { OFPHTN_ONF = 0, /* ONF namespace. */ OFPHTN_ETHERTYPE = 1, /* ns_type is an Ethertype. */ OFPHTN_IP_PROTO = 2, /* ns_type is a IP protocol number. */ OFPHTN_UDP_TCP_PORT = 3, /* ns_type is a TCP or UDP port. */ OFPHTN_IPV4_OPTION = 4, /* ns_type is an IPv4 option number. */ }; The lower 16 bits specify the actual type in the context of the name space. Only name spaces 0 and 1 will be supported for now. For name space OFPHTN_ONF the relevant packet type is 0 (Ethernet). This is the default packet_type in OVS and the only one supported so far. Packets of type (OFPHTN_ONF, 0) are called Ethernet packets. In name space OFPHTN_ETHERTYPE the type is the Ethertype of the packet. A packet of type (OFPHTN_ETHERTYPE, <Ethertype>) is a standard L2 packet whith the Ethernet header (and any VLAN tags) removed to expose the L3 (or L2.5) payload of the packet. These will simply be called L3 packets. The Ethernet address fields dl_src and dl_dst in struct flow are not applicable for an L3 packet and must be zero. However, to maintain compatibility with the large code base, we have chosen to copy the Ethertype of an L3 packet into the the dl_type field of struct flow. This does not mean that it will be possible to match on dl_type for L3 packets with PTAP later on. Matching must be done on packet_type instead. New dp_packets are initialized with packet_type Ethernet. Ports that receive L3 packets will have to explicitly adjust the packet_type. Signed-off-by: Jean Tourrilhes <jt@labs.hpe.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>
Diffstat (limited to 'include')
-rw-r--r--include/openflow/openflow-common.h9
-rw-r--r--include/openvswitch/flow.h16
-rw-r--r--include/openvswitch/ofp-print.h10
3 files changed, 26 insertions, 9 deletions
diff --git a/include/openflow/openflow-common.h b/include/openflow/openflow-common.h
index 5936e3f09..3a0a57550 100644
--- a/include/openflow/openflow-common.h
+++ b/include/openflow/openflow-common.h
@@ -458,4 +458,13 @@ enum ofp_table_config {
OFPTC14_VACANCY_EVENTS = 1 << 3, /* Enable vacancy events. */
};
+/* Header and packet type name spaces. */
+enum ofp_header_type_namespaces {
+ OFPHTN_ONF = 0, /* ONF namespace. */
+ OFPHTN_ETHERTYPE = 1, /* ns_type is an Ethertype. */
+ OFPHTN_IP_PROTO = 2, /* ns_type is a IP protocol number. */
+ OFPHTN_UDP_TCP_PORT = 3, /* ns_type is a TCP or UDP port. */
+ OFPHTN_IPV4_OPTION = 4, /* ns_type is an IPv4 option number. */
+};
+
#endif /* openflow/openflow-common.h */
diff --git a/include/openvswitch/flow.h b/include/openvswitch/flow.h
index 188467dc4..36a2a8577 100644
--- a/include/openvswitch/flow.h
+++ b/include/openvswitch/flow.h
@@ -23,7 +23,7 @@
/* This sequence number should be incremented whenever anything involving flows
* or the wildcarding of flows changes. This will cause build assertion
* failures in places which likely need to be updated. */
-#define FLOW_WC_SEQ 38
+#define FLOW_WC_SEQ 39
/* Number of Open vSwitch extension 32-bit registers. */
#define FLOW_N_REGS 16
@@ -108,7 +108,7 @@ struct flow {
uint8_t ct_nw_proto; /* CT orig tuple IP protocol. */
uint16_t ct_zone; /* Connection tracking zone. */
uint32_t ct_mark; /* Connection mark.*/
- uint8_t pad1[4]; /* Pad to 64 bits. */
+ ovs_be32 packet_type; /* OpenFlow packet type. */
ovs_u128 ct_label; /* Connection label. */
uint32_t conj_id; /* Conjunction ID. */
ofp_port_t actset_output; /* Output port in action set. */
@@ -116,8 +116,10 @@ struct flow {
/* L2, Order the same as in the Ethernet header! (64-bit aligned) */
struct eth_addr dl_dst; /* Ethernet destination address. */
struct eth_addr dl_src; /* Ethernet source address. */
- ovs_be16 dl_type; /* Ethernet frame type. */
- uint8_t pad2[2]; /* Pad to 64 bits. */
+ ovs_be16 dl_type; /* Ethernet frame type.
+ Note: This also holds the Ethertype for L3
+ packets of type PACKET_TYPE(1, Ethertype) */
+ uint8_t pad1[2]; /* Pad to 64 bits. */
union flow_vlan_hdr vlans[FLOW_MAX_VLAN_HEADERS]; /* VLANs */
ovs_be32 mpls_lse[ROUND_UP(FLOW_MAX_MPLS_LABELS, 2)]; /* MPLS label stack
(with padding). */
@@ -139,7 +141,7 @@ struct flow {
struct eth_addr arp_sha; /* ARP/ND source hardware address. */
struct eth_addr arp_tha; /* ARP/ND target hardware address. */
ovs_be16 tcp_flags; /* TCP flags. With L3 to avoid matching L4. */
- ovs_be16 pad3; /* Pad to 64 bits. */
+ ovs_be16 pad2; /* Pad to 64 bits. */
/* L4 (64-bit aligned) */
ovs_be16 tp_src; /* TCP/UDP/SCTP source port/ICMP type. */
@@ -148,7 +150,7 @@ struct flow {
ovs_be16 ct_tp_dst; /* CT original tuple dst port/ICMP code. */
ovs_be32 igmp_group_ip4; /* IGMP group IPv4 address.
* Keep last for BUILD_ASSERT_DECL below. */
- ovs_be32 pad4; /* Pad to 64 bits. */
+ ovs_be32 pad3; /* Pad to 64 bits. */
};
BUILD_ASSERT_DECL(sizeof(struct flow) % sizeof(uint64_t) == 0);
BUILD_ASSERT_DECL(sizeof(struct flow_tnl) % sizeof(uint64_t) == 0);
@@ -158,7 +160,7 @@ BUILD_ASSERT_DECL(sizeof(struct flow_tnl) % sizeof(uint64_t) == 0);
/* Remember to update FLOW_WC_SEQ when changing 'struct flow'. */
BUILD_ASSERT_DECL(offsetof(struct flow, igmp_group_ip4) + sizeof(uint32_t)
== sizeof(struct flow_tnl) + 300
- && FLOW_WC_SEQ == 38);
+ && FLOW_WC_SEQ == 39);
/* Incremental points at which flow classification may be performed in
* segments.
diff --git a/include/openvswitch/ofp-print.h b/include/openvswitch/ofp-print.h
index 863f7aaa2..08b642900 100644
--- a/include/openvswitch/ofp-print.h
+++ b/include/openvswitch/ofp-print.h
@@ -22,6 +22,8 @@
#include <stdint.h>
#include <stdio.h>
+#include <openvswitch/types.h>
+
struct ds;
struct ofp10_match;
struct ofp_flow_mod;
@@ -29,19 +31,23 @@ struct ofp_header;
struct ofputil_flow_stats;
struct ofputil_table_features;
struct ofputil_table_stats;
+struct dp_packet;
#ifdef __cplusplus
extern "C" {
#endif
void ofp_print(FILE *, const void *, size_t, int verbosity);
-void ofp_print_packet(FILE *stream, const void *data, size_t len);
+void ofp_print_packet(FILE *stream, const void *data,
+ size_t len, ovs_be32 packet_type);
+void ofp_print_dp_packet(FILE *stream, const struct dp_packet *packet);
void ofp10_match_print(struct ds *, const struct ofp10_match *, int verbosity);
char *ofp_to_string(const void *, size_t, int verbosity);
char *ofp10_match_to_string(const struct ofp10_match *, int verbosity);
-char *ofp_packet_to_string(const void *data, size_t len);
+char *ofp_packet_to_string(const void *data, size_t len, ovs_be32 packet_type);
+char *ofp_dp_packet_to_string(const struct dp_packet *packet);
void ofp_print_flow_stats(struct ds *, const struct ofputil_flow_stats *);
void ofp_print_version(const struct ofp_header *, struct ds *);