LCOV - code coverage report
Current view: top level - vnsw/agent/controller - controller_export.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 270 312 86.5 %
Date: 2026-11-30 02:00:48 Functions: 17 17 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #include <boost/uuid/uuid_io.hpp>
       7             : 
       8             : #include <cmn/agent_cmn.h>
       9             : #include <init/agent_param.h>
      10             : #include <oper/ecmp_load_balance.h>
      11             : #include <oper/route_common.h>
      12             : #include <oper/peer.h>
      13             : #include <oper/nexthop.h>
      14             : #include <oper/peer.h>
      15             : #include <oper/mirror_table.h>
      16             : #include "oper/tunnel_nh.h"
      17             : 
      18             : #include <controller/controller_vrf_export.h>
      19             : #include <controller/controller_init.h>
      20             : #include <controller/controller_export.h>
      21             : #include <controller/controller_peer.h>
      22             : #include <controller/controller_types.h>
      23             : 
      24          72 : RouteExport::State::State() :
      25          72 :     DBState(), exported_(false), ingress_replication_exported_(false),
      26          72 :     multicast_exported_(false),
      27          72 :     force_chg_(false), label_(MplsTable::kInvalidLabel), vn_(), sg_list_(),
      28         144 :     tag_list_(), tunnel_type_(TunnelType::INVALID), path_preference_(),
      29         216 :     destination_(), source_(), ecmp_load_balance_(), isid_(0), tunnel_bmap_(0) {
      30          72 : }
      31             : 
      32         121 : bool RouteExport::State::Changed(const AgentRoute *route, const AgentPath *path) const {
      33         121 :     if (exported_ == false)
      34          38 :         return true;
      35             : 
      36          83 :     if (force_chg_ == true)
      37           0 :         return true;
      38             : 
      39          83 :     if (label_ != path->GetActiveLabel())
      40           2 :         return true;
      41             : 
      42          81 :     if (tunnel_type_ != path->tunnel_type()) {
      43           0 :         return true;
      44             :     };
      45             : 
      46          81 :     if (vn_ != path->dest_vn_name())
      47           0 :         return true;
      48             : 
      49          81 :     if (sg_list_ != path->sg_list())
      50          15 :         return true;
      51             : 
      52          66 :     if (tag_list_ != path->tag_list())
      53           0 :         return true;
      54             : 
      55          66 :     if (communities_ != path->communities())
      56           0 :         return true;
      57             : 
      58          66 :     if (path_preference_ != path->path_preference())
      59          13 :         return true;
      60             : 
      61          53 :     if(ecmp_load_balance_ != path->ecmp_load_balance())
      62           0 :         return true;
      63             : 
      64          53 :     if (etree_leaf_ != path->etree_leaf())
      65           0 :         return true;
      66             : 
      67          53 :     if (tunnel_bmap_ != path->tunnel_bmap())
      68           0 :         return true;
      69             : 
      70          53 :     return false;
      71             : }
      72             : 
      73          68 : void RouteExport::State::Update(const AgentRoute *route, const AgentPath *path) {
      74          68 :     force_chg_ = false;
      75          68 :     label_ = path->GetActiveLabel();
      76          68 :     vn_ = path->dest_vn_name();
      77          68 :     sg_list_ = path->sg_list();
      78          68 :     tag_list_ = path->tag_list();
      79          68 :     communities_ = path->communities();
      80          68 :     tunnel_type_ = path->tunnel_type();
      81          68 :     path_preference_ = path->path_preference();
      82          68 :     ecmp_load_balance_ = path->ecmp_load_balance();
      83          68 :     etree_leaf_ = path->etree_leaf();
      84          68 :     tunnel_bmap_ = path->tunnel_bmap();
      85          68 : }
      86             : 
      87          42 : RouteExport::RouteExport(AgentRouteTable *rt_table):
      88          42 :     rt_table_(rt_table), marked_delete_(false),
      89          42 :     table_delete_ref_(this, rt_table->deleter()) {
      90          84 :     walk_ref_ = rt_table->AllocWalker(
      91             :             boost::bind(&RouteExport::DeleteState, this, _1, _2),
      92          42 :             boost::bind(&RouteExport::Walkdone, _1, _2, this));
      93          42 : }
      94             : 
      95          42 : RouteExport::~RouteExport() {
      96          42 :     if (rt_table_) {
      97          42 :         rt_table_->Unregister(id_);
      98          42 :         rt_table_->ReleaseWalker(walk_ref_);
      99             :     }
     100          42 :     table_delete_ref_.Reset(NULL);
     101          42 : }
     102             : 
     103          42 : void RouteExport::ManagedDelete() {
     104          42 :     marked_delete_ = true;
     105          42 : }
     106             : 
     107             : // Route entry add/change/del notification handler
     108         484 : void RouteExport::Notify(const Agent *agent,
     109             :                          AgentXmppChannel *bgp_xmpp_peer,
     110             :                          bool associate,
     111             :                          Agent::RouteTableType type,
     112             :                          DBTablePartBase *partition,
     113             :                          DBEntryBase *e) {
     114         484 :     AgentRoute *route = static_cast<AgentRoute *>(e);
     115             : 
     116             :     // Primitive checks for non-delete notification
     117         484 :     if (!route->IsDeleted()) {
     118             :         // If there is no active BGP peer attached to channel, ignore
     119             :         // non-delete notification for this channel
     120         366 :         if (!AgentXmppChannel::IsBgpPeerActive(agent, bgp_xmpp_peer))
     121           0 :             return;
     122             : 
     123         366 :         if (route->GetActivePath()->inactive())
     124           0 :             return;
     125             : 
     126             :         // Extract the listener ID of active BGP peer for route table to which
     127             :         // this route entry belongs to. Listeners of route table can be active
     128             :         // bgp peers as well as decommisioned BGP peers(if they exist). Active
     129             :         // and decommisoned BGP peer can co-exist till cleanup timer is fired.
     130             :         // During this interval ignore notification for decommisioned bgp peer
     131             :         // listener id
     132         366 :         VrfEntry *vrf = route->vrf();
     133             :         BgpPeer *bgp_peer = static_cast<BgpPeer *>(bgp_xmpp_peer->
     134         366 :                                                    bgp_peer_id());
     135         366 :         DBTableBase::ListenerId vrf_id = bgp_peer->GetVrfExportListenerId();
     136             :         VrfExport::State *vs =
     137         366 :             static_cast<VrfExport::State *>(vrf->GetState(vrf->get_table(),
     138             :                                                           vrf_id));
     139             :         // If VRF state is not present then listener has not been added.
     140             :         // Addition of listener later will result in walk to notify all routes.
     141             :         // That in turn will add state as well by calling current routine.
     142             :         // Therefore return when empty VRF state is found.
     143         366 :         if (!vs)
     144           0 :             return;
     145             : 
     146             :         //Make sure that vrf has been subscribed before route is published.
     147         366 :         if (vs->IsExportable(bgp_xmpp_peer->sequence_number()))
     148           0 :             return;
     149             : 
     150             :         // There may be instances when decommisioned peer is not yet
     151             :         // unregistered while a new peer is already present. So there will be
     152             :         // two notifications. If its for decommisioned peer then ignore the same
     153             :         // by checking the listener id with active bgp peer listener id.
     154         366 :         DBTableBase::ListenerId id = vs->rt_export_[route->GetTableType()]->
     155         366 :             GetListenerId();
     156         366 :         if (id != id_)
     157           0 :             return;
     158             :     }
     159             : 
     160             :     //If channel is no more active, ignore any updates.
     161             :     //It may happen that notify is enqueued before channel is removed.
     162         484 :     if (!AgentXmppChannel::IsBgpPeerActive(agent, bgp_xmpp_peer))
     163           0 :         return;
     164             : 
     165         484 :     if (route->is_multicast()) {
     166          54 :         MulticastNotify(bgp_xmpp_peer, associate, partition, e);
     167             :     } else {
     168         430 :         UnicastNotify(bgp_xmpp_peer, partition, e, type);
     169             :     }
     170             : }
     171             : 
     172         430 : void RouteExport::UnicastNotify(AgentXmppChannel *bgp_xmpp_peer,
     173             :                                 DBTablePartBase *partition, DBEntryBase *e,
     174             :                                 Agent::RouteTableType type) {
     175         430 :     AgentRoute *route = static_cast<AgentRoute *>(e);
     176             :     //TODO Currently BRIDGE notifications are coming because multicast route
     177             :     //are installed in same. Once multicast route is shifted to EVPN table
     178             :     //then there will be no export from Bridge and check below can be removed.
     179         430 :     if (route->GetTableType() == Agent::BRIDGE)
     180         180 :         return;
     181             : 
     182         250 :     if (route->vrf()->ShouldExportRoute() == false) {
     183           0 :         return;
     184             :     }
     185             : 
     186             :     AgentRouteTable *table = static_cast<AgentRouteTable *>
     187         250 :         (partition->parent());
     188         250 :     State *state = static_cast<State *>(route->GetState(partition->parent(),
     189             :                                                         id_));
     190         250 :     AgentPath *path = NULL;
     191         250 :     path = route->FindLocalVmPortPath();
     192             : 
     193         250 :     std::stringstream path_str;
     194         250 :     if (path && path->peer())
     195         121 :         path_str << path->peer()->GetName();
     196             :     else
     197         129 :         path_str << "None";
     198             : 
     199         250 :     if (marked_delete_) {
     200             :         //Ignore route updates on delete marked vrf
     201          15 :         goto done;
     202             :     }
     203             :     // if vrf is fabric vrf and route is not labelled inet route
     204             :     // then don't export the route
     205         121 :     if (path && (route->vrf()->GetName() == table->agent()->fabric_vrf_name())
     206         356 :             && (type != Agent::INET4_MPLS)) {
     207             :         //Dont export vhost IP path to control-node
     208             :         const InetUnicastRouteEntry *inet_rt =
     209           0 :             dynamic_cast<const InetUnicastRouteEntry *>(route);
     210           0 :         if (inet_rt && inet_rt->prefix_address() == table->agent()->router_id()) {
     211           0 :             path = NULL;
     212             :         }
     213             :     }
     214             : 
     215         235 :     if (!state && route->IsDeleted()) {
     216           0 :         goto done;
     217             :     }
     218             : 
     219         235 :     if (state == NULL) {
     220          65 :         state = new State();
     221          65 :         route->SetState(partition->parent(), id_, state);
     222             :     }
     223             : 
     224         235 :     if (path && !path->is_local()) {
     225         121 :         if (state->Changed(route, path)) {
     226          68 :             state->Update(route, path);
     227          68 :             VnListType vn_list;
     228          68 :             vn_list.insert(state->vn_);
     229          68 :             uint32_t label = state->label_;
     230          68 :             if ((route->vrf()->GetName() == table->agent()->fabric_vrf_name()) &&
     231          68 :                     (label != MplsTable::kInvalidLabel )&& (label != MplsTable::kImplicitNullLabel )) {
     232           0 :                 label  = 0;
     233             :             }
     234          68 :             state->exported_ =
     235         136 :                 AgentXmppChannel::ControllerSendRouteAdd(bgp_xmpp_peer,
     236             :                       static_cast<AgentRoute * >(route),
     237             :                       path->NexthopIp(table->agent()), vn_list,
     238             :                       label, path->GetTunnelBmap(),
     239          68 :                       &path->sg_list(), &path->tag_list(), &path->communities(),
     240          68 :                       type, state->path_preference_,
     241          68 :                       state->ecmp_load_balance_,
     242             :                       path->native_vrf_id());
     243          68 :         }
     244             :     } else {
     245         114 :         if (state->exported_ == true) {
     246          38 :             VnListType vn_list;
     247          38 :             vn_list.insert(state->vn_);
     248          38 :             AgentXmppChannel::ControllerSendRouteDelete(bgp_xmpp_peer,
     249             :                     static_cast<AgentRoute *>(route), vn_list,
     250          38 :                     (state->tunnel_type_ == TunnelType::VXLAN ?
     251             :                      state->label_ : 0),
     252             :                     TunnelType::AllType(), NULL, NULL, NULL,
     253          38 :                     type, state->path_preference_);
     254          38 :             state->exported_ = false;
     255          38 :         }
     256             :     }
     257          76 : done:
     258         250 :     if (route->IsDeleted()) {
     259          65 :         if (state) {
     260          64 :             route->ClearState(partition->parent(), id_);
     261          64 :             delete state;
     262             :         }
     263             :     }
     264         250 : }
     265             : 
     266         123 : static const AgentPath *GetMulticastExportablePath(const Agent *agent,
     267             :                                                    const AgentRoute *route) {
     268         123 :     const AgentPath *active_path = route->FindPath(agent->local_vm_peer());
     269             : 
     270             :     //OVS peer path
     271         123 :     if (active_path == NULL) {
     272             :         const EvpnRouteEntry *evpn_route =
     273          31 :             dynamic_cast<const EvpnRouteEntry *>(route);
     274          31 :         active_path = evpn_route ? evpn_route->FindOvsPath() : NULL;
     275             :     }
     276             :     //If no loca peer, then look for tor peer as that should also result
     277             :     //in export of route.
     278         123 :     if (active_path == NULL)
     279          31 :         active_path = route->FindPath(agent->multicast_tor_peer());
     280             :     //Subnet discard
     281         123 :     if (active_path == NULL) {
     282          31 :         const AgentPath *local_path = route->FindPath(agent->local_peer());
     283          31 :         if (local_path && !agent->tor_agent_enabled()) {
     284          24 :             return local_path;
     285             :         }
     286             :     }
     287             : 
     288          99 :     return active_path;
     289             : }
     290             : 
     291          54 : bool RouteExport::MulticastRouteCanDissociate(const AgentRoute *route) {
     292          54 :     bool can_dissociate = route->IsDeleted();
     293          54 :     Agent *agent = static_cast<AgentRouteTable*>(route->get_table())->
     294          54 :         agent();
     295          54 :     const AgentPath *local_path = route->FindPath(agent->local_peer());
     296             : 
     297          54 :     if (route->GetTableType() == Agent::INET4_MULTICAST) {
     298           0 :         const AgentPath *active_path = route->FindPath(agent->local_vm_peer());
     299           0 :         if (!active_path) {
     300           0 :             return true;
     301             :         }
     302           0 :         return can_dissociate;
     303             :     }
     304             : 
     305          54 :     if (local_path && !agent->tor_agent_enabled()) {
     306          25 :         return can_dissociate;
     307             :     }
     308          29 :     if (route->is_multicast()) {
     309          29 :         const AgentPath *active_path = GetMulticastExportablePath(agent, route);
     310          29 :         if (active_path == NULL)
     311           7 :             return true;
     312          22 :         const NextHop *nh = active_path ? active_path->ComputeNextHop(agent) : NULL;
     313          22 :         const CompositeNH *cnh = static_cast<const CompositeNH *>(nh);
     314          22 :         if (cnh && cnh->ComponentNHCount() == 0)
     315           0 :             return true;
     316             :     }
     317          22 :     return can_dissociate;
     318             : }
     319             : 
     320          47 : void RouteExport::SubscribeMulticastRouting(const Agent *agent,
     321             :                                            AgentXmppChannel *bgp_xmpp_peer,
     322             :                                            AgentRoute *route,
     323             :                                            RouteExport::State *state) {
     324          47 :     const AgentPath *active_path = GetMulticastExportablePath(agent, route);
     325             :     //Agent running as tor(simulate_evpn_tor) - dont subscribe
     326             :     //Route has path with peer OVS_PEER i.e. TOR agent mode - dont subscribe
     327             :     //Subscribe condition:
     328             :     //first time subscription or force change
     329          94 :     if (!(agent->simulate_evpn_tor()) &&
     330          94 :         (active_path->peer()->GetType() != Peer::OVS_PEER) &&
     331          47 :         ((state->multicast_exported_ == false) ||
     332          40 :          (state->force_chg_ == true))) {
     333             :         //TODO optimize by checking for force_chg? In other cases duplicate
     334             :         //request can be filtered.
     335           8 :         if (state->multicast_exported_ == true) {
     336             :             //Unsubscribe before re-sending subscription, this makes sure in any
     337             :             //corner case control-node does not see this as a duplicate request.
     338           1 :             AgentXmppChannel::ControllerSendMcastRouteDelete(bgp_xmpp_peer,
     339             :                                                              route);
     340           1 :             state->multicast_exported_ = false;
     341             :         }
     342             :         //Sending 255.255.255.255 for fabric tree
     343           8 :         state->multicast_exported_ =
     344           8 :             AgentXmppChannel::ControllerSendMcastRouteAdd(bgp_xmpp_peer,
     345             :                                                           route);
     346             :     }
     347          47 : }
     348             : 
     349             : // Handles subscription of multicast routes.
     350             : // Following are the kind of subscription:
     351             : // Fabric - For fabric replication tree
     352             : // EVPN Ingress replication - For adding compute node in EVPN replication list.
     353             : // TOR Ingress replication - For adding in TOR replication list (relevant for
     354             : // TSN).
     355             : //
     356             : // For Tor-agent its a route with tunnel NH and there is no subscription.
     357          54 : void RouteExport::MulticastNotify(AgentXmppChannel *bgp_xmpp_peer,
     358             :                                   bool associate,
     359             :                                   DBTablePartBase *partition,
     360             :                                   DBEntryBase *e) {
     361          54 :     Agent *agent = bgp_xmpp_peer->agent();
     362          54 :     AgentRoute *route = static_cast<AgentRoute *>(e);
     363          54 :     State *state = static_cast<State *>(route->GetState(partition->parent(), id_));
     364             : 
     365             :     // Bridge Multicast routes are not sent to control.
     366          54 :     BridgeRouteEntry *l2_route = dynamic_cast<BridgeRouteEntry *>(route);
     367         108 :     if ((route->GetTableType() == Agent::BRIDGE) &&
     368          54 :         (l2_route->prefix_address() != MacAddress::BroadcastMac())) {
     369             : 
     370           0 :         return;
     371             :     }
     372             : 
     373          54 :     bool route_can_be_dissociated = MulticastRouteCanDissociate(route);
     374             : 
     375          54 :     if (marked_delete_ && state) {
     376           1 :         route->ClearState(partition->parent(), id_);
     377           1 :         delete state;
     378           1 :         state = NULL;
     379           1 :         return;
     380             :     }
     381             : 
     382             :     //Handle withdraw for following cases:
     383             :     //- Route is not having any active multicast exportable path or is deleted.
     384             :     //- associate(false): Bgp Peer has gone down and state needs to be removed.
     385          53 :     if (route_can_be_dissociated || !associate) {
     386           6 :         if (state == NULL) {
     387           0 :             return;
     388             :         }
     389             : 
     390           6 :         if (state->multicast_exported_ == true) {
     391           6 :             AgentXmppChannel::ControllerSendMcastRouteDelete(bgp_xmpp_peer,
     392             :                                                              route);
     393           6 :             state->multicast_exported_ = false;
     394             :         }
     395             : 
     396           6 :         if ((state->ingress_replication_exported_ == true)) {
     397           3 :             uint32_t label = state->label_;
     398           3 :             if (route->vrf()->IsPbbVrf()) {
     399           0 :                 label = state->isid_;
     400             :             }
     401           3 :             state->tunnel_type_ = TunnelType::INVALID;
     402           6 :             AgentXmppChannel::ControllerSendEvpnRouteDelete(bgp_xmpp_peer,
     403             :                                                             route,
     404           3 :                                                             state->vn_,
     405             :                                                             label,
     406           3 :                                                             state->destination_,
     407           3 :                                                             state->source_,
     408             :                                                             TunnelType::AllType());
     409           3 :             state->ingress_replication_exported_ = false;
     410             :         }
     411             : 
     412           6 :         route->ClearState(partition->parent(), id_);
     413           6 :         delete state;
     414           6 :         state = NULL;
     415           6 :         return;
     416             :     }
     417             : 
     418          47 :     if (marked_delete_) {
     419             :         //Ignore route updates on delete marked vrf
     420           0 :         return;
     421             :     }
     422             : 
     423          47 :     if (state == NULL) {
     424           7 :         state = new State();
     425           7 :         route->SetState(partition->parent(), id_, state);
     426             :     }
     427             : 
     428             :     // Bridge Broadcast route is sent with 255.255.255.255 address to control.
     429             :     // Inet Multicast route can be because of MVPN or EVPN:
     430             :     //  For EVPN: send route updates for ERMVPN and EVPN.
     431             :     //  For MVPN: send route updates for ERMVPN on native VRF
     432             :     //              and MVPN on ip-fabric VRF.
     433          47 :     if (route->vrf()->ShouldExportRoute()) {
     434          47 :         SubscribeMulticastRouting(agent, bgp_xmpp_peer, route, state);
     435             :     }
     436             : 
     437          47 :     bool ingress_replication = true;
     438          47 :     if ((route->GetTableType() == Agent::INET4_MULTICAST) &&
     439           0 :         (agent->params()->mvpn_ipv4_enable())) {
     440             : 
     441           0 :         ingress_replication = false;
     442             :     }
     443          47 :     if (ingress_replication) {
     444          47 :         SubscribeIngressReplication(agent, bgp_xmpp_peer, route, state);
     445             :     }
     446             : 
     447          47 :     state->force_chg_ = false;
     448          47 :     return;
     449             : }
     450             : 
     451          47 : void RouteExport::SubscribeIngressReplication(Agent *agent,
     452             :                                               AgentXmppChannel *bgp_xmpp_peer,
     453             :                                               AgentRoute *route,
     454             :                                               RouteExport::State *state) {
     455             :     //Check if bridging mode is enabled for this VN by verifying bridge flag
     456             :     //in local peer path.
     457          47 :     bool bridging = false;
     458          47 :     if (route->vrf() && route->vrf()->vn() && route->vrf()->vn()->bridging())
     459          25 :         bridging = true;
     460             : 
     461          47 :     const AgentPath *active_path = GetMulticastExportablePath(agent, route);
     462             :     //Sending ff:ff:ff:ff:ff:ff for evpn replication
     463          47 :     TunnelType::Type old_tunnel_type = state->tunnel_type_;
     464          47 :     uint32_t old_label = state->label_;
     465          47 :     TunnelType::Type new_tunnel_type = active_path->tunnel_type();
     466          47 :     uint32_t new_label = active_path->GetActiveLabel();
     467             : 
     468             :     //Evaluate if ingress replication subscription needs to be withdrawn.
     469             :     //Conditions: Tunnel type changed (VXLAN to MPLS) in turn label change,
     470             :     //bridging is disabled/enabled on VN
     471          47 :     if ((state->ingress_replication_exported_ == true) ||
     472          26 :         (state->force_chg_ == true)) {
     473          21 :         bool withdraw = false;
     474          21 :         uint32_t withdraw_label = 0;
     475             : 
     476          21 :         if (old_tunnel_type == TunnelType::VXLAN) {
     477           8 :             if ((new_tunnel_type != TunnelType::VXLAN) ||
     478             :                 (old_label != new_label)) {
     479           4 :                 withdraw_label = old_label;
     480           4 :                 withdraw = true;
     481             :             }
     482          13 :         } else if (new_tunnel_type == TunnelType::VXLAN) {
     483           3 :             withdraw = true;
     484             :         }
     485             : 
     486          21 :         if (route->vrf()->IsPbbVrf()) {
     487           0 :             if (state->isid_ != active_path->vxlan_id()) {
     488           0 :                 uint32_t old_isid = state->isid_;
     489           0 :                 state->isid_ = active_path->vxlan_id();
     490           0 :                 withdraw_label = old_isid;
     491           0 :                 withdraw = true;
     492             :             } else {
     493           0 :                 state->isid_ = active_path->vxlan_id();
     494             :             }
     495             :         }
     496             : 
     497          21 :         if (bridging == false)
     498           0 :             withdraw = true;
     499             : 
     500          21 :         if (withdraw) {
     501             :             AgentXmppChannel::ControllerSendEvpnRouteDelete
     502           7 :                 (bgp_xmpp_peer, route, state->vn_, withdraw_label,
     503           7 :                  state->destination_, state->source_,
     504           7 :                  state->tunnel_type_);
     505           7 :             state->ingress_replication_exported_ = false;
     506             :         }
     507             :     }
     508             : 
     509          47 :     state->isid_ = active_path->vxlan_id();
     510             :     //Update state values with new values if there is any change.
     511             :     //Also force change same i.e. update.
     512          47 :     if (active_path->tunnel_type() != state->tunnel_type_) {
     513          13 :         state->force_chg_ = true;
     514          13 :         state->tunnel_type_ = active_path->tunnel_type();
     515             :     }
     516             : 
     517          47 :     if (active_path->GetActiveLabel() != state->label_) {
     518          14 :         state->force_chg_ = true;
     519          14 :         state->label_ = active_path->GetActiveLabel();
     520             :     }
     521             : 
     522          47 :     if (route->vrf()->IsPbbVrf()) {
     523           0 :         if (active_path->vxlan_id() == 0) {
     524           0 :             return;
     525             :         }
     526             :     }
     527             : 
     528             :     //Subcribe if:
     529             :     //- Bridging is enabled
     530             :     //- First time (ingress_replication_exported is false)
     531             :     //- Forced Change
     532          47 :     if (bridging &&
     533          25 :         ((state->ingress_replication_exported_ == false) ||
     534          14 :         (state->force_chg_ == true))) {
     535          12 :         state->label_ = active_path->GetActiveLabel();
     536          12 :         state->vn_ = route->dest_vn_name();
     537             :         const TunnelNH *tnh =
     538          12 :             dynamic_cast<const TunnelNH *>(active_path->nexthop());
     539          12 :         if (tnh) {
     540           0 :             state->destination_ = tnh->GetDip()->to_string();
     541           0 :             state->source_ = tnh->GetSip()->to_string();
     542             :         }
     543          12 :         SecurityGroupList sg;
     544          12 :         TagList tag;
     545          12 :         state->ingress_replication_exported_ =
     546             :             AgentXmppChannel::ControllerSendEvpnRouteAdd
     547          12 :             (bgp_xmpp_peer, route,
     548             :              active_path->NexthopIp(agent),
     549          12 :              route->dest_vn_name(), state->label_,
     550             :              TunnelType::GetTunnelBmap(state->tunnel_type_),
     551          12 :              &sg, &tag, NULL, state->destination_,
     552          24 :              state->source_, PathPreference());
     553          12 :     }
     554             : }
     555             : 
     556           1 : bool RouteExport::DeleteState(DBTablePartBase *partition,
     557             :                               DBEntryBase *entry) {
     558             :     State *state = static_cast<State *>
     559           1 :                        (entry->GetState(partition->parent(), id_));
     560           1 :     if (state) {
     561           1 :         entry->ClearState(partition->parent(), id_);
     562           1 :         delete state;
     563             :     }
     564           1 :     return true;
     565             : }
     566             : 
     567          42 : void RouteExport::Walkdone(DBTable::DBTableWalkRef walk_ref,
     568             :                            DBTableBase *partition,
     569             :                            RouteExport *rt_export) {
     570          42 :     delete rt_export;
     571          42 : }
     572             : 
     573          42 : void RouteExport::Unregister() {
     574             :     //Start unregister process
     575          42 :     rt_table_->WalkTable(walk_ref_);
     576          42 : }
     577             : 
     578          42 : RouteExport* RouteExport::Init(AgentRouteTable *table,
     579             :                                AgentXmppChannel *bgp_xmpp_peer) {
     580          42 :     RouteExport *rt_export = new RouteExport(table);
     581          42 :     bool associate = true;
     582          84 :     rt_export->id_ = table->Register(boost::bind(&RouteExport::Notify,
     583             :                                      rt_export, table->agent(), bgp_xmpp_peer,
     584          42 :                                      associate, table->GetTableType(), _1, _2));
     585          42 :     return rt_export;
     586             : }
     587             : 

Generated by: LCOV version 1.14