Skip to content

Commit

Permalink
Merge pull request #1 from netsec-ethz/juagargi/hummingbird_sciond
Browse files Browse the repository at this point in the history
Hummingbird library in scion daemon
  • Loading branch information
juagargi authored Mar 11, 2024
2 parents 9eea093 + 299b738 commit 6c34da3
Show file tree
Hide file tree
Showing 44 changed files with 4,024 additions and 1,216 deletions.
1 change: 1 addition & 0 deletions daemon/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ go_library(
"//pkg/private/prom:go_default_library",
"//pkg/private/serrors:go_default_library",
"//private/env:go_default_library",
"//private/hummingbirddb:go_default_library",
"//private/revcache:go_default_library",
"//private/trust:go_default_library",
"//private/trust/grpc:go_default_library",
Expand Down
14 changes: 14 additions & 0 deletions daemon/cmd/daemon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,24 @@ func realMain(ctx context.Context) error {
})
defer pathDB.Close()
defer revCache.Close()

hbirdDB, err := storage.NewHummingbirdStorage(globalCfg.HbirdDB)
if err != nil {
return serrors.WrapStr("initializing hummingbird storage", err)
}
defer hbirdDB.Close()

cleaner := periodic.Start(pathdb.NewCleaner(pathDB, "sd_segments"),
300*time.Second, 295*time.Second)
defer cleaner.Stop()
rcCleaner := periodic.Start(revcache.NewCleaner(revCache, "sd_revocation"),
10*time.Second, 10*time.Second)
defer rcCleaner.Stop()
defer cleaner.Stop()

// Hummingbird DB has its cleaner started already in the New method. Use that one.
hbirdCleaner := hbirdDB.GetCleaner()
defer hbirdCleaner.Stop()

dialer := &libgrpc.TCPDialer{
SvcResolver: func(dst addr.SVC) []resolver.Address {
Expand Down Expand Up @@ -271,9 +283,11 @@ func realMain(ctx context.Context) error {
Cfg: globalCfg.SD,
},
),

Engine: engine,
RevCache: revCache,
DRKeyClient: drkeyClientEngine,
FlyoverDB: hbirdDB,
},
))

