Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
19 changes: 10 additions & 9 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 gateway/dataplane/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ go_test(
"//pkg/private/xtest:go_default_library",
"//pkg/snet:go_default_library",
"//pkg/snet/mock_snet:go_default_library",
"//pkg/snet/multihomed:go_default_library",
"//pkg/snet/path:go_default_library",
"//private/ringbuf:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
Expand Down
2 changes: 2 additions & 0 deletions gateway/dataplane/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/scionproto/scion/pkg/private/mocks/net/mock_net"
"github.com/scionproto/scion/pkg/snet"
"github.com/scionproto/scion/pkg/snet/mock_snet"
"github.com/scionproto/scion/pkg/snet/multihomed"
snetpath "github.com/scionproto/scion/pkg/snet/path"
)

Expand Down Expand Up @@ -82,6 +83,7 @@ func TestTwoPaths(t *testing.T) {
}

func TestNoLeak(t *testing.T) {
multihomed.StopContinuousCheckInterfaces(t)
defer goleak.VerifyNone(t)

ctrl := gomock.NewController(t)
Expand Down
1 change: 1 addition & 0 deletions pkg/snet/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ go_library(
"//pkg/slayers/path/epic:go_default_library",
"//pkg/slayers/path/onehop:go_default_library",
"//pkg/slayers/path/scion:go_default_library",
"//pkg/snet/multihomed:go_default_library",
"//private/topology:go_default_library",
"//private/topology/underlay:go_default_library",
"@com_github_gopacket_gopacket//:go_default_library",
Expand Down
12 changes: 7 additions & 5 deletions pkg/snet/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/scionproto/scion/pkg/private/common"
"github.com/scionproto/scion/pkg/private/ctrl/path_mgmt"
"github.com/scionproto/scion/pkg/private/serrors"
"github.com/scionproto/scion/pkg/slayers"
)

Expand Down Expand Up @@ -58,7 +57,12 @@ type Conn struct {
// NewCookedConn returns a "cooked" Conn. The Conn object can be used to
// send/receive SCION traffic with the usual methods.
// It takes as arguments a non-nil PacketConn and a non-nil Topology parameter.
// Nil or unspecified addresses for the PacketConn object are not supported.
// The local address of the PacketConn can be nil or unspecified, leaving the socket not bound
// to any particular interface; however it has its limitations, namely a created Conn not
// being able to properly react to a routing change in the OS unless the routing change is
// accompanied by a change in the local network interfaces, in the form of changing their
// local IP addresses, or adding/removing one or more local network interfaces.
//
// This is an advanced API, that allows fine-tuning of the Conn underlay functionality.
// The general methods for obtaining a Conn object are still SCIONNetwork.Listen and
// SCIONNetwork.Dial.
Expand All @@ -72,9 +76,7 @@ func NewCookedConn(
IA: topo.LocalIA,
Host: pconn.LocalAddr().(*net.UDPAddr),
}
if local.Host == nil || local.Host.IP.IsUnspecified() {
return nil, serrors.New("nil or unspecified address is not supported.")
}

return &Conn{
conn: pconn,
local: local,
Expand Down
34 changes: 34 additions & 0 deletions pkg/snet/multihomed/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("@rules_go//go:def.bzl", "go_library")
load("//tools:go.bzl", "go_test")

go_library(
name = "go_default_library",
srcs = [
"interfaces.go",
"outbound_addr.go",
],
importpath = "github.com/scionproto/scion/pkg/snet/multihomed",
visibility = ["//visibility:public"],
deps = [
"//pkg/log:go_default_library",
"//pkg/private/serrors:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = [
"export_test.go",
"integrated_test.go",
"multihomed_test.go",
],
embed = [":go_default_library"],
deps = [
"//pkg/addr:go_default_library",
"//pkg/daemon:go_default_library",
"//pkg/private/xtest:go_default_library",
"//pkg/snet:go_default_library",
"@com_github_stretchr_testify//require:go_default_library",
"@com_github_stretchr_testify//suite:go_default_library",
],
)
49 changes: 49 additions & 0 deletions pkg/snet/multihomed/export_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2025 ETH Zurich
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package multihomed

import (
"net/netip"
"sync"
"testing"

"github.com/stretchr/testify/require"
)

func MustGetEgressIpAddresses(t *testing.T) []netip.Addr {
addrs, err := egressIpAddresses()
require.NoError(t, err)
return addrs
}

func GetInternalMutex() *sync.RWMutex {
return &muRemoteToEgress
}

func StopTicker() {
stopContinuousCheckInterfaces()
}

func GetRemoteToEgressMap() map[netip.Addr]netip.Addr {
return remoteToEgress
}

func ReplaceRemoteToEgressMap(newMap map[netip.Addr]netip.Addr) {
remoteToEgress = newMap
}

func GetEgressesLastState() *[]netip.Addr {
return &localAddresses
}
Loading
Loading