Search in sources :

Example 1 with RouteDistinguisher

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher in project netvirt by opendaylight.

the class VpnSubnetRouteHandler method addSubnetRouteToFib.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private boolean addSubnetRouteToFib(String rd, String subnetIp, BigInteger nhDpnId, String nextHopIp, String vpnName, Long elanTag, long label, long l3vni, Uuid subnetId, boolean isBgpVpn, String networkName) {
    Preconditions.checkNotNull(rd, LOGGING_PREFIX + " addSubnetRouteToFib: RouteDistinguisher cannot be null or empty!");
    Preconditions.checkNotNull(subnetIp, LOGGING_PREFIX + " addSubnetRouteToFib: SubnetRouteIp cannot be null or empty!");
    Preconditions.checkNotNull(vpnName, LOGGING_PREFIX + " addSubnetRouteToFib: vpnName cannot be null or empty!");
    Preconditions.checkNotNull(elanTag, LOGGING_PREFIX + " addSubnetRouteToFib: elanTag cannot be null or empty!");
    Preconditions.checkNotNull(label, LOGGING_PREFIX + " addSubnetRouteToFib: label cannot be null or empty!");
    VrfEntry.EncapType encapType = VpnUtil.getEncapType(VpnUtil.isL3VpnOverVxLan(l3vni));
    VpnPopulator vpnPopulator = L3vpnRegistry.getRegisteredPopulator(encapType);
    LOG.info("{} addSubnetRouteToFib: Adding SubnetRoute fib entry for vpnName {}, subnetIP {}, elanTag {}", LOGGING_PREFIX, vpnName, subnetIp, elanTag);
    L3vpnInput input = new L3vpnInput().setRouteOrigin(RouteOrigin.CONNECTED).setRd(rd).setVpnName(vpnName).setSubnetIp(subnetIp).setNextHopIp(nextHopIp).setL3vni(l3vni).setLabel(label).setElanTag(elanTag).setDpnId(nhDpnId).setEncapType(encapType).setNetworkName(networkName).setPrimaryRd(rd);
    if (!isBgpVpn) {
        vpnPopulator.populateFib(input, null);
        return true;
    }
    Preconditions.checkNotNull(nextHopIp, LOGGING_PREFIX + "NextHopIp cannot be null or empty!");
    VpnUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, VpnUtil.getPrefixToInterfaceIdentifier(VpnUtil.getVpnId(dataBroker, vpnName), subnetIp), VpnUtil.getPrefixToInterface(nhDpnId, subnetId.getValue(), subnetIp, subnetId, Prefixes.PrefixCue.SubnetRoute));
    vpnPopulator.populateFib(input, null);
    try {
        // BGP manager will handle withdraw and advertise internally if prefix
        // already exist
        bgpManager.advertisePrefix(rd, null, /*macAddress*/
        subnetIp, Collections.singletonList(nextHopIp), encapType, label, l3vni, 0, /*l2vni*/
        null);
    } catch (Exception e) {
        LOG.error("{} addSubnetRouteToFib: Subnet route not advertised for subnet {} subnetIp {} vpnName {} rd {} " + "with dpnid {}", LOGGING_PREFIX, subnetId.getValue(), subnetIp, vpnName, rd, nhDpnId, e);
        return false;
    }
    return true;
}
Also used : VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VpnPopulator(org.opendaylight.netvirt.vpnmanager.populator.intfc.VpnPopulator) L3vpnInput(org.opendaylight.netvirt.vpnmanager.populator.input.L3vpnInput)

Example 2 with RouteDistinguisher

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher in project bgpcep by opendaylight.

the class RouteDistinguisherUtilTest method testAs2BLongRouteDistinguisher.

@Test
public void testAs2BLongRouteDistinguisher() {
    final RouteDistinguisher expected = createRouteDistinguisher(0, ADMIN, ASSIGNED_NUMBER_BIG);
    final RouteDistinguisher parsed = RouteDistinguisherUtil.parseRouteDistinguisher(Unpooled.copiedBuffer(AS_2B_BYTES_BIG));
    assertEquals(expected.getRdTwoOctetAs(), parsed.getRdTwoOctetAs());
    final ByteBuf byteAggregator = Unpooled.buffer(AS_2B_BYTES_BIG.length);
    RouteDistinguisherUtil.serializeRouteDistinquisher(expected, byteAggregator);
    assertArrayEquals(AS_2B_BYTES_BIG, byteAggregator.array());
    assertEquals("0" + SEPARATOR + ADMIN + SEPARATOR + ASSIGNED_NUMBER_BIG, parsed.getRdTwoOctetAs().getValue());
}
Also used : RouteDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 3 with RouteDistinguisher

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher in project bgpcep by opendaylight.

