OpenSDN source code
bgp_config_yaml.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
3  */
4 #include "bgp/bgp_config_yaml.h"
5 
6 #include <boost/assign/list_of.hpp>
7 #include <boost/bind/bind.hpp>
8 #include <yaml-cpp/yaml.h>
9 #include "base/logging.h"
10 #include "base/map_util.h"
11 
12 using namespace std;
13 using boost::assign::map_list_of;
14 using namespace boost::placeholders;
15 
16 // Container of per-instance data.
18 public:
20 
21  explicit YamlInstanceData(const std::string &name) : protocol_(name) {
22  }
24  STLDeleteElements(&neighbors_);
25  }
26 
27  // Transfers the memory ownership of the neighbor config to this object.
28  bool AddNeighbor(BgpNeighborConfig *neighbor) {
29  pair<NeighborMap::iterator, bool> result =
30  neighbors_.insert(make_pair(neighbor->name(), neighbor));
31  bool success = result.second;
32  if (!success) {
33  delete neighbor;
34  }
35  return success;
36  }
37 
38  const NeighborMap &neighbors() const {
39  return neighbors_;
40  }
41 
43  return &neighbors_;
44  }
45 
46  BgpProtocolConfig *GetProtocol() { return &protocol_; }
47 
48 private:
51 };
52 
53 // Configuration data
55 public:
56  typedef map<string, YamlInstanceData *> InstanceDataMap;
57 
59  DefaultConfig();
60  }
61 
62  virtual ~Configuration() {
63  STLDeleteElements(&routing_policies_);
64  STLDeleteElements(&instances_);
65  STLDeleteElements(&config_map_);
66  }
67 
68  bool AddNeighbor(const string &instance, BgpNeighborConfig *neighbor) {
69  YamlInstanceData *config = LocateInstanceData(instance);
70  return config->AddNeighbor(neighbor);
71  }
72 
74  return GetProtocolConfig(BgpConfigManager::kMasterInstance);
75  }
76 
77  BgpProtocolConfig *GetProtocolConfig(const std::string &instance_name) {
78  YamlInstanceData *config = LocateInstanceData(instance_name);
79  return config->GetProtocol();
80  }
81 
83  const YamlInstanceData *config = LocateInstanceData(
85  return config->neighbors();
86  }
87 
89  YamlInstanceData *config = LocateInstanceData(
91  return config->neighbors();
92  }
93 
94  const InstanceMap &GetInstanceMap() const {
95  return instances_;
96  }
98  return &instances_;
99  }
100 
102  return routing_policies_;
103  }
105  return &routing_policies_;
106  }
107 
108 private:
109  BgpInstanceConfig *LocateInstance(const std::string &name) {
110  InstanceMap::iterator loc = instances_.find(name);
111  if (loc != instances_.end()) {
112  return loc->second;
113  }
114  pair<InstanceMap::iterator, bool> result =
115  instances_.insert(
116  make_pair(name, new BgpInstanceConfig(name)));
117  return result.first->second;
118  }
119 
120  BgpRoutingPolicyConfig *LocateRoutingPolicy(const std::string &name) {
121  RoutingPolicyMap::iterator loc = routing_policies_.find(name);
122  if (loc != routing_policies_.end()) {
123  return loc->second;
124  }
125  pair<RoutingPolicyMap::iterator, bool> result =
126  routing_policies_.insert(
127  make_pair(name, new BgpRoutingPolicyConfig(name)));
128  return result.first->second;
129  }
130 
131  YamlInstanceData *LocateInstanceData(const std::string &name) {
132  InstanceDataMap::iterator loc = config_map_.find(name);
133  if (loc != config_map_.end()) {
134  return loc->second;
135  }
136  pair<InstanceDataMap::iterator, bool> result =
137  config_map_.insert(
138  make_pair(name, new YamlInstanceData(name)));
139  return result.first->second;
140  }
141 
142  void DefaultConfig() {
143  BgpProtocolConfig *proto = GetProtocolConfig();
144  proto->set_autonomous_system(
147  LocateInstance(BgpConfigManager::kMasterInstance);
148  }
149 
153 };
154 
155 typedef map<string, BgpNeighborConfig::Type> PeerTypeMap;
156 static PeerTypeMap peertype_map = map_list_of
157  ("ibgp", BgpNeighborConfig::IBGP)
158  ("ebgp", BgpNeighborConfig::EBGP);
159 
160 static BgpNeighborConfig::Type PeerTypeGetValue(const string &value) {
161  PeerTypeMap::const_iterator loc = peertype_map.find(value);
162  if (loc != peertype_map.end()) {
163  return loc->second;
164  }
166 }
167 
169  : BgpConfigManager(server),
170  data_(new Configuration()) {
171 }
172 
174 }
175 
177 }
178 
179 const string &BgpYamlConfigManager::localname() const {
180  static string localname;
181  return localname;
182 }
183 
185 BgpYamlConfigManager::InstanceMapItems(const string &start_name) const {
186  const BgpConfigManager::InstanceMap &map = data_->GetInstanceMap();
187  return make_pair(map.lower_bound(start_name), map.end());
188 }
189 
192  const std::string &policy_name) const {
193  const BgpConfigManager::RoutingPolicyMap map = data_->GetRoutingPolicyMap();
194  return make_pair(map.begin(), map.end());
195 }
196 
198  const std::string &instance_name) const {
199  const BgpConfigManager::NeighborMap map = data_->GetNeighborMap();
200  return make_pair(map.begin(), map.end());
201 }
202 
204  const std::string &instance_name) const {
205  const BgpConfigManager::NeighborMap map = data_->GetNeighborMap();
206  return map.size();
207 }
208 
210  const std::string &name) const {
211  return NULL;
212 }
213 
215  const std::string &instance_name) const {
216  return data_->GetProtocolConfig(instance_name);
217 }
218 
220  const std::string &instance_name, const std::string &name) const {
221  return NULL;
222 }
223 
224 static bool ParseTimers(const YAML::Node &timers, uint32_t *hold_time,
225  string *error_msg) {
226  if (timers["hold-time"]) {
227  uint32_t value;
228  try {
229  value = timers["hold-time"].as<uint32_t>();
230  } catch (...) {
231  *error_msg = "Invalid hold-time value: not an integer";
232  return false;
233  }
234  if (value < 0 || value > BgpYamlConfigManager::kMaxHoldTime) {
235  ostringstream msg;
236  msg << "Invalid hold-time value (out of range): " << value;
237  *error_msg = msg.str();
238  return false;
239  }
240  *hold_time = value;
241  } else {
242  *hold_time = 0;
243  }
244  return true;
245 }
246 
247 /*
248  * Computes the parsed identifier value (in network order).
249  */
250 static bool ParseIdentifier(const YAML::Node &node, uint32_t *valuep,
251  string *error_msg) {
252  string value;
253  try {
254  value = node.as<string>();
255  } catch (...) {
256  *error_msg = "Invalid identifier value: not a string";
257  return false;
258  }
259  boost::system::error_code ec;
260  Ip4Address address = Ip4Address::from_string(value, ec);
261  if (ec) {
262  char *endp;
263  long int id = strtol(value.c_str(), &endp, 10);
264  size_t strlen = endp - value.c_str();
265  if (id == 0 || strlen != value.length()) {
266  *error_msg = "Invalid identifier value: "
267  "not an IP address or integer";
268  return false;
269  }
270  *valuep = htonl(id);
271  } else {
272  *valuep = htonl(address.to_ulong());
273  }
274  return true;
275 }
276 
278  BgpNeighborConfig *neighbor, const YAML::Node &node, string *error_msg) {
279  if (node["peer-as"]) {
280  int value;
281  try {
282  value = node["peer-as"].as<int>();
283  } catch (...) {
284  *error_msg = "Invalid peer-as value: not an integer";
285  return false;
286  }
287  if (value < 0 || value > USHRT_MAX) {
288  ostringstream msg;
289  msg << "Invalid peer-as value (out of range): " << value;
290  *error_msg = msg.str();
291  return false;
292  }
293  neighbor->set_peer_as(value);
294  }
295 
296  if (node["port"]) {
297  int value;
298  try {
299  value = node["port"].as<int>();
300  } catch (...) {
301  *error_msg = "Invalid port value: not an integer";
302  return false;
303  }
304  if (value < 0 || value > USHRT_MAX) {
305  ostringstream msg;
306  msg << "Invalid port value (out of range): " << value;
307  *error_msg = msg.str();
308  return false;
309  }
310  neighbor->set_port(value);
311  }
312 
313  if (node["peer-type"]) {
314  string value;
315  try {
316  value = node["peer-type"].as<string>();
317  } catch (...) {
318  *error_msg = "Invalid peer-type value: not a string";
319  return false;
320  }
323  ostringstream msg;
324  msg << "Invalid peer-type value: " << value;
325  *error_msg = msg.str();
326  return false;
327  }
328  neighbor->set_peer_type(type);
329  }
330 
331  if (node["identifier"]) {
332  uint32_t value;
333  if (!ParseIdentifier(node["identifier"], &value, error_msg)) {
334  return false;
335  }
336  neighbor->set_peer_identifier(value);
337  }
338 
339  if (node["local-identifier"]) {
340  uint32_t value;
341  if (!ParseIdentifier(node["local-identifier"], &value, error_msg)) {
342  return false;
343  }
344  neighbor->set_local_identifier(value);
345  }
346 
347  if (node["local-address"]) {
348  string value;
349  try {
350  value = node["local-address"].as<string>();
351  } catch (...) {
352  *error_msg = "Invalid local-address value: not a string";
353  return false;
354  }
355  boost::system::error_code ec;
356  IpAddress address = IpAddress::from_string(value, ec);
357  if (ec) {
358  ostringstream ss;
359  ss << "Invalid local-address value: " << value;
360  *error_msg = ss.str();
361  return false;
362  }
363  LOG(DEBUG, "local-address " << address.to_string() << " not used");
364  // TODO: store local address and select bind address for peer.
365  }
366 
367  if (node["timers"]) {
368  uint32_t hold_time;
369  if (!ParseTimers(node["timers"], &hold_time, error_msg)) {
370  return false;
371  }
372  if (hold_time) {
373  neighbor->set_hold_time(hold_time);
374  }
375  }
376 
377  if (node["address-families"]) {
378  YAML::Node families = node["address-families"];
380  for (YAML::const_iterator iter = families.begin();
381  iter != families.end(); ++iter) {
382  string family;
383  try {
384  family = iter->as<string>();
385  } catch (...) {
386  *error_msg = "Invalid address family value: not a string";
387  return false;
388  }
390  *error_msg = "Invalid address family value: " + family;
391  return false;
392  }
393  BgpFamilyAttributesConfig family_config(family);
394  list.push_back(family_config);
395  }
396  neighbor->set_family_attributes_list(list);
397  }
398  return true;
399 }
400 
401 static bool ParseBgpNeighbor(
402  BgpNeighborConfig *neighbor, const YAML::Node &node, string *error_msg) {
403  return ParseBgpGroupNeighborCommon(neighbor, node, error_msg);
404 }
405 
407  const BgpNeighborConfig *tmpl,
408  const YAML::Node &node, string *error_msg) {
409  if (!node.IsMap()) {
410  *error_msg = "Expected mapping under bgp:neighbors";
411  return false;
412  }
413  for (YAML::const_iterator iter = node.begin();
414  iter != node.end(); ++iter) {
415  string address;
416  try {
417  address = iter->first.as<string>();
418  } catch (...) {
419  *error_msg = "Invalid neighbor key: not a string";
420  return false;
421  }
422  boost::system::error_code ec;
423  IpAddress ipaddress = IpAddress::from_string(address, ec);
424  if (ec) {
425  *error_msg = "Invalid address: " + address;
426  return false;
427  }
428  LOG(DEBUG, "neighbor: " << address);
429  unique_ptr<BgpNeighborConfig> neighbor(new BgpNeighborConfig());
430  neighbor->CopyValues(*tmpl);
431  neighbor->set_name(address);
432  neighbor->set_peer_address(ipaddress);
433  if (!ParseBgpNeighbor(neighbor.get(), iter->second, error_msg)) {
434  return false;
435  }
437  neighbor.release())) {
438  *error_msg = "Duplicate neighbor " + address;
439  return false;
440  }
441  }
442 
443  return true;
444 }
445 
447  const BgpNeighborConfig *global,
448  const string &group_name,
449  const YAML::Node &node, string *error_msg) {
450  BgpNeighborConfig tmpl;
451  tmpl.CopyValues(*global);
452  tmpl.set_group_name(group_name);
453 
454  if (!ParseBgpGroupNeighborCommon(&tmpl, node, error_msg)) {
455  return false;
456  }
457 
458  YAML::Node neighbors = node["neighbors"];
459  if (neighbors && !ParseBgpNeighbors(data, &tmpl, neighbors, error_msg)) {
460  return false;
461  }
462  return true;
463 }
464 
466  const BgpNeighborConfig *global,
467  const YAML::Node &node, string *error_msg) {
468  if (!node.IsMap()) {
469  *error_msg = "Expected mapping under bgp:peer-groups";
470  return false;
471  }
472 
473  for (YAML::const_iterator iter = node.begin();
474  iter != node.end(); ++iter) {
475  string group_name;
476  try {
477  group_name = iter->first.as<string>();
478  } catch (...) {
479  *error_msg = "Invalid group key: not a string";
480  return false;
481  }
482  if (!ParseBgpGroup(data, global, group_name, iter->second,
483  error_msg)) {
484  return false;
485  }
486  }
487  return true;
488 }
489 
491  const YAML::Node &node, string *error_msg) {
492  BgpNeighborConfig global;
493  BgpProtocolConfig *config = data->GetProtocolConfig();
494 
495  if (node["autonomous-system"]) {
496  int value;
497  try {
498  value = node["autonomous-system"].as<int>();
499  } catch (...) {
500  *error_msg = "Invalid autonomous-system number: not an integer";
501  return false;
502  }
503  config->set_autonomous_system(value);
504  }
505 
506  if (node["port"]) {
507  int value;
508  try {
509  value = node["port"].as<int>();
510  } catch (...) {
511  *error_msg = "Invalid port number: not an integer";
512  return false;
513  }
514  if (value < 0 || value > USHRT_MAX) {
515  ostringstream msg;
516  msg << "Invalid port value (out of range): " << value;
517  *error_msg = msg.str();
518  return false;
519  }
520  config->set_port(value);
521  }
522 
523  if (node["identifier"]) {
524  uint32_t value;
525  if (!ParseIdentifier(node["identifier"], &value, error_msg)) {
526  return false;
527  }
528  config->set_identifier(value);
529  }
530 
531  YAML::Node timers = node["timers"];
532  if (timers) {
533  int hold_time;
534  if (!ParseTimers(node["timers"], &hold_time, error_msg)) {
535  return false;
536  }
537  if (hold_time) {
538  config->set_hold_time(hold_time);
539  }
540  }
541 
542  YAML::Node groups = node["peer-groups"];
543  if (groups && !ParseBgpGroups(data, &global, groups, error_msg)) {
544  return false;
545  }
546 
547  YAML::Node neighbors = node["neighbors"];
548  if (neighbors && !ParseBgpNeighbors(data, &global, neighbors, error_msg)) {
549  return false;
550  }
551 
552  return true;
553 }
554 
556  string *error_msg) {
557  BgpProtocolConfig *config = candidate->GetProtocolConfig();
558  const NeighborMap &neighbors = candidate->GetNeighborMap();
559  for (NeighborMap::const_iterator iter = neighbors.begin();
560  iter != neighbors.end(); ++iter) {
561  BgpNeighborConfig *neighbor = iter->second;
562  if (neighbor->peer_as() == 0) {
563  if (neighbor->peer_type() == BgpNeighborConfig::IBGP) {
564  neighbor->set_peer_as(config->autonomous_system());
565  } else {
566  ostringstream msg;
567  msg << "Neighbor " << neighbor->name()
568  << " autonomous-system must be set";
569  *error_msg = msg.str();
570  return false;
571  }
572  } else {
573  if (neighbor->peer_type() == BgpNeighborConfig::IBGP) {
574  if (neighbor->peer_as() != config->autonomous_system()) {
575  ostringstream msg;
576  msg << "Neighbor " << neighbor->name()
577  << ": autonomous-system mismatch ("
578  << neighbor->peer_as()
579  << ") for IBGP peer";
580  *error_msg = msg.str();
581  return false;
582  }
583  } else if (neighbor->peer_type() == BgpNeighborConfig::EBGP) {
584  if (neighbor->peer_as() == config->autonomous_system()) {
585  ostringstream msg;
586  msg << "Neighbor " << neighbor->name()
587  << ": EBGP peer configured with local "
588  << "autonomous-system";
589  *error_msg = msg.str();
590  return false;
591  }
592  } else {
593  if (neighbor->peer_as() == config->autonomous_system()) {
595  } else {
597  }
598  }
599  }
600  }
601  return true;
602 }
603 
605  Configuration *current, Configuration *next) {
606  BgpProtocolConfig *curr_proto = current->GetProtocolConfig();
607  BgpProtocolConfig *next_proto = next->GetProtocolConfig();
608  if (curr_proto->CompareTo(*next_proto) == 0) {
609  Notify(next_proto, CFG_CHANGE);
610  }
611 }
612 
613 void BgpYamlConfigManager::AddInstance(InstanceMap::iterator iter) {
614  Notify(iter->second, CFG_ADD);
615 }
616 void BgpYamlConfigManager::DeleteInstance(InstanceMap::iterator iter) {
617  Notify(iter->second, CFG_DELETE);
618 }
619 
620 void BgpYamlConfigManager::UpdateInstance(InstanceMap::iterator iter1,
621  InstanceMap::iterator iter2) {
622  // The instance configuration is always considered to be equal since
623  // the configuration parameters are not settable by the YAML parser (yet).
624  swap(iter1->second, iter2->second);
625 }
626 
628  Configuration *current, Configuration *next) {
630  current->InstanceMapMutable()->begin(),
631  current->InstanceMapMutable()->end(),
632  next->InstanceMapMutable()->begin(),
633  next->InstanceMapMutable()->end(),
634  boost::bind(&BgpYamlConfigManager::AddInstance, this, _1),
635  boost::bind(&BgpYamlConfigManager::DeleteInstance, this, _1),
636  boost::bind(&BgpYamlConfigManager::UpdateInstance, this, _1, _2));
637 }
638 
639 void BgpYamlConfigManager::AddNeighbor(NeighborMap::iterator iter) {
640  Notify(iter->second, CFG_ADD);
641 }
642 void BgpYamlConfigManager::DeleteNeighbor(NeighborMap::iterator iter) {
643  Notify(iter->second, CFG_DELETE);
644 }
645 
646 void BgpYamlConfigManager::UpdateNeighbor(NeighborMap::iterator iter1,
647  NeighborMap::iterator iter2) {
648  if (*iter1->second != *iter2->second) {
649  Notify(iter2->second, CFG_CHANGE);
650  } else {
651  swap(iter1->second, iter2->second);
652  }
653 }
654 
656  Configuration *current, Configuration *next) {
658  current->NeighborMapMutable()->begin(),
659  current->NeighborMapMutable()->end(),
660  next->NeighborMapMutable()->begin(),
661  next->NeighborMapMutable()->end(),
662  boost::bind(&BgpYamlConfigManager::AddNeighbor, this, _1),
663  boost::bind(&BgpYamlConfigManager::DeleteNeighbor, this, _1),
664  boost::bind(&BgpYamlConfigManager::UpdateNeighbor, this, _1, _2));
665 }
666 
668  UpdateProtocol(current, next);
669  UpdateInstances(current, next);
670  UpdateNeighbors(current, next);
671 }
672 
673 bool BgpYamlConfigManager::Parse(istream *stream, string *error_msg) {
674  YAML::Node config;
675  try {
676  config = YAML::Load(*stream);
677  } catch (YAML::Exception &ex) {
678  *error_msg = ex.msg;
679  return false;
680  }
681 
682  YAML::Node bgp = config["bgp"];
683  unique_ptr<Configuration> candidate(new Configuration());
684  if (bgp && !ParseBgp(candidate.get(), bgp, error_msg)) {
685  return false;
686  }
687 
688  if (!Resolve(candidate.get(), error_msg)) {
689  return false;
690  }
691  Update(data_.get(), candidate.get());
692  data_ = candidate;
693 
694  return true;
695 }
boost::asio::ip::address IpAddress
Definition: address.h:13
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
static PeerTypeMap peertype_map
static bool ParseBgpNeighbors(BgpYamlConfigManager::Configuration *data, const BgpNeighborConfig *tmpl, const YAML::Node &node, string *error_msg)
static bool ParseBgpNeighbor(BgpNeighborConfig *neighbor, const YAML::Node &node, string *error_msg)
map< string, BgpNeighborConfig::Type > PeerTypeMap
static bool ParseBgpGroups(BgpYamlConfigManager::Configuration *data, const BgpNeighborConfig *global, const YAML::Node &node, string *error_msg)
static BgpNeighborConfig::Type PeerTypeGetValue(const string &value)
static bool ParseIdentifier(const YAML::Node &node, uint32_t *valuep, string *error_msg)
static bool ParseBgp(BgpYamlConfigManager::Configuration *data, const YAML::Node &node, string *error_msg)
static bool ParseTimers(const YAML::Node &timers, uint32_t *hold_time, string *error_msg)
static bool ParseBgpGroupNeighborCommon(BgpNeighborConfig *neighbor, const YAML::Node &node, string *error_msg)
static bool ParseBgpGroup(BgpYamlConfigManager::Configuration *data, const BgpNeighborConfig *global, const string &group_name, const YAML::Node &node, string *error_msg)
@ UNSPEC
Definition: address.h:25
static Family FamilyFromString(const std::string &family)
Definition: address.cc:54
static const int kDefaultPort
Definition: bgp_config.h:780
std::map< std::string, BgpNeighborConfig * > NeighborMap
Definition: bgp_config.h:773
void Notify(const BgpConfigObject *, EventType)
std::pair< NeighborMap::const_iterator, NeighborMap::const_iterator > NeighborMapRange
Definition: bgp_config.h:775
std::map< std::string, BgpInstanceConfig * > InstanceMap
Definition: bgp_config.h:770
std::map< std::string, BgpRoutingPolicyConfig * > RoutingPolicyMap
Definition: bgp_config.h:767
static const uint32_t kDefaultAutonomousSystem
Definition: bgp_config.h:781
virtual RoutingPolicyMapRange RoutingPolicyMapItems(const std::string &start_policy=std::string()) const =0
static const char * kMasterInstance
Definition: bgp_config.h:778
std::pair< InstanceMap::const_iterator, InstanceMap::const_iterator > InstanceMapRange
Definition: bgp_config.h:772
std::pair< RoutingPolicyMap::const_iterator, RoutingPolicyMap::const_iterator > RoutingPolicyMapRange
Definition: bgp_config.h:769
void set_peer_as(uint32_t peer_as)
Definition: bgp_config.h:199
void set_hold_time(int hold_time)
Definition: bgp_config.h:228
void set_port(uint16_t port)
Definition: bgp_config.h:217
void set_group_name(const std::string &group_name)
Definition: bgp_config.h:174
const std::string & name() const
Definition: bgp_config.h:162
uint32_t peer_as() const
Definition: bgp_config.h:198
std::vector< BgpFamilyAttributesConfig > FamilyAttributesList
Definition: bgp_config.h:142
void set_family_attributes_list(const FamilyAttributesList &family_attributes_list)
Definition: bgp_config.h:257
void set_peer_type(Type type)
Definition: bgp_config.h:179
Type peer_type() const
Definition: bgp_config.h:178
void CopyValues(const BgpNeighborConfig &rhs)
Definition: bgp_config.cc:202
void set_peer_identifier(uint32_t identifier)
Definition: bgp_config.h:206
void set_local_identifier(uint32_t identifier)
Definition: bgp_config.h:237
void set_port(int port)
Definition: bgp_config.h:588
void set_hold_time(uint32_t hold_time)
Definition: bgp_config.h:591
uint32_t autonomous_system() const
Definition: bgp_config.h:575
void set_autonomous_system(uint32_t autonomous_system)
Definition: bgp_config.h:576
void set_identifier(uint32_t identifier)
Definition: bgp_config.h:561
int CompareTo(const BgpProtocolConfig &rhs) const
Definition: bgp_config.cc:321
YamlInstanceData * LocateInstanceData(const std::string &name)
const InstanceMap & GetInstanceMap() const
BgpInstanceConfig * LocateInstance(const std::string &name)
map< string, YamlInstanceData * > InstanceDataMap
bool AddNeighbor(const string &instance, BgpNeighborConfig *neighbor)
BgpConfigManager::InstanceMap instances_
const NeighborMap & GetNeighborMap()
RoutingPolicyMap * RoutingPolicyMapMutable()
BgpProtocolConfig * GetProtocolConfig(const std::string &instance_name)
BgpConfigManager::RoutingPolicyMap routing_policies_
const RoutingPolicyMap & GetRoutingPolicyMap() const
BgpRoutingPolicyConfig * LocateRoutingPolicy(const std::string &name)
BgpProtocolConfig * GetProtocolConfig()
virtual const std::string & localname() const
void UpdateNeighbor(NeighborMap::iterator iter1, NeighborMap::iterator iter2)
void UpdateProtocol(Configuration *current, Configuration *next)
virtual const BgpInstanceConfig * FindInstance(const std::string &name) const
BgpYamlConfigManager(BgpServer *server)
void AddNeighbor(NeighborMap::iterator iter)
bool Parse(std::istream *istream, std::string *error_msg)
virtual const BgpProtocolConfig * GetProtocolConfig(const std::string &instance_name) const
virtual NeighborMapRange NeighborMapItems(const std::string &instance_name) const
virtual int NeighborCount(const std::string &instance_name) const
std::unique_ptr< Configuration > data_
void UpdateInstance(InstanceMap::iterator iter1, InstanceMap::iterator iter2)
static const int kMaxHoldTime
virtual const BgpNeighborConfig * FindNeighbor(const std::string &instance_name, const std::string &name) const
void UpdateNeighbors(Configuration *current, Configuration *next)
void DeleteInstance(InstanceMap::iterator iter)
void DeleteNeighbor(NeighborMap::iterator iter)
void Update(Configuration *current, Configuration *next)
virtual void Terminate()
bool Resolve(Configuration *candidate, std::string *error_msg)
void AddInstance(InstanceMap::iterator iter)
virtual InstanceMapRange InstanceMapItems(const std::string &start_name=std::string()) const
void UpdateInstances(Configuration *current, Configuration *next)
NeighborMap * neighbors()
bool AddNeighbor(BgpNeighborConfig *neighbor)
const NeighborMap & neighbors() const
BgpProtocolConfig protocol_
BgpConfigManager::NeighborMap NeighborMap
YamlInstanceData(const std::string &name)
BgpProtocolConfig * GetProtocol()
NeighborMap neighbors_
uint8_t type
Definition: load_balance.h:2
#define LOG(_Level, _Msg)
Definition: logging.h:34
void map_difference(ForwardIterator __first1, ForwardIterator __last1, ForwardIterator __first2, ForwardIterator __last2, AddFunctor __add_fn, DelFunctor __del_fn, EqFunctor __eq_fn)
Definition: map_util.h:20
void STLDeleteElements(Container *container)
Definition: util.h:114