Skip to content

Commit

Permalink
Add support for OpenFlow 1.6 (draft) port status and port mod messages.
Browse files Browse the repository at this point in the history
OpenFlow 1.6 adds support for EUI-64 addresses for ports, and extends
the maximum length of OpenFlow port names from 16 to 64 bytes.

ONF-JIRA: EXT-566
Signed-off-by: Ben Pfaff <[email protected]>
Acked-by: Andy Zhou <[email protected]>
  • Loading branch information
blp committed Apr 7, 2017
1 parent b2342f7 commit 2f2b904
Show file tree
Hide file tree
Showing 18 changed files with 503 additions and 109 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Post-v2.7.0
database.
- Add the command 'ovs-appctl stp/show' (see ovs-vswitchd(8)).
- OpenFlow:
* Increased support for OpenFlow 1.6 (draft).
* Bundles now support hashing by just nw_src or nw_dst.
* The "learn" action now supports a "limit" option (see ovs-ofctl(8)).

Expand Down
1 change: 1 addition & 0 deletions include/openflow/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ openflowinclude_HEADERS = \
include/openflow/openflow-1.3.h \
include/openflow/openflow-1.4.h \
include/openflow/openflow-1.5.h \
include/openflow/openflow-1.6.h \
include/openflow/openflow-common.h \
include/openflow/openflow.h

Expand Down
7 changes: 6 additions & 1 deletion include/openflow/openflow-1.0.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@

#include <openflow/openflow-common.h>

/* Maximum name of a port.
*
* OpenFlow 1.6 (draft) increases this to 64. */
#define OFP10_MAX_PORT_NAME_LEN 16

/* Port number(s) meaning
* --------------- --------------------------------------
* 0x0000 not assigned a meaning by OpenFlow 1.0
Expand Down Expand Up @@ -97,7 +102,7 @@ enum ofp10_port_features {
struct ofp10_phy_port {
ovs_be16 port_no;
struct eth_addr hw_addr;
char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
char name[OFP10_MAX_PORT_NAME_LEN]; /* Null-terminated */

ovs_be32 config; /* Bitmap of OFPPC_* and OFPPC10_* flags. */
ovs_be32 state; /* Bitmap of OFPPS_* and OFPPS10_* flags. */
Expand Down
3 changes: 2 additions & 1 deletion include/openflow/openflow-1.1.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#define OPENFLOW_11_H 1

#include <openflow/openflow-common.h>
#include <openflow/openflow-1.0.h>

/* OpenFlow 1.1 uses 32-bit port numbers. Open vSwitch, for now, uses OpenFlow
* 1.0 port numbers internally. We map them to OpenFlow 1.0 as follows:
Expand Down Expand Up @@ -112,7 +113,7 @@ struct ofp11_port {
uint8_t pad[4];
struct eth_addr hw_addr;
uint8_t pad2[2]; /* Align to 64 bits. */
char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
char name[OFP10_MAX_PORT_NAME_LEN]; /* Null-terminated */

ovs_be32 config; /* Bitmap of OFPPC_* flags. */
ovs_be32 state; /* Bitmap of OFPPS_* and OFPPS11_* flags. */
Expand Down
4 changes: 2 additions & 2 deletions include/openflow/openflow-1.4.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2008, 2014 The Board of Trustees of The Leland Stanford
/* Copyright (c) 2008, 2014, 2017 The Board of Trustees of The Leland Stanford
* Junior University
* Copyright (c) 2011, 2012 Open Networking Foundation
*
Expand Down Expand Up @@ -80,7 +80,7 @@ struct ofp14_port {
uint8_t pad[2];
struct eth_addr hw_addr;
uint8_t pad2[2]; /* Align to 64 bits. */
char name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
char name[OFP10_MAX_PORT_NAME_LEN]; /* Null-terminated */

ovs_be32 config; /* Bitmap of OFPPC_* flags. */
ovs_be32 state; /* Bitmap of OFPPS_* flags. */
Expand Down
98 changes: 98 additions & 0 deletions include/openflow/openflow-1.6.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford
* Junior University
* Copyright (c) 2011, 2013, 2014 Open Networking Foundation
*
* We are making the OpenFlow specification and associated documentation
* (Software) available for public use and benefit with the expectation
* that others will use, modify and enhance the Software and contribute
* those enhancements back to the community. However, since we would
* like to make the Software available for broadest use, with as few
* restrictions as possible permission is hereby granted, free of
* charge, to any person obtaining a copy of this Software to deal in
* the Software under the copyrights without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* The name and trademarks of copyright holder(s) may NOT be used in
* advertising or publicity pertaining to the Software or any
* derivatives without specific, written prior permission.
*/

