scionproto / scion

SCION Internet Architecture
https://scion.org
Apache License 2.0
381 stars 160 forks source link

snet/daemon: daemon Connector should cache local topology information #4542

Open matzf opened 3 months ago

matzf commented 3 months ago

Follow up from https://github.com/scionproto/scion/pull/4344#pullrequestreview-1965863271.

The snet.Topology interface was added in #4344, as a sub-interface for pkg/daemon.Connector:

type Topology interface {
    LocalIA(ctx context.Context) (addr.IA, error)
    PortRange(ctx context.Context) (uint16, uint16, error)
    Interfaces(ctx context.Context) (map[uint16]netip.AddrPort, error)
}

This information is accessed by snet e.g. when opening new sockets. Previously, only the LocalIA information was required and it was used by value in addr.IA the snet.SCIONNetwork struct.

To avoid requesting this same topology information over and over from the daemon, it should be cached somewhere. The pkg/daemon.grpcConn can transparently cache the results of these API invocations.

Alternatively, the snet interface is not yet frozen. The snet.Topology could be changed into a struct that contains LocalIA, PortRange and Interface as values; the daemon Connector interface can be adapted to return this in one go for convenient initialization of the snet.SCIONNetwork.