use of org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder in project netvirt by opendaylight.
the class VpnManagerImpl method installArpResponderFlowsToExternalNetworkIp.
private void installArpResponderFlowsToExternalNetworkIp(String macAddress, BigInteger dpnId, String extInterfaceName, int lportTag, String fixedIp) {
// reset the split-horizon bit to allow traffic to be sent back to the
// provider port
List<Instruction> instructions = new ArrayList<>();
instructions.add(new InstructionWriteMetadata(BigInteger.ZERO, MetaDataUtil.METADATA_MASK_SH_FLAG).buildInstruction(1));
instructions.addAll(ArpResponderUtil.getExtInterfaceInstructions(interfaceManager, extInterfaceName, fixedIp, macAddress));
ArpReponderInputBuilder builder = new ArpReponderInputBuilder().setDpId(dpnId).setInterfaceName(extInterfaceName).setSpa(fixedIp).setSha(macAddress).setLportTag(lportTag);
builder.setInstructions(instructions);
elanService.addArpResponderFlow(builder.buildForInstallFlow());
}
use of org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder in project netvirt by opendaylight.
the class ArpResponderHandler method addArpResponderFlow.
/**
* Add ARP Responder flow, by invoking ELan RPC service.
*
* @param dpnId
* dpn Id on which ARP responder flow to be added
* @param lportTag
* lport tag of the interface
* @param interfaceName
* interface to which ARP responder flow to be added
* @param gatewayIp
* gateway ip of the interface
* @param mac
* mac address
*/
public void addArpResponderFlow(BigInteger dpnId, int lportTag, String interfaceName, String gatewayIp, String mac) {
LOG.trace("Creating the ARP Responder flow for VPN Interface {}", interfaceName);
ArpReponderInputBuilder builder = new ArpReponderInputBuilder();
builder.setDpId(dpnId).setInterfaceName(interfaceName).setSpa(gatewayIp).setSha(mac).setLportTag(lportTag);
builder.setInstructions(ArpResponderUtil.getInterfaceInstructions(interfaceManager, interfaceName, gatewayIp, mac));
elanService.addArpResponderFlow(builder.buildForInstallFlow());
}
use of org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder in project netvirt by opendaylight.
the class DhcpNeutronPortListener method add.
@Override
protected void add(InstanceIdentifier<Port> identifier, Port add) {
LOG.trace("Port added {}", add);
if (NeutronConstants.IS_ODL_DHCP_PORT.test(add)) {
jobCoordinator.enqueueJob(getJobKey(add), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
DhcpServiceUtils.createSubnetDhcpPortData(add, (subnetDhcpPortIdfr, subnetToDhcpport) -> tx.put(LogicalDatastoreType.CONFIGURATION, subnetDhcpPortIdfr, subnetToDhcpport));
processArpResponderForElanDpns(add, arpInput -> {
LOG.trace("Installing ARP RESPONDER Flows for dhcp port {} ipaddress {} with mac {} on dpn {}", arpInput.getInterfaceName(), arpInput.getSpa(), arpInput.getSha(), arpInput.getDpId());
ArpReponderInputBuilder builder = new ArpReponderInputBuilder(arpInput);
builder.setInstructions(ArpResponderUtil.getInterfaceInstructions(interfaceManager, arpInput.getInterfaceName(), arpInput.getSpa(), arpInput.getSha()));
elanService.addArpResponderFlow(builder.buildForInstallFlow());
});
})));
java.util.Optional<String> ip4Address = DhcpServiceUtils.getIpV4Address(add);
if (ip4Address.isPresent()) {
dhcpExternalTunnelManager.addOrRemoveDhcpArpFlowforElan(add.getNetworkId().getValue(), true, ip4Address.get(), add.getMacAddress().getValue());
}
}
if (!isVnicTypeDirectOrMacVtap(add)) {
return;
}
addPort(add);
}
use of org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder in project netvirt by opendaylight.
the class DhcpInterfaceAddJob method call.
@Override
public List<ListenableFuture<Void>> call() {
String interfaceName = interfaceAdd.getName();
LOG.trace("Received add DCN for interface {}, dpid {}", interfaceName, dpnId);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManager.getInterfaceInfoFromConfigDataStore(interfaceName);
if (iface != null) {
IfTunnel tunnelInterface = iface.getAugmentation(IfTunnel.class);
if (tunnelInterface != null && !tunnelInterface.isInternal()) {
IpAddress tunnelIp = tunnelInterface.getTunnelDestination();
List<BigInteger> dpns = DhcpServiceUtils.getListOfDpns(dataBroker);
if (dpns.contains(dpnId)) {
return dhcpExternalTunnelManager.handleTunnelStateUp(tunnelIp, dpnId);
}
return Collections.emptyList();
}
}
if (!dpnId.equals(DhcpMConstants.INVALID_DPID)) {
Port port = dhcpManager.getNeutronPort(interfaceName);
Subnet subnet = dhcpManager.getNeutronSubnet(port);
if (null == subnet || !subnet.isEnableDhcp()) {
LOG.debug("DHCP is not enabled for port {}", port.getName());
return Collections.emptyList();
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
// Support for VM migration use cases.
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx)));
LOG.info("DhcpInterfaceEventListener add isEnableDhcp:{}", subnet.isEnableDhcp());
futures.addAll(installDhcpEntries(interfaceAdd.getName(), dpnId));
LOG.trace("Checking ElanDpnInterface {} for dpn {} ", interfaceName, dpnId);
String subnetId = subnet.getUuid().getValue();
java.util.Optional<SubnetToDhcpPort> subnetToDhcp = DhcpServiceUtils.getSubnetDhcpPortData(dataBroker, subnetId);
if (!subnetToDhcp.isPresent()) {
return Collections.emptyList();
}
LOG.trace("Installing the Arp responder for interface {} with DHCP MAC {} & IP {}.", interfaceName, subnetToDhcp.get().getPortMacaddress(), subnetToDhcp.get().getPortFixedip());
ArpReponderInputBuilder builder = new ArpReponderInputBuilder();
builder.setDpId(dpnId).setInterfaceName(interfaceName).setSpa(subnetToDhcp.get().getPortFixedip()).setSha(subnetToDhcp.get().getPortMacaddress()).setLportTag(interfaceAdd.getIfIndex());
builder.setInstructions(ArpResponderUtil.getInterfaceInstructions(interfaceManager, interfaceName, subnetToDhcp.get().getPortFixedip(), subnetToDhcp.get().getPortMacaddress()));
elanService.addArpResponderFlow(builder.buildForInstallFlow());
return futures;
}
return Collections.emptyList();
}
use of org.opendaylight.netvirt.elan.arp.responder.ArpResponderInput.ArpReponderInputBuilder in project netvirt by opendaylight.
the class VpnManagerImpl method removeArpResponderFlowsToExternalNetworkIp.
private void removeArpResponderFlowsToExternalNetworkIp(BigInteger dpnId, Integer lportTag, String fixedIp, String extInterfaceName) {
ArpResponderInput arpInput = new ArpReponderInputBuilder().setDpId(dpnId).setInterfaceName(extInterfaceName).setSpa(fixedIp).setLportTag(lportTag).buildForRemoveFlow();
elanService.removeArpResponderFlow(arpInput);
}
Aggregations