added routes cache size config to bgplgd

This commit is contained in:
Annika Hannig 2021-09-15 17:28:01 +02:00
parent 09426f3b05
commit 2417c86718
No known key found for this signature in database
GPG Key ID: 62E226E47DDCE58D
5 changed files with 26 additions and 5 deletions

View File

@ -203,6 +203,7 @@ servertime_ext = Mon, 02 Jan 2006 15:04:05 -0700
# Cache results from openbgpd for n seconds, 0 disables the cache.
# cache_ttl = 30
# routes_cache_size = 1024 # Neighbors
# [source.rs0-example-bgplgd]
# name = rs-example.bgplgd

View File

@ -192,4 +192,21 @@ processing_timeout = 300
type = multi_table
peer_table_prefix = T
pipe_protocol_prefix = M
neighbors_refresh_timeout = 2
neighbors_refresh_timeout = 2
[source.rs3-example.openbgpd-state-server]
name = rs-example.openbgpd-state-server
[source.rs3-example.openbgpd-state-server]
api = http://165.22.27.105:29111/api
# Cache results from openbgpd for n seconds, 0 disables the cache.
cache_ttl = 30
routes_cache_size = 1024 # Neighbors
[source.rs4-example-bgplgd]
name = rs-example.bgplgd
[source.rs4-example-bgplgd.openbgpd-bgplgd]
api = http://165.22.27.105:29111/api
cache_ttl = 30
routes_cache_size = 1024 # Neighbors

View File

@ -735,6 +735,7 @@ func getSources(config *ini.File) ([]*SourceConfig, error) {
case SourceBackendOpenBGPDStateServer:
// Get cache TTL and reject communities from the config
cacheTTL := time.Second * time.Duration(backendConfig.Key("cache_ttl").MustInt(0))
routesCacheSize := backendConfig.Key("routes_cache_size").MustInt(1024)
rc, err := getRoutesRejections(config)
if err != nil {
return nil, err
@ -745,6 +746,7 @@ func getSources(config *ini.File) ([]*SourceConfig, error) {
ID: srcCfg.ID,
Name: srcCfg.Name,
CacheTTL: cacheTTL,
RoutesCacheSize: routesCacheSize,
RejectCommunities: rejectComms,
}
backendConfig.MapTo(&c)

View File

@ -38,9 +38,9 @@ func NewBgplgdSource(cfg *Config) *BgplgdSource {
// Initialize caches
nc := caches.NewNeighborsCache(cacheDisabled)
rc := caches.NewRoutesCache(cacheDisabled, 128)
rrc := caches.NewRoutesCache(cacheDisabled, 128)
rfc := caches.NewRoutesCache(cacheDisabled, 128)
rc := caches.NewRoutesCache(cacheDisabled, cfg.RoutesCacheSize)
rrc := caches.NewRoutesCache(cacheDisabled, cfg.RoutesCacheSize)
rfc := caches.NewRoutesCache(cacheDisabled, cfg.RoutesCacheSize)
return &BgplgdSource{
cfg: cfg,

View File

@ -13,7 +13,8 @@ type Config struct {
ID string
Name string
CacheTTL time.Duration
CacheTTL time.Duration
RoutesCacheSize int
API string `ini:"api"`