use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project netvirt by opendaylight.
the class ArpNotificationHandler method processArpLearning.
private void processArpLearning(String srcInterface, IpAddress srcIP, PhysAddress srcMac, BigInteger metadata, IpAddress dstIP) {
if (metadata != null && !Objects.equals(metadata, BigInteger.ZERO)) {
Optional<List<String>> vpnList = VpnUtil.getVpnHandlingIpv4AssociatedWithInterface(dataBroker, srcInterface);
if (vpnList.isPresent()) {
for (String vpnName : vpnList.get()) {
LOG.info("Received ARP for sender MAC {} and sender IP {} via interface {}", srcMac.getValue(), srcIP.getIpv4Address().getValue(), srcInterface);
String ipToQuery = srcIP.getIpv4Address().getValue();
LOG.info("ARP being processed for Source IP {}", ipToQuery);
VpnPortipToPort vpnPortipToPort = VpnUtil.getNeutronPortFromVpnPortFixedIp(dataBroker, vpnName, ipToQuery);
if (vpnPortipToPort != null) {
/* This is a well known neutron port and so should be ignored
* from being discovered
*/
continue;
}
LearntVpnVipToPort learntVpnVipToPort = VpnUtil.getLearntVpnVipToPort(dataBroker, vpnName, ipToQuery);
if (learntVpnVipToPort != null) {
String oldPortName = learntVpnVipToPort.getPortName();
String oldMac = learntVpnVipToPort.getMacAddress();
if (!oldMac.equalsIgnoreCase(srcMac.getValue())) {
// MAC has changed for requested IP
LOG.info("ARP Source IP/MAC data modified for IP {} with MAC {} and Port {}", ipToQuery, srcMac, srcInterface);
synchronized ((vpnName + ipToQuery).intern()) {
removeMipAdjacency(vpnName, oldPortName, srcIP);
VpnUtil.removeLearntVpnVipToPort(dataBroker, vpnName, ipToQuery);
putVpnIpToMigrateArpCache(vpnName, ipToQuery, srcMac);
}
}
} else if (!isIpInArpMigrateCache(vpnName, ipToQuery)) {
learnMacFromArpPackets(vpnName, srcInterface, srcIP, srcMac, dstIP);
}
}
} else {
LOG.info("ARP NO_RESOLVE: VPN not configured. Ignoring responding to ARP requests from this" + " Interface {}.", srcInterface);
return;
}
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project netvirt by opendaylight.
the class InterfaceUtils method getMacAddressFromInterfaceState.
public static Optional<String> getMacAddressFromInterfaceState(Interface ifState) {
Optional<String> macAddressOptional = Optional.absent();
PhysAddress macAddress = ifState.getPhysAddress();
if (macAddress != null) {
macAddressOptional = Optional.of(macAddress.getValue());
}
return macAddressOptional;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project netvirt by opendaylight.
the class InterfaceUtils method getMacAddressForInterface.
public static Optional<String> getMacAddressForInterface(DataBroker dataBroker, String interfaceName) {
Optional<String> macAddressOptional = Optional.absent();
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = buildStateInterfaceId(interfaceName);
Optional<Interface> ifStateOptional = read(dataBroker, LogicalDatastoreType.OPERATIONAL, ifStateId);
if (ifStateOptional.isPresent()) {
PhysAddress macAddress = ifStateOptional.get().getPhysAddress();
if (macAddress != null) {
macAddressOptional = Optional.of(macAddress.getValue());
}
}
return macAddressOptional;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project netvirt by opendaylight.
the class CoeUtils method updateElanInterfaceWithStaticMac.
public static void updateElanInterfaceWithStaticMac(String macAddress, IpAddress ipAddress, String elanInterfaceName, WriteTransaction wrtConfigTxn) {
InstanceIdentifier<ElanInterface> id = InstanceIdentifier.builder(ElanInterfaces.class).child(ElanInterface.class, new ElanInterfaceKey(elanInterfaceName)).build();
PhysAddress physAddress = PhysAddress.getDefaultInstance(macAddress);
List<StaticMacEntries> staticMacEntriesList = new ArrayList<>();
StaticMacEntries staticMacEntries = new StaticMacEntriesBuilder().setKey(new StaticMacEntriesKey(physAddress)).setMacAddress(physAddress).setIpPrefix(ipAddress).build();
staticMacEntriesList.add(staticMacEntries);
ElanInterface elanInterface = new ElanInterfaceBuilder().setName(elanInterfaceName).setKey(new ElanInterfaceKey(elanInterfaceName)).setStaticMacEntries(staticMacEntriesList).build();
wrtConfigTxn.merge(LogicalDatastoreType.CONFIGURATION, id, elanInterface);
LOG.debug("Updating ELAN Interface with static mac {}", elanInterface);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project netvirt by opendaylight.
the class VpnFloatingIpHandler method sendGarpOnInterface.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void sendGarpOnInterface(final BigInteger dpnId, Uuid networkId, final IpAddress floatingIpAddress, String floatingIpPortMacAddress) {
if (floatingIpAddress.getIpv4Address() == null) {
LOG.error("sendGarpOnInterface : Failed to send GARP for IP. recieved IPv6.");
NatServiceCounters.garp_failed_ipv6.inc();
return;
}
String interfaceName = elanService.getExternalElanInterface(networkId.getValue(), dpnId);
if (interfaceName == null) {
LOG.warn("sendGarpOnInterface : Failed to send GARP for IP. Failed to retrieve interface name " + "from network {} and dpn id {}.", networkId.getValue(), dpnId);
NatServiceCounters.garp_failed_missing_interface.inc();
return;
}
try {
// find the external network interface name for dpn
List<InterfaceAddress> interfaceAddresses = new ArrayList<>();
interfaceAddresses.add(new InterfaceAddressBuilder().setInterface(interfaceName).setIpAddress(floatingIpAddress).setMacaddress(new PhysAddress(floatingIpPortMacAddress)).build());
SendArpRequestInput sendArpRequestInput = new SendArpRequestInputBuilder().setIpaddress(floatingIpAddress).setInterfaceAddress(interfaceAddresses).build();
JdkFutures.addErrorLogging(arpUtilService.sendArpRequest(sendArpRequestInput), LOG, "sendArpRequest");
NatServiceCounters.garp_sent.inc();
} catch (Exception e) {
LOG.error("sendGarpOnInterface : Failed to send GARP request for floating ip {} from interface {}", floatingIpAddress.getIpv4Address().getValue(), interfaceName, e);
NatServiceCounters.garp_failed_send.inc();
}
}
Aggregations