use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project netvirt by opendaylight.
the class IfMgr method addRouterIntf.
public void addRouterIntf(Uuid portId, Uuid rtrId, Uuid snetId, Uuid networkId, IpAddress fixedIp, String macAddress, String deviceOwner) {
LOG.debug("addRouterIntf portId {}, rtrId {}, snetId {}, networkId {}, ip {}, mac {}", portId, rtrId, 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(true).deviceOwner(deviceOwner).build();
intf.setSubnetInfo(snetId, fixedIp);
intf.setPeriodicTimer(ipv6Queue);
boolean newIntf = false;
VirtualPort prevIntf = vintfs.putIfAbsent(portId, intf);
if (prevIntf == null) {
newIntf = true;
MacAddress ifaceMac = MacAddress.getDefaultInstance(macAddress);
Ipv6Address llAddr = ipv6ServiceUtils.getIpv6LinkLocalAddressFromMac(ifaceMac);
/* A new router interface is created. This is basically triggered when an
IPv6 subnet is associated to the router. Check if network is already hosting
any VMs. If so, on all the hosts that have VMs on the network, program the
icmpv6 punt flows in IPV6_TABLE(45).
*/
programIcmpv6RSPuntFlows(intf, Ipv6Constants.ADD_FLOW);
programIcmpv6NSPuntFlowForAddress(intf, llAddr, Ipv6Constants.ADD_FLOW);
} else {
intf = prevIntf;
intf.setSubnetInfo(snetId, fixedIp);
}
VirtualRouter rtr = getRouter(rtrId);
VirtualSubnet snet = getSubnet(snetId);
if (rtr != null && snet != null) {
snet.setRouter(rtr);
intf.setSubnet(snetId, snet);
rtr.addSubnet(snet);
} else if (snet != null) {
intf.setSubnet(snetId, snet);
addUnprocessed(unprocessedRouterIntfs, rtrId, intf);
} else {
addUnprocessed(unprocessedRouterIntfs, rtrId, intf);
addUnprocessed(unprocessedSubnetIntfs, snetId, intf);
}
if (networkId != null) {
vrouterv6IntfMap.put(networkId, intf);
}
programIcmpv6NSPuntFlowForAddress(intf, fixedIp.getIpv6Address(), Ipv6Constants.ADD_FLOW);
if (newIntf) {
LOG.debug("start the periodic RA Timer for routerIntf {}", portId);
transmitUnsolicitedRA(intf);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project netvirt by opendaylight.
the class IfMgr method updateRouterIntf.
public void updateRouterIntf(Uuid portId, Uuid rtrId, List<FixedIps> fixedIpsList) {
LOG.info("updateRouterIntf portId {}, fixedIpsList {} ", portId, fixedIpsList);
VirtualPort intf = getPort(portId);
if (intf == null) {
LOG.info("Skip Router interface update for non-ipv6 port {}", portId);
return;
}
List<Ipv6Address> existingIPv6AddressList = intf.getIpv6AddressesWithoutLLA();
List<Ipv6Address> newlyAddedIpv6AddressList = new ArrayList<>();
intf.clearSubnetInfo();
for (FixedIps fip : fixedIpsList) {
IpAddress fixedIp = fip.getIpAddress();
if (fixedIp.getIpv4Address() != null) {
continue;
}
// Save the interface ipv6 address in its fully expanded format
Ipv6Address addr = new Ipv6Address(InetAddresses.forString(fixedIp.getIpv6Address().getValue()).getHostAddress());
fixedIp = new IpAddress(addr);
Uuid subnetId = fip.getSubnetId();
intf.setSubnetInfo(subnetId, fixedIp);
VirtualRouter rtr = getRouter(rtrId);
VirtualSubnet snet = getSubnet(subnetId);
if (rtr != null && snet != null) {
snet.setRouter(rtr);
intf.setSubnet(subnetId, snet);
rtr.addSubnet(snet);
} else if (snet != null) {
intf.setSubnet(subnetId, snet);
addUnprocessed(unprocessedRouterIntfs, rtrId, intf);
} else {
addUnprocessed(unprocessedRouterIntfs, rtrId, intf);
addUnprocessed(unprocessedSubnetIntfs, subnetId, intf);
}
Uuid networkID = intf.getNetworkID();
if (networkID != null) {
vrouterv6IntfMap.put(networkID, intf);
}
if (existingIPv6AddressList.contains(fixedIp.getIpv6Address())) {
existingIPv6AddressList.remove(fixedIp.getIpv6Address());
} else {
newlyAddedIpv6AddressList.add(fixedIp.getIpv6Address());
}
}
/* This is a port update event for routerPort. Check if any IPv6 subnet is added
or removed from the router port. Depending on subnet added/removed, we add/remove
the corresponding flows from IPV6_TABLE(45).
*/
for (Ipv6Address ipv6Address : newlyAddedIpv6AddressList) {
// Some v6 subnets are associated to the routerPort add the corresponding NS Flows.
programIcmpv6NSPuntFlowForAddress(intf, ipv6Address, Ipv6Constants.ADD_FLOW);
}
for (Ipv6Address ipv6Address : existingIPv6AddressList) {
// Some v6 subnets are disassociated from the routerPort, remove the corresponding NS Flows.
programIcmpv6NSPuntFlowForAddress(intf, ipv6Address, Ipv6Constants.DEL_FLOW);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project netvirt by opendaylight.
the class IfMgr method addSubnet.
/**
* Add Subnet.
*
* @param snetId subnet id
* @param name subnet name
* @param tenantId tenant id
* @param gatewayIp gateway ip address
* @param ipVersion IP Version "IPv4 or IPv6"
* @param subnetCidr subnet CIDR
* @param ipV6AddressMode Address Mode of IPv6 Subnet
* @param ipV6RaMode RA Mode of IPv6 Subnet.
*/
public void addSubnet(Uuid snetId, String name, Uuid tenantId, IpAddress gatewayIp, String ipVersion, IpPrefix subnetCidr, String ipV6AddressMode, String ipV6RaMode) {
// in expanded form and are used during Neighbor Discovery Support.
if (gatewayIp != null) {
Ipv6Address addr = new Ipv6Address(InetAddresses.forString(gatewayIp.getIpv6Address().getValue()).getHostAddress());
gatewayIp = new IpAddress(addr);
}
VirtualSubnet snet = VirtualSubnet.builder().subnetUUID(snetId).tenantID(tenantId).name(name).gatewayIp(gatewayIp).subnetCidr(subnetCidr).ipVersion(ipVersion).ipv6AddressMode(ipV6AddressMode).ipv6RAMode(ipV6RaMode).build();
vsubnets.put(snetId, snet);
List<VirtualPort> intfList = unprocessedSubnetIntfs.remove(snetId);
if (intfList == null) {
LOG.debug("No unprocessed interfaces for the subnet {}", snetId);
return;
}
synchronized (intfList) {
for (VirtualPort intf : intfList) {
if (intf != null) {
intf.setSubnet(snetId, snet);
snet.addInterface(intf);
VirtualRouter rtr = intf.getRouter();
if (rtr != null) {
rtr.addSubnet(snet);
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project netvirt by opendaylight.
the class Ipv6NdUtilServiceImpl method sendNeighborSolicitation.
@Override
public Future<RpcResult<Void>> sendNeighborSolicitation(SendNeighborSolicitationInput ndInput) {
RpcResultBuilder<Void> failureBuilder = RpcResultBuilder.failed();
RpcResultBuilder<Void> successBuilder = RpcResultBuilder.success();
Ipv6Address targetIpv6Address = null;
Ipv6Address srcIpv6Address;
String interfaceName = null;
String macAddr = null;
BigInteger dpnId;
int localErrorCount = 0;
targetIpv6Address = ndInput.getTargetIpAddress();
for (InterfaceAddress interfaceAddress : ndInput.getInterfaceAddress()) {
try {
interfaceName = interfaceAddress.getInterface();
srcIpv6Address = interfaceAddress.getSrcIpAddress();
GetPortFromInterfaceOutput portResult = getPortFromInterface(interfaceName);
checkNotNull(portResult);
dpnId = portResult.getDpid();
Long portid = portResult.getPortno();
checkArgument(null != dpnId && BigInteger.ZERO != dpnId, DPN_NOT_FOUND_ERROR, interfaceName);
NodeConnectorRef nodeRef = MDSALUtil.getNodeConnRef(dpnId, portid.toString());
checkNotNull(nodeRef, NODE_CONNECTOR_NOT_FOUND_ERROR, interfaceName);
if (interfaceAddress.getSrcMacAddress() != null) {
macAddr = interfaceAddress.getSrcMacAddress().getValue();
}
checkNotNull(macAddr, FAILED_TO_GET_SRC_MAC_FOR_INTERFACE, interfaceName, nodeRef.getValue());
ipv6NeighborSolicitation.transmitNeighborSolicitation(dpnId, nodeRef, new MacAddress(macAddr), srcIpv6Address, targetIpv6Address);
} catch (NullPointerException | IllegalArgumentException e) {
LOG.trace("Failed to send Neighbor Solicitation for {} on interface {}", ndInput.getTargetIpAddress(), interfaceName);
failureBuilder.withError(RpcError.ErrorType.APPLICATION, FAILED_TO_SEND_NS_FOR_INTERFACE + interfaceName, e);
successBuilder.withError(RpcError.ErrorType.APPLICATION, FAILED_TO_SEND_NS_FOR_INTERFACE + interfaceName, e);
localErrorCount++;
}
}
if (localErrorCount == ndInput.getInterfaceAddress().size()) {
// Failed to send IPv6 Neighbor Solicitation on all the interfaces, return failure.
return Futures.immediateFuture(failureBuilder.build());
}
return Futures.immediateFuture(successBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project netvirt by opendaylight.
the class Ipv6ServiceInterfaceEventListener method add.
@Override
protected void add(InstanceIdentifier<Interface> key, Interface add) {
List<String> ofportIds = add.getLowerLayerIf();
if (!L2vlan.class.equals(add.getType())) {
return;
}
// In ipv6service, we are only interested in the notification for NeutronPort, so we skip other notifications
if (ofportIds == null || ofportIds.isEmpty() || !isNeutronPort(add.getName())) {
return;
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface;
iface = ipv6ServiceUtils.getInterface(add.getName());
if (null != iface) {
LOG.debug("Port {} is a Neutron port", iface.getName());
NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
BigInteger dpId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
if (!dpId.equals(Ipv6Constants.INVALID_DPID)) {
Uuid portId = new Uuid(iface.getName());
VirtualPort port = ifMgr.obtainV6Interface(portId);
if (port == null) {
LOG.info("Port {} does not include IPv6Address, skipping.", portId);
return;
}
Long ofPort = MDSALUtil.getOfPortNumberFromPortName(nodeConnectorId);
ifMgr.updateDpnInfo(portId, dpId, ofPort);
VirtualPort routerPort = ifMgr.getRouterV6InterfaceForNetwork(port.getNetworkID());
if (routerPort == null) {
LOG.info("Port {} is not associated to a Router, skipping.", portId);
return;
}
// Check and program icmpv6 punt flows on the dpnID if its the first VM on the host.
ifMgr.programIcmpv6PuntFlowsIfNecessary(portId, dpId, routerPort);
if (!port.getServiceBindingStatus()) {
jobCoordinator.enqueueJob("IPv6-" + String.valueOf(portId), () -> {
// Bind Service
Long elanTag = ifMgr.getNetworkElanTag(routerPort.getNetworkID());
ipv6ServiceUtils.bindIpv6Service(portId.getValue(), elanTag, NwConstants.IPV6_TABLE);
port.setServiceBindingStatus(true);
return Collections.emptyList();
}, SystemPropertyReader.getDataStoreJobCoordinatorMaxRetries());
}
}
}
}
Aggregations