aboutsummaryrefslogtreecommitdiffstats
path: root/src/VppEndPointManager.cpp
blob: 4be8f700efb890672acb1e88a5262804718f13cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */
/*
 * Copyright (c) 2017-2018 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

#include <opflexagent/Endpoint.h>
#include <opflexagent/EndpointManager.h>
#include <opflexagent/logging.h>

#include <modelgbp/gbp/RoutingModeEnumT.hpp>
#include <modelgbp/l2/EtherTypeEnumT.hpp>

#include <vom/acl_binding.hpp>
#include <vom/acl_ethertype.hpp>
#include <vom/bridge_domain.hpp>
#include <vom/bridge_domain_arp_entry.hpp>
#include <vom/bridge_domain_entry.hpp>
#include <vom/gbp_contract.hpp>
#include <vom/gbp_endpoint.hpp>
#include <vom/gbp_endpoint_group.hpp>
#include <vom/gbp_ext_itf.hpp>
#include <vom/gbp_recirc.hpp>
#include <vom/gbp_subnet.hpp>
#include <vom/l2_binding.hpp>
#include <vom/l3_binding.hpp>
#include <vom/nat_binding.hpp>
#include <vom/nat_static.hpp>
#include <vom/neighbour.hpp>
#include <vom/om.hpp>
#include <vom/route.hpp>
#include <vom/route_domain.hpp>
#include <vom/stat_reader.hpp>
#include <vom/sub_interface.hpp>

#include "VppEndPointGroupManager.hpp"
#include "VppEndPointManager.hpp"
#include "VppLog.hpp"
#include "VppSecurityGroupManager.hpp"
#include "VppUtil.hpp"

using namespace VOM;
using namespace boost;

namespace VPP
{
EndPointManager::EndPointManager(Runtime &runtime)
    : m_runtime(runtime)
{
}

EndPointManager::~EndPointManager()
{
}

std::string
EndPointManager::get_ep_interface_name(const opflexagent::Endpoint &ep) throw(
    NoEpInterfaceException)
{
    const optional<std::string> &epAccessItf = ep.getAccessInterface();
    const optional<std::string> &epItf = ep.getInterfaceName();
    const std::string uuid = ep.getUUID();
    std::string iname;

    /*
     * the goal here is to get the name of the interface to which the VM
     * is attached.
     */
    if (epAccessItf)
        iname = epAccessItf.get();
    else if (epItf)
        iname = epItf.get();
    else
        throw NoEpInterfaceException();

    return iname;
}

std::shared_ptr<interface>
EndPointManager::mk_bd_interface(
    const opflexagent::Endpoint &ep,
    const std::shared_ptr<bridge_domain> bd,
    const std::shared_ptr<route_domain> rd) throw(NoEpInterfaceException)
{
    const optional<std::string> &epAccessItf = ep.getAccessInterface();
    const optional<std::string> &epItf = ep.getInterfaceName();
    const std::string uuid = ep.getUUID();
    std::string iname = get_ep_interface_name(ep);
    std::shared_ptr<interface> itf;

    if (ep.getAccessIfaceVlan())
    {
        uint16_t vlan_id;
        interface intf(iname,
                       getIntfTypeFromName(iname),
                       interface::admin_state_t::UP,
                       uuid);
        OM::write(uuid, intf);

        vlan_id = ep.getAccessIfaceVlan().get();
        sub_interface sub_itf(intf, interface::admin_state_t::UP, *rd, vlan_id);
        OM::write(uuid, sub_itf);
        itf = sub_itf.singular();

        /*
         * EP's interface is in the EPG's BD
         */
        l2_binding l2itf(*itf, *bd);
        if (ep.getAccessIfaceVlan())
        {
            l2itf.set(l2_vtr::option_t::POP_1, vlan_id);
        }

        OM::write(uuid, l2itf);
    }
    else
    {
        interface intf(iname,
                       getIntfTypeFromName(iname),
                       interface::admin_state_t::UP,
                       *rd,
                       uuid);
        OM::write(uuid, intf);
        itf = intf.singular();
    }

    /*
     * If the interface is not created then we cannot do anymore
     */
    if (handle_t::INVALID == itf->handle()) throw NoEpInterfaceException();

    return itf;
}

