diff options
author | Jan Scheurich <jan.scheurich@ericsson.com> | 2017-04-25 16:29:59 +0000 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2017-05-03 16:56:40 -0700 |
commit | 2482b0b0c8c4ceae1f7e4620cd8620ce144e1bf3 (patch) | |
tree | dca094fdddf67d6e24e686ecaf96485e48ffcb59 /lib/packets.h | |
parent | c2f4c39be4e288e7a08974aea53b18627a1ef9ef (diff) | |
download | openvswitch-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 'lib/packets.h')
-rw-r--r-- | lib/packets.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/packets.h b/lib/packets.h index 639f5e44d..8acfbf508 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -1130,6 +1130,44 @@ struct vxlanhdr { #define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */ +/* Input values for PACKET_TYPE macros have to be in host byte order. + * The _BE postfix indicates result is in network byte order. Otherwise result + * is in host byte order. */ +#define PACKET_TYPE(NS, NS_TYPE) ((uint32_t) ((NS) << 16 | (NS_TYPE))) +#define PACKET_TYPE_BE(NS, NS_TYPE) (htonl((NS) << 16 | (NS_TYPE))) + +/* Returns the host byte ordered namespace of 'packet type'. */ +static inline uint16_t +pt_ns(ovs_be32 packet_type) +{ + return ntohl(packet_type) >> 16; +} + +/* Returns the network byte ordered namespace type of 'packet type'. */ +static inline ovs_be16 +pt_ns_type_be(ovs_be32 packet_type) +{ + return be32_to_be16(packet_type); +} + +/* Returns the host byte ordered namespace type of 'packet type'. */ +static inline uint16_t +pt_ns_type(ovs_be32 packet_type) +{ + return ntohs(pt_ns_type_be(packet_type)); +} + +/* Well-known packet_type field values. */ +enum packet_type { + PT_ETH = PACKET_TYPE(OFPHTN_ONF, 0x0000), /* Default: Ethernet */ + PT_IPV4 = PACKET_TYPE(OFPHTN_ETHERTYPE, ETH_TYPE_IP), + PT_IPV6 = PACKET_TYPE(OFPHTN_ETHERTYPE, ETH_TYPE_IPV6), + PT_MPLS = PACKET_TYPE(OFPHTN_ETHERTYPE, ETH_TYPE_MPLS), + PT_MPLS_MC = PACKET_TYPE(OFPHTN_ETHERTYPE, ETH_TYPE_MPLS_MCAST), + PT_UNKNOWN = PACKET_TYPE(0xffff, 0xffff), /* Unknown packet type. */ +}; + + void ipv6_format_addr(const struct in6_addr *addr, struct ds *); void ipv6_format_addr_bracket(const struct in6_addr *addr, struct ds *, bool bracket); |