use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.
the class VrfEntryListener method removeInterVPNLinkRouteFlows.
public void removeInterVPNLinkRouteFlows(final InterVpnLinkDataComposite interVpnLink, final String vpnName, final VrfEntry vrfEntry) {
Preconditions.checkArgument(vrfEntry.getRoutePaths() != null && vrfEntry.getRoutePaths().size() == 1);
String interVpnLinkName = interVpnLink.getInterVpnLinkName();
List<BigInteger> targetDpns = interVpnLink.getEndpointDpnsByVpnName(vpnName);
if (targetDpns.isEmpty()) {
LOG.warn("Could not find DPNs for VPN {} in InterVpnLink {}", vpnName, interVpnLinkName);
return;
}
java.util.Optional<String> optNextHop = FibUtil.getFirstNextHopAddress(vrfEntry);
java.util.Optional<Long> optLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
// delete from FIB
//
optNextHop.ifPresent(nextHop -> {
String flowRef = getInterVpnFibFlowRef(interVpnLinkName, vrfEntry.getDestPrefix(), nextHop);
FlowKey flowKey = new FlowKey(new FlowId(flowRef));
Flow flow = new FlowBuilder().setKey(flowKey).setId(new FlowId(flowRef)).setTableId(NwConstants.L3_FIB_TABLE).setFlowName(flowRef).build();
LOG.trace("Removing flow in FIB table for interVpnLink {} key {}", interVpnLinkName, flowRef);
for (BigInteger dpId : targetDpns) {
LOG.debug("Removing flow: VrfEntry=[prefix={} nexthop={}] dpn {} for InterVpnLink {} in FIB", vrfEntry.getDestPrefix(), nextHop, dpId, interVpnLinkName);
mdsalManager.removeFlow(dpId, flow);
}
});
// delete from LFIB
//
optLabel.ifPresent(label -> {
LOG.trace("Removing flow in FIB table for interVpnLink {}", interVpnLinkName);
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
for (BigInteger dpId : targetDpns) {
LOG.debug("Removing flow: VrfEntry=[prefix={} label={}] dpn {} for InterVpnLink {} in LFIB", vrfEntry.getDestPrefix(), label, dpId, interVpnLinkName);
makeLFibTableEntry(dpId, label, /*instructions*/
null, LFIB_INTERVPN_PRIORITY, NwConstants.DEL_FLOW, tx);
}
tx.submit();
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.
the class ElanServiceTest method checkSMAC.
@Test
public void checkSMAC() throws Exception {
// Create Elan instance
createElanInstance(ExpectedObjects.ELAN1, ExpectedObjects.ELAN1_SEGMENT_ID);
awaitForElanTag(ExpectedObjects.ELAN1);
// Add Elan interface
InterfaceInfo interfaceInfo = ELAN_INTERFACES.get(ELAN1 + ":" + DPN1MAC1).getLeft();
addElanInterface(ExpectedObjects.ELAN1, interfaceInfo, DPN1IP1);
// Read Elan instance
InstanceIdentifier<ElanInstance> elanInstanceIid = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(ExpectedObjects.ELAN1)).build();
ElanInstance actualElanInstances = singleTxdataBroker.syncRead(CONFIGURATION, elanInstanceIid);
// Read and Compare SMAC flow
String flowId = new StringBuffer().append(NwConstants.ELAN_SMAC_TABLE).append(actualElanInstances.getElanTag()).append(DPN1_ID).append(interfaceInfo.getInterfaceTag()).append(interfaceInfo.getMacAddress()).toString();
InstanceIdentifier<Flow> flowInstanceIidSrc = getFlowIid(NwConstants.ELAN_SMAC_TABLE, new FlowId(flowId), DPN1_ID);
awaitForData(LogicalDatastoreType.CONFIGURATION, flowInstanceIidSrc);
Flow flowSrc = singleTxdataBroker.syncRead(CONFIGURATION, flowInstanceIidSrc);
flowSrc = getFlowWithoutCookie(flowSrc);
Flow expected = ExpectedObjects.checkSmac(flowId, interfaceInfo, actualElanInstances);
AssertDataObjects.assertEqualBeans(expected, flowSrc);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.
the class ElanServiceTestBase method getFlowIid.
protected InstanceIdentifier<Flow> getFlowIid(short tableId, FlowId flowid, BigInteger dpnId) {
FlowKey flowKey = new FlowKey(new FlowId(flowid));
NodeId nodeId = new NodeId("openflow:" + dpnId);
Node nodeDpn = new NodeBuilder().setId(nodeId).setKey(new NodeKey(nodeId)).build();
return InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId)).child(Flow.class, flowKey).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.
the class DhcpNeutronPortListener method processArpResponderForElanDpns.
/**
* Handle(Add/Remove) ARP Responder for DHCP IP on all the DPNs when DHCP is
* enabled/disabled on subnet add or update or delete.
*
* @param port
* DHCP port for which ARP Responder flow to be added when dhcp
* flag is enabled on the subnet or DHCP port for which ARP
* Responder flow to be removed when dhcp flag is disabled on the
* Subnet
* @param arpResponderAction
* ARP Responder Action to be performed i.e., add or remove flow
*/
private void processArpResponderForElanDpns(Port port, Consumer<ArpResponderInput> arpResponderAction) {
java.util.Optional<String> ip4Address = DhcpServiceUtils.getIpV4Address(port);
if (!ip4Address.isPresent()) {
LOG.warn("There is no IPv4Address for port {}, not performing ARP responder add/remove flow operation", port.getName());
return;
}
ElanHelper.getDpnInterfacesInElanInstance(broker, port.getNetworkId().getValue()).stream().map(ifName -> DhcpServiceUtils.getInterfaceInfo(interfaceManager, ifName)).forEach(interfaceInfo -> {
ArpResponderInput arpResponderInput = new ArpResponderInput.ArpReponderInputBuilder().setDpId(interfaceInfo.getDpId()).setInterfaceName(interfaceInfo.getInterfaceName()).setLportTag(interfaceInfo.getInterfaceTag()).setSha(port.getMacAddress().getValue()).setSpa(ip4Address.get()).build();
arpResponderAction.accept(arpResponderInput);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow in project netvirt by opendaylight.
the class DhcpNeutronPortListener method update.
@Override
protected void update(InstanceIdentifier<Port> identifier, Port original, Port update) {
LOG.trace("Port changed to {}", update);
// With Ipv6 changes we can get ipv4 subnets later. The below check is to support such scenario.
if (original.getFixedIps().size() < update.getFixedIps().size()) {
final String interfaceName = update.getUuid().getValue();
List<FixedIps> updatedFixedIps = update.getFixedIps();
// Need to check only the newly added fixed ip.
updatedFixedIps.removeAll(original.getFixedIps());
Subnet subnet = dhcpManager.getNeutronSubnet(updatedFixedIps);
if (null == subnet || !subnet.isEnableDhcp()) {
LOG.trace("Subnet is null/not ipv4 or not enabled {}", subnet);
return;
}
// Binding the DHCP service for an existing port because of subnet change.
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
LOG.debug("Binding DHCP service for interface {}", interfaceName);
DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx);
})), DhcpMConstants.RETRY_COUNT);
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), () -> {
BigInteger dpnId = interfaceManager.getDpnForInterface(interfaceName);
if (dpnId == null || dpnId.equals(DhcpMConstants.INVALID_DPID)) {
LOG.trace("Unable to install the DHCP flow since dpn is not available");
return Collections.emptyList();
}
return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> dhcpManager.installDhcpEntries(dpnId, DhcpServiceUtils.getAndUpdateVmMacAddress(tx, interfaceName, dhcpManager), tx)));
}, DhcpMConstants.RETRY_COUNT);
}
if (!isVnicTypeDirectOrMacVtap(update)) {
LOG.trace("Port updated is normal {}", update.getUuid());
if (isVnicTypeDirectOrMacVtap(original)) {
LOG.trace("Original Port was direct/macvtap {} so removing flows and cache entry if any", update.getUuid());
removePort(original);
}
return;
}
if (!isVnicTypeDirectOrMacVtap(original)) {
LOG.trace("Original port was normal and updated is direct. Calling addPort()");
addPort(update);
return;
}
String macOriginal = getMacAddress(original);
String macUpdated = getMacAddress(update);
String segmentationIdOriginal = DhcpServiceUtils.getSegmentationId(original.getNetworkId(), broker);
String segmentationIdUpdated = DhcpServiceUtils.getSegmentationId(update.getNetworkId(), broker);
if (macOriginal != null && !macOriginal.equalsIgnoreCase(macUpdated) && segmentationIdOriginal != null && !segmentationIdOriginal.equalsIgnoreCase(segmentationIdUpdated)) {
LOG.trace("Mac/segment id has changed");
dhcpExternalTunnelManager.removeVniMacToPortCache(new BigInteger(segmentationIdOriginal), macOriginal);
dhcpExternalTunnelManager.updateVniMacToPortCache(new BigInteger(segmentationIdUpdated), macUpdated, update);
}
}
Aggregations