use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.Ipv4 in project netvirt by opendaylight.
the class DhcpNeutronPortListener method update.
@Override
public void update(InstanceIdentifier<Port> identifier, Port original, Port update) {
if (!config.isControllerDhcpEnabled()) {
return;
}
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.nonnullFixedIps().size() < update.nonnullFixedIps().size()) {
final String interfaceName = update.getUuid().getValue();
List<FixedIps> updatedFixedIps = new ArrayList<>(update.nonnullFixedIps().values());
// Need to check only the newly added fixed ip.
updatedFixedIps.removeAll(original.nonnullFixedIps().values());
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(CONFIGURATION, tx -> {
LOG.debug("Binding DHCP service for interface {}", interfaceName);
DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx);
})), DhcpMConstants.RETRY_COUNT);
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), () -> {
Uint64 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();
}
String vmMacAddress = txRunner.applyWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> DhcpServiceUtils.getAndUpdateVmMacAddress(tx, interfaceName, dhcpManager)).get();
return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> dhcpManager.installDhcpEntries(dpnId, vmMacAddress, 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(Uint64.valueOf(segmentationIdOriginal), macOriginal);
dhcpExternalTunnelManager.updateVniMacToPortCache(Uint64.valueOf(segmentationIdUpdated), macUpdated, update);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.Ipv4 in project netvirt by opendaylight.
the class NeutronvpnManager method createPortIpAdjacencies.
protected Adjacencies createPortIpAdjacencies(Port port, Boolean isRouterInterface, TypedWriteTransaction<Configuration> wrtConfigTxn, @Nullable VpnInterface vpnIface) {
List<Adjacency> adjList = new ArrayList<>();
if (vpnIface != null) {
adjList = new ArrayList<>(vpnIface.augmentation(Adjacencies.class).getAdjacency().values());
}
String infName = port.getUuid().getValue();
LOG.trace("neutronVpnManager: create config adjacencies for Port: {}", infName);
for (FixedIps ip : port.nonnullFixedIps().values()) {
String ipValue = ip.getIpAddress().stringValue();
String ipPrefix = ip.getIpAddress().getIpv4Address() != null ? ipValue + "/32" : ipValue + "/128";
Subnetmap snTemp = neutronvpnUtils.getSubnetmap(ip.getSubnetId());
if (snTemp != null && !FibHelper.doesPrefixBelongToSubnet(ipPrefix, snTemp.getSubnetIp(), false)) {
continue;
}
Uuid vpnId = snTemp != null ? snTemp.getVpnId() : null;
if (vpnId != null) {
neutronvpnUtils.createVpnPortFixedIpToPort(vpnId.getValue(), ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
// Create Neutron port adjacency if VPN presence is existing for subnet
Adjacency vmAdj = new AdjacencyBuilder().withKey(new AdjacencyKey(ipPrefix)).setIpAddress(ipPrefix).setMacAddress(port.getMacAddress().getValue()).setAdjacencyType(AdjacencyType.PrimaryAdjacency).setSubnetId(ip.getSubnetId()).build();
if (!adjList.contains(vmAdj)) {
adjList.add(vmAdj);
}
}
Uuid routerId = snTemp != null ? snTemp.getRouterId() : null;
if (snTemp != null && snTemp.getInternetVpnId() != null) {
neutronvpnUtils.createVpnPortFixedIpToPort(snTemp.getInternetVpnId().getValue(), ipValue, infName, port.getMacAddress().getValue(), isRouterInterface, wrtConfigTxn);
}
if (routerId != null) {
Router rtr = neutronvpnUtils.getNeutronRouter(routerId);
if (rtr != null && rtr.getRoutes() != null) {
List<Routes> routeList = new ArrayList<>(rtr.getRoutes().values());
// create extraroute Adjacence for each ipValue,
// because router can have IPv4 and IPv6 subnet ports, or can have
// more that one IPv4 subnet port or more than one IPv6 subnet port
List<Adjacency> erAdjList = getAdjacencyforExtraRoute(routeList, ipValue);
if (!erAdjList.isEmpty()) {
adjList.addAll(erAdjList);
}
}
}
}
return new AdjacenciesBuilder().setAdjacency(getAdjacencyMap(adjList)).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.Ipv4 in project netvirt by opendaylight.
the class NeutronPortChangeListener method handleRouterInterfaceRemoved.
private void handleRouterInterfaceRemoved(Port routerPort) {
if (routerPort.getDeviceId() != null) {
Uuid routerId = new Uuid(routerPort.getDeviceId());
Uuid infNetworkId = routerPort.getNetworkId();
elanService.removeKnownL3DmacAddress(routerPort.getMacAddress().getValue(), infNetworkId.getValue());
Uuid vpnId = ObjectUtils.defaultIfNull(neutronvpnUtils.getVpnForRouter(routerId, true), routerId);
Map<FixedIpsKey, FixedIps> keyFixedIpsMap = routerPort.nonnullFixedIps();
boolean vpnInstanceInternetIpVersionRemoved = false;
Uuid vpnInstanceInternetUuid = null;
for (FixedIps portIP : keyFixedIpsMap.values()) {
// Internet VPN : flush InternetVPN first
Uuid subnetId = portIP.getSubnetId();
Subnetmap sn = neutronvpnUtils.getSubnetmap(subnetId);
if (sn != null && sn.getInternetVpnId() != null) {
if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, sn.getInternetVpnId())) {
vpnInstanceInternetIpVersionRemoved = true;
vpnInstanceInternetUuid = sn.getInternetVpnId();
}
nvpnManager.updateVpnInternetForSubnet(sn, sn.getInternetVpnId(), false);
}
}
/* Remove ping responder for router interfaces
* A router interface reference in a VPN will have to be removed before the host interface references
* for that subnet in the VPN are removed. This is to ensure that the FIB Entry of the router interface
* is not the last entry to be removed for that subnet in the VPN.
* If router interface FIB entry is the last to be removed for a subnet in a VPN , then all the host
* interface references in the vpn will already have been cleared, which will cause failures in
* cleanup of router interface flows*/
nvpnManager.deleteVpnInterface(routerPort.getUuid().getValue(), null, /* vpn-id */
null);
// update RouterInterfaces map
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
for (FixedIps portIP : keyFixedIpsMap.values()) {
Subnetmap sn = neutronvpnUtils.getSubnetmap(portIP.getSubnetId());
if (null == sn) {
LOG.error("Subnetmap for subnet {} not found", portIP.getSubnetId().getValue());
continue;
}
// router Port have either IPv4 or IPv6, never both
ipVersion = neutronvpnUtils.getIpVersionFromString(sn.getSubnetIp());
String ipValue = portIP.getIpAddress().stringValue();
neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipValue, confTx);
// NOTE: Please donot change the order of calls to removeSubnetFromVpn and
// and updateSubnetNodeWithFixedIP
nvpnManager.removeSubnetFromVpn(vpnId, sn, sn.getInternetVpnId());
nvpnManager.updateSubnetNodeWithFixedIp(portIP.getSubnetId(), null, null, null, null, null);
}
nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, routerPort.getUuid().getValue());
deleteElanInterface(routerPort.getUuid().getValue(), confTx);
deleteOfPortInterface(routerPort, confTx);
jobCoordinator.enqueueJob(routerId.toString(), () -> {
nvpnNatManager.handleSubnetsForExternalRouter(routerId);
return Collections.emptyList();
});
if (neutronvpnUtils.shouldVpnHandleIpVersionChoiceChange(ipVersion, routerId, false)) {
LOG.debug("vpnInstanceOpDataEntry is getting update with ip address family {} for VPN {}", ipVersion, vpnId.getValue());
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, false);
}
}), LOG, "Error handling interface removal");
if (vpnInstanceInternetIpVersionRemoved) {
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnInstanceInternetUuid.getValue(), IpVersionChoice.IPV6, false);
neutronvpnUtils.updateVpnInstanceWithFallback(routerId, vpnInstanceInternetUuid, false);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.Ipv4 in project netvirt by opendaylight.
the class NeutronPortChangeListenerTest method addPort__Ipv4FixedIps.
@Test
public void addPort__Ipv4FixedIps() throws Exception {
PortBuilder pb = new PortBuilder();
pb.setUuid(new Uuid("12345678-1234-1234-1234-123456789012"));
pb.setNetworkId(new Uuid("12345678-1234-1234-1234-123456789012"));
pb.setMacAddress(new MacAddress("AA:BB:CC:DD:EE:FF"));
IpAddress ipv4 = new IpAddress(new Ipv4Address("2.2.2.2"));
FixedIpsBuilder fib = new FixedIpsBuilder();
fib.setIpAddress(ipv4);
fib.setSubnetId(new Uuid("12345678-1234-1234-1234-123456789012"));
List<FixedIps> fixedIps = new ArrayList<>();
fixedIps.add(fib.build());
pb.setFixedIps(fixedIps);
Port port = pb.build();
neutronPortChangeListener.add(InstanceIdentifier.create(Port.class), port);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv4._case.Ipv4 in project openflowplugin by opendaylight.
the class OpenflowPluginBulkTransactionProvider method createICMPv6Match.
private static MatchBuilder createICMPv6Match() {
MatchBuilder match = new MatchBuilder();
EthernetMatchBuilder eth = new EthernetMatchBuilder();
EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
ethTypeBuilder.setType(new EtherType(0x86ddL));
eth.setEthernetType(ethTypeBuilder.build());
match.setEthernetMatch(eth.build());
// ipv4 version
IpMatchBuilder ipmatch = new IpMatchBuilder();
ipmatch.setIpProtocol((short) 58);
match.setIpMatch(ipmatch.build());
// icmpv6
Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
// match
icmpv6match.setIcmpv6Type((short) 135);
icmpv6match.setIcmpv6Code((short) 1);
match.setIcmpv6Match(icmpv6match.build());
return match;
}
Aggregations