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

pkg/snet: change snet.Topology to a struct #4673

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

lukedirtwalker
Copy link
Collaborator

@lukedirtwalker lukedirtwalker commented Dec 23, 2024

Instead of having the snet.Topology as an interface, change it to a struct.
This makes the contract clearer, LocalIA and PortRange are only considered when
creating a connection. The Interface information however can dynamically change.

The daemon API now exposes an adapter to load the topology information once
or to load the information periodically.

@lukedirtwalker lukedirtwalker requested a review from a team as a code owner December 23, 2024 06:07
@jiceatscion
Copy link
Contributor

This change is Reviewable

Copy link
Collaborator Author

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @JordiSubira)


a discussion (no related file):
This is more of a proposal of how we could deal with changing topologies for processes that have long standing connections. We could probably introduce some caching layer on top of snet.Topology. What do you think @JordiSubira ?

lukedirtwalker added a commit to Anapaya/os-scion that referenced this pull request Dec 23, 2024
This way we can resolve interfaces even if they are dynamically
changing.

OS-PR: scionproto#4673
lukedirtwalker added a commit to Anapaya/os-scion that referenced this pull request Dec 23, 2024
This way we can resolve interfaces even if they are dynamically
changing.

OS-PR: scionproto#4673
Copy link
Contributor

@JordiSubira JordiSubira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @lukedirtwalker)


a discussion (no related file):

Previously, lukedirtwalker (Lukas Vogel) wrote…

This is more of a proposal of how we could deal with changing topologies for processes that have long standing connections. We could probably introduce some caching layer on top of snet.Topology. What do you think @JordiSubira ?

Indeed, back on the dispatcherless PR we discussed about adding some wrapper around the snet.Daemon API for the caching topology related requests.

We decided to put on snet.SCIONPacketConn the interfaceMap as a "once"-cache when opening a connection, which is not ideal because as you said the interface<->ID mapping can dynamically change. We sacrificed this to avoid having to call the daemon API on each packet (because more of the applications use the daemon to implement n.Topology right now).

Do you think we can add the caching layer into this PR? We can have for the moment a simple one, even one shot and allow the application either to instantiate the wrapper or directly the snet.Daemon one.

Copy link
Collaborator Author

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @JordiSubira)


a discussion (no related file):

Previously, JordiSubira wrote…

Indeed, back on the dispatcherless PR we discussed about adding some wrapper around the snet.Daemon API for the caching topology related requests.

We decided to put on snet.SCIONPacketConn the interfaceMap as a "once"-cache when opening a connection, which is not ideal because as you said the interface<->ID mapping can dynamically change. We sacrificed this to avoid having to call the daemon API on each packet (because more of the applications use the daemon to implement n.Topology right now).

Do you think we can add the caching layer into this PR? We can have for the moment a simple one, even one shot and allow the application either to instantiate the wrapper or directly the snet.Daemon one.

Sure, I can add a caching layer here.

@lukedirtwalker lukedirtwalker changed the title pkg/snet: always use topology to resolve interfaces pkg/snet: change snet.Topology to a struct Dec 23, 2024
Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 10 of 13 files at r3.
Reviewable status: 10 of 13 files reviewed, 3 unresolved discussions (waiting on @JordiSubira and @lukedirtwalker)


pkg/daemon/topology.go line 94 at r3 (raw file):

}

func (t *ReloadingTopology) Run(ctx context.Context, period time.Duration) {

We never clean up the entries that are no longer present.

Is that an issue, or do we assume interfaces are not removed?
If we assume that, I think we should add a corresponding comment


control/cmd/control/main.go line 957 at r3 (raw file):

		},
		Interface: func(ifID uint16) (netip.AddrPort, bool) {
			// XXX(lukedirtwalker): The amount of conversiones between

nit: Given we know when the data changes, I think it would be easy to convert it only once and store it.

Copy link
Collaborator Author

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 9 of 14 files reviewed, 3 unresolved discussions (waiting on @JordiSubira and @oncilla)


control/cmd/control/main.go line 957 at r3 (raw file):

Previously, oncilla (Dominik Roos) wrote…

nit: Given we know when the data changes, I think it would be easy to convert it only once and store it.

yeah my issue is more that the topology loads as netip.AddrPort but then the API UnderlayNextHop exposes it as *net.UDPAddr, the snet API actually converts the netip.AddrPort back to *net.UDPAddr internally :trollface:


pkg/daemon/topology.go line 94 at r3 (raw file):

Previously, oncilla (Dominik Roos) wrote…

We never clean up the entries that are no longer present.

Is that an issue, or do we assume interfaces are not removed?
If we assume that, I think we should add a corresponding comment

Good catch

The only issue I could think of is memory leak. For now I added a comment, but for good measure I'll fix the actual implementation tomorrow.

Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 13 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @JordiSubira)

Copy link
Contributor

@oncilla oncilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @JordiSubira)

Copy link
Contributor

@JordiSubira JordiSubira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 12 of 13 files at r3, 3 of 3 files at r5, 2 of 2 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @lukedirtwalker)

Copy link
Contributor

@JordiSubira JordiSubira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @lukedirtwalker)

Instead of having the snet.Topology as an interface, change it to a
struct. This makes the contract clearer, LocalIA and PortRange are
only considered when creating a connection. The Interface information
however can dynamically change.

The daemon API now exposes an adapter to load the topology information
once or to load the information periodically.
@lukedirtwalker lukedirtwalker enabled auto-merge (squash) December 24, 2024 13:31
Copy link
Collaborator Author

@lukedirtwalker lukedirtwalker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @lukedirtwalker)

@lukedirtwalker lukedirtwalker merged commit 05dfe81 into scionproto:master Dec 24, 2024
5 checks passed
@lukedirtwalker lukedirtwalker deleted the snetTopologyOnConn branch December 24, 2024 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants