From abe529af477b8311a1fd68c130374bd7442003c3 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 11 May 2011 12:13:10 -0700 Subject: ofproto: Break apart into generic and hardware-specific parts. In addition to the changes to ofproto, this commit changes all of the instances of "struct flow" in the tree so that the "in_port" member is an OpenFlow port number. Previously, this member was an OpenFlow port number in some cases and an ODP port number in other cases. --- tests/ofproto-macros.at | 2 +- tests/ofproto.at | 2 +- tests/ovs-ofctl.at | 18 +++++++++--------- tests/test-classifier.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at index 06f9b65f..d5ff2ad6 100644 --- a/tests/ofproto-macros.at +++ b/tests/ofproto-macros.at @@ -7,7 +7,7 @@ m4_define([OFPROTO_START], trap 'kill `cat ovs-openflowd.pid`' 0 AT_CAPTURE_FILE([ovs-openflowd.log]) AT_CHECK( - [ovs-openflowd --detach --pidfile --enable-dummy --log-file dummy@br0 none --datapath-id=fedcba9876543210 $1], + [ovs-openflowd --detach --pidfile --enable-dummy --log-file --fail=closed dummy@br0 none --datapath-id=fedcba9876543210 $1], [0], [ignore], [ignore]) ]) diff --git a/tests/ofproto.at b/tests/ofproto.at index fc7ff57e..9587c978 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -52,8 +52,8 @@ dnl Tests for a bug in which ofproto ignored tun_id in tun_id_from_cookie dnl flow_mod commands. AT_CHECK([ovs-ofctl add-flow -F tun_id_from_cookie br0 tun_id=1,actions=mod_vlan_vid:4]) AT_CHECK([ovs-ofctl dump-flows br0 | STRIP_XIDS | STRIP_DURATION | sort], [0], [dnl + cookie=0x0, duration=?s, table_id=0, n_packets=0, n_bytes=0, in_port=0 actions=output:1 cookie=0x0, duration=?s, table_id=0, n_packets=0, n_bytes=0, in_port=1 actions=output:0 - cookie=0x0, duration=?s, table_id=0, n_packets=0, n_bytes=0, in_port=65534 actions=output:1 cookie=0x100000000, duration=?s, table_id=0, n_packets=0, n_bytes=0, tun_id=0x1 actions=mod_vlan_vid:4 NXST_FLOW reply: ]) diff --git a/tests/ovs-ofctl.at b/tests/ovs-ofctl.at index 466ade6b..ae3f70b2 100644 --- a/tests/ovs-ofctl.at +++ b/tests/ovs-ofctl.at @@ -41,17 +41,17 @@ normalization changed ofp_match, details: pre: wildcards= 0x3820f8 in_port=65534 dl_src=00:0a:e4:25:6b:b0 dl_dst=00:00:00:00:00:00 dl_vlan= 9 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 post: wildcards= 0x3ffff8 in_port=65534 dl_src=00:0a:e4:25:6b:b0 dl_dst=00:00:00:00:00:00 dl_vlan= 9 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 normalization changed ofp_match, details: - pre: wildcards= 0x3820ff in_port=65534 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 -post: wildcards= 0x3fffff in_port=65534 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 + pre: wildcards= 0x3820ff in_port= 0 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 +post: wildcards= 0x3fffff in_port= 0 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 normalization changed ofp_match, details: - pre: wildcards= 0x3820ff in_port=65534 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 -post: wildcards= 0x3fffff in_port=65534 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 + pre: wildcards= 0x3820ff in_port= 0 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 +post: wildcards= 0x3fffff in_port= 0 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 normalization changed ofp_match, details: - pre: wildcards= 0x3820ff in_port=65534 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 -post: wildcards= 0x3fffff in_port=65534 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 + pre: wildcards= 0x3820ff in_port= 0 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 +post: wildcards= 0x3fffff in_port= 0 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 normalization changed ofp_match, details: - pre: wildcards= 0x23820ff in_port=65534 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 -post: wildcards= 0x23fffff in_port=65534 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 + pre: wildcards= 0x23820ff in_port= 0 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 +post: wildcards= 0x23fffff in_port= 0 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 ]) AT_CLEANUP @@ -315,7 +315,7 @@ AT_CHECK([ovs-ofctl parse-nx-match < nx-match.txt], [0], [dnl # in port -NXM_OF_IN_PORT(fffe) +NXM_OF_IN_PORT(0000) NXM_OF_IN_PORT(fffe) # eth dst diff --git a/tests/test-classifier.c b/tests/test-classifier.c index 9af8aacb..bb75dba1 100644 --- a/tests/test-classifier.c +++ b/tests/test-classifier.c @@ -251,7 +251,7 @@ static ovs_be32 nw_dst_values[] = { CONSTANT_HTONL(0xc0a80002), static ovs_be64 tun_id_values[] = { 0, CONSTANT_HTONLL(UINT64_C(0xfedcba9876543210)) }; -static uint16_t in_port_values[] = { 1, ODPP_LOCAL }; +static uint16_t in_port_values[] = { 1, OFPP_LOCAL }; static ovs_be16 vlan_tci_values[] = { CONSTANT_HTONS(101), CONSTANT_HTONS(0) }; static ovs_be16 dl_type_values[] = { CONSTANT_HTONS(ETH_TYPE_IP), CONSTANT_HTONS(ETH_TYPE_ARP) }; -- cgit v1.2.3 From 08944c1db1ab2707e28deab838dc0937bf8de8ae Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 11 May 2011 14:06:48 -0700 Subject: ofproto: Make rule construction and destruction more symmetric. Before, ->rule_construct() both created the rule and inserted into the flow table, but ->rule_destruct() only destroyed the rule. This makes ->rule_destruct() also remove the rule from the flow table. --- tests/test-classifier.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/test-classifier.c b/tests/test-classifier.c index bb75dba1..1cfd5cf6 100644 --- a/tests/test-classifier.c +++ b/tests/test-classifier.c @@ -526,7 +526,7 @@ test_single_rule(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) tcls_init(&tcls); tcls_rule = tcls_insert(&tcls, rule); - assert(!classifier_insert(&cls, &rule->cls_rule)); + classifier_insert(&cls, &rule->cls_rule); check_tables(&cls, 1, 1, 0); compare_classifiers(&cls, &tcls); @@ -562,7 +562,7 @@ test_rule_replacement(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) classifier_init(&cls); tcls_init(&tcls); tcls_insert(&tcls, rule1); - assert(!classifier_insert(&cls, &rule1->cls_rule)); + classifier_insert(&cls, &rule1->cls_rule); check_tables(&cls, 1, 1, 0); compare_classifiers(&cls, &tcls); tcls_destroy(&tcls); @@ -570,7 +570,7 @@ test_rule_replacement(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) tcls_init(&tcls); tcls_insert(&tcls, rule2); assert(test_rule_from_cls_rule( - classifier_insert(&cls, &rule2->cls_rule)) == rule1); + classifier_replace(&cls, &rule2->cls_rule)) == rule1); free(rule1); check_tables(&cls, 1, 1, 0); compare_classifiers(&cls, &tcls); @@ -681,7 +681,7 @@ test_many_rules_in_one_list (int argc OVS_UNUSED, char *argv[] OVS_UNUSED) tcls_rules[j] = tcls_insert(&tcls, rules[j]); displaced_rule = test_rule_from_cls_rule( - classifier_insert(&cls, &rules[j]->cls_rule)); + classifier_replace(&cls, &rules[j]->cls_rule)); if (pri_rules[pris[j]] >= 0) { int k = pri_rules[pris[j]]; assert(displaced_rule != NULL); @@ -781,7 +781,7 @@ test_many_rules_in_one_table(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) rules[i] = make_rule(wcf, priority, value_pats[i]); tcls_rules[i] = tcls_insert(&tcls, rules[i]); - assert(!classifier_insert(&cls, &rules[i]->cls_rule)); + classifier_insert(&cls, &rules[i]->cls_rule); check_tables(&cls, 1, i + 1, 0); compare_classifiers(&cls, &tcls); @@ -839,7 +839,7 @@ test_many_rules_in_n_tables(int n_tables) int value_pat = rand() & ((1u << CLS_N_FIELDS) - 1); rule = make_rule(wcf, priority, value_pat); tcls_insert(&tcls, rule); - assert(!classifier_insert(&cls, &rule->cls_rule)); + classifier_insert(&cls, &rule->cls_rule); check_tables(&cls, -1, i + 1, -1); compare_classifiers(&cls, &tcls); } -- cgit v1.2.3 From eeaefa7878b6d7682c6dbd58789d685b6daecc86 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 27 Apr 2011 11:29:50 -0700 Subject: ofproto: Fix number of reported tables in OFPT_FEATURES_REPLY message. This has been wrong for a long time. --- tests/ofproto.at | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/ofproto.at b/tests/ofproto.at index 9587c978..6f785e97 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -11,7 +11,7 @@ OFPROTO_START AT_CHECK([ovs-ofctl -vANY:ANY:WARN show br0], [0], [stdout]) AT_CHECK([STRIP_XIDS stdout], [0], [dnl OFPT_FEATURES_REPLY: ver:0x1, dpid:fedcba9876543210 -n_tables:2, n_buffers:256 +n_tables:1, n_buffers:256 features: capabilities:0x87, actions:0xfff LOCAL(br0): addr:aa:55:aa:55:00:00, config: 0x1, state:0x1 OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0 @@ -33,7 +33,7 @@ do AT_CHECK([ovs-ofctl -vANY:ANY:WARN show br0], [0], [stdout]) AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl OFPT_FEATURES_REPLY: ver:0x1, dpid:fedcba9876543210 -n_tables:2, n_buffers:256 +n_tables:1, n_buffers:256 features: capabilities:0x87, actions:0xfff LOCAL(br0): addr:aa:55:aa:55:00:00, config: $config, state:$state OFPT_GET_CONFIG_REPLY: frags=normal miss_send_len=0 -- cgit v1.2.3 From 6c1491fbd75754d2e4d5028650554f9d5d3a4958 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 12 May 2011 09:58:01 -0700 Subject: Implement basic multiple table support. This implements basic multiple table support in ofproto and supporting libraries and utilities. The design is the same as the one that has been on the Open vSwitch "wdp" branch for a long time. There is no support for multiple tables in the software switch implementation (ofproto-dpif), only a set of hooks for other switch implementations to use. To allow controllers to add flows in a particular table, Open vSwitch adds an OpenFlow 1.0 extension called NXT_FLOW_MOD_TABLE_ID. --- tests/ovs-ofctl.at | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/ovs-ofctl.at b/tests/ovs-ofctl.at index ae3f70b2..a9c3c205 100644 --- a/tests/ovs-ofctl.at +++ b/tests/ovs-ofctl.at @@ -14,7 +14,7 @@ actions=note:41.42.43,note:00.01.02.03.04.05.06.07,note tun_id=0x1234,cookie=0x5678,actions=flood actions=set_tunnel:0x1234,set_tunnel64:0x9876,set_tunnel:0x123456789 actions=multipath(eth_src, 50, hrw, 12, 0, NXM_NX_REG0[0..3]),multipath(symmetric_l4, 1024, iter_hash, 5000, 5050, NXM_NX_REG0[0..12]) -actions=drop +table=1,actions=drop tun_id=0x1234000056780000/0xffff0000ffff0000,actions=drop ]]) AT_CHECK([ovs-ofctl parse-flows flows.txt @@ -32,9 +32,10 @@ NXT_TUN_ID_FROM_COOKIE: set=1 OFPT_FLOW_MOD: ADD cookie:0x123400005678 actions=FLOOD OFPT_FLOW_MOD: ADD actions=set_tunnel:0x1234,set_tunnel64:0x9876,set_tunnel64:0x123456789 OFPT_FLOW_MOD: ADD actions=multipath(eth_src,50,hrw,12,0,NXM_NX_REG0[0..3]),multipath(symmetric_l4,1024,iter_hash,5000,5050,NXM_NX_REG0[0..12]) -OFPT_FLOW_MOD: ADD actions=drop +NXT_FLOW_MOD_TABLE_ID: enable +OFPT_FLOW_MOD: ADD table_id:1 actions=drop NXT_SET_FLOW_FORMAT: format=nxm -NXT_FLOW_MOD: ADD tun_id=0x1234000056780000/0xffff0000ffff0000 actions=drop +NXT_FLOW_MOD: ADD table_id:255 tun_id=0x1234000056780000/0xffff0000ffff0000 actions=drop ]]) AT_CHECK([sed 's/.*|//' stderr], [0], [dnl normalization changed ofp_match, details: -- cgit v1.2.3 From e16b024e1b68b2b1c616cb5faa8f5f640e74861a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 12 May 2011 17:24:34 -0700 Subject: Fix bugs lingering from merge mistakes. I should have caught these when I did the merge from "master" earlier today, but I forgot to run the testsuite. --- tests/ofproto.at | 1 - tests/ovs-ofctl.at | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/ofproto.at b/tests/ofproto.at index 713cc769..bb43149f 100644 --- a/tests/ofproto.at +++ b/tests/ofproto.at @@ -51,7 +51,6 @@ AT_CHECK([ovs-ofctl add-flow br0 in_port=0,actions=1]) AT_CHECK([ovs-ofctl dump-flows br0 | STRIP_XIDS | STRIP_DURATION | sort], [0], [dnl cookie=0x0, duration=?s, table_id=0, n_packets=0, n_bytes=0, in_port=0 actions=output:1 cookie=0x0, duration=?s, table_id=0, n_packets=0, n_bytes=0, in_port=1 actions=output:0 - cookie=0x0, duration=?s, table_id=0, n_packets=0, n_bytes=0, in_port=65534 actions=output:1 NXST_FLOW reply: ]) AT_CHECK([ovs-ofctl del-flows br0]) diff --git a/tests/ovs-ofctl.at b/tests/ovs-ofctl.at index a8cdbe9a..3a8f0b6d 100644 --- a/tests/ovs-ofctl.at +++ b/tests/ovs-ofctl.at @@ -32,8 +32,9 @@ NXT_SET_FLOW_FORMAT: format=nxm NXT_FLOW_MOD: ADD tun_id=0x1234 cookie:0x5678 actions=FLOOD NXT_FLOW_MOD: ADD actions=set_tunnel:0x1234,set_tunnel64:0x9876,set_tunnel64:0x123456789 NXT_FLOW_MOD: ADD actions=multipath(eth_src,50,hrw,12,0,NXM_NX_REG0[0..3]),multipath(symmetric_l4,1024,iter_hash,5000,5050,NXM_NX_REG0[0..12]) -NXT_FLOW_MOD: ADD actions=drop -NXT_FLOW_MOD: ADD tun_id=0x1234000056780000/0xffff0000ffff0000 actions=drop +NXT_FLOW_MOD_TABLE_ID: enable +NXT_FLOW_MOD: ADD table_id:1 actions=drop +NXT_FLOW_MOD: ADD table_id:255 tun_id=0x1234000056780000/0xffff0000ffff0000 actions=drop ]]) AT_CHECK([sed 's/.*|//' stderr], [0], [dnl normalization changed ofp_match, details: @@ -43,8 +44,8 @@ normalization changed ofp_match, details: pre: wildcards= 0x3820ff in_port= 0 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 post: wildcards= 0x3fffff in_port= 0 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 normalization changed ofp_match, details: - pre: wildcards= 0x3820ff in_port=65534 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 -post: wildcards= 0x3fffff in_port=65534 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 + pre: wildcards= 0x3820ff in_port= 0 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 +post: wildcards= 0x3fffff in_port= 0 dl_src=00:00:00:00:00:00 dl_dst=00:00:00:00:00:00 dl_vlan= 0 dl_vlan_pcp= 0 dl_type= 0 nw_tos= 0 nw_proto= 0 nw_src= 0 nw_dst= 0 tp_src= 0 tp_dst= 0 ]) AT_CLEANUP -- cgit v1.2.3