summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNuman Siddique <nusiddiq@redhat.com>2017-11-02 06:19:24 +0530
committerBen Pfaff <blp@ovn.org>2017-11-02 13:39:14 -0700
commit52ed5fcc5dddc6ad7a7d500df73032fc1c5133b8 (patch)
tree028142e241184a1019e55f6f8fd99f995260b8cb /tests
parent16936e4d6e3f8dd68dd6a4959e4937c9daab3e4a (diff)
downloadopenvswitch-52ed5fcc5dddc6ad7a7d500df73032fc1c5133b8.tar.gz
ovn-controller: Add a new action - 'put_nd_ra_opts'
This patch adds a new OVN action 'put_nd_ra_opts' to support native IPv6 Router Advertisement in OVN. This action can be used to respond to the IPv6 Router Solicitation requests. ovn-controller parses this action and adds a NXT_PACKET_IN2 OF flow with 'pause' flag set and the RA options stored in 'userdata' field. This action is similar to 'put_dhcp_opts' and 'put_dhcpv6_opts'. When a valid IPv6 RS packet is received by the pinctrl module of ovn-controller, it frames a new RA packet and sets the RA options from the 'userdata' field and resumes the packet storing 1 in the 1-bit result sub-field. If the packet is invalid, it resumes the packet without any modifications storing 0 in the 1-bit result sub-field. Eg. reg0[5] = put_nd_ra_opts(address_mode = "slaac", mtu = 1450, slla = 01:02:03:04:05:06, prefix = aef0::/64) Note that unlike DHCPv4/v6, a new table to store the supported IPv6 ND RA options is not added in SB DB since there are only 3 ND RA options. Co-authored-by: Zongkai LI <zealokii@gmail.com> Signed-off-by: Zongkai LI <zealokii@gmail.com> Signed-off-by: Numan Siddique <nusiddiq@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/ovn.at31
-rw-r--r--tests/test-ovn.c13
2 files changed, 41 insertions, 3 deletions
diff --git a/tests/ovn.at b/tests/ovn.at
index 67709b55b..93515aa32 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -1072,6 +1072,37 @@ reg1[0] = dns_lookup();
reg1[0] = dns_lookup("foo");
dns_lookup doesn't take any parameters
+# put_nd_ra_opts
+reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = 1500, prefix = aef0::/64, slla = ae:01:02:03:04:05);
+ encodes as controller(userdata=00.00.00.08.00.00.00.00.00.01.de.10.00.00.00.40.86.00.00.00.ff.00.ff.ff.00.00.00.00.00.00.00.00.05.01.00.00.00.00.05.dc.03.04.40.c0.ff.ff.ff.ff.ff.ff.ff.ff.00.00.00.00.ae.f0.00.00.00.00.00.00.00.00.00.00.00.00.00.00.01.01.ae.01.02.03.04.05,pause)
+ has prereqs ip6
+reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateful", slla = ae:01:02:03:04:10, mtu = 1450);
+ encodes as controller(userdata=00.00.00.08.00.00.00.00.00.01.de.10.00.00.00.40.86.00.00.00.ff.80.ff.ff.00.00.00.00.00.00.00.00.01.01.ae.01.02.03.04.10.05.01.00.00.00.00.05.aa,pause)
+ has prereqs ip6
+reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateless", slla = ae:01:02:03:04:06, prefix = aef0::/64);
+ encodes as controller(userdata=00.00.00.08.00.00.00.00.00.01.de.10.00.00.00.40.86.00.00.00.ff.40.ff.ff.00.00.00.00.00.00.00.00.01.01.ae.01.02.03.04.06.03.04.40.c0.ff.ff.ff.ff.ff.ff.ff.ff.00.00.00.00.ae.f0.00.00.00.00.00.00.00.00.00.00.00.00.00.00,pause)
+ has prereqs ip6
+reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = 1500, prefix = aef0::/64);
+ slla option not present
+reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateful", mtu = 1450, prefix = aef0::/64, prefix = bef0::/64, slla = ae:01:02:03:04:10);
+ prefix option can't be set when address mode is dhcpv6_stateful.
+reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateful", mtu = 1450, prefix = aef0::/64, prefix = bef0::/64, slla = ae:01:02:03:04:10);
+ prefix option can't be set when address mode is dhcpv6_stateful.
+reg1[0] = put_nd_ra_opts(addr_mode = "slaac", slla = ae:01:02:03:04:10);
+ prefix option needs to be set when address mode is slaac/dhcpv6_stateless.
+reg1[0] = put_nd_ra_opts(addr_mode = "dhcpv6_stateless", slla = ae:01:02:03:04:10);
+ prefix option needs to be set when address mode is slaac/dhcpv6_stateless.
+reg1[0] = put_nd_ra_opts(addr_mode = dhcpv6_stateless, prefix = aef0::/64, slla = ae:01:02:03:04:10);
+ Syntax error at `dhcpv6_stateless' expecting constant.
+reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = 1500, prefix = aef0::, slla = ae:01:02:03:04:10);
+ Invalid value for "prefix" option
+reg1[0] = put_nd_ra_opts(addr_mode = "foo", mtu = 1500, slla = ae:01:02:03:04:10);
+ Invalid value for "addr_mode" option
+reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = "1500", slla = ae:01:02:03:04:10);
+ IPv6 ND RA option mtu requires numeric value.
+reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = 10.0.0.4, slla = ae:01:02:03:04:10);
+ Invalid value for "mtu" option
+
# Contradictionary prerequisites (allowed but not useful):
ip4.src = ip6.src[0..31];
encodes as move:NXM_NX_IPV6_SRC[0..31]->NXM_OF_IP_SRC[]
diff --git a/tests/test-ovn.c b/tests/test-ovn.c
index 67221ea50..f9a5085f7 100644
--- a/tests/test-ovn.c
+++ b/tests/test-ovn.c
@@ -155,7 +155,8 @@ create_symtab(struct shash *symtab)
}
static void
-create_dhcp_opts(struct hmap *dhcp_opts, struct hmap *dhcpv6_opts)
+create_gen_opts(struct hmap *dhcp_opts, struct hmap *dhcpv6_opts,
+ struct hmap *nd_ra_opts)
{
hmap_init(dhcp_opts);
dhcp_opt_add(dhcp_opts, "offerip", 0, "ipv4");
@@ -187,6 +188,10 @@ create_dhcp_opts(struct hmap *dhcp_opts, struct hmap *dhcpv6_opts)
dhcp_opt_add(dhcpv6_opts, "ia_addr", 5, "ipv6");
dhcp_opt_add(dhcpv6_opts, "dns_server", 23, "ipv6");
dhcp_opt_add(dhcpv6_opts, "domain_search", 24, "str");
+
+ /* IPv6 ND RA options. */
+ hmap_init(nd_ra_opts);
+ nd_ra_opts_init(nd_ra_opts);
}
static void
@@ -1193,12 +1198,13 @@ test_parse_actions(struct ovs_cmdl_context *ctx OVS_UNUSED)
struct shash symtab;
struct hmap dhcp_opts;
struct hmap dhcpv6_opts;
+ struct hmap nd_ra_opts;
struct simap ports;
struct ds input;
bool ok = true;
create_symtab(&symtab);
- create_dhcp_opts(&dhcp_opts, &dhcpv6_opts);
+ create_gen_opts(&dhcp_opts, &dhcpv6_opts, &nd_ra_opts);
/* Initialize group ids. */
struct group_table group_table;
@@ -1226,6 +1232,7 @@ test_parse_actions(struct ovs_cmdl_context *ctx OVS_UNUSED)
.symtab = &symtab,
.dhcp_opts = &dhcp_opts,
.dhcpv6_opts = &dhcpv6_opts,
+ .nd_ra_opts = &nd_ra_opts,
.n_tables = 24,
.cur_ltable = 10,
};
@@ -1310,7 +1317,7 @@ test_parse_actions(struct ovs_cmdl_context *ctx OVS_UNUSED)
shash_destroy(&symtab);
dhcp_opts_destroy(&dhcp_opts);
dhcp_opts_destroy(&dhcpv6_opts);
-
+ nd_ra_opts_destroy(&nd_ra_opts);
exit(ok ? EXIT_SUCCESS : EXIT_FAILURE);
}