summaryrefslogtreecommitdiff
path: root/lib/dp-packet.c
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 /lib/dp-packet.c
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 'lib/dp-packet.c')
-rw-r--r--lib/dp-packet.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/dp-packet.c b/lib/dp-packet.c
index 793b54f14..67aa40618 100644
--- a/lib/dp-packet.c
+++ b/lib/dp-packet.c
@@ -32,6 +32,8 @@ dp_packet_init__(struct dp_packet *b, size_t allocated, enum dp_packet_source so
pkt_metadata_init(&b->md, 0);
dp_packet_rss_invalidate(b);
dp_packet_reset_cutlen(b);
+ /* By default assume the packet type to be Ethernet. */
+ b->packet_type = htonl(PT_ETH);
}
static void
@@ -171,6 +173,7 @@ dp_packet_clone_with_headroom(const struct dp_packet *buffer, size_t headroom)
new_buffer->l4_ofs = buffer->l4_ofs;
new_buffer->md = buffer->md;
new_buffer->cutlen = buffer->cutlen;
+ new_buffer->packet_type = buffer->packet_type;
#ifdef DPDK_NETDEV
new_buffer->mbuf.ol_flags = buffer->mbuf.ol_flags;
#else