X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=utilities%2Fovs-ofctl.c;h=e5c52555536e7e2ceae5634785aa9d5fcd4ef539;hb=df778240e1e311f7eba9dfda4f5f8bf0f915ae5f;hp=39c3dae96a5e1620ee1fe44fcc25b883911a13f3;hpb=b592e72628c025ee0cc850127b90c96409c395df;p=sliver-openvswitch.git diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 39c3dae96..e5c525555 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -2528,6 +2528,81 @@ ofctl_parse_ofp11_instructions(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) ds_destroy(&in); } +/* "check-vlan VLAN_TCI VLAN_TCI_MASK": converts the specified vlan_tci and + * mask values to and from various formats and prints the results. */ +static void +ofctl_check_vlan(int argc OVS_UNUSED, char *argv[]) +{ + struct cls_rule rule; + + char *string_s; + struct ofputil_flow_mod fm; + + struct ofpbuf nxm; + struct cls_rule nxm_rule; + int nxm_match_len; + char *nxm_s; + + struct ofp10_match of10_match; + struct cls_rule of10_rule; + + struct ofp11_match of11_match; + struct cls_rule of11_rule; + + enum ofperr error; + + cls_rule_init_catchall(&rule, OFP_DEFAULT_PRIORITY); + rule.flow.vlan_tci = htons(strtoul(argv[1], NULL, 16)); + rule.wc.vlan_tci_mask = htons(strtoul(argv[2], NULL, 16)); + + /* Convert to and from string. */ + string_s = cls_rule_to_string(&rule); + printf("%s -> ", string_s); + fflush(stdout); + parse_ofp_str(&fm, -1, string_s, false); + printf("%04"PRIx16"/%04"PRIx16"\n", + ntohs(fm.cr.flow.vlan_tci), + ntohs(fm.cr.wc.vlan_tci_mask)); + + /* Convert to and from NXM. */ + ofpbuf_init(&nxm, 0); + nxm_match_len = nx_put_match(&nxm, false, &rule, htonll(0), htonll(0)); + nxm_s = nx_match_to_string(nxm.data, nxm_match_len); + error = nx_pull_match(&nxm, nxm_match_len, 0, &nxm_rule, NULL, NULL); + printf("NXM: %s -> ", nxm_s); + if (error) { + printf("%s\n", ofperr_to_string(error)); + } else { + printf("%04"PRIx16"/%04"PRIx16"\n", + ntohs(nxm_rule.flow.vlan_tci), + ntohs(nxm_rule.wc.vlan_tci_mask)); + } + free(nxm_s); + ofpbuf_uninit(&nxm); + + /* Convert to and from OpenFlow 1.0. */ + ofputil_cls_rule_to_ofp10_match(&rule, &of10_match); + ofputil_cls_rule_from_ofp10_match(&of10_match, 0, &of10_rule); + printf("OF1.0: %04"PRIx16"/%d,%02"PRIx8"/%d -> %04"PRIx16"/%04"PRIx16"\n", + ntohs(of10_match.dl_vlan), + (of10_match.wildcards & htonl(OFPFW10_DL_VLAN)) != 0, + of10_match.dl_vlan_pcp, + (of10_match.wildcards & htonl(OFPFW10_DL_VLAN_PCP)) != 0, + ntohs(of10_rule.flow.vlan_tci), + ntohs(of10_rule.wc.vlan_tci_mask)); + + /* Convert to and from OpenFlow 1.1. */ + ofputil_cls_rule_to_ofp11_match(&rule, &of11_match); + ofputil_cls_rule_from_ofp11_match(&of11_match, 0, &of11_rule); + printf("OF1.1: %04"PRIx16"/%d,%02"PRIx8"/%d -> %04"PRIx16"/%04"PRIx16"\n", + ntohs(of11_match.dl_vlan), + (of11_match.wildcards & htonl(OFPFW11_DL_VLAN)) != 0, + of11_match.dl_vlan_pcp, + (of11_match.wildcards & htonl(OFPFW11_DL_VLAN_PCP)) != 0, + ntohs(of11_rule.flow.vlan_tci), + ntohs(of11_rule.wc.vlan_tci_mask)); +} + /* "print-error ENUM": Prints the type and code of ENUM for every OpenFlow * version. */ static void @@ -2609,6 +2684,7 @@ static const struct command all_commands[] = { { "parse-ofp11-match", 0, 0, ofctl_parse_ofp11_match }, { "parse-ofp11-actions", 0, 0, ofctl_parse_ofp11_actions }, { "parse-ofp11-instructions", 0, 0, ofctl_parse_ofp11_instructions }, + { "check-vlan", 2, 2, ofctl_check_vlan }, { "print-error", 1, 1, ofctl_print_error }, { "ofp-print", 1, 2, ofctl_ofp_print },