From: Piotrek Zadroga Date: Fri, 26 May 2023 09:03:59 +0000 (+0200) Subject: [#2834] Addressed review comments X-Git-Tag: Kea-2.3.8~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6123d2a0a122fad941bc3b0f537be02ab734df26;p=thirdparty%2Fkea.git [#2834] Addressed review comments --- diff --git a/doc/sphinx/man/perfdhcp.8.rst b/doc/sphinx/man/perfdhcp.8.rst index 82f41482d9..d3127cde13 100644 --- a/doc/sphinx/man/perfdhcp.8.rst +++ b/doc/sphinx/man/perfdhcp.8.rst @@ -360,7 +360,7 @@ The following options only apply for DHCPv6 (i.e. when ``-6`` is given). ``--o1r code,hexstring`` This option is very similar to ``-o``, only that it forces ``perfdhcp`` to insert the specified extra option (or options if used several times) - into relayed DHCPv6 message at 1st level of encapsulation. The code + into relayed DHCPv6 message at first level of encapsulation. The code specifies the option code and the hexstring is a hexadecimal string that defines the content of the option. Care should be taken as ``perfdhcp`` does not offer any kind of logic behind those options; they are simply diff --git a/src/bin/perfdhcp/command_options.cc b/src/bin/perfdhcp/command_options.cc index 5167421c82..a01f967be3 100644 --- a/src/bin/perfdhcp/command_options.cc +++ b/src/bin/perfdhcp/command_options.cc @@ -608,9 +608,8 @@ CommandOptions::initialize(int argc, char** argv, bool print_cmd_line) { // and must be used together with -A option. check((ipversion_ != 6), "-6 must be explicitly specified before --o1r is used."); - if (v6_relay_encapsulation_level_ != 1) { - isc_throw(isc::InvalidParameter, "-A must be explicitly specified before --o1r is used."); - } + check(v6_relay_encapsulation_level_ <= 0, + "-A must be explicitly specified before --o1r is used."); // custom option (expected format: code,hexstring) std::string opt_text = std::string(optarg); diff --git a/src/bin/perfdhcp/tests/command_options_unittest.cc b/src/bin/perfdhcp/tests/command_options_unittest.cc index 7f5eb271ea..e2ac820c25 100644 --- a/src/bin/perfdhcp/tests/command_options_unittest.cc +++ b/src/bin/perfdhcp/tests/command_options_unittest.cc @@ -899,6 +899,16 @@ TEST_F(CommandOptionsTest, ElapsedTime) { EXPECT_EQ(10, opt.getWaitForElapsedTime()); } +TEST_F(CommandOptionsTest, UseRelayV6OptionsWithoutV6) { + CommandOptions opt; + EXPECT_NO_THROW(process(opt, "perfdhcp -6 -A1 --o1r 32,00000E10 -l ethx all")); + EXPECT_TRUE(opt.isUseRelayedV6()); + EXPECT_EQ(1, opt.getRelayOpts().size()); + + // --o1r must be used together with -6 + EXPECT_THROW(process(opt, "perfdhcp -A1 --o1r 32,00000E10 -l ethx all"), isc::InvalidParameter); +} + TEST_F(CommandOptionsTest, UseRelayV6OptionsWithoutRelayEncapsulation) { CommandOptions opt; EXPECT_NO_THROW(process(opt, "perfdhcp -6 -A1 --o1r 32,00000E10 -l ethx all"));