/*
* Copyright (c) 2017 Nicira, 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.
*/

#ifndef OPENFLOW_16_H
#define OPENFLOW_16_H 1

#include <openflow/openflow-common.h>

#define OFP16_MAX_PORT_NAME_LEN 64

/* Bitmap of hardware address types supported by an OpenFlow port. */
enum ofp16_hardware_address_type {
OFPPHAT16_EUI48 = 1 << 0, /* 48-bit Ethernet address. */
OFPPHAT16_EUI64 = 1 << 1, /* 64-bit Ethernet address. */
};

struct ofp16_port {
ovs_be32 port_no;
ovs_be16 length;
ovs_be16 hw_addr_type; /* Zero or more OFPPHAT16_*. */
struct eth_addr hw_addr; /* EUI-48 hardware address. */
uint8_t pad[2]; /* Align to 64 bits. */
struct eth_addr64 hw_addr64; /* EUI-64 hardware address */
char name[OFP16_MAX_PORT_NAME_LEN]; /* Null-terminated */

ovs_be32 config; /* Bitmap of OFPPC_* flags. */
ovs_be32 state; /* Bitmap of OFPPS_* flags. */

/* Followed by 0 or more OFPPDPT14_* properties. (OpenFlow 1.6 (draft)
* defines the same properties as OpenFlow 1.4.) */
};
OFP_ASSERT(sizeof(struct ofp16_port) == 96);

struct ofp16_port_mod {
ovs_be32 port_no;
ovs_be16 hw_addr_type; /* Zero or more OFPPHAT16_*. */
uint8_t pad[2]; /* Align to 64 bits. */
struct eth_addr hw_addr;
uint8_t pad2[2];
struct eth_addr64 hw_addr64; /* EUI-64 hardware address */

ovs_be32 config; /* Bitmap of OFPPC_* flags. */
ovs_be32 mask; /* Bitmap of OFPPC_* flags to be changed. */

/* Followed by 0 or more OFPPMPT14_* properties. (OpenFlow 1.6 (draft)
* defines the same properties as OpenFlow 1.4.) */
};
OFP_ASSERT(sizeof(struct ofp16_port_mod) == 32);


