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.lock

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

1 change: 1 addition & 0 deletions control/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ go_library(
"//pkg/scrypto:go_default_library",
"//pkg/scrypto/cppki:go_default_library",
"//pkg/segment:go_default_library",
"//pkg/segment/extensions/discovery:go_default_library",
"//pkg/snet:go_default_library",
"//pkg/snet/addrutil:go_default_library",
"//pkg/snet/metrics:go_default_library",
Expand Down
2 changes: 2 additions & 0 deletions control/beaconing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ go_library(
"//pkg/scrypto/cppki:go_default_library",
"//pkg/segment:go_default_library",
"//pkg/segment/extensions/digest:go_default_library",
"//pkg/segment/extensions/discovery:go_default_library",
"//pkg/segment/extensions/epic:go_default_library",
"//pkg/segment/extensions/staticinfo:go_default_library",
"//pkg/segment/iface:go_default_library",
Expand Down Expand Up @@ -73,6 +74,7 @@ go_test(
"//pkg/scrypto/cppki:go_default_library",
"//pkg/scrypto/signed:go_default_library",
"//pkg/segment:go_default_library",
"//pkg/segment/extensions/discovery:go_default_library",
"//pkg/segment/extensions/staticinfo:go_default_library",
"//pkg/segment/iface:go_default_library",
"//pkg/slayers/path:go_default_library",
Expand Down
7 changes: 7 additions & 0 deletions control/beaconing/extender.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/scionproto/scion/pkg/scrypto/cppki"
seg "github.com/scionproto/scion/pkg/segment"
"github.com/scionproto/scion/pkg/segment/extensions/digest"
"github.com/scionproto/scion/pkg/segment/extensions/discovery"
"github.com/scionproto/scion/pkg/segment/extensions/epic"
"github.com/scionproto/scion/pkg/slayers/path"
"github.com/scionproto/scion/private/trust"
Expand Down Expand Up @@ -79,6 +80,9 @@ type DefaultExtender struct {
Task string
// StaticInfo contains the configuration used for the StaticInfo Extension.
StaticInfo func() *StaticInfoCfg
// DiscoveryInformation contains the discovery information to be added to
// the segment.
DiscoveryInformation func() *discovery.Extension
// EPIC defines whether the EPIC authenticators should be added when the segment is extended.
EPIC bool

Expand Down Expand Up @@ -176,6 +180,9 @@ func (s *DefaultExtender) Extend(
if static := s.StaticInfo(); static != nil {
asEntry.Extensions.StaticInfo = static.Generate(s.Intfs, ingress, egress)
}
if discovery := s.DiscoveryInformation(); discovery != nil {
asEntry.Extensions.Discovery = discovery
}

// Add the detachable Epic extension
if s.EPIC {
Expand Down
37 changes: 21 additions & 16 deletions control/beaconing/extender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
cryptopb "github.com/scionproto/scion/pkg/proto/crypto"
"github.com/scionproto/scion/pkg/scrypto"
seg "github.com/scionproto/scion/pkg/segment"
"github.com/scionproto/scion/pkg/segment/extensions/discovery"
"github.com/scionproto/scion/pkg/slayers/path"
"github.com/scionproto/scion/private/topology"
"github.com/scionproto/scion/private/trust"
Expand Down Expand Up @@ -104,10 +105,11 @@ func TestDefaultExtenderExtend(t *testing.T) {
require.NoError(t, err)
return mac
},
Intfs: intfs,
MTU: 1337,
MaxExpTime: func() uint8 { return beacon.DefaultMaxExpTime },
StaticInfo: func() *beaconing.StaticInfoCfg { return nil },
Intfs: intfs,
MTU: 1337,
MaxExpTime: func() uint8 { return beacon.DefaultMaxExpTime },
StaticInfo: func() *beaconing.StaticInfoCfg { return nil },
DiscoveryInformation: func() *discovery.Extension { return nil },
}
pseg, err := seg.CreateSegment(time.Time{}, 0)
require.NoError(t, err)
Expand Down Expand Up @@ -175,10 +177,11 @@ func TestDefaultExtenderExtend(t *testing.T) {
require.NoError(t, err)
return mac
},
Intfs: intfs,
MTU: 1337,
MaxExpTime: func() uint8 { return 1 },
StaticInfo: func() *beaconing.StaticInfoCfg { return nil },
Intfs: intfs,
MTU: 1337,
MaxExpTime: func() uint8 { return 1 },
StaticInfo: func() *beaconing.StaticInfoCfg { return nil },
DiscoveryInformation: func() *discovery.Extension { return nil },
}
require.NoError(t, err)
pseg, err := seg.CreateSegment(time.Now(), uint16(mrand.Int()))
Expand Down Expand Up @@ -267,10 +270,11 @@ func TestDefaultExtenderExtend(t *testing.T) {
require.NoError(t, err)
return mac
},
Intfs: intfs,
MTU: 1337,
MaxExpTime: tc.MaxExpTime,
StaticInfo: func() *beaconing.StaticInfoCfg { return nil },
Intfs: intfs,
MTU: 1337,
MaxExpTime: tc.MaxExpTime,
StaticInfo: func() *beaconing.StaticInfoCfg { return nil },
DiscoveryInformation: func() *discovery.Extension { return nil },
}
pseg, err := seg.CreateSegment(ts, uint16(mrand.Int()))
require.NoError(t, err)
Expand Down Expand Up @@ -337,10 +341,11 @@ func TestDefaultExtenderExtend(t *testing.T) {
require.NoError(t, err)
return mac
},
Intfs: intfs,
MTU: 1337,
MaxExpTime: func() uint8 { return beacon.DefaultMaxExpTime },
StaticInfo: func() *beaconing.StaticInfoCfg { return nil },
Intfs: intfs,
MTU: 1337,
MaxExpTime: func() uint8 { return beacon.DefaultMaxExpTime },
StaticInfo: func() *beaconing.StaticInfoCfg { return nil },
DiscoveryInformation: func() *discovery.Extension { return nil },
}
pseg, err := seg.CreateSegment(time.Now(), uint16(mrand.Int()))
require.NoError(t, err)
Expand Down
25 changes: 23 additions & 2 deletions control/beaconing/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package beaconing

import (
"context"
"net"
"slices"
"strconv"

"github.com/opentracing/opentracing-go"
Expand Down Expand Up @@ -127,13 +129,32 @@ func (h Handler) verifySegment(ctx context.Context, segment *seg.PathSegment,
if err != nil {
return err
}
svcToQuery := &snet.SVCAddr{
var remoteAddr net.Addr = &snet.SVCAddr{
IA: peer.IA,
Path: peerPath.Dataplane(),
NextHop: peerPath.UnderlayNextHop(),
SVC: addr.SvcCS,
}
return segverifier.VerifySegment(ctx, h.Verifier, svcToQuery, segment)

i := slices.IndexFunc(segment.ASEntries, func(e seg.ASEntry) bool {
return e.Local.Equal(peer.IA)
})
if i < 0 {
return serrors.New("no AS entry for peer in segment",
"peer", peer.IA, "segment", segment.ID(),
"ase_entries", segment.ASEntries)
}
if disco := segment.ASEntries[i].Extensions.Discovery; disco != nil &&
len(disco.ControlServices) > 0 {
remoteAddr = &snet.UDPAddr{
IA: peer.IA,
Path: peerPath.Dataplane(),
NextHop: peerPath.UnderlayNextHop(),
Host: net.UDPAddrFromAddrPort(disco.ControlServices[0]),
}
}

return segverifier.VerifySegment(ctx, h.Verifier, remoteAddr, segment)
}

func (h Handler) updateMetric(span opentracing.Span, l handlerLabels, err error) {
Expand Down
40 changes: 34 additions & 6 deletions control/beaconing/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestHandlerHandleBeacon(t *testing.T) {
},
Peer: func() *snet.UDPAddr {
return &snet.UDPAddr{
IA: 0,
IA: addr.MustParseIA("2-ff00:0:220"),
Path: path.SCION{},
}
},
Expand All @@ -108,7 +108,7 @@ func TestHandlerHandleBeacon(t *testing.T) {
},
Peer: func() *snet.UDPAddr {
return &snet.UDPAddr{
IA: 0,
IA: addr.MustParseIA("2-ff00:0:220"),
Path: path.SCION{},
}
},
Expand All @@ -134,7 +134,7 @@ func TestHandlerHandleBeacon(t *testing.T) {
},
Peer: func() *snet.UDPAddr {
return &snet.UDPAddr{
IA: 0,
IA: addr.MustParseIA("2-ff00:0:220"),
Path: path.SCION{},
}
},
Expand All @@ -160,6 +160,34 @@ func TestHandlerHandleBeacon(t *testing.T) {
b.Segment.ASEntries[b.Segment.MaxIdx()].Local = addr.MustParseIA("1-ff00:0:111")
return b
},
Peer: func() *snet.UDPAddr {
return &snet.UDPAddr{
IA: addr.MustParseIA("2-ff00:0:220"),
Path: path.SCION{},
}
},
Assertion: assert.Error,
},
"invalid peer ISD-AS": {
Inserter: func(mctrl *gomock.Controller) *mock_beaconing.MockBeaconInserter {
inserter := mock_beaconing.NewMockBeaconInserter(mctrl)
inserter.EXPECT().PreFilter(gomock.Any()).Return(nil)
return inserter
},
Verifier: func(mctrl *gomock.Controller) *mock_infra.MockVerifier {
return mock_infra.NewMockVerifier(mctrl)
},
Beacon: func(t *testing.T, mctrl *gomock.Controller) beacon.Beacon {
g := graph.NewDefaultGraph(mctrl)
b := beacon.Beacon{
Segment: testSegment(g, []uint16{
graph.If_220_X_120_B, graph.If_120_A_110_X,
}),
InIfID: localIF,
}
b.Segment.ASEntries[b.Segment.MaxIdx()].Next = addr.MustParseIA("1-ff00:0:111")
return b
},
Peer: func() *snet.UDPAddr {
return &snet.UDPAddr{
IA: 0,
Expand Down Expand Up @@ -190,7 +218,7 @@ func TestHandlerHandleBeacon(t *testing.T) {
},
Peer: func() *snet.UDPAddr {
return &snet.UDPAddr{
IA: 0,
IA: addr.MustParseIA("2-ff00:0:220"),
Path: path.SCION{},
}
},
Expand All @@ -216,7 +244,7 @@ func TestHandlerHandleBeacon(t *testing.T) {
},
Peer: func() *snet.UDPAddr {
return &snet.UDPAddr{
IA: 0,
IA: addr.MustParseIA("2-ff00:0:220"),
Path: path.SCION{},
}
},
Expand Down Expand Up @@ -245,7 +273,7 @@ func TestHandlerHandleBeacon(t *testing.T) {
},
Peer: func() *snet.UDPAddr {
return &snet.UDPAddr{
IA: 0,
IA: addr.MustParseIA("2-ff00:0:220"),
Path: path.SCION{},
}
},
Expand Down
31 changes: 17 additions & 14 deletions control/beaconing/originator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
cryptopb "github.com/scionproto/scion/pkg/proto/crypto"
"github.com/scionproto/scion/pkg/scrypto/signed"
seg "github.com/scionproto/scion/pkg/segment"
"github.com/scionproto/scion/pkg/segment/extensions/discovery"
"github.com/scionproto/scion/private/topology"
"github.com/scionproto/scion/private/trust"
)
Expand Down Expand Up @@ -68,13 +69,14 @@ func TestOriginatorRun(t *testing.T) {
senderFactory := mock_beaconing.NewMockSenderFactory(mctrl)
o := beaconing.Originator{
Extender: &beaconing.DefaultExtender{
IA: topo.IA(),
MTU: topo.MTU(),
SignerGen: testSignerGen{Signers: []trust.Signer{signer}},
Intfs: intfs,
MAC: macFactory,
MaxExpTime: func() uint8 { return beacon.DefaultMaxExpTime },
StaticInfo: func() *beaconing.StaticInfoCfg { return nil },
IA: topo.IA(),
MTU: topo.MTU(),
SignerGen: testSignerGen{Signers: []trust.Signer{signer}},
Intfs: intfs,
MAC: macFactory,
MaxExpTime: func() uint8 { return beacon.DefaultMaxExpTime },
StaticInfo: func() *beaconing.StaticInfoCfg { return nil },
DiscoveryInformation: func() *discovery.Extension { return nil },
},
SenderFactory: senderFactory,
IA: topo.IA(),
Expand Down Expand Up @@ -131,13 +133,14 @@ func TestOriginatorRun(t *testing.T) {
sender := mock_beaconing.NewMockSender(mctrl)
o := beaconing.Originator{
Extender: &beaconing.DefaultExtender{
IA: topo.IA(),
MTU: topo.MTU(),
SignerGen: testSignerGen{Signers: []trust.Signer{signer}},
Intfs: intfs,
MAC: macFactory,
MaxExpTime: func() uint8 { return beacon.DefaultMaxExpTime },
StaticInfo: func() *beaconing.StaticInfoCfg { return nil },
IA: topo.IA(),
MTU: topo.MTU(),
SignerGen: testSignerGen{Signers: []trust.Signer{signer}},
Intfs: intfs,
MAC: macFactory,
MaxExpTime: func() uint8 { return beacon.DefaultMaxExpTime },
StaticInfo: func() *beaconing.StaticInfoCfg { return nil },
DiscoveryInformation: func() *discovery.Extension { return nil },
},
SenderFactory: senderFactory,
IA: topo.IA(),
Expand Down
Loading
Loading