Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snet: Add Fingerprint and MTU to Path interface #3224

Merged
merged 1 commit into from
Oct 4, 2019
Merged
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
8 changes: 8 additions & 0 deletions go/lib/infra/messenger/addr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@ func initResolver(resolver *mock_messenger.MockResolver, f func(*mock_messenger.

type testPath struct{}

func (t *testPath) Fingerprint() string {
panic("not implemented")
}

func (t *testPath) OverlayNextHop() *overlay.OverlayAddr {
panic("not implemented")
}
Expand All @@ -490,3 +494,7 @@ func (t *testPath) Path() *spath.Path {
func (t *testPath) Destination() addr.IA {
panic("not implemented")
}

func (t *testPath) MTU() uint16 {
panic("not implemented")
}
28 changes: 28 additions & 0 deletions go/lib/snet/mock_snet/snet.go

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

29 changes: 29 additions & 0 deletions go/lib/snet/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ func (r *BaseRouter) LocalIA() addr.IA {
// if the source and destination ASes match, or if a router was configured
// without a source of paths).
type Path interface {
// Fingerprint uniquely identifies the path based on the sequence of
// ASes and BRs. Other metadata, such as MTU or NextHop have no effect
// on the fingerprint. Empty string means unknown fingerprint.
Fingerprint() string
// OverlayNextHop returns the address:port pair of a local-AS overlay
// speaker. Usually, this is a border router that will forward the traffic.
OverlayNextHop() *overlay.OverlayAddr
Expand All @@ -129,6 +133,8 @@ type Path interface {
// Destination is the AS the path points to. Empty paths return the local
// AS of the router that created them.
Destination() addr.IA
// MTU returns the MTU of the path. If the result is zero, MTU is unknown.
MTU() uint16
}

var _ Path = (*path)(nil)
Expand All @@ -144,6 +150,14 @@ type path struct {
source addr.IA
}

func (p *path) Fingerprint() string {
if p.sciondPath == nil {
return ""
}
ap := spathmeta.AppPath{Entry: p.sciondPath}
return string(ap.Key())
}

func (p *path) OverlayNextHop() *overlay.OverlayAddr {
return p.overlay
}
Expand All @@ -162,6 +176,13 @@ func (p *path) Destination() addr.IA {
return p.sciondPath.Path.DstIA()
}

func (p *path) MTU() uint16 {
if p.sciondPath == nil {
return 0
}
return p.sciondPath.Path.Mtu
}

// partialPath is a path object with incomplete metadata. It is used as a
// temporary solution where a full path cannot be reconstituted from other
// objects, notably snet.Addr.
Expand All @@ -171,6 +192,10 @@ type partialPath struct {
destination addr.IA
}

func (p *partialPath) Fingerprint() string {
return ""
}

func (p *partialPath) OverlayNextHop() *overlay.OverlayAddr {
return p.overlay
}
Expand All @@ -186,6 +211,10 @@ func (p *partialPath) Destination() addr.IA {
return p.destination
}

func (p *partialPath) MTU() uint16 {
return 0
}

// LocalMachine describes aspects of the host system and its network.
type LocalMachine struct {
// InterfaceIP is the default L3 address for connections originating from
Expand Down
8 changes: 8 additions & 0 deletions go/lib/svc/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ type path struct {
destination addr.IA
}

func (p *path) Fingerprint() string {
return ""
}

func (p *path) OverlayNextHop() *overlay.OverlayAddr {
return p.overlay
}
Expand All @@ -180,3 +184,7 @@ func (p *path) Path() *spath.Path {
func (p *path) Destination() addr.IA {
return p.destination
}

func (p *path) MTU() uint16 {
return 0
}