OF support and translation of generic encap and decap
This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.
CLI syntax for encap action with properties:
encap(<header>)
encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...))
For example:
encap(ethernet)
encap(nsh(md_type=1))
encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210)))
CLI syntax for decap action:
decap()
decap(packet_type(ns=<pt_ns>,type=<pt_type>))
For example:
decap()
decap(packet_type(ns=0,type=0xfffe))
decap(packet_type(ns=1,type=0x894f))
The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).
This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.
In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.
The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.
Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-08-02 16:04:12 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Intel, Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include "openvswitch/ofp-ed-props.h"
|
|
|
|
#include "openvswitch/ofp-util.h"
|
|
|
|
#include "openvswitch/ofpbuf.h"
|
|
|
|
#include "openvswitch/ofp-parse.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "lib/packets.h"
|
|
|
|
|
|
|
|
|
|
|
|
enum ofperr
|
|
|
|
decode_ed_prop(const struct ofp_ed_prop_header **ofp_prop,
|
|
|
|
struct ofpbuf *out OVS_UNUSED,
|
|
|
|
size_t *remaining)
|
|
|
|
{
|
|
|
|
uint16_t prop_class = ntohs((*ofp_prop)->prop_class);
|
2017-08-05 13:41:11 +08:00
|
|
|
uint8_t prop_type = (*ofp_prop)->type;
|
OF support and translation of generic encap and decap
This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.
CLI syntax for encap action with properties:
encap(<header>)
encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...))
For example:
encap(ethernet)
encap(nsh(md_type=1))
encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210)))
CLI syntax for decap action:
decap()
decap(packet_type(ns=<pt_ns>,type=<pt_type>))
For example:
decap()
decap(packet_type(ns=0,type=0xfffe))
decap(packet_type(ns=1,type=0x894f))
The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).
This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.
In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.
The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.
Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-08-02 16:04:12 +08:00
|
|
|
size_t len = (*ofp_prop)->len;
|
|
|
|
size_t pad_len = ROUND_UP(len, 8);
|
|
|
|
|
|
|
|
if (pad_len > *remaining) {
|
|
|
|
return OFPERR_OFPBAC_BAD_LEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (prop_class) {
|
2017-08-05 13:41:11 +08:00
|
|
|
case OFPPPC_NSH: {
|
|
|
|
switch (prop_type) {
|
|
|
|
case OFPPPT_PROP_NSH_MDTYPE: {
|
|
|
|
struct ofp_ed_prop_nsh_md_type *opnmt =
|
|
|
|
ALIGNED_CAST(struct ofp_ed_prop_nsh_md_type *, *ofp_prop);
|
|
|
|
if (len > sizeof(*opnmt) || len > *remaining) {
|
|
|
|
return OFPERR_NXBAC_BAD_ED_PROP;
|
|
|
|
}
|
|
|
|
struct ofpact_ed_prop_nsh_md_type *pnmt =
|
|
|
|
ofpbuf_put_uninit(out, sizeof(*pnmt));
|
|
|
|
pnmt->header.prop_class = prop_class;
|
|
|
|
pnmt->header.type = prop_type;
|
|
|
|
pnmt->header.len = len;
|
|
|
|
pnmt->md_type = opnmt->md_type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OFPPPT_PROP_NSH_TLV: {
|
|
|
|
struct ofp_ed_prop_nsh_tlv *opnt =
|
|
|
|
ALIGNED_CAST(struct ofp_ed_prop_nsh_tlv *, *ofp_prop);
|
|
|
|
size_t tlv_pad_len = ROUND_UP(opnt->tlv_len, 8);
|
|
|
|
if (len != sizeof(*opnt) + tlv_pad_len || len > *remaining) {
|
|
|
|
return OFPERR_NXBAC_BAD_ED_PROP;
|
|
|
|
}
|
|
|
|
struct ofpact_ed_prop_nsh_tlv *pnt =
|
|
|
|
ofpbuf_put_uninit(out, sizeof(*pnt));
|
|
|
|
pnt->header.prop_class = prop_class;
|
|
|
|
pnt->header.type = prop_type;
|
|
|
|
pnt->header.len = len;
|
|
|
|
pnt->tlv_class = opnt->tlv_class;
|
|
|
|
pnt->tlv_type = opnt->tlv_type;
|
|
|
|
pnt->tlv_len = opnt->tlv_len;
|
|
|
|
ofpbuf_put(out, opnt->data, tlv_pad_len);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return OFPERR_NXBAC_UNKNOWN_ED_PROP;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
OF support and translation of generic encap and decap
This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.
CLI syntax for encap action with properties:
encap(<header>)
encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...))
For example:
encap(ethernet)
encap(nsh(md_type=1))
encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210)))
CLI syntax for decap action:
decap()
decap(packet_type(ns=<pt_ns>,type=<pt_type>))
For example:
decap()
decap(packet_type(ns=0,type=0xfffe))
decap(packet_type(ns=1,type=0x894f))
The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).
This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.
In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.
The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.
Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-08-02 16:04:12 +08:00
|
|
|
default:
|
|
|
|
return OFPERR_NXBAC_UNKNOWN_ED_PROP;
|
|
|
|
}
|
|
|
|
|
|
|
|
*remaining -= pad_len;
|
|
|
|
*ofp_prop = ALIGNED_CAST(const struct ofp_ed_prop_header *,
|
|
|
|
((char *)(*ofp_prop) + pad_len));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum ofperr
|
|
|
|
encode_ed_prop(const struct ofpact_ed_prop **prop,
|
|
|
|
struct ofpbuf *out OVS_UNUSED)
|
|
|
|
{
|
|
|
|
size_t prop_len;
|
|
|
|
|
|
|
|
switch ((*prop)->prop_class) {
|
2017-08-05 13:41:11 +08:00
|
|
|
case OFPPPC_NSH: {
|
|
|
|
switch ((*prop)->type) {
|
|
|
|
case OFPPPT_PROP_NSH_MDTYPE: {
|
|
|
|
struct ofpact_ed_prop_nsh_md_type *pnmt =
|
|
|
|
ALIGNED_CAST(struct ofpact_ed_prop_nsh_md_type *, *prop);
|
|
|
|
struct ofp_ed_prop_nsh_md_type *opnmt =
|
|
|
|
ofpbuf_put_uninit(out, sizeof(*opnmt));
|
|
|
|
opnmt->header.prop_class = htons((*prop)->prop_class);
|
|
|
|
opnmt->header.type = (*prop)->type;
|
|
|
|
opnmt->header.len =
|
|
|
|
offsetof(struct ofp_ed_prop_nsh_md_type, pad);
|
|
|
|
opnmt->md_type = pnmt->md_type;
|
|
|
|
prop_len = sizeof(*pnmt);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OFPPPT_PROP_NSH_TLV: {
|
|
|
|
struct ofpact_ed_prop_nsh_tlv *pnt =
|
|
|
|
ALIGNED_CAST(struct ofpact_ed_prop_nsh_tlv *, *prop);
|
|
|
|
struct ofp_ed_prop_nsh_tlv *opnt;
|
|
|
|
size_t tlv_pad_len = ROUND_UP(pnt->tlv_len, 8);
|
|
|
|
size_t len = sizeof(*opnt) + tlv_pad_len;
|
|
|
|
opnt = ofpbuf_put_uninit(out, len);
|
|
|
|
opnt->header.prop_class = htons((*prop)->prop_class);
|
|
|
|
opnt->header.type = (*prop)->type;
|
|
|
|
opnt->header.len = len;
|
|
|
|
opnt->tlv_class = pnt->tlv_class;
|
|
|
|
opnt->tlv_type = pnt->tlv_type;
|
|
|
|
opnt->tlv_len = pnt->tlv_len;
|
|
|
|
memcpy(opnt->data, pnt->data, tlv_pad_len);
|
|
|
|
prop_len = sizeof(*pnt) + tlv_pad_len;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return OFPERR_OFPBAC_BAD_ARGUMENT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
OF support and translation of generic encap and decap
This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.
CLI syntax for encap action with properties:
encap(<header>)
encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...))
For example:
encap(ethernet)
encap(nsh(md_type=1))
encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210)))
CLI syntax for decap action:
decap()
decap(packet_type(ns=<pt_ns>,type=<pt_type>))
For example:
decap()
decap(packet_type(ns=0,type=0xfffe))
decap(packet_type(ns=1,type=0x894f))
The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).
This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.
In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.
The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.
Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-08-02 16:04:12 +08:00
|
|
|
default:
|
|
|
|
return OFPERR_OFPBAC_BAD_ARGUMENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
*prop = ALIGNED_CAST(const struct ofpact_ed_prop *,
|
|
|
|
((char *)(*prop) + prop_len));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
parse_ed_prop_class(const char *str OVS_UNUSED,
|
|
|
|
uint16_t *prop_class)
|
|
|
|
{
|
|
|
|
if (!strcmp(str,"basic")) {
|
|
|
|
*prop_class = OFPPPC_BASIC;
|
|
|
|
} else if (!strcmp(str,"ethernet")) {
|
|
|
|
*prop_class = OFPPPC_BASIC;
|
|
|
|
} else if (!strcmp(str,"mpls")) {
|
|
|
|
*prop_class = OFPPPC_MPLS;
|
|
|
|
} else if (!strcmp(str,"gre")) {
|
|
|
|
*prop_class = OFPPPC_GRE;
|
|
|
|
} else if (!strcmp(str,"gtp")) {
|
|
|
|
*prop_class = OFPPPC_GTP;
|
2017-08-05 13:41:11 +08:00
|
|
|
} else if (!strcmp(str,"nsh")) {
|
|
|
|
*prop_class = OFPPPC_NSH;
|
OF support and translation of generic encap and decap
This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.
CLI syntax for encap action with properties:
encap(<header>)
encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...))
For example:
encap(ethernet)
encap(nsh(md_type=1))
encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210)))
CLI syntax for decap action:
decap()
decap(packet_type(ns=<pt_ns>,type=<pt_type>))
For example:
decap()
decap(packet_type(ns=0,type=0xfffe))
decap(packet_type(ns=1,type=0x894f))
The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).
This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.
In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.
The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.
Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-08-02 16:04:12 +08:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
parse_ed_prop_type(uint16_t prop_class,
|
|
|
|
const char *str OVS_UNUSED,
|
|
|
|
uint8_t *type OVS_UNUSED)
|
|
|
|
{
|
|
|
|
switch (prop_class) {
|
2017-08-05 13:41:11 +08:00
|
|
|
case OFPPPC_NSH:
|
|
|
|
if (!strcmp(str, "md_type")) {
|
|
|
|
*type = OFPPPT_PROP_NSH_MDTYPE;
|
|
|
|
return true;
|
|
|
|
} else if (!strcmp(str, "tlv")) {
|
|
|
|
*type = OFPPPT_PROP_NSH_TLV;
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
OF support and translation of generic encap and decap
This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.
CLI syntax for encap action with properties:
encap(<header>)
encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...))
For example:
encap(ethernet)
encap(nsh(md_type=1))
encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210)))
CLI syntax for decap action:
decap()
decap(packet_type(ns=<pt_ns>,type=<pt_type>))
For example:
decap()
decap(packet_type(ns=0,type=0xfffe))
decap(packet_type(ns=1,type=0x894f))
The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).
This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.
In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.
The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.
Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-08-02 16:04:12 +08:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse the value of an encap/decap property based on property class
|
|
|
|
* and type and append the parsed property in internal format to the
|
|
|
|
* ofpbuf out.
|
|
|
|
* Returns a malloced string in the event of a parse error. The caller
|
|
|
|
* must free the string.
|
|
|
|
*/
|
|
|
|
|
|
|
|
char *
|
|
|
|
parse_ed_prop_value(uint16_t prop_class, uint8_t prop_type OVS_UNUSED,
|
|
|
|
const char *value, struct ofpbuf *out OVS_UNUSED)
|
|
|
|
{
|
2017-08-05 13:41:11 +08:00
|
|
|
char *error = NULL;
|
OF support and translation of generic encap and decap
This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.
CLI syntax for encap action with properties:
encap(<header>)
encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...))
For example:
encap(ethernet)
encap(nsh(md_type=1))
encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210)))
CLI syntax for decap action:
decap()
decap(packet_type(ns=<pt_ns>,type=<pt_type>))
For example:
decap()
decap(packet_type(ns=0,type=0xfffe))
decap(packet_type(ns=1,type=0x894f))
The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).
This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.
In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.
The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.
Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-08-02 16:04:12 +08:00
|
|
|
|
|
|
|
if (value == NULL || *value == '\0') {
|
|
|
|
return xstrdup("Value missing for encap property");
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (prop_class) {
|
2017-08-05 13:41:11 +08:00
|
|
|
case OFPPPC_NSH:
|
|
|
|
switch (prop_type) {
|
|
|
|
case OFPPPT_PROP_NSH_MDTYPE: {
|
|
|
|
/* Format: "<md_type>:uint8_t". */
|
|
|
|
uint8_t md_type;
|
|
|
|
error = str_to_u8(value, "md_type", &md_type);
|
|
|
|
if (error != NULL) {
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
if (md_type < 1 || md_type > 2) {
|
|
|
|
return xstrdup("invalid md_type");
|
|
|
|
}
|
|
|
|
struct ofpact_ed_prop_nsh_md_type *pnmt =
|
|
|
|
ofpbuf_put_uninit(out, sizeof(*pnmt));
|
|
|
|
pnmt->header.prop_class = prop_class;
|
|
|
|
pnmt->header.type = prop_type;
|
|
|
|
pnmt->header.len =
|
|
|
|
offsetof(struct ofp_ed_prop_nsh_md_type, pad);
|
|
|
|
pnmt->md_type = md_type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case OFPPPT_PROP_NSH_TLV: {
|
|
|
|
/* Format: "<class>:ovs_be16,<type>:uint8_t,<val>:hex_string" */
|
|
|
|
struct ofpact_ed_prop_nsh_tlv *pnt;
|
|
|
|
uint16_t tlv_class;
|
|
|
|
uint8_t tlv_type;
|
|
|
|
char buf[256];
|
|
|
|
size_t tlv_value_len, padding;
|
|
|
|
size_t start_ofs = out->size;
|
|
|
|
|
|
|
|
if (!ovs_scan(value, "0x%"SCNx16",%"SCNu8",0x%251[0-9a-fA-F]",
|
|
|
|
&tlv_class, &tlv_type, buf)) {
|
|
|
|
return xasprintf("Invalid NSH TLV header: %s", value);
|
|
|
|
}
|
|
|
|
ofpbuf_put_uninit(out, sizeof(*pnt));
|
|
|
|
ofpbuf_put_hex(out, buf, &tlv_value_len);
|
|
|
|
pnt = ALIGNED_CAST(struct ofpact_ed_prop_nsh_tlv *,
|
|
|
|
((char *)out->data + start_ofs));
|
|
|
|
padding = ROUND_UP(tlv_value_len, 8) - tlv_value_len;
|
|
|
|
pnt->header.prop_class = prop_class;
|
|
|
|
pnt->header.type = prop_type;
|
|
|
|
pnt->header.len = sizeof(*pnt) + tlv_value_len + padding;
|
|
|
|
pnt->tlv_class = htons(tlv_class);
|
|
|
|
pnt->tlv_type = tlv_type;
|
|
|
|
pnt->tlv_len = tlv_value_len;
|
|
|
|
if (padding > 0) {
|
|
|
|
ofpbuf_put_zeros(out, padding);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
/* Unsupported property types rejected before. */
|
|
|
|
OVS_NOT_REACHED();
|
|
|
|
}
|
|
|
|
break;
|
OF support and translation of generic encap and decap
This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.
CLI syntax for encap action with properties:
encap(<header>)
encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...))
For example:
encap(ethernet)
encap(nsh(md_type=1))
encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210)))
CLI syntax for decap action:
decap()
decap(packet_type(ns=<pt_ns>,type=<pt_type>))
For example:
decap()
decap(packet_type(ns=0,type=0xfffe))
decap(packet_type(ns=1,type=0x894f))
The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).
This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.
In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.
The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.
Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-08-02 16:04:12 +08:00
|
|
|
default:
|
|
|
|
/* Unsupported property classes rejected before. */
|
|
|
|
OVS_NOT_REACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
format_ed_prop_class(const struct ofpact_ed_prop *prop)
|
|
|
|
{
|
|
|
|
switch (prop->prop_class) {
|
|
|
|
case OFPPPC_BASIC:
|
|
|
|
return "basic";
|
|
|
|
case OFPPPC_MPLS:
|
|
|
|
return "mpls";
|
|
|
|
case OFPPPC_GRE:
|
|
|
|
return "gre";
|
|
|
|
case OFPPPC_GTP:
|
|
|
|
return "gtp";
|
2017-08-05 13:41:11 +08:00
|
|
|
case OFPPPC_NSH:
|
|
|
|
return "nsh";
|
OF support and translation of generic encap and decap
This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.
CLI syntax for encap action with properties:
encap(<header>)
encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...))
For example:
encap(ethernet)
encap(nsh(md_type=1))
encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210)))
CLI syntax for decap action:
decap()
decap(packet_type(ns=<pt_ns>,type=<pt_type>))
For example:
decap()
decap(packet_type(ns=0,type=0xfffe))
decap(packet_type(ns=1,type=0x894f))
The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).
This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.
In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.
The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.
Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-08-02 16:04:12 +08:00
|
|
|
default:
|
|
|
|
OVS_NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
format_ed_prop_type(const struct ofpact_ed_prop *prop)
|
|
|
|
{
|
|
|
|
switch (prop->prop_class) {
|
2017-08-05 13:41:11 +08:00
|
|
|
case OFPPPC_NSH:
|
|
|
|
switch (prop->type) {
|
|
|
|
case OFPPPT_PROP_NSH_MDTYPE:
|
|
|
|
return "md_type";
|
|
|
|
case OFPPPT_PROP_NSH_TLV:
|
|
|
|
return "tlv";
|
|
|
|
default:
|
|
|
|
OVS_NOT_REACHED();
|
|
|
|
}
|
|
|
|
break;
|
OF support and translation of generic encap and decap
This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.
CLI syntax for encap action with properties:
encap(<header>)
encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...))
For example:
encap(ethernet)
encap(nsh(md_type=1))
encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210)))
CLI syntax for decap action:
decap()
decap(packet_type(ns=<pt_ns>,type=<pt_type>))
For example:
decap()
decap(packet_type(ns=0,type=0xfffe))
decap(packet_type(ns=1,type=0x894f))
The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).
This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.
In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.
The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.
Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-08-02 16:04:12 +08:00
|
|
|
default:
|
|
|
|
OVS_NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
format_ed_prop(struct ds *s OVS_UNUSED,
|
|
|
|
const struct ofpact_ed_prop *prop)
|
|
|
|
{
|
|
|
|
switch (prop->prop_class) {
|
2017-08-05 13:41:11 +08:00
|
|
|
case OFPPPC_NSH:
|
|
|
|
switch (prop->type) {
|
|
|
|
case OFPPPT_PROP_NSH_MDTYPE: {
|
|
|
|
struct ofpact_ed_prop_nsh_md_type *pnmt =
|
|
|
|
ALIGNED_CAST(struct ofpact_ed_prop_nsh_md_type *, prop);
|
|
|
|
ds_put_format(s, "%s=%d", format_ed_prop_type(prop),
|
|
|
|
pnmt->md_type);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
case OFPPPT_PROP_NSH_TLV: {
|
|
|
|
struct ofpact_ed_prop_nsh_tlv *pnt =
|
|
|
|
ALIGNED_CAST(struct ofpact_ed_prop_nsh_tlv *, prop);
|
|
|
|
ds_put_format(s, "%s(0x%04x,%d,",
|
|
|
|
format_ed_prop_type(prop),
|
|
|
|
ntohs(pnt->tlv_class), pnt->tlv_type);
|
|
|
|
ds_put_hex(s, pnt->data, pnt->tlv_len);
|
|
|
|
ds_put_cstr(s,")");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
OVS_NOT_REACHED();
|
|
|
|
}
|
OF support and translation of generic encap and decap
This commit adds support for the OpenFlow actions generic encap
and decap (as specified in ONF EXT-382) to the OVS control plane.
CLI syntax for encap action with properties:
encap(<header>)
encap(<header>(<prop>=<value>,<tlv>(<class>,<type>,<value>),...))
For example:
encap(ethernet)
encap(nsh(md_type=1))
encap(nsh(md_type=2,tlv(0x1000,10,0x12345678),tlv(0x2000,20,0xfedcba9876543210)))
CLI syntax for decap action:
decap()
decap(packet_type(ns=<pt_ns>,type=<pt_type>))
For example:
decap()
decap(packet_type(ns=0,type=0xfffe))
decap(packet_type(ns=1,type=0x894f))
The first header supported for encap and decap is "ethernet" to convert
packets between packet_type (1,Ethertype) and (0,0).
This commit also implements a skeleton for the translation of generic
encap and decap actions in ofproto-dpif and adds support to encap and
decap an Ethernet header.
In general translation of encap commits pending actions and then rewrites
struct flow in accordance with the new packet type and header. In the
case of encap(ethernet) it suffices to change the packet type from
(1, Ethertype) to (0,0) and set the dl_type accordingly. A new
pending_encap flag in xlate ctx is set to mark that an corresponding
datapath encap action must be triggered at the next commit. In the
case of encap(ethernet) ofproto generetas a push_eth action.
The general case for translation of decap() is to emit a datapath action
to decap the current outermost header and then recirculate the packet
to reparse the inner headers. In the special case of an Ethernet packet,
decap() just changes the packet type from (0,0) to (1, dl_type) without
a need to recirculate. The emission of the pop_eth action for the
datapath is postponed to the next commit.
Hence encap(ethernet) and decap() on an Ethernet packet are OF octions
that only incur a cost in the dataplane when a modifed packet is
actually committed, e.g. because it is sent out. They can freely be
used for normalizing the packet type in the OF pipeline without
degrading performance.
Signed-off-by: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltan Balogh <zoltan.balogh@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
2017-08-02 16:04:12 +08:00
|
|
|
default:
|
|
|
|
OVS_NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|