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