static void
allow_dhcp_request(ACL::l3_list::rules_t &in_rules,
                   ACL::l3_list::rules_t &out_rules,
                   uint16_t etherType)
{

    ACL::action_t act = ACL::action_t::PERMIT;

    if (etherType == modelgbp::l2::EtherTypeEnumT::CONST_IPV4)
    {
        route::prefix_t pfx = route::prefix_t::ZERO;

        ACL::l3_rule rule(200, act, pfx, pfx);

        rule.set_proto(17);
        rule.set_src_from_port(68);
        rule.set_src_to_port(68);
        rule.set_dst_from_port(67);
        rule.set_dst_to_port(67);

        in_rules.insert(rule);

        ACL::l3_rule out_rule(200, act, pfx, pfx);

        out_rule.set_proto(17);
        out_rule.set_src_from_port(67);
        out_rule.set_src_to_port(67);
        out_rule.set_dst_from_port(68);
        out_rule.set_dst_to_port(68);

        out_rules.insert(out_rule);
    }
    else
    {
        route::prefix_t pfx = route::prefix_t::ZEROv6;

        ACL::l3_rule rule(200, act, pfx, pfx);

        rule.set_proto(17);
        rule.set_src_from_port(546);
        rule.set_src_to_port(546);
        rule.set_dst_from_port(547);
        rule.set_dst_to_port(547);

        in_rules.insert(rule);

        ACL::l3_rule out_rule(200, act, pfx, pfx);

        out_rule.set_proto(17);
        out_rule.set_src_from_port(547);
        out_rule.set_src_to_port(547);
        out_rule.set_dst_from_port(546);
        out_rule.set_dst_to_port(546);

        out_rules.insert(out_rule);
    }
}

static std::vector<asio::ip::address>
get_ep_ips(const opflexagent::Endpoint &ep)
{
    /* check and parse the IP-addresses */
    system::error_code ec;
    std::vector<asio::ip::address> ipAddresses;

    const optional<opflex::modb::MAC> mac = ep.getMAC();

    for (const std::string &ipStr : ep.getIPs())
    {
        asio::ip::address addr = asio::ip::address::from_string(ipStr, ec);
        if (ec)
        {
            LOG(opflexagent::WARNING) << "Invalid endpoint IP: " << ipStr
                                      << ": " << ec.message();
        }
        else
        {
            ipAddresses.push_back(addr);
        }
    }

    if (mac)
    {
        asio::ip::address_v6 linkLocalIp(
            opflexagent::network::construct_link_local_ip_addr(mac.get()));
        if (ep.getIPs().find(linkLocalIp.to_string()) == ep.getIPs().end())
            ipAddresses.push_back(linkLocalIp);
    }

    return ipAddresses;
}