#endif /* openflow/openflow-1.6.h */
1 change: 0 additions & 1 deletion include/openflow/openflow-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ enum ofp_version {
#define INTEL_VENDOR_ID 0x0000AA01 /* Intel */

#define OFP_MAX_TABLE_NAME_LEN 32
#define OFP_MAX_PORT_NAME_LEN 16

#define OFP_OLD_PORT 6633
#define OFP_PORT 6653
Expand Down
3 changes: 2 additions & 1 deletion include/openflow/openflow.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2017 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,5 +23,6 @@
#include <openflow/openflow-1.3.h>
#include <openflow/openflow-1.4.h>
#include <openflow/openflow-1.5.h>
#include <openflow/openflow-1.6.h>

#endif /* openflow/openflow.h */
16 changes: 11 additions & 5 deletions include/openvswitch/ofp-msgs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, 2014, 2015, 2016 Nicira, Inc.
* Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -170,8 +170,10 @@ enum ofpraw {
OFPRAW_OFPT10_PORT_STATUS,
/* OFPT 1.1-1.3 (12): struct ofp_port_status, struct ofp11_port. */
OFPRAW_OFPT11_PORT_STATUS,
/* OFPT 1.4+ (12): struct ofp_port_status, struct ofp14_port, uint8_t[8][]. */
/* OFPT 1.4-1.5 (12): struct ofp_port_status, struct ofp14_port, uint8_t[8][]. */
OFPRAW_OFPT14_PORT_STATUS,
/* OFPT 1.6+ (12): struct ofp_port_status, struct ofp16_port, uint8_t[8][]. */
OFPRAW_OFPT16_PORT_STATUS,

/* OFPT 1.0 (13): struct ofp10_packet_out, uint8_t[]. */
OFPRAW_OFPT10_PACKET_OUT,
Expand All @@ -194,8 +196,10 @@ enum ofpraw {
OFPRAW_OFPT10_PORT_MOD,
/* OFPT 1.1-1.3 (16): struct ofp11_port_mod. */
OFPRAW_OFPT11_PORT_MOD,
/* OFPT 1.4+ (16): struct ofp14_port_mod, uint8_t[8][]. */
/* OFPT 1.4-1.5 (16): struct ofp14_port_mod, uint8_t[8][]. */
OFPRAW_OFPT14_PORT_MOD,
/* OFPT 1.6+ (16): struct ofp16_port_mod, uint8_t[8][]. */
OFPRAW_OFPT16_PORT_MOD,

/* OFPT 1.1-1.3 (17): struct ofp11_table_mod. */
OFPRAW_OFPT11_TABLE_MOD,
Expand Down Expand Up @@ -552,7 +556,8 @@ enum ofptype {
* OFPRAW_NXT_FLOW_REMOVED. */
OFPTYPE_PORT_STATUS, /* OFPRAW_OFPT10_PORT_STATUS.
* OFPRAW_OFPT11_PORT_STATUS.
* OFPRAW_OFPT14_PORT_STATUS. */
* OFPRAW_OFPT14_PORT_STATUS.
* OFPRAW_OFPT16_PORT_STATUS. */

/* Controller command messages. */
OFPTYPE_PACKET_OUT, /* OFPRAW_OFPT10_PACKET_OUT.
Expand All @@ -564,7 +569,8 @@ enum ofptype {
* OFPRAW_OFPT15_GROUP_MOD. */
OFPTYPE_PORT_MOD, /* OFPRAW_OFPT10_PORT_MOD.
* OFPRAW_OFPT11_PORT_MOD.
* OFPRAW_OFPT14_PORT_MOD. */
* OFPRAW_OFPT14_PORT_MOD.
* OFPRAW_OFPT16_PORT_MOD. */
OFPTYPE_TABLE_MOD, /* OFPRAW_OFPT11_TABLE_MOD.
* OFPRAW_OFPT14_TABLE_MOD. */

Expand Down
15 changes: 12 additions & 3 deletions include/openvswitch/ofp-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ovs_be32 ofputil_port_to_ofp11(ofp_port_t ofp10_port);

bool ofputil_port_from_string(const char *, ofp_port_t *portp);
void ofputil_format_port(ofp_port_t port, struct ds *);
void ofputil_port_to_string(ofp_port_t, char namebuf[OFP_MAX_PORT_NAME_LEN],
void ofputil_port_to_string(ofp_port_t, char namebuf[OFP10_MAX_PORT_NAME_LEN],
size_t bufsize);

/* Group numbers. */
Expand Down Expand Up @@ -598,11 +598,19 @@ enum ofputil_port_state {
OFPUTIL_PS_STP_MASK = 3 << 8 /* Bit mask for OFPPS10_STP_* values. */
};

/* Abstract ofp10_phy_port or ofp11_port. */
/* Abstract ofp10_phy_port, ofp11_port, ofp14_port, or ofp16_port. */
struct ofputil_phy_port {
ofp_port_t port_no;

/* Hardware addresses.
*
* Most hardware has a normal 48-bit Ethernet address, in hw_addr.
* Some hardware might have a 64-bit address in hw_addr64.
* All-bits-0 indicates that a given address is not present. */
struct eth_addr hw_addr;
char name[OFP_MAX_PORT_NAME_LEN];
struct eth_addr64 hw_addr64;

char name[OFP16_MAX_PORT_NAME_LEN]; /* 64 bytes in OF1.6+, 16 otherwise. */
enum ofputil_port_config config;
enum ofputil_port_state state;

Expand Down Expand Up @@ -682,6 +690,7 @@ struct ofpbuf *ofputil_encode_port_status(const struct ofputil_port_status *,
struct ofputil_port_mod {
ofp_port_t port_no;
struct eth_addr hw_addr;
struct eth_addr64 hw_addr64;
enum ofputil_port_config config;
enum ofputil_port_config mask;
enum netdev_features advertise;
Expand Down
9 changes: 9 additions & 0 deletions lib/ofp-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,11 @@ ofp_print_phy_port(struct ds *string, const struct ofputil_phy_port *port)
ds_put_format(string, "(%s): addr:"ETH_ADDR_FMT"\n",
name, ETH_ADDR_ARGS(port->hw_addr));

if (!eth_addr64_is_zero(port->hw_addr64)) {
ds_put_format(string, " addr64: "ETH_ADDR64_FMT"\n",
ETH_ADDR64_ARGS(port->hw_addr64));
}

ds_put_cstr(string, " config: ");
ofp_print_port_config(string, port->config);

Expand Down Expand Up @@ -1011,6 +1016,10 @@ ofp_print_port_mod(struct ds *string, const struct ofp_header *oh)
ofputil_format_port(pm.port_no, string);
ds_put_format(string, ": addr:"ETH_ADDR_FMT"\n",
ETH_ADDR_ARGS(pm.hw_addr));
if (!eth_addr64_is_zero(pm.hw_addr64)) {
ds_put_format(string, " addr64: "ETH_ADDR64_FMT"\n",
ETH_ADDR64_ARGS(pm.hw_addr64));
}

ds_put_cstr(string, " config: ");
ofp_print_port_config(string, pm.config);
Expand Down
Loading

0 comments on commit 2f2b904

Please sign in to comment.