use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project bgpcep by opendaylight.
the class BGPSessionImpl method handleMessage.
/**
* Handles incoming message based on their type.
*
* @param msg incoming message
*/
void handleMessage(final Notification msg) {
// synchronize on listener and then on this object to ensure correct order of locking
synchronized (this.listener) {
synchronized (this) {
if (this.state == State.IDLE) {
return;
}
try {
// Update last reception time
this.lastMessageReceivedAt = System.nanoTime();
if (msg instanceof Open) {
// Open messages should not be present here
terminate(new BGPDocumentedException(null, BGPError.FSM_ERROR));
} else if (msg instanceof Notify) {
final Notify notify = (Notify) msg;
// Notifications are handled internally
LOG.info("Session closed because Notification message received: {} / {}, data={}", notify.getErrorCode(), notify.getErrorSubcode(), notify.getData() != null ? ByteBufUtil.hexDump(notify.getData()) : null);
notifyTerminationReasonAndCloseWithoutMessage(notify.getErrorCode(), notify.getErrorSubcode());
} else if (msg instanceof Keepalive) {
// Keepalives are handled internally
LOG.trace("Received KeepAlive message.");
this.kaCounter++;
if (this.kaCounter >= 2) {
this.sync.kaReceived();
}
} else if (msg instanceof RouteRefresh) {
this.listener.onMessage(this, msg);
} else if (msg instanceof Update) {
this.listener.onMessage(this, msg);
this.sync.updReceived((Update) msg);
} else {
LOG.warn("Ignoring unhandled message: {}.", msg.getClass());
}
this.sessionState.messageReceived(msg);
} catch (final BGPDocumentedException e) {
terminate(e);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project bgpcep by opendaylight.
the class BGPSynchronization method updReceived.
/**
* For each received Update message, the upd sync variable needs to be updated to true, for particular AFI/SAFI
* combination. Currently we only assume Unicast SAFI. From the Update message we have to extract the AFI. Each
* Update message can contain BGP Object with one type of AFI. If the object is BGP Link, BGP Node or a BGPPrefix
* the AFI is Linkstate. In case of BGPRoute, the AFI depends on the IP Address of the prefix.
*
* @param msg received Update message
*/
public void updReceived(final Update msg) {
TablesKey type = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
boolean isEOR = false;
if (msg.getNlri() == null && msg.getWithdrawnRoutes() == null) {
final Attributes attrs = msg.getAttributes();
if (attrs != null) {
if (attrs.augmentation(AttributesReach.class) != null) {
final AttributesReach pa = attrs.augmentation(AttributesReach.class);
if (pa.getMpReachNlri() != null) {
type = new TablesKey(pa.getMpReachNlri().getAfi(), pa.getMpReachNlri().getSafi());
}
} else if (attrs.augmentation(AttributesUnreach.class) != null) {
final AttributesUnreach pa = attrs.augmentation(AttributesUnreach.class);
if (pa.getMpUnreachNlri() != null) {
type = new TablesKey(pa.getMpUnreachNlri().getAfi(), pa.getMpUnreachNlri().getSafi());
}
if (pa.getMpUnreachNlri().getWithdrawnRoutes() == null) {
// EOR message contains only MPUnreach attribute and no NLRI
isEOR = true;
}
}
} else {
// true for empty Update Message
isEOR = true;
}
}
syncType(type, isEOR);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project bgpcep by opendaylight.
the class EffectiveRibInWriter method writeRoute.
private void writeRoute(final DOMDataTreeWriteTransaction tx, final RIBSupport<?, ?> ribSupport, final YangInstanceIdentifier routePath, final Optional<NormalizedNode> routeBefore, final NormalizedNode routeAfter, final boolean longLivedStale) {
final TablesKey tablesKey = ribSupport.getTablesKey();
CountersUtil.increment(this.prefixesReceived.get(tablesKey), tablesKey);
// Lookup per-table attributes from RIBSupport
final ContainerNode advertisedAttrs = (ContainerNode) NormalizedNodes.findNode(routeAfter, ribSupport.routeAttributesIdentifier()).orElse(null);
final Attributes routeAttrs = ribSupport.attributeFromContainerNode(advertisedAttrs);
final Optional<Attributes> optEffAtt;
// considered as received with LLGR_STALE from peer which is not true.
if (longLivedStale) {
// LLGR procedures are in effect. If the route is tagged with NO_LLGR, it needs to be removed.
final List<Communities> effCommunities = routeAttrs.getCommunities();
if (effCommunities != null && effCommunities.contains(CommunityUtil.NO_LLGR)) {
deleteRoute(tx, ribSupport, routePath, routeBefore.orElse(null));
return;
}
optEffAtt = Optional.of(wrapLongLivedStale(routeAttrs));
} else {
optEffAtt = ribPolicies.applyImportPolicies(peerImportParameters, routeAttrs, verifyNotNull(tableTypeRegistry.getAfiSafiType(ribSupport.getTablesKey())));
}
if (!optEffAtt.isPresent()) {
deleteRoute(tx, ribSupport, routePath, routeBefore.orElse(null));
return;
}
handleRouteTarget(ModificationType.WRITE, ribSupport, routePath, routeAfter);
tx.put(LogicalDatastoreType.OPERATIONAL, routePath, routeAfter);
CountersUtil.increment(this.prefixesInstalled.get(tablesKey), tablesKey);
final Attributes attToStore = optEffAtt.get();
if (!attToStore.equals(routeAttrs)) {
final YangInstanceIdentifier attPath = routePath.node(ribSupport.routeAttributesIdentifier());
final ContainerNode finalAttribute = ribSupport.attributeToContainerNode(attPath, attToStore);
tx.put(LogicalDatastoreType.OPERATIONAL, attPath, finalAttribute);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project bgpcep by opendaylight.
the class GracefulRestartTest method waitForEORonLocalGracefulRestart.
/**
* Wait with route selection until EOT is received.
*
* @throws Exception on reading Rib failure
*/
@Test
public void waitForEORonLocalGracefulRestart() throws Exception {
performLocalGracefulRestart();
final List<Ipv4Prefix> ipv4prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1));
final List<Ipv6Prefix> ipv6prefixes = Arrays.asList(new Ipv6Prefix(PREFIX3));
insertRoutes(ipv4prefixes, ipv6prefixes);
checkLocRibIpv4Routes(2);
checkLocRibIpv6Routes(0);
insertRoutes(null, null);
checkLocRibIpv4Routes(2);
checkLocRibIpv6Routes(1);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received in project bgpcep by opendaylight.
the class BGPPeerBuilder method createPeer.
static void createPeer(final BGPDispatcher dispatcher, final Arguments arguments, final InetSocketAddress localAddress, final BGPSessionListener sessionListener, final BgpParameters bgpParameters) {
final AsNumber as = arguments.getAs();
final BGPSessionPreferences proposal = new BGPSessionPreferences(as, arguments.getHoldTimer(), new BgpId(localAddress.getAddress().getHostAddress()), as, Collections.singletonList(bgpParameters), Optional.empty());
final BGPPeerRegistry strictBGPPeerRegistry = dispatcher.getBGPPeerRegistry();
if (arguments.getInitiateConnection()) {
for (final InetSocketAddress remoteAddress : arguments.getRemoteAddresses()) {
strictBGPPeerRegistry.addPeer(StrictBGPPeerRegistry.getIpAddress(remoteAddress), sessionListener, proposal);
addFutureListener(localAddress, ((BGPDispatcherImpl) dispatcher).createClient(localAddress, remoteAddress, RETRY_TIMER, true));
}
} else {
for (final InetSocketAddress remoteAddress : arguments.getRemoteAddresses()) {
strictBGPPeerRegistry.addPeer(StrictBGPPeerRegistry.getIpAddress(remoteAddress), sessionListener, proposal);
}
addFutureListener(localAddress, dispatcher.createServer(localAddress));
}
LOG.debug("Listener {} received proposal {}", sessionListener, proposal);
}
Aggregations