import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
externalSubnet.getIpVersion() == 4 &&
gatewayPort.getFixedIPs() != null) {
LOG.info("Trigger MAC resolution for gateway ip {}", externalSubnet.getGatewayIP());
-
- gatewayMacResolver.resolveMacAddress(
+ Neutron_IPs neutronIP = null;
+ for (Neutron_IPs nIP : gatewayPort.getFixedIPs()) {
+ InetAddress ipAddress;
+ try {
+ ipAddress = InetAddress.getByAddress(nIP.getIpAddress().getBytes());
+ } catch (UnknownHostException e) {
+ LOG.warn("unknown host exception {}", e);
+ continue;
+ }
+ if (ipAddress instanceof Inet4Address) {
+ neutronIP = nIP;
+ break;
+ }
+ }
+ if (neutronIP == null) {
+ // TODO IPv6 neighbor discovery
+ LOG.debug("Ignoring gateway ports with IPv6 only fixed ip {}",
+ gatewayPort.getFixedIPs());
+ } else {
+ gatewayMacResolver.resolveMacAddress(
this, /* gatewayMacResolverListener */
null, /* externalNetworkBridgeDpid */
true, /* refreshExternalNetworkBridgeDpidIfNeeded */
new Ipv4Address(externalSubnet.getGatewayIP()),
- new Ipv4Address(gatewayPort.getFixedIPs().get(0).getIpAddress()),
+ new Ipv4Address(neutronIP.getIpAddress()),
new MacAddress(gatewayPort.getMacAddress()),
true /* periodicRefresh */);
+ }
} else {
LOG.warn("No gateway IP address found for external network {}", externalNetwork);
}