Skip to content

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiSubira committed May 10, 2024
1 parent 138e5f2 commit 568dfc0
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 98 deletions.
26 changes: 0 additions & 26 deletions acceptance/topo_cs_reload/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,6 @@ go_test(
],
)

# dispatcher container
oci_tarball(
name = "dispatcher.tar",
format = "docker",
image = ":dispatcher_image",
repo_tags = ["scion/" + package_name() + ":dispatcher"],
)

oci_image(
name = "dispatcher_image",
base = "//docker:dispatcher",
cmd = [
"--config",
"/disp.toml",
],
entrypoint = ["/app/dispatcher"],
tars = [
":dispatcher_data",
],
)

pkg_tar(
name = "dispatcher_data",
srcs = ["testdata/disp.toml"],
)

# control container
oci_tarball(
name = "control.tar",
Expand Down
14 changes: 0 additions & 14 deletions acceptance/topo_cs_reload/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,8 @@ networks:
config:
- subnet: 242.253.100.0/24
services:
<<<<<<< HEAD
topo_cs_reload_dispatcher:
image: scion/acceptance/topo_cs_reload:dispatcher
networks:
bridge1:
ipv4_address: 242.253.100.2
volumes:
- vol_topo_cs_reload_disp:/run/shm/dispatcher:rw
topo_cs_reload_control_srv:
image: scion/acceptance/topo_cs_reload:control
depends_on:
- topo_cs_reload_dispatcher
=======
topo_cs_reload_control_srv:
image: bazel/acceptance/topo_cs_reload:control
>>>>>>> 6b820ef10 (change last-mile router port forwarding)
volumes:
- "${TOPO_CS_RELOAD_CONFIG_DIR}/certs:/certs:ro"
- "${TOPO_CS_RELOAD_CONFIG_DIR}/keys:/keys:ro"
Expand Down
4 changes: 0 additions & 4 deletions acceptance/topo_cs_reload/reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ func setupTest(t *testing.T) testState {
s.mustExec(t, "tar", "-xf", "crypto.tar", "-C", tmpDir)
// first load the docker images from bazel into the docker deamon, the
// tars are in the same folder as this test runs in bazel.
s.mustExec(t, "docker", "image", "load", "-i", "dispatcher.tar/tarball.tar")
t.Cleanup(func() {
s.mustExec(t, "docker", "image", "rm", "scion/acceptance/topo_cs_reload:dispatcher")
})
s.mustExec(t, "docker", "image", "load", "-i", "control.tar/tarball.tar")
t.Cleanup(func() {
s.mustExec(t, "docker", "image", "rm", "scion/acceptance/topo_cs_reload:control")
Expand Down
26 changes: 0 additions & 26 deletions acceptance/topo_daemon_reload/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,6 @@ go_test(
],
)

# dispatcher container
oci_tarball(
name = "dispatcher.tar",
format = "docker",
image = ":dispatcher_image",
repo_tags = ["scion/" + package_name() + ":dispatcher"],
)

oci_image(
name = "dispatcher_image",
base = "//docker:dispatcher",
cmd = [
"--config",
"/disp.toml",
],
entrypoint = ["/app/dispatcher"],
tars = [
":dispatcher_data",
],
)

pkg_tar(
name = "dispatcher_data",
srcs = ["testdata/disp.toml"],
)

# daemon container
oci_tarball(
name = "daemon.tar",
Expand Down
8 changes: 0 additions & 8 deletions acceptance/topo_daemon_reload/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ networks:
config:
- subnet: 242.254.100.0/24
services:
topo_daemon_reload_dispatcher:
container_name: topo_daemon_reload_dispatcher
image: scion/acceptance/topo_daemon_reload:dispatcher
networks:
bridge1:
ipv4_address: 242.254.100.2
volumes:
- vol_topo_daemon_reload_disp:/run/shm/dispatcher:rw
topo_daemon_reload_daemon:
container_name: topo_daemon_reload_daemon
image: scion/acceptance/topo_daemon_reload:daemon
Expand Down
6 changes: 1 addition & 5 deletions acceptance/topo_daemon_reload/reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,13 @@ func TestSDTopoReload(t *testing.T) {
func setupTest(t *testing.T) {
// first load the docker images from bazel into the docker deamon, the
// tars are in the same folder as this test runs in bazel.
mustExec(t, "docker", "image", "load", "-i", "dispatcher.tar/tarball.tar")
t.Cleanup(func() {
mustExec(t, "docker", "image", "rm", "scion/acceptance/topo_daemon_reload:dispatcher")
})
mustExec(t, "docker", "image", "load", "-i", "daemon.tar/tarball.tar")
t.Cleanup(func() {
mustExec(t, "docker", "image", "rm", "scion/acceptance/topo_daemon_reload:daemon")
})
// now start the docker containers
mustExec(t, "docker", "compose", "-f", "docker-compose.yml",
"up", "-d", "topo_daemon_reload_dispatcher", "topo_daemon_reload_daemon")
"up", "-d", "topo_daemon_reload_daemon")
t.Cleanup(func() { mustExec(t, "docker", "compose", "-f", "docker-compose.yml", "down", "-v") })
// wait a bit to make sure the containers are ready.
time.Sleep(time.Second / 2)
Expand Down
6 changes: 3 additions & 3 deletions control/cmd/control/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"crypto/x509"
"encoding/json"
"errors"
"net"
"net/http"
_ "net/http/pprof"
"net/netip"
"path/filepath"
"strings"
"sync"
Expand Down Expand Up @@ -948,9 +948,9 @@ func (c cpInfoProvider) PortRange(_ context.Context) (uint16, uint16, error) {
return start, end, nil
}

func (c cpInfoProvider) Interfaces(_ context.Context) (map[uint16]*net.UDPAddr, error) {
func (c cpInfoProvider) Interfaces(_ context.Context) (map[uint16]netip.AddrPort, error) {
ifMap := c.topo.InterfaceInfoMap()
ifsToUDP := make(map[uint16]*net.UDPAddr, len(ifMap))
ifsToUDP := make(map[uint16]netip.AddrPort, len(ifMap))
for i, v := range ifMap {
if i > (1<<16)-1 {
return nil, serrors.New("invalid interface id", "id", i)
Expand Down
4 changes: 2 additions & 2 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package daemon

import (
"context"
"net"
"net/netip"

"github.com/scionproto/scion/pkg/addr"
"github.com/scionproto/scion/pkg/daemon/internal/metrics"
Expand Down Expand Up @@ -68,7 +68,7 @@ type Connector interface {
// for the local IA.
PortRange(ctx context.Context) (uint16, uint16, error)
// Interfaces returns the map of interface identifiers to the underlay internal address.
Interfaces(ctx context.Context) (map[uint16]*net.UDPAddr, error)
Interfaces(ctx context.Context) (map[uint16]netip.AddrPort, error)
// Paths requests from the daemon a set of end to end paths between the source and destination.
Paths(ctx context.Context, dst, src addr.IA, f PathReqFlags) ([]snet.Path, error)
// ASInfo requests from the daemon information about AS ia, the zero IA can be
Expand Down
7 changes: 4 additions & 3 deletions pkg/daemon/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package daemon
import (
"context"
"net"
"net/netip"
"time"

"google.golang.org/grpc"
Expand Down Expand Up @@ -84,16 +85,16 @@ func (c grpcConn) PortRange(ctx context.Context) (uint16, uint16, error) {
return uint16(response.DispatchedPortStart), uint16(response.DispatchedPortEnd), nil
}

func (c grpcConn) Interfaces(ctx context.Context) (map[uint16]*net.UDPAddr, error) {
func (c grpcConn) Interfaces(ctx context.Context) (map[uint16]netip.AddrPort, error) {
client := sdpb.NewDaemonServiceClient(c.conn)
response, err := client.Interfaces(ctx, &sdpb.InterfacesRequest{})
if err != nil {
c.metrics.incInterface(err)
return nil, err
}
result := make(map[uint16]*net.UDPAddr)
result := make(map[uint16]netip.AddrPort, len(response.Interfaces))
for ifID, intf := range response.Interfaces {
a, err := net.ResolveUDPAddr("udp", intf.Address.Address)
a, err := netip.ParseAddrPort(intf.Address.Address)
if err != nil {
c.metrics.incInterface(err)
return nil, serrors.WrapStr("parsing reply", err, "raw_uri", intf.Address.Address)
Expand Down
10 changes: 7 additions & 3 deletions pkg/snet/packet_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package snet

import (
"net"
"net/netip"
"syscall"
"time"

Expand Down Expand Up @@ -342,12 +343,15 @@ type SerializationOptions struct {
InitializePaths bool
}

type interfaceMap map[uint16]*net.UDPAddr
type interfaceMap map[uint16]netip.AddrPort

func (m interfaceMap) get(id uint16) (*net.UDPAddr, error) {
addr, ok := m[id]
addrPort, ok := m[id]
if !ok {
return nil, serrors.New("interface number not found", "interface", id)
}
return addr, nil
return &net.UDPAddr{
IP: addrPort.Addr().AsSlice(),
Port: int(addrPort.Port()),
}, nil
}
3 changes: 2 additions & 1 deletion pkg/snet/snet.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"context"
"errors"
"net"
"net/netip"
"syscall"

"github.com/scionproto/scion/pkg/addr"
Expand All @@ -52,7 +53,7 @@ import (
type Topology interface {
LocalIA(ctx context.Context) (addr.IA, error)
PortRange(ctx context.Context) (uint16, uint16, error)
Interfaces(ctx context.Context) (map[uint16]*net.UDPAddr, error)
Interfaces(ctx context.Context) (map[uint16]netip.AddrPort, error)
}

var _ Network = (*SCIONNetwork)(nil)
Expand Down
8 changes: 5 additions & 3 deletions router/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ type Connector struct {
externalInterfaces map[uint16]control.ExternalInterface
siblingInterfaces map[uint16]control.SiblingInterface

ReceiveBufferSize int
SendBufferSize int
BFD config.BFD
ReceiveBufferSize int
SendBufferSize int
BFD config.BFD
DispatchedPortStart *int
DispatchedPortEnd *int
}
Expand Down Expand Up @@ -232,6 +232,8 @@ func (c *Connector) applyBFDDefaults(cfg control.BFD) control.BFD {
cfg.RequiredMinRxInterval = c.BFD.RequiredMinRxInterval.Duration
}
return cfg
}

func (c *Connector) SetPortRange(start, end uint16) {
c.mtx.Lock()
defer c.mtx.Unlock()
Expand Down

0 comments on commit 568dfc0

Please sign in to comment.