OpenSDN source code
bgp_rib_policy.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #ifndef SRC_BGP_BGP_RIB_POLICY_H_
7 #define SRC_BGP_BGP_RIB_POLICY_H_
8 
9 #include "bgp/bgp_proto.h"
10 
11 //
12 // This class represents the export policy for a rib. Given that we do not
13 // currently support any real policy configuration, this is pretty trivial
14 // for now.
15 //
16 // Including the AS number as part of the policy results in creation of a
17 // different RibOut for every neighbor AS that we peer with. This allows a
18 // simplified implementation of the sender side AS path loop check. In most
19 // practical deployment scenarios all eBGP peers will belong to the same
20 // neighbor AS anyway.
21 //
22 // Including AS override as part of the policy results in creation of a
23 // different RibOuts for neighbors that need and don't AS override.
24 //
25 // Including the nexthop as part of the policy results in creation of a
26 // different RibOut for each set of BGPaaS clients that belong to the same
27 // subnet. This allows us to rewrite the nexthop to the specified value.
28 //
29 // Including the CPU affinity as part of the RibExportPolicy allows us to
30 // artificially create more RibOuts than otherwise necessary. This is used
31 // to achieve higher concurrency at the expense of creating more state.
32 //
33 // Including llgr as part of the policy results in the creation of a different
34 // ribout for each set of peers that do (or do not) support long lived
35 // graceful restart functionality. In order to ensure correctness, we need
36 // to not advertise LLGR_STALE community to peers who do not support LLGR.
37 // Instead, we should bring down the local pref to make the paths less
38 // preferable.
39 //
40 // Adding as4_supported so that peers who support 4 byte AS can be grouped
41 // together. For non AS4 neighbors, we need to add AS_TRANS in AS_PATH if
42 // local AS does not fit in 2 bytes.
43 //
45  enum Encoding {
46  BGP,
48  };
49 
52 
53  bool enabled;
54  bool all;
55  bool replace;
57  };
58 
60  explicit RibExportPolicy(uint32_t cluster_id);
62  int affinity, uint32_t cluster_id);
64  as_t as_number, bool as_override, bool llgr, bool as4_supported,
65  int affinity, uint32_t cluster_id, as_t local_as_number = 0);
67  as_t as_number, bool as_override, bool llgr, bool as4_supported,
68  IpAddress nexthop, int affinity, uint32_t cluster_id,
69  std::vector<std::string> &default_tunnel_encap_list,
70  as_t local_as_number = 0);
71  void SetRemovePrivatePolicy(bool all, bool replace, bool peer_loop_check);
72  bool operator<(const RibExportPolicy &rhs) const;
73 
80  int affinity;
81  bool llgr;
83  uint32_t cluster_id;
85  std::vector<std::string> default_tunnel_encap_list;
86 };
87 
88 #endif // SRC_BGP_BGP_RIB_POLICY_H_
boost::asio::ip::address IpAddress
Definition: address.h:14
uint32_t as_t
Definition: bgp_common.h:22
IpAddress nexthop
std::vector< std::string > default_tunnel_encap_list
void SetRemovePrivatePolicy(bool all, bool replace, bool peer_loop_check)
BgpProto::BgpPeerType type
RemovePrivatePolicy remove_private
uint32_t cluster_id
RibExportPolicy(BgpProto::BgpPeerType type, Encoding encoding, as_t as_number, bool as_override, bool llgr, bool as4_supported, IpAddress nexthop, int affinity, uint32_t cluster_id, std::vector< std::string > &default_tunnel_encap_list, as_t local_as_number=0)
bool operator<(const RibExportPolicy &rhs) const