void
EndPointManager::handle_interface_stat_i(const interface &itf)
{
    VLOGD << "Interface Stat: " << itf.to_string();

    opflexagent::EndpointManager &epMgr = m_runtime.agent.getEndpointManager();

    opflexagent::EndpointManager::EpCounters counters;
    std::unordered_set<std::string> endpoints;
    auto &data = itf.get_stats();

    VLOGD << "Stats data: " << data;

    epMgr.getEndpointsByAccessIface(itf.name(), endpoints);

    memset(&counters, 0, sizeof(counters));
    counters.txPackets = data.m_tx.packets;
    counters.rxPackets = data.m_rx.packets;
    counters.txBytes = data.m_tx.bytes;
    counters.rxBytes = data.m_rx.bytes;
    counters.rxUnicast = data.m_rx_unicast.packets;
    counters.txUnicast = data.m_tx_unicast.packets;
    counters.rxBroadcast = data.m_rx_broadcast.packets;
    counters.txBroadcast = data.m_tx_broadcast.packets;
    counters.rxMulticast = data.m_rx_multicast.packets;
    counters.txMulticast = data.m_tx_multicast.packets;
    // counters.txDrop = data.tx_dropped;
    // counters.rxDrop = data.rx_dropped;

    for (const std::string &uuid : endpoints)
    {
        if (counters.rxDrop == std::numeric_limits<uint64_t>::max())
            counters.rxDrop = 0;
        if (counters.txDrop == std::numeric_limits<uint64_t>::max())
            counters.txDrop = 0;
        if (counters.txPackets == std::numeric_limits<uint64_t>::max())
            counters.txPackets = 0;
        if (counters.rxPackets == std::numeric_limits<uint64_t>::max())
            counters.rxPackets = 0;
        if (counters.txBroadcast == std::numeric_limits<uint64_t>::max())
            counters.txBroadcast = 0;
        if (counters.rxBroadcast == std::numeric_limits<uint64_t>::max())
            counters.rxBroadcast = 0;
        if (counters.txMulticast == std::numeric_limits<uint64_t>::max())
            counters.txMulticast = 0;
        if (counters.rxMulticast == std::numeric_limits<uint64_t>::max())
            counters.rxMulticast = 0;
        if (counters.txUnicast == std::numeric_limits<uint64_t>::max())
            counters.txUnicast = 0;
        if (counters.rxUnicast == std::numeric_limits<uint64_t>::max())
            counters.rxUnicast = 0;
        if (counters.rxBytes == std::numeric_limits<uint64_t>::max())
            counters.rxBytes = 0;
        if (counters.txBytes == std::numeric_limits<uint64_t>::max())
            counters.txBytes = 0;
        epMgr.updateEndpointCounters(uuid, counters);
    }
}

void
EndPointManager::handle_interface_stat(const interface &itf)
{
    handle_interface_stat_i(itf);
}

