face: allow setting default UDP face MTU in config
refs #5138
Change-Id: Ibb3767b27aec2b046d1f41292f3d61001866f8c0
diff --git a/tests/daemon/face/udp-factory.t.cpp b/tests/daemon/face/udp-factory.t.cpp
index 0bf7e03..e2788f5 100644
--- a/tests/daemon/face/udp-factory.t.cpp
+++ b/tests/daemon/face/udp-factory.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2020, Regents of the University of California,
+ * Copyright (c) 2014-2021, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -195,9 +195,10 @@
parseConfig(CONFIG, false);
checkChannelListEqual(factory, {"udp4://0.0.0.0:6363", "udp6://[::]:6363"});
- auto channels = factory.getChannels();
- BOOST_CHECK(std::all_of(channels.begin(), channels.end(),
- [] (const auto& ch) { return ch->isListening(); }));
+ for (const auto& ch : factory.getChannels()) {
+ BOOST_CHECK(ch->isListening());
+ BOOST_CHECK_EQUAL(ch->getDefaultMtu(), ndn::MAX_NDN_PACKET_SIZE);
+ }
}
BOOST_AUTO_TEST_CASE(DisableListen)
@@ -218,9 +219,9 @@
parseConfig(CONFIG, false);
checkChannelListEqual(factory, {"udp4://0.0.0.0:7001", "udp6://[::]:7001"});
- auto channels = factory.getChannels();
- BOOST_CHECK(std::none_of(channels.begin(), channels.end(),
- [] (const auto& ch) { return ch->isListening(); }));
+ for (const auto& ch : factory.getChannels()) {
+ BOOST_CHECK(!ch->isListening());
+ }
}
BOOST_AUTO_TEST_CASE(DisableV4)
@@ -233,6 +234,7 @@
port 7001
enable_v4 no
enable_v6 yes
+ unicast_mtu 1452
mcast no
}
}
@@ -242,6 +244,9 @@
parseConfig(CONFIG, false);
checkChannelListEqual(factory, {"udp6://[::]:7001"});
+ for (const auto& ch : factory.getChannels()) {
+ BOOST_CHECK_EQUAL(ch->getDefaultMtu(), 1452);
+ }
}
BOOST_AUTO_TEST_CASE(DisableV6)
@@ -254,6 +259,7 @@
port 7001
enable_v4 yes
enable_v6 no
+ unicast_mtu 1452
mcast no
}
}
@@ -263,6 +269,9 @@
parseConfig(CONFIG, false);
checkChannelListEqual(factory, {"udp4://0.0.0.0:7001"});
+ for (const auto& ch : factory.getChannels()) {
+ BOOST_CHECK_EQUAL(ch->getDefaultMtu(), 1452);
+ }
}
BOOST_FIXTURE_TEST_CASE(EnableDisableMcast, UdpFactoryMcastFixture)
@@ -666,6 +675,51 @@
BOOST_CHECK_THROW(parseConfig(CONFIG2, false), ConfigFile::Error);
}
+BOOST_AUTO_TEST_CASE(BadMtu)
+{
+ // not a number
+ const std::string CONFIG1 = R"CONFIG(
+ face_system
+ {
+ udp
+ {
+ unicast_mtu hello
+ }
+ }
+ )CONFIG";
+
+ BOOST_CHECK_THROW(parseConfig(CONFIG1, true), ConfigFile::Error);
+ BOOST_CHECK_THROW(parseConfig(CONFIG1, false), ConfigFile::Error);
+
+ // underflow
+ const std::string CONFIG2 = R"CONFIG(
+ face_system
+ {
+ udp
+ {
+ unicast_mtu 63
+ }
+ }
+ )CONFIG";
+
+ BOOST_CHECK_THROW(parseConfig(CONFIG2, true), ConfigFile::Error);
+ BOOST_CHECK_THROW(parseConfig(CONFIG2, false), ConfigFile::Error);
+
+ // underflow
+ const std::string CONFIG3 = R"CONFIG(
+ face_system
+ {
+ udp
+ {
+ unicast_mtu 8801
+ }
+ }
+ )CONFIG";
+
+ BOOST_CHECK_THROW(parseConfig(CONFIG3, true), ConfigFile::Error);
+ BOOST_CHECK_THROW(parseConfig(CONFIG3, false), ConfigFile::Error);
+}
+
BOOST_AUTO_TEST_CASE(BadMcast)
{
const std::string CONFIG = R"CONFIG(