Search in sources :

Example 41 with IpAddress

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.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);
    }
}
Also used : IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 42 with IpAddress

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.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);
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 43 with IpAddress

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.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);
    }
}
Also used : Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 44 with IpAddress

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.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;
}
Also used : ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) HostRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnet.attributes.HostRoutes)

Example 45 with IpAddress

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.alivenessmonitor.rev160411.endpoint.endpoint.type.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);
    }
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Aggregations

IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)232 ArrayList (java.util.ArrayList)71 Test (org.junit.Test)67 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)67 BigInteger (java.math.BigInteger)47 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)30 ByteBuf (io.netty.buffer.ByteBuf)28 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)27 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)22 InetAddress (java.net.InetAddress)19 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)19 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)19 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)18 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)18 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)17 List (java.util.List)14 ExecutionException (java.util.concurrent.ExecutionException)14 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)12 Inet6Address (java.net.Inet6Address)11 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)11