use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class IPv6Handler method installPing6ResponderFlowEntry.
public void installPing6ResponderFlowEntry(Uint64 dpnId, Uint32 vpnId, String routerInternalIp, MacAddress routerMac, Uint32 label, int addOrRemove) {
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchIpProtocol.ICMPV6);
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId.longValue()), MetaDataUtil.METADATA_MASK_VRFID));
matches.add(new MatchIcmpv6((short) 128, (short) 0));
matches.add(MatchEthernetType.IPV6);
matches.add(new MatchIpv6Destination(routerInternalIp));
List<ActionInfo> actionsInfos = new ArrayList<>();
// Set Eth Src and Eth Dst
actionsInfos.add(new ActionMoveSourceDestinationEth());
actionsInfos.add(new ActionSetFieldEthernetSource(routerMac));
// Move Ipv6 Src to Ipv6 Dst
actionsInfos.add(new ActionMoveSourceDestinationIpv6());
actionsInfos.add(new ActionSetSourceIpv6(new Ipv6Prefix(routerInternalIp)));
// Set the ICMPv6 type to 129 (echo reply)
actionsInfos.add(new ActionSetIcmpv6Type((short) 129));
actionsInfos.add(new ActionNxLoadInPort(Uint64.ZERO));
actionsInfos.add(new ActionNxResubmit(NwConstants.L3_FIB_TABLE));
List<InstructionInfo> instructions = new ArrayList<>();
instructions.add(new InstructionApplyActions(actionsInfos));
int priority = FibConstants.DEFAULT_FIB_FLOW_PRIORITY + FibConstants.DEFAULT_IPV6_PREFIX_LENGTH;
String flowRef = FibUtil.getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, label, priority);
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, NwConstants.COOKIE_VM_FIB_TABLE, matches, instructions);
if (addOrRemove == NwConstants.ADD_FLOW) {
mdsalManager.syncInstallFlow(flowEntity);
} else {
mdsalManager.syncRemoveFlow(flowEntity);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class IfMgr method addHostIntf.
public void addHostIntf(Uuid portId, Uuid snetId, Uuid networkId, IpAddress fixedIp, String macAddress, String deviceOwner) {
LOG.debug("addHostIntf portId {}, snetId {}, networkId {}, ip {}, mac {}", portId, snetId, networkId, fixedIp, macAddress);
// Save the interface ipv6 address in its fully expanded format
Ipv6Address addr = new Ipv6Address(InetAddresses.forString(fixedIp.getIpv6Address().getValue()).getHostAddress());
fixedIp = new IpAddress(addr);
VirtualPort intf = VirtualPort.builder().intfUUID(portId).networkID(networkId).macAddress(macAddress).routerIntfFlag(false).deviceOwner(deviceOwner).build();
intf.setSubnetInfo(snetId, fixedIp);
VirtualPort prevIntf = vintfs.putIfAbsent(portId, intf);
if (prevIntf == null) {
Long elanTag = getNetworkElanTag(networkId);
final VirtualPort virtIntf = intf;
String jobKey = Ipv6ServiceUtils.buildIpv6MonitorJobKey(portId.getValue());
coordinator.enqueueJob(jobKey, () -> {
// Do service binding for the port and set the serviceBindingStatus to true.
ipv6ServiceUtils.bindIpv6Service(portId.getValue(), elanTag, NwConstants.IPV6_TABLE);
virtIntf.setServiceBindingStatus(true);
/* Update the intf dpnId/ofPort from the Operational Store */
updateInterfaceDpidOfPortInfo(portId);
if (Objects.equals(ipV6NAConfigHelper.getNaResponderMode(), Ipv6serviceConfig.NaResponderMode.Switch)) {
checkIcmpv6NsMatchAndResponderFlow(Uint64.ZERO, 0, virtIntf, Ipv6ServiceConstants.ADD_FLOW);
}
return Collections.emptyList();
});
} else {
intf = prevIntf;
intf.setSubnetInfo(snetId, fixedIp);
}
VirtualSubnet snet = getSubnet(snetId);
if (snet != null) {
intf.setSubnet(snetId, snet);
} else {
addUnprocessed(unprocessedSubnetIntfs, snetId, intf);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv6._case.Ipv6 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.types.rev181109.endpoints.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class NeutronvpnManager method associateExtNetworkToVpn.
private boolean associateExtNetworkToVpn(@NonNull Uuid vpnId, @NonNull Network extNet, VpnInstance.BgpvpnType bgpVpnType) {
if (!addExternalNetworkToVpn(extNet, vpnId)) {
return false;
}
if (!bgpVpnType.equals(VpnInstance.BgpvpnType.InternetBGPVPN)) {
LOG.info("associateExtNetworkToVpn: External network {} is associated to VPN {}." + "Hence set vpnInstance type to {} from {} ", extNet.key().getUuid().getValue(), vpnId.getValue(), VpnInstance.BgpvpnType.InternetBGPVPN.getName(), VpnInstance.BgpvpnType.BGPVPN.getName());
neutronvpnUtils.updateVpnInstanceWithBgpVpnType(VpnInstance.BgpvpnType.InternetBGPVPN, vpnId);
}
// Update VpnMap with ext-nw is needed first before processing V6 internet default fallback flows
List<Uuid> extNwList = Collections.singletonList(extNet.key().getUuid());
updateVpnMaps(vpnId, null, null, null, extNwList);
IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
for (Uuid snId : neutronvpnUtils.getPrivateSubnetsToExport(extNet, vpnId)) {
Subnetmap sm = neutronvpnUtils.getSubnetmap(snId);
if (sm == null) {
LOG.error("associateExtNetworkToVpn: can not find subnet with Id {} in ConfigDS", snId.getValue());
continue;
}
IpVersionChoice ipVers = NeutronvpnUtils.getIpVersionFromString(sm.getSubnetIp());
if (ipVers.isIpVersionChosen(IpVersionChoice.IPV4)) {
continue;
}
if (ipVers.isIpVersionChosen(IpVersionChoice.IPV6)) {
updateVpnInternetForSubnet(sm, vpnId, true);
}
if (!ipVersion.isIpVersionChosen(ipVers)) {
ipVersion = ipVersion.addVersion(ipVers);
}
}
if (ipVersion != IpVersionChoice.UNDEFINED) {
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), IpVersionChoice.IPV6, true);
LOG.info("associateExtNetworkToVpn: add IPv6 Internet default route in VPN {}", vpnId.getValue());
neutronvpnUtils.updateVpnInstanceWithFallback(/*routerId*/
null, vpnId, true);
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class NeutronvpnManager method dissociateNetworksFromVpn.
/**
* Parses and disassociates networks list from given VPN.
*
* @param vpnId Uuid of given VPN.
* @param networkList List list of network Ids (Uuid), which will be disassociated.
* @return list of formatted strings with detailed error messages.
*/
@NonNull
protected List<String> dissociateNetworksFromVpn(@NonNull Uuid vpnId, @NonNull List<Uuid> networkList) {
List<String> failedNwList = new ArrayList<>();
HashSet<Uuid> passedNwList = new HashSet<>();
ConcurrentMap<Uuid, Network> extNwMap = new ConcurrentHashMap<>();
IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
if (networkList.isEmpty()) {
LOG.error("dissociateNetworksFromVpn: Failed as networks list is empty");
failedNwList.add(String.format("Failed to disassociate networks from VPN %s as networks list is empty", vpnId.getValue()));
return failedNwList;
}
for (Uuid nw : networkList) {
List<Uuid> networkSubnets = neutronvpnUtils.getSubnetIdsFromNetworkId(nw);
if (networkSubnets == null) {
passedNwList.add(nw);
continue;
}
Network network = neutronvpnUtils.getNeutronNetwork(nw);
if (network == null) {
LOG.error("dissociateNetworksFromVpn: Network {} not found in ConfigDS", nw.getValue());
failedNwList.add(String.format("Failed to disassociate network %s as is not found in ConfigDS", nw.getValue()));
continue;
}
Uuid networkVpnId = neutronvpnUtils.getVpnForNetwork(nw);
if (networkVpnId == null) {
LOG.error("dissociateNetworksFromVpn: Network {} is not associated to any VPN", nw.getValue());
failedNwList.add(String.format("Failed to disassociate network %s as is not associated to any VPN", nw.getValue()));
continue;
}
if (!vpnId.equals(networkVpnId)) {
LOG.error("dissociateNetworksFromVpn: Network {} is associated to another VPN {} instead of given {}", nw.getValue(), networkVpnId.getValue(), vpnId.getValue());
failedNwList.add(String.format("Failed to disassociate network %s as it is associated to another " + "vpn %s instead of given %s", nw.getValue(), networkVpnId.getValue(), vpnId.getValue()));
continue;
}
/* Handle disassociation of external network(s) from Internet BGP-VPN use case outside of the
* networkList iteration
*/
if (neutronvpnUtils.getIsExternal(network)) {
extNwMap.put(nw, network);
// Handle external-Nw to BGPVPN Disassociation and still ext-router is being set with external-Nw
List<Uuid> routerList = neutronvpnUtils.getRouterIdsForExtNetwork(nw);
if (!routerList.isEmpty()) {
for (Uuid routerId : routerList) {
// If v6 subnet was already added to router means it requires IPv6 AddrFamily in VpnInstance
if (neutronvpnUtils.isV6SubnetPartOfRouter(routerId)) {
ipVersion = ipVersion.addVersion(IpVersionChoice.IPV6);
LOG.debug("dissociateNetworksFromVpn: External network {} is still associated with " + "router(router-gw) {} and V6 subnet is part of that router. Hence Set IPv6 " + "address family type in Internet VPN Instance {}", network, routerId, vpnId);
break;
}
}
}
}
for (Uuid subnet : networkSubnets) {
Subnetmap subnetmap = neutronvpnUtils.getSubnetmap(subnet);
if (subnetmap == null) {
failedNwList.add(String.format("subnetmap %s not found for network %s", subnet.getValue(), nw.getValue()));
LOG.error("dissociateNetworksFromVpn: Subnetmap for subnet {} not found when " + "dissociating network {} from VPN {}", subnet.getValue(), nw.getValue(), vpnId.getValue());
continue;
}
IpVersionChoice ipVers = NeutronvpnUtils.getIpVersionFromString(subnetmap.getSubnetIp());
if (!ipVersion.isIpVersionChosen(ipVers)) {
ipVersion = ipVersion.addVersion(ipVers);
}
if (!NeutronvpnUtils.getIsExternal(network)) {
LOG.debug("dissociateNetworksFromVpn: Withdraw subnet {} from VPN {}", subnet.getValue(), vpnId.getValue());
removeSubnetFromVpn(vpnId, subnetmap, null);
Set<VpnTarget> routeTargets = vpnManager.getRtListForVpn(vpnId.getValue());
vpnManager.removeRouteTargetsToSubnetAssociation(routeTargets, subnetmap.getSubnetIp(), vpnId.getValue());
passedNwList.add(nw);
}
}
if (ipVersion != IpVersionChoice.UNDEFINED) {
LOG.debug("dissociateNetworksFromVpn: Updating vpnInstance with ip address family {}" + " for VPN {}", ipVersion, vpnId);
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, false);
}
}
// Handle disassociation of external network(s) from Internet BGP-VPN Instance use case
if (!extNwMap.isEmpty() || extNwMap != null) {
for (Network extNw : extNwMap.values()) {
if (disassociateExtNetworkFromVpn(vpnId, extNw)) {
passedNwList.add(extNw.getUuid());
} else {
LOG.error("dissociateNetworksFromVpn: Failed to withdraw External Provider Network {} from VPN {}", extNw, vpnId.getValue());
failedNwList.add(String.format("Failed to withdraw External Provider Network %s from VPN %s", extNw, vpnId.getValue()));
continue;
}
}
}
clearFromVpnMaps(vpnId, null, new ArrayList<>(passedNwList));
LOG.info("dissociateNetworksFromVpn: Network(s) {} disassociated from L3VPN {} successfully", passedNwList, vpnId.getValue());
return failedNwList;
}
Aggregations