Skip to content

Commit

Permalink
Merge "Check that the address sent via thrift is Ipv4."
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jul 23, 2015
2 parents b972628 + 86e67b7 commit 35c2cc5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/vnsw/agent/openstack/instance_service_server.cc
Expand Up @@ -66,10 +66,11 @@ InstanceServiceAsyncHandler::AddPort(const PortList& port_list) {
boost::system::error_code ec;
IpAddress ip = IpAddress::from_string(port.ip_address, ec);
bool v4_valid = (ec.value() == 0);
if (v4_valid == false) {
if (v4_valid == false || ip.is_v4() == false) {
CFG_TRACE(IntfInfo,
"IPv4 address is not correct, " + port.ip_address);
v4_valid = false;
ip = IpAddress();
}

bool v6_valid = false;
Expand Down
11 changes: 11 additions & 0 deletions src/vnsw/agent/openstack/test/test_instance_service.cc
Expand Up @@ -290,6 +290,17 @@ TEST_F(InstanceServiceTest, AddPortWrongIP) {
TASK_UTIL_EXPECT_EQ(0, cfg_table_->Size());
}

// Wrong IP address : send IPv6 address
TEST_F(InstanceServiceTest, AddPortWrongIPIsv6) {
Port port;
InitPortInfo(port, 2, 2, 2, PortTypes::NovaVMPort);
port.ip_address = "30:32::03";
AddPort(port);
client->WaitForIdle();

TASK_UTIL_EXPECT_EQ(0, cfg_table_->Size());
}

// Null uuids, ports do get created
TEST_F(InstanceServiceTest, NullUUIDTest) {
Port port;
Expand Down

0 comments on commit 35c2cc5

Please sign in to comment.