use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.AddressFamily in project bgpcep by opendaylight.
the class GracefulCapabilityHandler method serializeTables.
private void serializeTables(final List<Tables> tables, final ByteBuf bytes) {
if (tables == null) {
return;
}
for (final Tables t : tables) {
final Class<? extends AddressFamily> afi = t.getAfi();
final Integer afival = this.afiReg.numberForClass(afi);
Preconditions.checkArgument(afival != null, "Unhandled address family " + afi);
bytes.writeShort(afival);
final Class<? extends SubsequentAddressFamily> safi = t.getSafi();
final Integer safival = this.safiReg.numberForClass(safi);
Preconditions.checkArgument(safival != null, "Unhandled subsequent address family " + safi);
bytes.writeByte(safival);
if (t.getAfiFlags() != null && t.getAfiFlags().isForwardingState()) {
bytes.writeByte(AFI_FLAG_FORWARDING_STATE);
} else {
bytes.writeZero(1);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.AddressFamily in project bgpcep by opendaylight.
the class AbstractTeLspNlriCodec method serializeTeLsp.
public static TeLspCase serializeTeLsp(final ChoiceNode objectType) {
final TeLspCaseBuilder teLsp = new TeLspCaseBuilder();
teLsp.setLspId(new LspId((Long) objectType.getChild(LSP_ID).get().getValue()));
teLsp.setTunnelId(new TunnelId((Integer) objectType.getChild(TUNNEL_ID).get().getValue()));
final ChoiceNode addressFamily = (ChoiceNode) objectType.getChild(ADDRESS_FAMILY).get();
teLsp.setAddressFamily(serializeAddressFamily(addressFamily, addressFamily.getChild(IPV4_TUNNEL_SENDER_ADDRESS).isPresent()));
return teLsp.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.AddressFamily in project netvirt by opendaylight.
the class VpnInstanceListener method addBgpVrfTableForVpn.
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void addBgpVrfTableForVpn(VpnInstance vpnInstance, String vpnName, List<String> vpnInstanceUpdatedRdList, boolean isVpnInstanceRdUpdated) {
String primaryRd = vpnUtil.getPrimaryRd(vpnName);
Collection<VpnTarget> vpnTargetCollection = (vpnInstance.getVpnTargets() != null) ? vpnInstance.getVpnTargets().getVpnTarget().values() : null;
List<VpnTarget> vpnTargetList = new ArrayList<VpnTarget>(vpnTargetCollection != null ? vpnTargetCollection : Collections.emptyList());
List<String> exportRTList = new ArrayList<>();
List<String> importRTList = new ArrayList<>();
if (!vpnTargetList.isEmpty()) {
for (VpnTarget vpnTarget : vpnTargetList) {
if (vpnTarget.getVrfRTType() == VpnTarget.VrfRTType.ExportExtcommunity) {
exportRTList.add(vpnTarget.getVrfRTValue());
}
if (vpnTarget.getVrfRTType() == VpnTarget.VrfRTType.ImportExtcommunity) {
importRTList.add(vpnTarget.getVrfRTValue());
}
if (vpnTarget.getVrfRTType() == VpnTarget.VrfRTType.Both) {
exportRTList.add(vpnTarget.getVrfRTValue());
importRTList.add(vpnTarget.getVrfRTValue());
}
}
}
synchronized (vpnName.intern()) {
List<String> rds = Collections.emptyList();
// Vpn Instance RD Update for ECMP use case
if (isVpnInstanceRdUpdated) {
rds = vpnInstanceUpdatedRdList;
} else {
rds = vpnInstance.getRouteDistinguisher() != null ? new ArrayList<>(vpnInstance.getRouteDistinguisher()) : new ArrayList<>();
}
for (String rd : rds) {
List<String> irtList = rd.equals(primaryRd) ? importRTList : Collections.emptyList();
int ipAddrFamilyConfigured = vpnInstance.getIpAddressFamilyConfigured().getIntValue();
switch(ipAddrFamilyConfigured) {
case 10:
bgpManager.addVrf(rd, irtList, exportRTList, AddressFamily.IPV4);
bgpManager.addVrf(rd, irtList, exportRTList, AddressFamily.IPV6);
LOG.debug("addBgpVrfTableForVpn: ADD BGP VRF table for VPN {} with RD {}, ImportRTList {}, " + "ExportRTList {} for IPv4andIPv6 AddressFamily ", vpnName, rd, irtList, exportRTList);
break;
case 6:
bgpManager.addVrf(rd, irtList, exportRTList, AddressFamily.IPV6);
LOG.debug("addBgpVrfTableForVpn: ADD BGP VRF table for VPN {} with RD {}, ImportRTList {}, " + "ExportRTList {} for IPv6 AddressFamily ", vpnName, rd, irtList, exportRTList);
break;
case 4:
bgpManager.addVrf(rd, irtList, exportRTList, AddressFamily.IPV4);
LOG.debug("addBgpVrfTableForVpn: ADD BGP VRF table for VPN {} with RD {}, ImportRTList {}, " + "ExportRTList {} for IPv4 AddressFamily ", vpnName, rd, irtList, exportRTList);
break;
default:
break;
}
// L2VPN Use case
if (vpnInstance.isL2vpn()) {
bgpManager.addVrf(rd, importRTList, exportRTList, AddressFamily.L2VPN);
LOG.debug("addBgpVrfTableForVpn: ADD BGP VRF table for VPN {} RD {}, ImportRTList {}, " + "ExportRTList {} for L2VPN AddressFamily ", vpnName, rd, irtList, exportRTList);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.AddressFamily in project netvirt by opendaylight.
the class BgpConfigurationManager method replayNbrConfig.
private static boolean replayNbrConfig(List<Neighbors> neighbors, BgpRouter br) {
if (neighbors == null || neighbors.isEmpty()) {
LOG.error("Replaying nbr configuration, received NULL list ");
return true;
}
List<ReplayNbr> replayNbrList = new ArrayList<>();
for (Neighbors nbr : neighbors) {
if (nbr != null) {
replayNbrList.add(new ReplayNbr(nbr, true));
}
}
final int numberOfNbrRetries = 3;
RetryOnException nbrRetry = new RetryOnException(numberOfNbrRetries);
do {
for (ReplayNbr replayNbr : replayNbrList) {
if (!replayNbr.isShouldRetry()) {
continue;
}
boolean replayDone = false;
LOG.debug("Replaying addNbr {}", replayNbr.getNbr().getAddress().getValue());
replayDone = false;
try {
final String md5password = extractMd5Secret(replayNbr.getNbr());
br.addNeighbor(replayNbr.getNbr().getAddress().getValue(), replayNbr.getNbr().getRemoteAs().longValue(), md5password);
replayDone = true;
} catch (TApplicationException tae) {
LOG.debug("Replaying addNbr {}, tapplicationexception: ", replayNbr.getNbr().getAddress().getValue(), tae);
if (tae.getType() == BgpRouterException.BGP_ERR_PEER_EXISTS) {
LOG.debug("Replaying addNbr Neighbor already present");
replayDone = true;
} else {
LOG.error("Replaying addNbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), tae);
}
} catch (TException | BgpRouterException eNbr) {
LOG.debug("Replaying addNbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eNbr);
}
LOG.debug("Replay addNbr {} successful", replayNbr.getNbr().getAddress().getValue());
// Update Source handling
UpdateSource us = replayNbr.getNbr().getUpdateSource();
if (us != null) {
LOG.debug("Replaying updatesource {} to peer {}", us.getSourceIp().getValue(), us.getPeerIp().getValue());
try {
br.addUpdateSource(us.getPeerIp().getValue(), us.getSourceIp().getValue());
} catch (TException | BgpRouterException eUs) {
LOG.debug("Replaying UpdateSource for Nbr {}, exception:", replayNbr.getNbr().getAddress().getValue(), eUs);
}
LOG.debug("Replay updatesource {} successful", us.getSourceIp().getValue());
}
// Ebgp Multihope
EbgpMultihop en = replayNbr.getNbr().getEbgpMultihop();
if (en != null) {
try {
br.addEbgpMultihop(en.getPeerIp().getValue(), en.getNhops().intValue());
} catch (TException | BgpRouterException eEbgpMhop) {
LOG.debug("Replaying EbgpMultihop for Nbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eEbgpMhop);
}
}
// keyAddressFamiliesMap
Map<AddressFamiliesKey, AddressFamilies> keyAddressFamiliesMap = replayNbr.getNbr().getAddressFamilies();
if (keyAddressFamiliesMap != null) {
for (AddressFamilies af : keyAddressFamiliesMap.values()) {
af_afi afi = af_afi.findByValue(af.getAfi().intValue());
af_safi safi = af_safi.findByValue(af.getSafi().intValue());
try {
br.addAddressFamily(af.getPeerIp().getValue(), afi, safi);
} catch (TException | BgpRouterException eAFs) {
LOG.debug("Replaying AddressFamily for Nbr {}, exception:", replayNbr.getNbr().getAddress().getValue(), eAFs);
}
}
}
// replay is success --> no need to replay this nbr in next iteration.
replayNbr.setShouldRetry(replayDone ? false : true);
}
} while (nbrRetry.decrementAndRetry());
boolean replaySuccess = true;
for (ReplayNbr replayNbr : replayNbrList) {
replaySuccess = replaySuccess && !replayNbr.isShouldRetry();
if (replaySuccess == false) {
LOG.error("replayNbrConfig: will be cancelling stale cleanup, cfg nbr: {} Failed:", replayNbr.getNbr().getAddress().getValue());
}
}
return replaySuccess;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.AddressFamily in project bgpcep by opendaylight.
the class LUNlriParser method parseNlri.
@Override
public void parseNlri(final ByteBuf nlri, final MpReachNlriBuilder builder, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
if (!nlri.isReadable()) {
return;
}
final Class<? extends AddressFamily> afi = builder.getAfi();
final boolean multiPathSupported = MultiPathSupportUtil.isTableTypeSupported(constraint, new BgpTableTypeImpl(builder.getAfi(), builder.getSafi()));
final List<CLabeledUnicastDestination> dst = parseNlri(nlri, afi, multiPathSupported);
DestinationType destination = null;
if (afi == Ipv4AddressFamily.class) {
destination = new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(dst).build()).build();
} else if (afi == Ipv6AddressFamily.class) {
destination = new DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(new DestinationIpv6LabeledUnicastBuilder().setCLabeledUnicastDestination(dst).build()).build();
}
builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(destination).build());
}
Aggregations