[ovs-dev] [PATCH 14/22] ofp-print: Support printing of (draft) OpenFlow 1.5 group messages with bucket actions
Simon Horman
simon.horman at netronome.com
Mon Nov 10 04:48:01 UTC 2014
EXT-350
Signed-off-by: Simon Horman <simon.horman at netronome.com>
---
lib/ofp-print.c | 50 +++++++++++++++++++++++++++++++++++----------
tests/ofp-print.at | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 97 insertions(+), 13 deletions(-)
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 68f5740..13596f9 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -2104,7 +2104,7 @@ ofp_header_to_string__(const struct ofp_header *oh, enum ofpraw raw,
}
static void
-ofp_print_bucket_id(struct ds *s, uint32_t bucket_id,
+ofp_print_bucket_id(struct ds *s, const char *label, uint32_t bucket_id,
enum ofp_version ofp_version)
{
switch (ofp_version) {
@@ -2122,7 +2122,7 @@ ofp_print_bucket_id(struct ds *s, uint32_t bucket_id,
OVS_NOT_REACHED();
}
- ds_put_cstr(s, "bucket_id:");
+ ds_put_cstr(s, label);
if (bucket_id >= OFPG15_BUCKET_FIRST) {
static const char *id_str[] = { "first", "last", "all" };
@@ -2137,22 +2137,29 @@ ofp_print_bucket_id(struct ds *s, uint32_t bucket_id,
static void
ofp_print_group(struct ds *s, uint32_t group_id, uint8_t type,
- struct list *p_buckets, enum ofp_version ofp_version)
+ struct list *p_buckets, enum ofp_version ofp_version,
+ bool suppress_type)
{
- static const char *type_str[] = { "all", "select", "indirect",
- "ff", "unknown" };
struct ofputil_bucket *bucket;
- ds_put_format(s, "group_id=%"PRIu32",type=%s",
- group_id, type_str[type > 4 ? 4 : type]);
+ ds_put_format(s, "group_id=%"PRIu32, group_id);
+
+ if (!suppress_type) {
+ static const char *type_str[] = { "all", "select", "indirect",
+ "ff", "unknown" };
+ ds_put_format(s, ",type=%s", type_str[type > 4 ? 4 : type]);
+ }
+
if (!p_buckets) {
return;
}
+ ds_put_char(s, ',');
+
LIST_FOR_EACH (bucket, list_node, p_buckets) {
- ds_put_cstr(s, ",bucket=");
+ ds_put_cstr(s, "bucket=");
- ofp_print_bucket_id(s, bucket->bucket_id, ofp_version);
+ ofp_print_bucket_id(s, "bucket_id:", bucket->bucket_id, ofp_version);
if (bucket->weight != 1) {
ds_put_format(s, "weight:%"PRIu16",", bucket->weight);
}
@@ -2165,7 +2172,10 @@ ofp_print_group(struct ds *s, uint32_t group_id, uint8_t type,
ds_put_cstr(s, "actions=");
ofpacts_format(bucket->ofpacts, bucket->ofpacts_len, s);
+ ds_put_char(s, ',');
}
+
+ ds_chomp(s, ',');
}
static void
@@ -2197,7 +2207,8 @@ ofp_print_group_desc(struct ds *s, const struct ofp_header *oh)
ds_put_char(s, '\n');
ds_put_char(s, ' ');
- ofp_print_group(s, gd.group_id, gd.type, &gd.buckets, oh->version);
+ ofp_print_group(s, gd.group_id, gd.type, &gd.buckets, oh->version,
+ false);
ofputil_bucket_list_destroy(&gd.buckets);
}
}
@@ -2306,6 +2317,7 @@ ofp_print_group_mod(struct ds *s, const struct ofp_header *oh)
{
struct ofputil_group_mod gm;
int error;
+ bool bucket_command = false;
error = ofputil_decode_group_mod(oh, &gm);
if (error) {
@@ -2329,12 +2341,28 @@ ofp_print_group_mod(struct ds *s, const struct ofp_header *oh)
ds_put_cstr(s, "DEL");
break;
+ case OFPGC15_INSERT_BUCKET:
+ ds_put_cstr(s, "INSERT_BUCKET");
+ bucket_command = true;
+ break;
+
+ case OFPGC15_REMOVE_BUCKET:
+ ds_put_cstr(s, "REMOVE_BUCKET");
+ bucket_command = true;
+ break;
+
default:
ds_put_format(s, "cmd:%"PRIu16"", gm.command);
}
ds_put_char(s, ' ');
- ofp_print_group(s, gm.group_id, gm.type, &gm.buckets, oh->version);
+ if (bucket_command) {
+ ofp_print_bucket_id(s, "command_bucket_id:",
+ gm.command_bucket_id, oh->version);
+ }
+
+ ofp_print_group(s, gm.group_id, gm.type, &gm.buckets, oh->version,
+ bucket_command);
ofputil_bucket_list_destroy(&gm.buckets);
}
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index ee3f95d..1221335 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -1959,7 +1959,7 @@ AT_CHECK([ovs-ofctl ofp-print "\
])
AT_CLEANUP
-AT_SETUP([OFPST_GROUP_DESC reply])
+AT_SETUP([OFPST_GROUP_DESC reply - OF1.1])
AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
AT_CHECK([ovs-ofctl ofp-print "\
02 13 00 78 00 00 00 02 00 07 00 00 00 00 00 00 \
@@ -1976,6 +1976,26 @@ OFPST_GROUP_DESC reply (OF1.1) (xid=0x2):
])
AT_CLEANUP
+AT_SETUP([OFPST_GROUP_DESC reply - OF1.5])
+AT_KEYWORDS([ofp-print OFPT_STATS_REPLY])
+AT_CHECK([ovs-ofctl ofp-print "\
+06 13 00 98 00 00 00 02 00 07 00 00 00 00 00 00 \
+00 88 01 00 00 00 20 00 00 78 00 00 00 00 00 00 \
+00 28 00 10 00 00 00 00 00 00 00 10 00 00 00 01 \
+00 00 00 00 00 00 00 00 00 00 00 08 00 64 00 00 \
+00 01 00 08 00 00 00 01 \
+00 28 00 10 00 00 00 01 00 00 00 10 00 00 00 02 \
+00 00 00 00 00 00 00 00 00 00 00 08 00 c8 00 00 \
+00 01 00 08 00 00 00 02 \
+00 28 00 10 00 00 00 02 00 00 00 10 00 00 00 03 \
+00 00 00 00 00 00 00 00 00 00 00 08 00 c8 00 00 \
+00 01 00 08 00 00 00 03 \
+"], [0], [dnl
+OFPST_GROUP_DESC reply (OF1.5) (xid=0x2):
+ group_id=8192,type=select,bucket=bucket_id:0,weight:100,watch_port:1,actions=output:1,bucket=bucket_id:1,weight:200,watch_port:2,actions=output:2,bucket=bucket_id:2,weight:200,watch_port:3,actions=output:3
+])
+AT_CLEANUP
+
AT_SETUP([OFPST_GROUP_FEATURES request])
AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
AT_CHECK([ovs-ofctl ofp-print "\
@@ -2759,7 +2779,7 @@ NXT_FLOW_MOD (xid=0x2): ADD NXM_NX_TUN_ID(00000000000001c8), NXM_NX_REG0(0000007
])
AT_CLEANUP
-AT_SETUP([OFPT_GROUP_MOD])
+AT_SETUP([OFPT_GROUP_MOD - OF1.1])
AT_KEYWORDS([ofp-print])
AT_CHECK([ovs-ofctl ofp-print "\
02 0f 00 70 11 22 33 44 00 00 01 00 87 65 43 21 \
@@ -2775,6 +2795,42 @@ OFPT_GROUP_MOD (OF1.1) (xid=0x11223344):
])
AT_CLEANUP
+AT_SETUP([OFPT_GROUP_MOD add - OF1.5])
+AT_KEYWORDS([ofp-print])
+AT_CHECK([ovs-ofctl ofp-print "\
+06 0f 00 90 11 22 33 44 00 00 01 00 87 65 43 21 \
+00 78 00 00 ff ff ff ff 00 28 00 10 00 00 00 00 \
+00 00 00 10 00 00 00 01 00 00 00 00 00 00 00 00 \
+00 00 00 08 00 64 00 00 00 01 00 08 00 00 00 01 \
+00 28 00 10 00 00 00 01 00 00 00 10 00 00 00 02 \
+00 00 00 00 00 00 00 00 00 00 00 08 00 c8 00 00 \
+00 01 00 08 00 00 00 02 00 28 00 10 00 00 00 02 \
+00 00 00 10 00 00 00 03 00 00 00 00 00 00 00 00 \
+00 00 00 08 00 c8 00 00 00 01 00 08 00 00 00 03 \
+"], [0], [dnl
+OFPT_GROUP_MOD (OF1.5) (xid=0x11223344):
+ ADD group_id=2271560481,type=select,bucket=bucket_id:0,weight:100,watch_port:1,actions=output:1,bucket=bucket_id:1,weight:200,watch_port:2,actions=output:2,bucket=bucket_id:2,weight:200,watch_port:3,actions=output:3
+])
+AT_CLEANUP
+
+AT_SETUP([OFPT_GROUP_MOD insert bucket - OF1.5])
+AT_KEYWORDS([ofp-print])
+AT_CHECK([ovs-ofctl ofp-print "\
+06 0f 00 90 11 22 33 44 00 03 01 00 87 65 43 21 \
+00 78 00 00 ff ff ff fd 00 28 00 10 00 00 00 00 \
+00 00 00 10 00 00 00 01 00 00 00 00 00 00 00 00 \
+00 00 00 08 00 64 00 00 00 01 00 08 00 00 00 01 \
+00 28 00 10 00 00 00 01 00 00 00 10 00 00 00 02 \
+00 00 00 00 00 00 00 00 00 00 00 08 00 c8 00 00 \
+00 01 00 08 00 00 00 02 00 28 00 10 00 00 00 02 \
+00 00 00 10 00 00 00 03 00 00 00 00 00 00 00 00 \
+00 00 00 08 00 c8 00 00 00 01 00 08 00 00 00 03 \
+"], [0], [dnl
+OFPT_GROUP_MOD (OF1.5) (xid=0x11223344):
+ INSERT_BUCKET command_bucket_id:first,group_id=2271560481,bucket=bucket_id:0,weight:100,watch_port:1,actions=output:1,bucket=bucket_id:1,weight:200,watch_port:2,actions=output:2,bucket=bucket_id:2,weight:200,watch_port:3,actions=output:3
+])
+AT_CLEANUP
+
AT_SETUP([NXT_FLOW_REMOVED])
AT_KEYWORDS([ofp-print])
AT_CHECK([ovs-ofctl ofp-print "\
--
2.1.1
More information about the dev
mailing list