Search in sources :

Example 1 with Update

use of org.opendaylight.netvirt.bgpmanager.thrift.gen.Update 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?
    }
}
Also used : TException(org.apache.thrift.TException) BgpRouterException(org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouterException) org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi(org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi) Routes(org.opendaylight.netvirt.bgpmanager.thrift.gen.Routes) Update(org.opendaylight.netvirt.bgpmanager.thrift.gen.Update)

Aggregations

TException (org.apache.thrift.TException)1 BgpRouterException (org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouterException)1 Routes (org.opendaylight.netvirt.bgpmanager.thrift.gen.Routes)1 Update (org.opendaylight.netvirt.bgpmanager.thrift.gen.Update)1 org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi (org.opendaylight.netvirt.bgpmanager.thrift.gen.af_afi)1