Expand Down
10 changes: 10 additions & 0 deletions daemon/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Config struct {
Tracing env.Tracing `toml:"tracing,omitempty"`
TrustDB storage.DBConfig `toml:"trust_db,omitempty"`
PathDB storage.DBConfig `toml:"path_db,omitempty"`
HbirdDB storage.DBConfig `toml:"hbird_db,omitempty"`
SD SDConfig `toml:"sd,omitempty"`
TrustEngine trustengine.Config `toml:"trustengine,omitempty"`
DRKeyLevel2DB storage.DBConfig `toml:"drkey_level2_db,omitempty"`
Expand All @@ -61,6 +62,7 @@ func (cfg *Config) InitDefaults() {
&cfg.Tracing,
cfg.TrustDB.WithDefault(fmt.Sprintf(storage.DefaultTrustDBPath, "sd")),
cfg.PathDB.WithDefault(fmt.Sprintf(storage.DefaultPathDBPath, "sd")),
cfg.HbirdDB.WithDefault(fmt.Sprintf(storage.DefaultHbirdDBPath, "sd")),
&cfg.SD,
&cfg.TrustEngine,
)
Expand All @@ -75,6 +77,7 @@ func (cfg *Config) Validate() error {
&cfg.API,
&cfg.TrustDB,
&cfg.PathDB,
&cfg.HbirdDB,
&cfg.SD,
&cfg.TrustEngine,
&cfg.DRKeyLevel2DB,
Expand Down Expand Up @@ -103,6 +106,13 @@ func (cfg *Config) Sample(dst io.Writer, path config.Path, _ config.CtxMap) {
),
"path_db",
),
config.OverrideName(
config.FormatData(
&cfg.HbirdDB,
fmt.Sprintf(storage.DefaultHbirdDBPath, "sd"),
),
"hbird_db",
),
&cfg.SD,
&cfg.TrustEngine,
config.OverrideName(
Expand Down
4 changes: 4 additions & 0 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/scionproto/scion/pkg/private/prom"
"github.com/scionproto/scion/pkg/private/serrors"
"github.com/scionproto/scion/private/env"
"github.com/scionproto/scion/private/hummingbirddb"
"github.com/scionproto/scion/private/revcache"
"github.com/scionproto/scion/private/trust"
trustgrpc "github.com/scionproto/scion/private/trust/grpc"
Expand Down Expand Up @@ -114,6 +115,8 @@ type ServerConfig struct {
Engine trust.Engine
Topology servers.Topology
DRKeyClient *drkey.ClientEngine

FlyoverDB hummingbirddb.DB
}

// NewServer constructs a daemon API server.
Expand All @@ -126,6 +129,7 @@ func NewServer(cfg ServerConfig) *servers.DaemonServer {
ASInspector: cfg.Engine.Inspector,
RevCache: cfg.RevCache,
DRKeyClient: cfg.DRKeyClient,
FlyoverDB: cfg.FlyoverDB,
Metrics: servers.Metrics{
PathsRequests: servers.RequestMetrics{
Requests: metrics.NewPromCounterFrom(prometheus.CounterOpts{
Expand Down
25 changes: 24 additions & 1 deletion daemon/internal/servers/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
load("//tools/lint:go.bzl", "go_library")
load("//tools/lint:go.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"grpc.go",
"grpc_hummingbird.go",
"metrics.go",
],
importpath = "github.com/scionproto/scion/daemon/internal/servers",
Expand All @@ -13,6 +14,7 @@ go_library(
"//daemon/fetcher:go_default_library",
"//pkg/addr:go_default_library",
"//pkg/drkey:go_default_library",
"//pkg/hummingbird:go_default_library",
"//pkg/log:go_default_library",
"//pkg/metrics:go_default_library",
"//pkg/private/common:go_default_library",
Expand All @@ -24,6 +26,7 @@ go_library(
"//pkg/proto/daemon:go_default_library",
"//pkg/snet:go_default_library",
"//pkg/snet/path:go_default_library",
"//private/hummingbirddb:go_default_library",
"//private/revcache:go_default_library",
"//private/topology:go_default_library",
"//private/trust:go_default_library",
Expand All @@ -33,3 +36,23 @@ go_library(
"@org_golang_x_sync//singleflight:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = ["grpc_hummingbird_test.go"],
embed = [":go_default_library"],
deps = [
"//pkg/addr:go_default_library",
"//pkg/hummingbird:go_default_library",
"//pkg/private/common:go_default_library",
"//pkg/private/util:go_default_library",
"//pkg/private/xtest:go_default_library",
"//pkg/proto/daemon:go_default_library",
"//pkg/slayers/path:go_default_library",
"//pkg/slayers/path/scion:go_default_library",
"//pkg/snet:go_default_library",
"//pkg/snet/path:go_default_library",
"//private/hummingbirddb:go_default_library",
"@com_github_stretchr_testify//require:go_default_library",
],
)
3 changes: 3 additions & 0 deletions daemon/internal/servers/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
sdpb "github.com/scionproto/scion/pkg/proto/daemon"
"github.com/scionproto/scion/pkg/snet"
snetpath "github.com/scionproto/scion/pkg/snet/path"
"github.com/scionproto/scion/private/hummingbirddb"
"github.com/scionproto/scion/private/revcache"
"github.com/scionproto/scion/private/topology"
"github.com/scionproto/scion/private/trust"
Expand All @@ -61,6 +62,8 @@ type DaemonServer struct {
ASInspector trust.Inspector
DRKeyClient *drkey_daemon.ClientEngine

FlyoverDB hummingbirddb.DB

Metrics Metrics

foregroundPathDedupe singleflight.Group
Expand Down
Loading

0 comments on commit 6c34da3

Please sign in to comment.