use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry in project netvirt by opendaylight.
the class ArpMonitoringHandler method remove.
@Override
protected void remove(InstanceIdentifier<LearntVpnVipToPort> key, LearntVpnVipToPort value) {
runOnlyInOwnerNode("ArpMonitoringHandler: remove event", () -> {
try {
InetAddress srcInetAddr = InetAddress.getByName(value.getPortFixedip());
if (value.getMacAddress() == null) {
LOG.warn("The mac address received is null for LearntVpnVipToPort {}, ignoring the DTCN", value);
return;
}
String vpnName = value.getVpnName();
String learntIp = srcInetAddr.getHostAddress();
LearntVpnVipToPort vpnVipToPort = VpnUtil.getLearntVpnVipToPort(dataBroker, vpnName, learntIp);
if (vpnVipToPort != null && !vpnVipToPort.getCreationTime().equals(value.getCreationTime())) {
LOG.warn("The MIP {} over vpn {} has been learnt again and processed. " + "Ignoring this remove event.", learntIp, vpnName);
return;
}
MacAddress srcMacAddress = MacAddress.getDefaultInstance(value.getMacAddress());
String interfaceName = value.getPortName();
MacEntry macEntry = new MacEntry(vpnName, srcMacAddress, srcInetAddr, interfaceName, value.getCreationTime());
jobCoordinator.enqueueJob(buildJobKey(srcInetAddr.toString(), vpnName), new ArpMonitorStopTask(macEntry, dataBroker, alivenessManager));
} catch (UnknownHostException e) {
LOG.error("Error in deserializing packet {} with exception", value, e);
}
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry in project netvirt by opendaylight.
the class BgpConfigurationManager method deleteExternalFibRoutes.
/*
* BGP config remove scenario, Need to remove all the
* external routes from FIB.
*/
public void deleteExternalFibRoutes() {
totalExternalRoutes = 0;
totalExternalMacRoutes = 0;
try {
InstanceIdentifier<FibEntries> id = InstanceIdentifier.create(FibEntries.class);
Optional<FibEntries> fibEntries = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
if (fibEntries.isPresent()) {
if (fibEntries.get().getVrfTables() == null) {
LOG.error("deleteExternalFibRoutes::getVrfTables is null");
return;
}
List<VrfTables> staleVrfTables = fibEntries.get().getVrfTables();
for (VrfTables vrfTable : staleVrfTables) {
String rd = vrfTable.getRouteDistinguisher();
if (vrfTable.getVrfEntry() != null) {
for (VrfEntry vrfEntry : vrfTable.getVrfEntry()) {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
// route cleanup is only meant for the routes learned through BGP.
continue;
}
totalExternalRoutes++;
fibDSWriter.removeFibEntryFromDS(rd, vrfEntry.getDestPrefix());
}
} else if (vrfTable.getMacVrfEntry() != null) {
for (MacVrfEntry macEntry : vrfTable.getMacVrfEntry()) {
if (RouteOrigin.value(macEntry.getOrigin()) != RouteOrigin.BGP) {
// route cleanup is only meant for the routes learned through BGP.
continue;
}
totalExternalMacRoutes++;
fibDSWriter.removeMacEntryFromDS(rd, macEntry.getMac());
}
}
}
} else {
LOG.error("deleteExternalFibRoutes:: FIBentries.class is not present");
}
} catch (ReadFailedException e) {
LOG.error("deleteExternalFibRoutes:: error ", e);
}
LOG.debug("deleted {} fib entries {} mac entries", totalExternalRoutes, totalExternalMacRoutes);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry in project netvirt by opendaylight.
the class ElanL2GatewayUtils method getElanMacTableEntriesMacs.
/**
* Gets the elan mac table entries as remote ucast macs. <br>
* Note: ELAN MAC table only contains internal switches MAC's. It doesn't
* contain external device MAC's.
*
* @param elanName
* the elan name
* @param hwVtepNodeId
* the hw vtep node id
* @param logicalSwitchName
* the logical switch name
* @return the elan mac table entries as remote ucast macs
*/
public List<RemoteUcastMacs> getElanMacTableEntriesMacs(String elanName, NodeId hwVtepNodeId, String logicalSwitchName) {
List<RemoteUcastMacs> lstRemoteUcastMacs = new ArrayList<>();
MacTable macTable = ElanUtils.getElanMacTable(broker, elanName);
if (macTable == null || macTable.getMacEntry() == null || macTable.getMacEntry().isEmpty()) {
LOG.trace("MacTable is empty for elan: {}", elanName);
return lstRemoteUcastMacs;
}
for (MacEntry macEntry : macTable.getMacEntry()) {
BigInteger dpnId = getDpidFromInterface(macEntry.getInterface());
if (dpnId == null) {
LOG.error("DPN ID not found for interface {}", macEntry.getInterface());
continue;
}
IpAddress dpnTepIp = elanItmUtils.getSourceDpnTepIp(dpnId, hwVtepNodeId);
LOG.trace("Dpn Tep IP: {} for dpnId: {} and nodeId: {}", dpnTepIp, dpnId, hwVtepNodeId.getValue());
if (dpnTepIp == null) {
LOG.error("TEP IP not found for dpnId {} and nodeId {}", dpnId, hwVtepNodeId.getValue());
continue;
}
HwvtepPhysicalLocatorAugmentation physLocatorAug = HwvtepSouthboundUtils.createHwvtepPhysicalLocatorAugmentation(String.valueOf(dpnTepIp.getValue()));
// TODO: Query ARP cache to get IP address corresponding to the
// MAC
RemoteUcastMacs remoteUcastMac = HwvtepSouthboundUtils.createRemoteUcastMac(hwVtepNodeId, macEntry.getMacAddress().getValue().toLowerCase(Locale.getDefault()), null, /*IpAddress*/
logicalSwitchName, physLocatorAug);
lstRemoteUcastMacs.add(remoteUcastMac);
}
return lstRemoteUcastMacs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry in project netvirt by opendaylight.
the class ElanMacTableGet method doExecute.
@Override
protected Object doExecute() {
LOG.debug("Executing elan mac table get command for {}", elanName);
Collection<MacEntry> macTables = elanProvider.getElanMacTable(elanName);
if (!macTables.isEmpty()) {
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy:HH:mm:ss");
session.getConsole().println(getMacTableHeaderOutput());
session.getConsole().println(elanName);
for (MacEntry mac : macTables) {
boolean isStatic = mac.isIsStaticAddress();
session.getConsole().println(String.format(ElanCLIUtils.MAC_TABLE_CLI_FORMAT, "", mac.getInterface(), mac.getMacAddress().getValue(), ""));
session.getConsole().println(String.format(ElanCLIUtils.MAC_TABLE_CLI_FORMAT, "", isStatic, "", isStatic ? "-" : formatter.format(new Date(mac.getControllerLearnedForwardingEntryTimestamp().longValue()))));
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry in project netvirt by opendaylight.
the class ElanForwardingEntriesHandler method addElanInterfaceForwardingTableList.
public void addElanInterfaceForwardingTableList(String elanInstanceName, String interfaceName, StaticMacEntries staticMacEntries, WriteTransaction tx) {
MacEntry macEntry = new MacEntryBuilder().setIsStaticAddress(true).setMacAddress(staticMacEntries.getMacAddress()).setIpPrefix(staticMacEntries.getIpPrefix()).setInterface(interfaceName).setKey(new MacEntryKey(staticMacEntries.getMacAddress())).build();
createElanForwardingTablesList(elanInstanceName, macEntry, tx);
createElanInterfaceForwardingTablesList(interfaceName, macEntry, tx);
}
Aggregations