Skip to content

Commit

Permalink
ofproto: Return the OFPC_BUNDLES bit in switch features reply.
Browse files Browse the repository at this point in the history
Add definitions for the OpenFlow 1.4.1/1.5 specific capabilities bits
OFPC14_BUNDLES and OFPC14_FLOW_MONITORING.  Return the bundles
capability bit in switch features reply.

Reported-by: Andrej Leitner <[email protected]>
Signed-off-by: Jarno Rajahalme <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
Jarno Rajahalme committed Nov 14, 2016
1 parent 14bf795 commit 50b73fe
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 7 deletions.
6 changes: 6 additions & 0 deletions include/openflow/openflow-1.4.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@

#include <openflow/openflow-1.3.h>

/* OpenFlow 1.4.1+ specific capabilities
* (struct ofp_switch_features, member capabilities). */
enum ofp14_capabilities {
OFPC14_BUNDLES = 1 << 9, /* Switch supports bundles. */
OFPC14_FLOW_MONITORING = 1 << 10, /* Switch supports flow monitoring. */
};

/* ## ---------- ## */
/* ## ofp14_port ## */
Expand Down
11 changes: 8 additions & 3 deletions include/openvswitch/ofp-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ struct ofputil_phy_port {
};

enum ofputil_capabilities {
/* OpenFlow 1.0, 1.1, 1.2, and 1.3 share these capability values. */
/* All OpenFlow versions share these capability values. */
OFPUTIL_C_FLOW_STATS = 1 << 0, /* Flow statistics. */
OFPUTIL_C_TABLE_STATS = 1 << 1, /* Table statistics. */
OFPUTIL_C_PORT_STATS = 1 << 2, /* Port statistics. */
Expand All @@ -626,11 +626,16 @@ enum ofputil_capabilities {
/* OpenFlow 1.0 only. */
OFPUTIL_C_STP = 1 << 3, /* 802.1d spanning tree. */

/* OpenFlow 1.1, 1.2, and 1.3 share this capability. */
/* OpenFlow 1.1+ only. Note that this bit value does not match the one
* in the OpenFlow message. */
OFPUTIL_C_GROUP_STATS = 1 << 4, /* Group statistics. */

/* OpenFlow 1.2 and 1.3 share this capability */
/* OpenFlow 1.2+ only. */
OFPUTIL_C_PORT_BLOCKED = 1 << 8, /* Switch will block looping ports */

/* OpenFlow 1.4+ only. */
OFPUTIL_C_BUNDLES = 1 << 9, /* Switch supports bundles. */
OFPUTIL_C_FLOW_MONITORING = 1 << 10, /* Switch supports flow monitoring. */
};

/* Abstract ofp_switch_features. */
Expand Down
2 changes: 2 additions & 0 deletions lib/ofp-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ ofputil_capabilities_to_name(uint32_t bit)
case OFPUTIL_C_STP: return "STP";
case OFPUTIL_C_GROUP_STATS: return "GROUP_STATS";
case OFPUTIL_C_PORT_BLOCKED: return "PORT_BLOCKED";
case OFPUTIL_C_BUNDLES: return "BUNDLES";
case OFPUTIL_C_FLOW_MONITORING: return "FLOW_MONITORING";
}

return NULL;
Expand Down
8 changes: 6 additions & 2 deletions lib/ofp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -4644,6 +4644,9 @@ BUILD_ASSERT_DECL((int) OFPUTIL_C_PORT_STATS == OFPC_PORT_STATS);
BUILD_ASSERT_DECL((int) OFPUTIL_C_IP_REASM == OFPC_IP_REASM);
BUILD_ASSERT_DECL((int) OFPUTIL_C_QUEUE_STATS == OFPC_QUEUE_STATS);
BUILD_ASSERT_DECL((int) OFPUTIL_C_ARP_MATCH_IP == OFPC_ARP_MATCH_IP);
BUILD_ASSERT_DECL((int) OFPUTIL_C_PORT_BLOCKED == OFPC12_PORT_BLOCKED);
BUILD_ASSERT_DECL((int) OFPUTIL_C_BUNDLES == OFPC14_BUNDLES);
BUILD_ASSERT_DECL((int) OFPUTIL_C_FLOW_MONITORING == OFPC14_FLOW_MONITORING);

