use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress in project netvirt by opendaylight.
the class IVpnLinkServiceImpl method handleStaticRoute.
/*
* Takes care of an static route to see if flows related to interVpnLink
* must be installed in tables 20 and 17
*
* @param vpnId Vpn to which the route belongs
* @param route Route to handle. Will only be considered if its nexthop is the VPN's endpoint IpAddress
* at the other side of the InterVpnLink
* @param iVpnLink
*/
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleStaticRoute(String vpnId, Routes route, InterVpnLinkDataComposite ivpnLink) {
IpAddress nhIpAddr = route.getNexthop();
String routeNextHop = nhIpAddr.getIpv4Address() != null ? nhIpAddr.getIpv4Address().getValue() : nhIpAddr.getIpv6Address().getValue();
String destination = String.valueOf(route.getDestination().getValue());
// is nexthop the other endpoint's IP
String otherEndpoint = ivpnLink.getOtherEndpoint(vpnId);
if (!routeNextHop.equals(otherEndpoint)) {
LOG.debug("VPN {}: Route to {} nexthop={} points to an InterVpnLink endpoint, but its not " + "the other endpoint. Other endpoint is {}", vpnId, destination, routeNextHop, otherEndpoint);
return;
}
// Lets work: 1) write Fibentry, 2) advertise to BGP and 3) check if it must be leaked
String vpnRd = VpnUtil.getVpnRd(dataBroker, vpnId);
if (vpnRd == null) {
LOG.warn("Could not find Route-Distinguisher for VpnName {}", vpnId);
return;
}
int label = VpnUtil.getUniqueId(idManager, VpnConstants.VPN_IDPOOL_NAME, VpnUtil.getNextHopLabelKey(vpnId, destination));
try {
InterVpnLinkUtil.handleStaticRoute(ivpnLink, vpnId, destination, routeNextHop, label, dataBroker, fibManager, bgpManager);
} catch (Exception e) {
LOG.error("Exception while advertising prefix for intervpn link, {}", e);
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress in project netvirt by opendaylight.
the class DhcpMcastMacListener method removed.
@Override
protected void removed(InstanceIdentifier<RemoteMcastMacs> identifier, RemoteMcastMacs del) {
String elanInstanceName = getElanName(del);
IpAddress tunnelIp = dhcpL2GwUtil.getHwvtepNodeTunnelIp(identifier.firstIdentifierOf(Node.class));
if (tunnelIp == null) {
LOG.error("Could not find tunnelIp for {}", identifier);
return;
}
BigInteger designatedDpnId = externalTunnelManager.readDesignatedSwitchesForExternalTunnel(tunnelIp, elanInstanceName);
if (designatedDpnId == null) {
LOG.error("Could not find designated DPN ID elanInstanceName {}, tunnelIp {}", elanInstanceName, tunnelIp);
return;
}
externalTunnelManager.removeDesignatedSwitchForExternalTunnel(designatedDpnId, tunnelIp, elanInstanceName);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress in project netvirt by opendaylight.
the class DhcpMcastMacListener method added.
@Override
protected void added(InstanceIdentifier<RemoteMcastMacs> identifier, RemoteMcastMacs add) {
String elanInstanceName = getElanName(add);
IpAddress tunnelIp = dhcpL2GwUtil.getHwvtepNodeTunnelIp(identifier.firstIdentifierOf(Node.class));
if (tunnelIp == null) {
LOG.error("Could not find tunnelIp for {}", identifier);
return;
}
List<BigInteger> dpns = DhcpServiceUtils.getListOfDpns(dataBroker);
BigInteger designatedDpnId = externalTunnelManager.designateDpnId(tunnelIp, elanInstanceName, dpns);
if (designatedDpnId == null || designatedDpnId.equals(DhcpMConstants.INVALID_DPID)) {
LOG.error("Unable to designate a DPN for {}", identifier);
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress in project netvirt by opendaylight.
the class DhcpPktHandler method getDhcpInfo.
private DhcpInfo getDhcpInfo(Port port, Subnet subnet, String serverIp) {
DhcpInfo dhcpInfo = null;
if (port != null && subnet != null) {
String clientIp = getIpv4Address(port);
List<IpAddress> dnsServers = subnet.getDnsNameservers();
dhcpInfo = new DhcpInfo();
if (isIpv4Address(subnet.getGatewayIp())) {
dhcpInfo.setGatewayIp(subnet.getGatewayIp().getIpv4Address().getValue());
}
if (clientIp != null && serverIp != null) {
List<HostRoutes> subnetHostRoutes = new ArrayList<>(subnet.getHostRoutes().size());
for (HostRoutes hostRoute : subnet.getHostRoutes()) {
if (!String.valueOf(hostRoute.getNexthop().getValue()).equals(clientIp)) {
subnetHostRoutes.add(hostRoute);
}
}
dhcpInfo.setClientIp(clientIp).setServerIp(serverIp).setCidr(String.valueOf(subnet.getCidr().getValue())).setHostRoutes(subnetHostRoutes).setDnsServersIpAddrs(dnsServers);
}
}
return dhcpInfo;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress in project netvirt by opendaylight.
the class DhcpServiceUtils method setupDhcpArpRequest.
@SuppressWarnings("checkstyle:IllegalCatch")
public static void setupDhcpArpRequest(BigInteger dpId, short tableId, BigInteger vni, String dhcpIpAddress, int lportTag, Long elanTag, boolean add, IMdsalApiManager mdsalUtil) {
List<MatchInfo> matches = getDhcpArpMatch(vni, dhcpIpAddress);
if (add) {
Flow flow = MDSALUtil.buildFlowNew(tableId, getDhcpArpFlowRef(dpId, tableId, lportTag, dhcpIpAddress), DhcpMConstants.DEFAULT_DHCP_ARP_FLOW_PRIORITY, "DHCPArp", 0, 0, generateDhcpArpCookie(lportTag, dhcpIpAddress), matches, null);
LOG.trace("Removing DHCP ARP Flow DpId {}, DHCP Port IpAddress {}", dpId, dhcpIpAddress);
mdsalUtil.removeFlow(dpId, flow);
} else {
Flow flow = MDSALUtil.buildFlowNew(tableId, getDhcpArpFlowRef(dpId, tableId, lportTag, dhcpIpAddress), DhcpMConstants.DEFAULT_DHCP_ARP_FLOW_PRIORITY, "DHCPArp", 0, 0, generateDhcpArpCookie(lportTag, dhcpIpAddress), matches, getDhcpArpInstructions(elanTag, lportTag));
LOG.trace("Adding DHCP ARP Flow DpId {}, DHCPPort IpAddress {}", dpId, dhcpIpAddress);
mdsalUtil.installFlow(dpId, flow);
}
}
Aggregations