the class RouteDistinguisherUtilTest method testAs4BRouteDistinguisher.

@Test
public void testAs4BRouteDistinguisher() {
    final RouteDistinguisher expected = createRouteDistinguisher(2, ADMIN, ASSIGNED_NUMBER);
    final RouteDistinguisher parsed = RouteDistinguisherUtil.parseRouteDistinguisher(Unpooled.copiedBuffer(AS_4B_BYTES));
    assertEquals(expected.getRdAs(), parsed.getRdAs());
    final ByteBuf byteAggregator = Unpooled.buffer(AS_4B_BYTES.length);
    RouteDistinguisherUtil.serializeRouteDistinquisher(expected, byteAggregator);
    assertArrayEquals(AS_4B_BYTES, byteAggregator.array());
    assertEquals(ADMIN + SEPARATOR + ASSIGNED_NUMBER, parsed.getRdAs().getValue());
}
Also used : RouteDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 4 with RouteDistinguisher

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher in project bgpcep by opendaylight.

the class RouteDistinguisherUtilTest method testAs2BRouteDistinguisher.

@Test
public void testAs2BRouteDistinguisher() {
    final RouteDistinguisher expected = createRouteDistinguisher(0, ADMIN, ASSIGNED_NUMBER);
    final RouteDistinguisher parsed = RouteDistinguisherUtil.parseRouteDistinguisher(Unpooled.copiedBuffer(AS_2B_BYTES));
    assertEquals(expected.getRdTwoOctetAs(), parsed.getRdTwoOctetAs());
    final ByteBuf byteAggregator = Unpooled.buffer(AS_2B_BYTES.length);
    RouteDistinguisherUtil.serializeRouteDistinquisher(expected, byteAggregator);
    assertArrayEquals(AS_2B_BYTES, byteAggregator.array());
    assertEquals("0" + SEPARATOR + ADMIN + SEPARATOR + ASSIGNED_NUMBER, parsed.getRdTwoOctetAs().getValue());
}
Also used : RouteDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 5 with RouteDistinguisher

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher in project bgpcep by opendaylight.

the class RouteDistinguisherUtilTest method testParseRouteDistinguisher.

@Test
public void testParseRouteDistinguisher() {
    final RouteDistinguisher expected = RouteDistinguisherUtil.parseRouteDistinguisher(ADMIN + SEPARATOR + ASSIGNED_NUMBER);
    final RouteDistinguisher parsed = RouteDistinguisherUtil.parseRouteDistinguisher(Unpooled.copiedBuffer(AS_4B_BYTES));
    assertEquals(expected.getRdAs(), parsed.getRdAs());
    final RouteDistinguisher expectedRD = RouteDistinguisherUtil.parseRouteDistinguisher(expected);
    assertEquals(expectedRD.getRdAs(), parsed.getRdAs());
    final RouteDistinguisher expectedObj = RouteDistinguisherUtil.parseRouteDistinguisher((Object) (ADMIN + SEPARATOR + ASSIGNED_NUMBER));
    assertEquals(expectedObj.getRdAs(), parsed.getRdAs());
}
Also used : RouteDistinguisher(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher) Test(org.junit.Test)

Aggregations

RouteDistinguisher (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher)25 Test (org.junit.Test)16 ByteBuf (io.netty.buffer.ByteBuf)13 Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec)13 RouteDistinguisherUtil.extractRouteDistinguisher (org.opendaylight.bgp.concepts.RouteDistinguisherUtil.extractRouteDistinguisher)10 ArrayList (java.util.ArrayList)9 MockitoAnnotations (org.mockito.MockitoAnnotations)8 FlowspecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.FlowspecBuilder)8 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)8 FlowspecType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.FlowspecType)6 DestinationFlowspecL3vpnIpv4Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4Builder)6 DestinationFlowspecL3vpnIpv6Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6Builder)6 List (java.util.List)5 FlowspecL3vpnIpv4NlriParser (org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv4.FlowspecL3vpnIpv4NlriParser)4 DestinationFlowspecL3vpnIpv6 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6)4 DestinationFlowspecL3vpnIpv4 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4)3 Attributes1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1Builder)3 Attributes2Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2Builder)3 MpReachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlriBuilder)3 MpUnreachNlriBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlriBuilder)3