static uint32_t
ofputil_capabilities_mask(enum ofp_version ofp_version)
Expand All @@ -4655,10 +4658,12 @@ ofputil_capabilities_mask(enum ofp_version ofp_version)
return OFPC_COMMON | OFPC_ARP_MATCH_IP;
case OFP12_VERSION:
case OFP13_VERSION:
return OFPC_COMMON | OFPC12_PORT_BLOCKED;
case OFP14_VERSION:
case OFP15_VERSION:
case OFP16_VERSION:
return OFPC_COMMON | OFPC12_PORT_BLOCKED;
return OFPC_COMMON | OFPC12_PORT_BLOCKED | OFPC14_BUNDLES
| OFPC14_FLOW_MONITORING;
default:
/* Caller needs to check osf->header.version itself */
return 0;
Expand Down Expand Up @@ -4784,7 +4789,6 @@ ofputil_encode_switch_features(const struct ofputil_switch_features *features,
osf->n_buffers = htonl(features->n_buffers);
osf->n_tables = features->n_tables;

osf->capabilities = htonl(features->capabilities & OFPC_COMMON);
osf->capabilities = htonl(features->capabilities &
ofputil_capabilities_mask(version));
switch (version) {
Expand Down
2 changes: 1 addition & 1 deletion ofproto/ofproto.c
Original file line number Diff line number Diff line change
Expand Up @@ -3295,7 +3295,7 @@ handle_features_request(struct ofconn *ofconn, const struct ofp_header *oh)
features.n_tables = ofproto_get_n_visible_tables(ofproto);
features.capabilities = (OFPUTIL_C_FLOW_STATS | OFPUTIL_C_TABLE_STATS |
OFPUTIL_C_PORT_STATS | OFPUTIL_C_QUEUE_STATS |
OFPUTIL_C_GROUP_STATS);
OFPUTIL_C_GROUP_STATS | OFPUTIL_C_BUNDLES);
if (arp_match_ip) {
features.capabilities |= OFPUTIL_C_ARP_MATCH_IP;
}
Expand Down
24 changes: 24 additions & 0 deletions tests/ofp-print.at
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,30 @@ capabilities: FLOW_STATS TABLE_STATS PORT_STATS IP_REASM QUEUE_STATS PORT_BLOCKE
])
AT_CLEANUP

AT_SETUP([OFPT_FEATURES_REPLY - OF1.4])
AT_KEYWORDS([ofp-print])
AT_CHECK([ovs-ofctl ofp-print "\
05 06 00 20 00 00 00 01 00 00 50 54 00 00 00 01 \
00 00 01 00 ff 00 00 00 00 00 07 6f 00 00 00 00 \
"], [0], [dnl
OFPT_FEATURES_REPLY (OF1.4) (xid=0x1): dpid:0000505400000001
n_tables:255, n_buffers:256
capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS IP_REASM QUEUE_STATS PORT_BLOCKED BUNDLES FLOW_MONITORING
])
AT_CLEANUP

AT_SETUP([OFPT_FEATURES_REPLY - OF1.5])
AT_KEYWORDS([ofp-print])
AT_CHECK([ovs-ofctl ofp-print "\
06 06 00 20 00 00 00 01 00 00 50 54 00 00 00 01 \
00 00 01 00 ff 00 00 00 00 00 07 6f 00 00 00 00 \
"], [0], [dnl
OFPT_FEATURES_REPLY (OF1.5) (xid=0x1): dpid:0000505400000001
n_tables:255, n_buffers:256
capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS IP_REASM QUEUE_STATS PORT_BLOCKED BUNDLES FLOW_MONITORING
])
AT_CLEANUP

AT_SETUP([OFPT_FEATURES_REPLY - with auxiliary_id - OF1.3])
AT_KEYWORDS([ofp-print])
AT_CHECK([ovs-ofctl ofp-print "\
Expand Down
2 changes: 1 addition & 1 deletion tests/ofproto.at
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ do
AT_CHECK_UNQUOTED([strip_xids < stdout], [0], [dnl
OFPT_FEATURES_REPLY (OF1.4): dpid:fedcba9876543210
n_tables:254, n_buffers:0
capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS
capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS BUNDLES
OFPST_PORT_DESC reply (OF1.4):
LOCAL(br0): addr:aa:55:aa:55:00:00
config: $config
Expand Down

0 comments on commit 50b73fe

Please sign in to comment.