use of org.opendaylight.netvirt.bgpmanager.thrift.gen.Routes in project netvirt by opendaylight.
the class BgpRouter method doRibSync.
public Routes doRibSync(BgpSyncHandle handle, af_afi afi) throws TException, BgpRouterException {
if (bgpClient == null) {
throw new BgpRouterException(BgpRouterException.BGP_ERR_NOT_INITED);
}
int state = handle.getState();
if (state != BgpSyncHandle.INITED && state != BgpSyncHandle.ITERATING) {
Routes routes = new Routes();
routes.setErrcode(BgpRouterException.BGP_ERR_NOT_ITER);
return routes;
}
int op = state == BgpSyncHandle.INITED ? GET_RTS_INIT : GET_RTS_NEXT;
handle.setState(BgpSyncHandle.ITERATING);
int winSize = handle.getMaxCount() * handle.getRouteSize();
// TODO: receive correct protocol_type here, currently populating with dummy protocol type
Routes outRoutes = bgpClient.getRoutes(protocol_type.PROTOCOL_ANY, op, winSize, afi);
if (outRoutes.more == 0) {
handle.setState(BgpSyncHandle.DONE);
}
return outRoutes;
}
use of org.opendaylight.netvirt.bgpmanager.thrift.gen.Routes in project netvirt by opendaylight.
the class BgpConfigurationManager method doRouteSync.
private void doRouteSync() {
LOG.error("Starting BGP route sync");
try {
bgpRouter.initRibSync(bgpSyncHandle);
} catch (BgpRouterException e) {
LOG.error("Route sync aborted, exception when initializing", e);
return;
}
while (bgpSyncHandle.getState() != BgpSyncHandle.DONE) {
for (af_afi afi : af_afi.values()) {
Routes routes = null;
try {
routes = bgpRouter.doRibSync(bgpSyncHandle, afi);
} catch (TException | BgpRouterException e) {
LOG.error("Route sync aborted, exception when syncing", e);
return;
}
Iterator<Update> updates = routes.getUpdatesIterator();
while (updates.hasNext()) {
Update update = updates.next();
String rd = update.getRd();
String nexthop = update.getNexthop();
// TODO: decide correct label here
int label = update.getL3label();
int l2label = update.getL2label();
String prefix = update.getPrefix();
int plen = update.getPrefixlen();
// TODO: protocol type will not be available in "update"
// use "rd" to query vrf table and obtain the protocol_type.
// Currently using PROTOCOL_EVPN as default.
onUpdatePushRoute(protocol_type.PROTOCOL_EVPN, rd, prefix, plen, nexthop, update.getMacaddress(), label, l2label, update.getRoutermac(), afi);
}
}
}
try {
LOG.error("Ending BGP route-sync");
bgpRouter.endRibSync(bgpSyncHandle);
} catch (BgpRouterException e) {
// Ignored?
}
}
Aggregations