mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 01:51:26 +00:00
ovs-ofctl: New testing command "parse-group".
This will be used in an upcoming test. Acked-by: Numan Siddique <nusiddiq@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
parent
9f0721e989
commit
4304fd986e
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2017 Nicira, Inc.
|
||||
* Copyright (c) 2008-2017, 2019 Nicira, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -2014,6 +2014,8 @@ ofputil_encode_ofp11_group_mod(enum ofp_version ofp_version,
|
||||
ogm->type = gm->type;
|
||||
ogm->group_id = htonl(gm->group_id);
|
||||
|
||||
ofpmsg_update_length(b);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
@ -2080,6 +2082,7 @@ ofputil_encode_ofp15_group_mod(enum ofp_version ofp_version,
|
||||
}
|
||||
|
||||
id_pool_destroy(bucket_ids);
|
||||
ofpmsg_update_length(b);
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008-2017 Nicira, Inc.
|
||||
* Copyright (c) 2008-2017, 2019 Nicira, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -4175,6 +4175,44 @@ ofctl_parse_flows(struct ovs_cmdl_context *ctx)
|
||||
free(fms);
|
||||
}
|
||||
|
||||
/* "parse-group GROUP": parses the argument as a group (like add-group) and
|
||||
* prints it back to stdout. */
|
||||
static void
|
||||
ofctl_parse_group(struct ovs_cmdl_context *ctx)
|
||||
{
|
||||
enum ofputil_protocol usable_protocols;
|
||||
struct ofputil_group_mod gm;
|
||||
char *error = parse_ofp_group_mod_str(&gm, OFPGC11_ADD, ctx->argv[1], NULL,
|
||||
NULL, &usable_protocols);
|
||||
if (error) {
|
||||
ovs_fatal(0, "%s", error);
|
||||
}
|
||||
|
||||
char *usable_s = ofputil_protocols_to_string(usable_protocols);
|
||||
printf("usable protocols: %s\n", usable_s);
|
||||
free(usable_s);
|
||||
|
||||
if (!(usable_protocols & allowed_protocols)) {
|
||||
ovs_fatal(0, "no usable protocol");
|
||||
}
|
||||
enum ofputil_protocol protocol = 0;
|
||||
for (int i = 0; i < sizeof(enum ofputil_protocol) * CHAR_BIT; i++) {
|
||||
protocol = 1 << i;
|
||||
if (protocol & usable_protocols & allowed_protocols) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
enum ofp_version version = ofputil_protocol_to_ofp_version(protocol);
|
||||
printf("chosen version: %s\n", ofputil_version_to_string(version));
|
||||
|
||||
struct ofpbuf *msg = ofputil_encode_group_mod(version, &gm, NULL, false);
|
||||
ofp_print(stdout, msg->data, msg->size, NULL, NULL, verbosity);
|
||||
ofpbuf_delete(msg);
|
||||
|
||||
ofputil_uninit_group_mod(&gm);
|
||||
}
|
||||
|
||||
static void
|
||||
ofctl_parse_nxm__(bool oxm, enum ofp_version version)
|
||||
{
|
||||
@ -5033,6 +5071,7 @@ static const struct ovs_cmdl_command all_commands[] = {
|
||||
/* Undocumented commands for testing. */
|
||||
{ "parse-flow", NULL, 1, 1, ofctl_parse_flow, OVS_RW },
|
||||
{ "parse-flows", NULL, 1, 1, ofctl_parse_flows, OVS_RW },
|
||||
{ "parse-group", NULL, 1, 1, ofctl_parse_group, OVS_RW },
|
||||
{ "parse-nx-match", NULL, 0, 0, ofctl_parse_nxm, OVS_RW },
|
||||
{ "parse-nxm", NULL, 0, 0, ofctl_parse_nxm, OVS_RW },
|
||||
{ "parse-oxm", NULL, 1, 1, ofctl_parse_oxm, OVS_RW },
|
||||
|
Loading…
x
Reference in New Issue
Block a user