Skip to content

Commit

Permalink
Merge branch 'master' into v6_address_design
Browse files Browse the repository at this point in the history
  • Loading branch information
jiceatscion authored Feb 20, 2025
2 parents e62c498 + 896d790 commit 5a782c0
Show file tree
Hide file tree
Showing 313 changed files with 3,092 additions and 2,604 deletions.
2 changes: 1 addition & 1 deletion .golangcilint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ linters:
- typecheck
- unused
# Extended linters.
- exportloopref
# - copyloopvar
- rowserrcheck
- sqlclosecheck
- unconvert
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ GO_BUILD_TAGS_ARG=$(shell bazel info --ui_event_filters=-stdout,-stderr --announ
lint-go-golangci:
$(info ==> $@)
@if [ -t 1 ]; then tty=true; else tty=false; fi; \
tools/quiet docker run --tty=$$tty --rm -v golangci-lint-modcache:/go -v golangci-lint-buildcache:/root/.cache -v "${PWD}:/src" -w /src golangci/golangci-lint:v1.60.3 golangci-lint run --config=/src/.golangcilint.yml --timeout=3m $(GO_BUILD_TAGS_ARG) --skip-dirs doc ./...
tools/quiet docker run --tty=$$tty --rm -v golangci-lint-modcache:/go -v golangci-lint-buildcache:/root/.cache -v "${PWD}:/src" -w /src golangci/golangci-lint:v1.64.5 golangci-lint run --config=/src/.golangcilint.yml --timeout=3m $(GO_BUILD_TAGS_ARG) --skip-dirs doc ./...

lint-go-semgrep:
$(info ==> $@)
Expand Down
5 changes: 1 addition & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe

go_rules_dependencies()

go_register_toolchains(
nogo = "@//:nogo",
version = "1.22.7",
)
go_register_toolchains(version = "1.24.0")

# Gazelle
http_archive(
Expand Down
6 changes: 3 additions & 3 deletions acceptance/router_benchmark/brload/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ go_library(
"//pkg/scrypto:go_default_library",
"//pkg/slayers:go_default_library",
"//private/keyconf:go_default_library",
"@com_github_google_gopacket//:go_default_library",
"@com_github_google_gopacket//afpacket:go_default_library",
"@com_github_google_gopacket//layers:go_default_library",
"@com_github_gopacket_gopacket//:go_default_library",
"@com_github_gopacket_gopacket//afpacket:go_default_library",
"@com_github_gopacket_gopacket//layers:go_default_library",
"@com_github_spf13_cobra//:go_default_library",
"@org_golang_x_sys//unix:go_default_library",
],
Expand Down
6 changes: 3 additions & 3 deletions acceptance/router_benchmark/brload/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import (
"reflect"
"time"

"github.com/google/gopacket"
"github.com/google/gopacket/afpacket"
"github.com/google/gopacket/layers"
"github.com/gopacket/gopacket"
"github.com/gopacket/gopacket/afpacket"
"github.com/gopacket/gopacket/layers"
"github.com/spf13/cobra"

"github.com/scionproto/scion/acceptance/router_benchmark/cases"
Expand Down
2 changes: 1 addition & 1 deletion acceptance/router_benchmark/brload/mmsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"reflect"
"unsafe"

"github.com/google/gopacket/afpacket"
"github.com/gopacket/gopacket/afpacket"
"golang.org/x/sys/unix"
)

Expand Down
4 changes: 2 additions & 2 deletions acceptance/router_benchmark/cases/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ go_library(
"//pkg/slayers:go_default_library",
"//pkg/slayers/path:go_default_library",
"//pkg/slayers/path/scion:go_default_library",
"@com_github_google_gopacket//:go_default_library",
"@com_github_google_gopacket//layers:go_default_library",
"@com_github_gopacket_gopacket//:go_default_library",
"@com_github_gopacket_gopacket//layers:go_default_library",
"@com_github_mdlayher_arp//:go_default_library",
"@com_github_mdlayher_ethernet//:go_default_library",
],
Expand Down
2 changes: 1 addition & 1 deletion acceptance/router_benchmark/cases/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package cases

import (
"github.com/google/gopacket"
"github.com/gopacket/gopacket"
)

// We make the assumption os protocol sanity: the length and checksum fields are of fixed size
Expand Down
2 changes: 1 addition & 1 deletion acceptance/router_benchmark/cases/topo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strings"
"time"

"github.com/google/gopacket/layers"
"github.com/gopacket/gopacket/layers"
"github.com/mdlayher/arp"
"github.com/mdlayher/ethernet"

Expand Down
4 changes: 2 additions & 2 deletions acceptance/router_benchmark/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
# Those values are valid expectations only when running in the CI environment.
TEST_CASES = {
"in": 700000,
"out": 730000,
"out": 723000,
"in_transit": 700000,
"out_transit": 720000,
"out_transit": 716000,
"br_transit": 720000,
}

Expand Down
1 change: 0 additions & 1 deletion control/beacon/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ go_library(
deps = [
"//pkg/addr:go_default_library",
"//pkg/log:go_default_library",
"//pkg/private/common:go_default_library",
"//pkg/private/ptr:go_default_library",
"//pkg/private/serrors:go_default_library",
"//pkg/proto/control_plane:go_default_library",
Expand Down
9 changes: 0 additions & 9 deletions control/beacon/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,10 @@ import (
"google.golang.org/protobuf/proto"

"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/private/common"
cppb "github.com/scionproto/scion/pkg/proto/control_plane"
seg "github.com/scionproto/scion/pkg/segment"
)

const (
// ErrReadingRows is the error message in case we fail to read more from
// the database.
ErrReadingRows common.ErrMsg = "Failed to read rows"
// ErrParse is the error message in case the parsing a db entry fails.
ErrParse common.ErrMsg = "Failed to parse entry"
)

// InsertStats provides statistics about an insertion.
type InsertStats struct {
Inserted, Updated, Filtered int
Expand Down
2 changes: 1 addition & 1 deletion control/beaconing/extender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"crypto/rand"
"errors"
"hash"
mrand "math/rand"
mrand "math/rand/v2"
"testing"
"time"

Expand Down
6 changes: 3 additions & 3 deletions control/beaconing/propagator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestPropagatorRunNonCore(t *testing.T) {
}
g := graph.NewDefaultGraph(mctrl)
provider.EXPECT().BeaconsToPropagate(gomock.Any()).Times(1).DoAndReturn(
func(_ interface{}) ([]beacon.Beacon, error) {
func(_ any) ([]beacon.Beacon, error) {
res := make([]beacon.Beacon, 0, len(beacons))
for _, desc := range beacons {
res = append(res, testBeacon(g, desc))
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestPropagatorRunCore(t *testing.T) {
}
g := graph.NewDefaultGraph(mctrl)
provider.EXPECT().BeaconsToPropagate(gomock.Any()).Times(2).DoAndReturn(
func(_ interface{}) ([]beacon.Beacon, error) {
func(_ any) ([]beacon.Beacon, error) {
res := make([]beacon.Beacon, 0, len(beacons))
for _, desc := range beacons {
res = append(res, testBeacon(g, desc))
Expand Down Expand Up @@ -248,7 +248,7 @@ func TestPropagatorFastRecovery(t *testing.T) {
// We call run 4 times in this test, since the interface to 1-ff00:0:120
// will never be beaconed on, because the beacons are filtered for loops.
provider.EXPECT().BeaconsToPropagate(gomock.Any()).Times(4).DoAndReturn(
func(_ interface{}) ([]beacon.Beacon, error) {
func(_ any) ([]beacon.Beacon, error) {
return []beacon.Beacon{testBeacon(g, beacons[0])}, nil
},
)
Expand Down
4 changes: 2 additions & 2 deletions control/beaconing/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ type silentLogger struct {
log.Logger
}

func (s silentLogger) Info(msg string, ctx ...interface{}) {
func (s silentLogger) Info(msg string, ctx ...any) {
s.Logger.Debug(msg, ctx...)
}
func (s silentLogger) Error(msg string, ctx ...interface{}) {
func (s silentLogger) Error(msg string, ctx ...any) {
s.Logger.Debug(msg, ctx...)
}
6 changes: 3 additions & 3 deletions control/beaconing/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestRegistrarRun(t *testing.T) {

g := graph.NewDefaultGraph(mctrl)
segProvider.EXPECT().SegmentsToRegister(gomock.Any(), test.segType).DoAndReturn(
func(_, _ interface{}) ([]beacon.Beacon, error) {
func(_, _ any) ([]beacon.Beacon, error) {
res := make([]beacon.Beacon, 0, len(test.beacons))
for _, desc := range test.beacons {
res = append(res, testBeacon(g, desc))
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestRegistrarRun(t *testing.T) {

g := graph.NewDefaultGraph(mctrl)
segProvider.EXPECT().SegmentsToRegister(gomock.Any(), test.segType).DoAndReturn(
func(_, _ interface{}) ([]beacon.Beacon, error) {
func(_, _ any) ([]beacon.Beacon, error) {
res := make([]beacon.Beacon, len(test.beacons))
for _, desc := range test.beacons {
res = append(res, testBeacon(g, desc))
Expand Down Expand Up @@ -313,7 +313,7 @@ func TestRegistrarRun(t *testing.T) {
require.NoError(t, err)
segProvider.EXPECT().SegmentsToRegister(gomock.Any(),
seg.TypeDown).DoAndReturn(
func(_, _ interface{}) (<-chan beacon.Beacon, error) {
func(_, _ any) (<-chan beacon.Beacon, error) {
res := make(chan beacon.Beacon, 1)
b := testBeacon(g, []uint16{graph.If_120_X_111_B})
b.InIfID = 10
Expand Down
1 change: 0 additions & 1 deletion control/drkey/grpc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ go_library(
"//pkg/private/serrors:go_default_library",
"//pkg/proto/control_plane:go_default_library",
"//pkg/proto/drkey:go_default_library",
"//pkg/scrypto/cppki:go_default_library",
"//pkg/snet:go_default_library",
"@org_go4_netipx//:go_default_library",
"@org_golang_google_grpc//credentials:go_default_library",
Expand Down
7 changes: 2 additions & 5 deletions control/drkey/grpc/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/scionproto/scion/pkg/private/serrors"
cppb "github.com/scionproto/scion/pkg/proto/control_plane"
dkpb "github.com/scionproto/scion/pkg/proto/drkey"
"github.com/scionproto/scion/pkg/scrypto/cppki"
)

func secretRequestToMeta(req *cppb.DRKeySecretValueRequest) (drkey.SecretValueMeta, error) {
Expand Down Expand Up @@ -65,10 +64,8 @@ func getLevel1KeyFromReply(
return drkey.Level1Key{}, serrors.Wrap("invalid EpochEnd from response", err)
}
epoch := drkey.Epoch{
Validity: cppki.Validity{
NotBefore: rep.EpochBegin.AsTime(),
NotAfter: rep.EpochEnd.AsTime(),
},
NotBefore: rep.EpochBegin.AsTime(),
NotAfter: rep.EpochEnd.AsTime(),
}
returningKey := drkey.Level1Key{
SrcIA: meta.SrcIA,
Expand Down
4 changes: 2 additions & 2 deletions control/segreq/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package segreq
import (
"context"
"fmt"
"math/rand"
"math/rand/v2"
"net"
"time"

Expand Down Expand Up @@ -196,7 +196,7 @@ func (p *dstProvider) Dst(ctx context.Context, req segfetcher.Request) (net.Addr
if len(paths) == 0 {
return nil, segfetcher.ErrNotReachable
}
path = paths[rand.Intn(len(paths))]
path = paths[rand.IntN(len(paths))]
default:
panic(fmt.Errorf("Unsupported segment type for request forwarding. "+
"Up segment should have been resolved locally. SegType: %s", req.SegType))
Expand Down
4 changes: 2 additions & 2 deletions control/segreq/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package segreq

import (
"context"
"math/rand"
"math/rand/v2"

"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/private/serrors"
Expand Down Expand Up @@ -71,7 +71,7 @@ func (s *SegSelector) SelectSeg(ctx context.Context,
if len(segs) < 1 {
return nil, serrors.New("no segments found")
}
seg := segs[rand.Intn(len(segs))]
seg := segs[rand.IntN(len(segs))]

svcaddr, err := s.Pather.GetPath(addr.SvcCS, seg)
// odd interface, builds address not path. Use GetPath to convert to snet.Path
Expand Down
2 changes: 1 addition & 1 deletion control/trust/grpc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ go_test(
"//pkg/addr:go_default_library",
"//pkg/proto/control_plane:go_default_library",
"//pkg/scrypto/cppki:go_default_library",
"@com_github_golang_protobuf//ptypes:go_default_library_gen",
"@com_github_stretchr_testify//assert:go_default_library",
"@com_github_stretchr_testify//require:go_default_library",
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",
],
)
8 changes: 3 additions & 5 deletions control/trust/grpc/proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"testing"
"time"

"github.com/golang/protobuf/ptypes"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/timestamppb"

trustgrpc "github.com/scionproto/scion/control/trust/grpc"
"github.com/scionproto/scion/pkg/addr"
Expand All @@ -31,10 +31,8 @@ import (

func TestReqToChainQuery(t *testing.T) {
now := time.Now().UTC()
validUntil, err := ptypes.TimestampProto(now)
require.NoError(t, err)
validSince, err := ptypes.TimestampProto(now.Add(-time.Hour))
require.NoError(t, err)
validUntil := timestamppb.New(now)
validSince := timestamppb.New(now.Add(-time.Hour))

req := &cppb.ChainsRequest{
IsdAs: uint64(addr.MustParseIA("1-ff00:0:110")),
Expand Down
3 changes: 1 addition & 2 deletions daemon/drkey/grpc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ go_library(
"//pkg/private/serrors:go_default_library",
"//pkg/proto/control_plane:go_default_library",
"//pkg/proto/drkey:go_default_library",
"//pkg/scrypto/cppki:go_default_library",
"//pkg/snet:go_default_library",
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",
],
Expand All @@ -32,7 +31,7 @@ go_test(
"//pkg/proto/control_plane:go_default_library",
"//pkg/proto/control_plane/mock_control_plane:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_golang_protobuf//ptypes:go_default_library_gen",
"@com_github_stretchr_testify//require:go_default_library",
"@org_golang_google_protobuf//types/known/timestamppb:go_default_library",
],
)
10 changes: 4 additions & 6 deletions daemon/drkey/grpc/fetching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"time"

"github.com/golang/mock/gomock"
"github.com/golang/protobuf/ptypes"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/timestamppb"

sd_drkey "github.com/scionproto/scion/daemon/drkey"
sd_grpc "github.com/scionproto/scion/daemon/drkey/grpc"
Expand All @@ -38,10 +38,8 @@ func TestGetHostHost(t *testing.T) {
defer ctrl.Finish()

now := time.Now().UTC()
epochBegin, err := ptypes.TimestampProto(now)
require.NoError(t, err)
epochEnd, err := ptypes.TimestampProto(now.Add(24 * time.Hour))
require.NoError(t, err)
epochBegin := timestamppb.New(now)
epochEnd := timestamppb.New(now.Add(24 * time.Hour))

resp := &cppb.DRKeyHostHostResponse{
Key: xtest.MustParseHexString("c584cad32613547c64823c756651b6f5"),
Expand All @@ -65,6 +63,6 @@ func TestGetHostHost(t *testing.T) {
}

meta := drkey.HostHostMeta{}
_, err = fetcher.HostHostKey(context.Background(), meta)
_, err := fetcher.HostHostKey(context.Background(), meta)
require.NoError(t, err)
}
Loading

0 comments on commit 5a782c0

Please sign in to comment.