void
EndPointManager::handle_update_i(const std::string &uuid, bool is_external)
{
    /*
     * This is an update to all the state related to this endpoint.
     * At the end of processing we want all the state related to this endpint,
     * that we don't touch here, gone.
     */
    OM::mark_n_sweep ms(uuid);
    system::error_code ec;
    int rv;

    opflexagent::EndpointManager &epMgr = m_runtime.agent.getEndpointManager();
    std::shared_ptr<const opflexagent::Endpoint> epWrapper =
        epMgr.getEndpoint(uuid);

    if (!epWrapper)
    {
        VLOGD << "Deleting endpoint " << uuid;
        return;
    }
    VLOGD << "Updating endpoint " << uuid;

    optional<opflex::modb::URI> epgURI = epMgr.getComputedEPG(uuid);

    if (!epgURI)
    {
        // can't do much without EPG
        VLOGD << "Endpoint - no EPG " << uuid;
        return;
    }

    if (is_external && !epWrapper->isExternal())
    {
        VLOGE << "Endpoint - not external " << uuid;
        return;
    }

    std::shared_ptr<VOM::gbp_endpoint_group> gepg =
        EndPointGroupManager::mk_group(
            m_runtime, uuid, epgURI.get(), is_external);

    if (gepg)
    {
        std::shared_ptr<interface> bvi = gepg->get_bridge_domain()->get_bvi();
        std::shared_ptr<bridge_domain> bd =
            gepg->get_bridge_domain()->get_bridge_domain();
        std::shared_ptr<route_domain> rd =
            gepg->get_route_domain()->get_route_domain();

        /*
         * We want a veth interface - admin up
         */
        std::shared_ptr<interface> itf;
        try
        {
            const opflexagent::Endpoint &ep = *epWrapper.get();

            itf = mk_bd_interface(ep, bd, rd);

            /**
             * We are interested in getting detailed interface stats from VPP
             */
            itf->enable_stats(this);

            /*
             * Apply Security Groups
             */
            const opflexagent::EndpointListener::uri_set_t &secGrps =
                ep.getSecurityGroups();
            const std::string secGrpId = SecurityGroupManager::get_id(secGrps);
            std::hash<std::string> string_hash;
            const std::string secGrpKey = std::to_string(string_hash(secGrpId));

            ACL::l3_list::rules_t in_rules, out_rules;
            ACL::acl_ethertype::ethertype_rules_t ethertype_rules;

            optional<opflexagent::Endpoint::DHCPv4Config> v4c =
                ep.getDHCPv4Config();
            if (v4c)
            {
                ACL::ethertype_rule_t et(ethertype_t::IPV4, direction_t::INPUT);
                ethertype_rules.insert(et);
                ACL::ethertype_rule_t out_et(ethertype_t::IPV4,
                                             direction_t::OUTPUT);
                ethertype_rules.insert(out_et);
                allow_dhcp_request(in_rules,
                                   out_rules,
                                   modelgbp::l2::EtherTypeEnumT::CONST_IPV4);
            }
            optional<opflexagent::Endpoint::DHCPv6Config> v6c =
                ep.getDHCPv6Config();
            if (v6c)
            {
                ACL::ethertype_rule_t et(ethertype_t::IPV6, direction_t::INPUT);
                ethertype_rules.insert(et);
                ACL::ethertype_rule_t out_et(ethertype_t::IPV6,
                                             direction_t::OUTPUT);
                ethertype_rules.insert(out_et);
                allow_dhcp_request(in_rules,
                                   out_rules,
                                   modelgbp::l2::EtherTypeEnumT::CONST_IPV6);
            }

            SecurityGroupManager::build_update(m_runtime.agent,
                                               secGrps,
                                               secGrpId,
                                               in_rules,
                                               out_rules,
                                               ethertype_rules);

            if (!ethertype_rules.empty())
            {
                ACL::acl_ethertype a_e(*itf, ethertype_rules);
                OM::write(uuid, a_e);
            }
            if (!in_rules.empty())
            {
                ACL::l3_list in_acl(secGrpKey + "-in", in_rules);
                OM::write(uuid, in_acl);

                ACL::l3_binding in_binding(direction_t::INPUT, *itf, in_acl);
                OM::write(uuid, in_binding);
            }
            if (!out_rules.empty())
            {
                ACL::l3_list out_acl(secGrpKey + "-out", out_rules);
                OM::write(uuid, out_acl);

                ACL::l3_binding out_binding(direction_t::OUTPUT, *itf, out_acl);
                OM::write(uuid, out_binding);
            }

            uint8_t macAddr[6] = {0};
            bool hasMac = ep.getMAC() != none;

            if (hasMac) ep.getMAC().get().toUIntArray(macAddr);

            /* check and parse the IP-addresses */
            std::vector<asio::ip::address> ipAddresses = get_ep_ips(ep);

            ACL::l2_list::rules_t rules;
            if (itf->handle().value())
            {
                if (ep.isPromiscuousMode())
                {
                    ACL::l2_rule rulev6(50,
                                        ACL::action_t::PERMIT,
                                        route::prefix_t::ZEROv6,
                                        macAddr,
                                        mac_address_t::ZERO);

                    ACL::l2_rule rulev4(51,
                                        ACL::action_t::PERMIT,
                                        route::prefix_t::ZERO,
                                        macAddr,
                                        mac_address_t::ZERO);
                    rules.insert(rulev4);
                    rules.insert(rulev6);
                }
                else if (hasMac)
                {
                    ACL::l2_rule rulev6(20,
                                        ACL::action_t::PERMIT,
                                        route::prefix_t::ZEROv6,
                                        macAddr,
                                        mac_address_t::ONE);

                    ACL::l2_rule rulev4(21,
                                        ACL::action_t::PERMIT,
                                        route::prefix_t::ZERO,
                                        macAddr,
                                        mac_address_t::ONE);
                    rules.insert(rulev4);
                    rules.insert(rulev6);

                    for (auto &ipAddr : ipAddresses)
                    {
                        // Allow IPv4/IPv6 packets from port with EP IP address
                        route::prefix_t pfx(ipAddr, ipAddr.is_v4() ? 32 : 128);
                        if (ipAddr.is_v6())
                        {
                            ACL::l2_rule rule(30,
                                              ACL::action_t::PERMIT,
                                              pfx,
                                              macAddr,
                                              mac_address_t::ONE);
                            rules.insert(rule);
                        }
                        else
                        {
                            ACL::l2_rule rule(31,
                                              ACL::action_t::PERMIT,
                                              pfx,
                                              macAddr,
                                              mac_address_t::ONE);
                            rules.insert(rule);
                        }
                    }
                }

                for (const opflexagent::Endpoint::virt_ip_t &vip :
                     ep.getVirtualIPs())
                {
                    opflexagent::network::cidr_t vip_cidr;
                    if (!opflexagent::network::cidr_from_string(vip.second,
                                                                vip_cidr))
                    {
                        LOG(opflexagent::WARNING)
                            << "Invalid endpoint VIP (CIDR): " << vip.second;
                        continue;
                    }
                    uint8_t vmac[6];
                    vip.first.toUIntArray(vmac);

                    for (auto &ipAddr : ipAddresses)
                    {
                        if (!opflexagent::network::cidr_contains(vip_cidr,
                                                                 ipAddr))
                        {
                            continue;
                        }
                        route::prefix_t pfx(ipAddr, ipAddr.is_v4() ? 32 : 128);
                        if (ipAddr.is_v6())
                        {
                            ACL::l2_rule rule(60,
                                              ACL::action_t::PERMIT,
                                              pfx,
                                              vmac,
                                              mac_address_t::ONE);
                            rules.insert(rule);
                        }
                        else
                        {
                            ACL::l2_rule rule(61,
                                              ACL::action_t::PERMIT,
                                              pfx,
                                              vmac,
                                              mac_address_t::ONE);
                            rules.insert(rule);
                        }
                    }
                }

                ACL::l2_list acl(uuid, rules);
                OM::write(uuid, acl);

                ACL::l2_binding binding(direction_t::INPUT, *itf, acl);
                OM::write(uuid, binding);
            }

            if (hasMac)
            {
                mac_address_t vmac(macAddr);

                /*
                 * add a GDBP endpoint
                 */
                gbp_endpoint gbpe(*itf,
                                  ipAddresses,
                                  vmac,
                                  *gepg,
                                  (is_external ? gbp_endpoint::flags_t::EXTERNAL
                                               : gbp_endpoint::flags_t::NONE));
                OM::write(uuid, gbpe);

                /*
                 * Floating IP addresses -> NAT
                 */
                if (m_runtime.vr &&
                    (modelgbp::gbp::RoutingModeEnumT::CONST_ENABLED ==
                     m_runtime.agent.getPolicyManager().getEffectiveRoutingMode(
                         epgURI.get())))
                {
                    auto ipms = ep.getIPAddressMappings();

                    if (0 != ipms.size())
                    {
                        /*
                         * there are floating IPs, we need a recirulation
                         * interface
                         * for this EP's EPG. These are NAT outside and input
                         * feautre
                         * since packets are sent to these interface in order to
                         * have
                         * the out2in translation applied.
                         */
                        interface recirc_itf("recirc-" +
                                                 std::to_string(gepg->sclass()),
                                             interface::type_t::LOOPBACK,
                                             interface::admin_state_t::UP,
                                             *rd);
                        OM::write(uuid, recirc_itf);

                        l2_binding recirc_l2b(recirc_itf, *bd);
                        OM::write(uuid, recirc_l2b);

                        nat_binding recirc_nb4(recirc_itf,
                                               direction_t::INPUT,
                                               l3_proto_t::IPV4,
                                               nat_binding::zone_t::OUTSIDE);
                        OM::write(uuid, recirc_nb4);

                        nat_binding recirc_nb6(recirc_itf,
                                               direction_t::INPUT,
                                               l3_proto_t::IPV6,
                                               nat_binding::zone_t::OUTSIDE);
                        OM::write(uuid, recirc_nb6);

                        gbp_recirc grecirc(
                            recirc_itf, gbp_recirc::type_t::INTERNAL, *gepg);
                        OM::write(uuid, grecirc);

                        for (auto &ipm : ipms)
                        {
                            if (!ipm.getMappedIP() || !ipm.getEgURI()) continue;

                            asio::ip::address mappedIp =
                                asio::ip::address::from_string(
                                    ipm.getMappedIP().get(), ec);
                            if (ec) continue;

                            asio::ip::address floatingIp;
                            if (ipm.getFloatingIP())
                            {
                                floatingIp = asio::ip::address::from_string(
                                    ipm.getFloatingIP().get(), ec);
                                if (ec) continue;
                                if (floatingIp.is_v4() != mappedIp.is_v4())
                                    continue;
                            }

                            EndPointGroupManager::ForwardInfo ffwd;

                            try
                            {
                                ffwd = EndPointGroupManager::get_fwd_info(
                                    m_runtime, ipm.getEgURI().get());

                                VLOGD << "EP:" << uuid << " - add Floating IP"
                                      << floatingIp << " => " << mappedIp;

                                /*
                                 * Route and Bridge Domains and the external EPG
                                 */
                                route_domain ext_rd(ffwd.rdId);
                                OM::write(uuid, ext_rd);
                                bridge_domain ext_bd(
                                    ffwd.bdId,
                                    bridge_domain::learning_mode_t::OFF);
                                OM::write(uuid, ext_bd);
                                interface ext_bvi("bvi-" +
                                                      std::to_string(ffwd.bdId),
                                                  interface::type_t::BVI,
                                                  interface::admin_state_t::UP,
                                                  ext_rd);
                                OM::write(uuid, ext_bvi);

                                /*
                                 * Route for the floating IP via the internal
                                 * EPG's recirc
                                 */
                                route::prefix_t fp_pfx(floatingIp);
                                route::ip_route fp_route(
                                    ext_rd,
                                    fp_pfx,
                                    {recirc_itf,
                                     fp_pfx.l3_proto().to_nh_proto(),
                                     route::path::flags_t::DVR});
                                OM::write(uuid, fp_route);

                                neighbour fp_ne(ext_bvi, floatingIp, {macAddr});
                                OM::write(uuid, fp_ne);

                                /*
                                 * reply to ARP's for the floating IP
                                 */
                                bridge_domain_arp_entry fp_bae(
                                    ext_bd, floatingIp, {macAddr});
                                OM::write(uuid, fp_bae);

                                /*
                                 * Bridge L2 packets addressed to the VM to the
                                 * recirc
                                 * interface
                                 */
                                bridge_domain_entry fp_be(
                                    ext_bd, macAddr, recirc_itf);
                                OM::write(uuid, fp_be);

                                /*
                                 * NAT static mapping
                                 */
                                nat_static ns(*rd, mappedIp, floatingIp);
                                OM::write(uuid, ns);
                            }
                            catch (EndPointGroupManager::NoFowardInfoException
                                       &nofwd)
                            {
                                VLOGD << "Endpoint Floating IP no fwd: "
                                      << nofwd.reason << " : " << uuid;
                            }
                        }
                    }
                }
            }
        }
        catch (EndPointManager::NoEpInterfaceException &noepitf)
        {
            VLOGD << "Endpoint - no interface " << uuid;
        }

        /*
         * If the EP is external then its EPG's BD interface is an external
         * interface
         */
        if (is_external)
        {
            gbp_ext_itf gei(
                *bvi, *gepg->get_bridge_domain(), *gepg->get_route_domain());
            OM::write(uuid, gei);
        }
    }

    /*
     * That's all folks ... destructor of mark_n_sweep calls the
     * sweep for the stale state
     */
}
void
EndPointManager::handle_update(const std::string &uuid)
{
    handle_update_i(uuid, false);
}
void
EndPointManager::handle_external_update(const std::string &uuid)
{
    handle_update_i(uuid, true);
}

void
EndPointManager::handle_remote_update(const std::string &uuid)
{
    VLOGE << "Endpoint - remote not supported: " << uuid;
}

}; // namespace VPP