diff --git a/src/vnsw/agent/openstack/instance_service_server.cc b/src/vnsw/agent/openstack/instance_service_server.cc index 6f716e5987d..3b5cbc77755 100644 --- a/src/vnsw/agent/openstack/instance_service_server.cc +++ b/src/vnsw/agent/openstack/instance_service_server.cc @@ -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; diff --git a/src/vnsw/agent/openstack/test/test_instance_service.cc b/src/vnsw/agent/openstack/test/test_instance_service.cc index ed18abea318..34c196c38af 100644 --- a/src/vnsw/agent/openstack/test/test_instance_service.cc +++ b/src/vnsw/agent/openstack/test/test_instance_service.cc @@ -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;