Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ linter.configure(
use_repo(linter, "apple_linters")

# Bazel rules for Golang
bazel_dep(name = "rules_go", version = "0.53.0")
bazel_dep(name = "rules_go", version = "0.59.0")
single_version_override(
module_name = "rules_go",
patches = ["//patches:rules_go/import.patch"],
)

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.24.2")
go_sdk.download(version = "1.25.5")
use_repo(go_sdk, "go_toolchains")

register_toolchains("@go_toolchains//:all")
Expand Down
20 changes: 12 additions & 8 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion acceptance/router_benchmark/brload/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func run(cmd *cobra.Command) int {
// Prepare a batch worth of packets.
batchSize := int(8)
allPkts := make([][]byte, batchSize)
for i := 0; i < batchSize; i++ {
for i := range batchSize {
allPkts[i] = make([]byte, len(rawPkt))
copy(allPkts[i], rawPkt)
}
Expand Down
13 changes: 7 additions & 6 deletions control/beaconing/originator.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2019 Anapaya Systems
// Copyright 2025 SCION Association
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -106,7 +107,6 @@ func (o *Originator) originateBeacons(ctx context.Context) {

s := newSummary()
var wg sync.WaitGroup
wg.Add(len(intfs))
for _, intf := range intfs {
b := beaconOriginator{
Originator: o,
Expand All @@ -115,15 +115,14 @@ func (o *Originator) originateBeacons(ctx context.Context) {
summary: s,
peers: peers,
}
go func() {
wg.Go(func() {
defer log.HandlePanic()
defer wg.Done()

if err := b.originateBeacon(ctx); err != nil {
logger.Info("Unable to originate on interface",
"egress_interface", b.intf.TopoInfo().ID, "err", err)
}
}()
})
}
wg.Wait()
o.logSummary(logger, s)
Expand Down Expand Up @@ -237,8 +236,10 @@ type originatorLabels struct {
}

func (l originatorLabels) Expand() []string {
return []string{"egress_interface", strconv.Itoa(int(l.intf.TopoInfo().ID)),
prom.LabelResult, l.Result}
return []string{
"egress_interface", strconv.Itoa(int(l.intf.TopoInfo().ID)),
prom.LabelResult, l.Result,
}
}

func (l originatorLabels) WithResult(result string) originatorLabels {
Expand Down
13 changes: 5 additions & 8 deletions control/beaconing/propagator.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2019 Anapaya Systems
// Copyright 2025 SCION Association
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -110,10 +111,8 @@ func (p *Propagator) run(ctx context.Context) error {
if len(beacons) == 0 {
continue
}
wg.Add(1)
go func() {
wg.Go(func() {
defer log.HandlePanic()
defer wg.Done()
p := propagator{
extender: p.Extender,
senderFactory: p.SenderFactory,
Expand All @@ -130,7 +129,7 @@ func (p *Propagator) run(ctx context.Context) error {
"err", err,
)
}
}()
})
}
wg.Wait()
return nil
Expand Down Expand Up @@ -277,10 +276,8 @@ func (p *propagator) Propagate(ctx context.Context) error {

var wg sync.WaitGroup
for _, b := range p.beacons {
wg.Add(1)
go func() {
wg.Go(func() {
defer log.HandlePanic()
defer wg.Done()

// Collect the ID before the segment is extended such that it
// matches the ID that was logged above in logCandidateBeacons.
Expand Down Expand Up @@ -326,7 +323,7 @@ func (p *propagator) Propagate(ctx context.Context) error {
"err", err,
)
}
}()
})
}
wg.Wait()
if !success {
Expand Down
16 changes: 6 additions & 10 deletions control/beaconing/writer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2019 Anapaya Systems
// Copyright 2025 SCION Association
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -376,11 +377,8 @@ func (r *remoteWriter) startSendSegReg(
reg seg.Meta,
addr net.Addr,
) {

r.wg.Add(1)
go func() {
r.wg.Go(func() {
defer log.HandlePanic()
defer r.wg.Done()

labels := writerLabels{
StartIA: bseg.Segment.FirstIA(),
Expand All @@ -402,7 +400,7 @@ func (r *remoteWriter) startSendSegReg(
labels.WithResult(prom.Success).Expand()...))
logger.Debug("Successfully registered segment", "seg_type", r.writer.Type,
"addr", addr, "seg", bseg.Segment)
}()
})
}

type writerLabels struct {
Expand Down Expand Up @@ -510,19 +508,17 @@ func (w *GroupWriter) Write(
// Run the tasks concurrently and collect the write stats.
allWriteStats := make([]WriteStats, len(tasks))
wg := sync.WaitGroup{}
wg.Add(len(tasks))
for i, task := range tasks {
go func(j int) {
defer wg.Done()
wg.Go(func() {
sum := task.Reg.RegisterSegments(ctx, task.Beacons, peers)
if sum == nil {
return
}
allWriteStats[j] = WriteStats{
allWriteStats[i] = WriteStats{
Count: sum.GetCount(),
StartIAs: sum.GetSrcs(),
}
}(i)
})
}
wg.Wait()
// Extend the write stats with the results from all registrars.
Expand Down
5 changes: 3 additions & 2 deletions control/drkey/arc_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2022 ETH Zurich
// Copyright 2025 SCION Association
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -87,8 +88,8 @@ func TestLevel1ARC(t *testing.T) {
cache, err := cs_drkey.NewLevel1ARC(tc.size)
require.NoError(t, err)

for j := 0; j < 2; j++ {
for i := 0; i < tc.lengthASes; i++ {
for range 2 {
for i := range tc.lengthASes {
cacheKey := cs_drkey.Level1PrefetchInfo{
IA: addr.MustIAFrom(1, addr.AS(i)),
Proto: drkey.Protocol(0),
Expand Down
4 changes: 1 addition & 3 deletions control/drkey/connect/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (f *Fetcher) Level1(
// explicitly keeping track of the path health.
var errList serrors.List
clear(f.errorPaths)
for i := 0; i < f.MaxRetries; i++ {
for i := range f.MaxRetries {
rep, err := f.getLevel1Key(ctx, meta.SrcIA, req)
if errors.Is(err, errNotReachable) {
return drkey.Level1Key{}, serrors.New(
Expand All @@ -100,15 +100,13 @@ func (f *Fetcher) Level1(
return drkey.Level1Key{}, serrors.Wrap(
"reached max retry attempts fetching level1 key",
errList)

}

func (f *Fetcher) getLevel1Key(
ctx context.Context,
srcIA addr.IA,
req *cppb.DRKeyLevel1Request,
) (*cppb.DRKeyLevel1Response, error) {

path, err := f.pathToDst(ctx, srcIA)
if err != nil {
return nil, err
Expand Down
5 changes: 2 additions & 3 deletions control/drkey/grpc/fetcher.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2022 ETH Zurich
// Copyright 2025 SCION Association
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -70,7 +71,7 @@ func (f *Fetcher) Level1(
// explicitly keeping track of the path health.
var errList serrors.List
clear(f.errorPaths)
for i := 0; i < f.MaxRetries; i++ {
for i := range f.MaxRetries {
rep, err := f.getLevel1Key(ctx, meta.SrcIA, req)
if errors.Is(err, errNotReachable) {
return drkey.Level1Key{}, serrors.New(
Expand All @@ -94,15 +95,13 @@ func (f *Fetcher) Level1(
return drkey.Level1Key{}, serrors.Wrap(
"reached max retry attempts fetching level1 key",
errList)

}

func (f *Fetcher) getLevel1Key(
ctx context.Context,
srcIA addr.IA,
req *cppb.DRKeyLevel1Request,
) (*cppb.DRKeyLevel1Response, error) {

path, err := f.pathToDst(ctx, srcIA)
if err != nil {
return nil, err
Expand Down
9 changes: 4 additions & 5 deletions control/drkey/prefetcher.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2022 ETH Zurich
// Copyright 2025 SCION Association
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -50,17 +51,15 @@ func (f *Prefetcher) Name() string {
// Run requests the level 1 keys to other CSs.
func (f *Prefetcher) Run(ctx context.Context) {
logger := log.FromCtx(ctx)
var wg sync.WaitGroup
keysMeta := f.Engine.GetLevel1PrefetchInfo()
logger.Debug("Prefetching level 1 DRKeys", "AS, proto:", keysMeta)
when := time.Now().Add(f.KeyDuration)
var wg sync.WaitGroup
for _, key := range keysMeta {
wg.Add(1)
go func() {
wg.Go(func() {
defer log.HandlePanic()
defer wg.Done()
getLevel1Key(ctx, f.Engine, key.IA, f.LocalIA, key.Proto, when)
}()
})
}
wg.Wait()
}
Expand Down
19 changes: 7 additions & 12 deletions gateway/control/configpublisher.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2020 Anapaya Systems
// Copyright 2025 SCION Association
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,32 +47,26 @@ func (n *ConfigPublisher) Publish(sp SessionPolicies, rp *routing.Policy) {
var wg sync.WaitGroup
if sp != nil {
n.sessionPolicies = sp.Copy()
wg.Add(len(n.sessionPoliciesSubscribers))
for _, c := range n.sessionPoliciesSubscribers {
go func() {
wg.Go(func() {
defer log.HandlePanic()
defer wg.Done()
c <- sp.Copy()
}()
})
}
wg.Add(len(n.remoteIAsSubscribers))
for _, c := range n.remoteIAsSubscribers {
go func() {
wg.Go(func() {
defer log.HandlePanic()
defer wg.Done()
c <- sp.RemoteIAs()
}()
})
}
}
if rp != nil {
n.routingPolicy = rp.Copy()
wg.Add(len(n.routingPoliciesSubscribers))
for _, c := range n.routingPoliciesSubscribers {
go func() {
wg.Go(func() {
defer log.HandlePanic()
defer wg.Done()
c <- rp.Copy()
}()
})
}
}
wg.Wait()
Expand Down
Loading
Loading