Skip to content

Commit

Permalink
Delete OverlayAddr (#3381)
Browse files Browse the repository at this point in the history
Type is not fully deleted yet; it is still used in the topology
to switch between IPv4/IPv6 when loading topology information.
However, applications should now use net.UDPAddr instead.

Fixes #3297.
  • Loading branch information
scrye authored Nov 18, 2019
1 parent 3638c5d commit 0e532f5
Show file tree
Hide file tree
Showing 106 changed files with 425 additions and 418 deletions.
4 changes: 2 additions & 2 deletions acceptance/topo_br_reload_if_ip_acceptance/test
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ change_local_ip() {
jq ".BorderRouters[].Interfaces[].PublicOverlay.Addr = $3" $1 | sponge $1
./tools/dc scion kill -s HUP scion_br"$2"-1
sleep 2
check_logs "posixOutput starting addr=[$(unqoute $3)]" $2
check_logs "posixInput starting addr=[$(unqoute $3)]" $2
check_logs "posixOutput starting addr=$(unqoute $3)" $2
check_logs "posixInput starting addr=$(unqoute $3)" $2
}

check_change_remote_ip() {
Expand Down
4 changes: 2 additions & 2 deletions acceptance/topo_br_reload_if_port_acceptance/test
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ check_change_local_port() {
jq '.BorderRouters[].Interfaces[].PublicOverlay.OverlayPort = 42424' $SRC_TOPO | sponge $SRC_TOPO
./tools/dc scion kill -s HUP scion_br"$SRC_IA_FILE"-1
sleep 2
check_logs "posixOutput starting addr=[$addr_src]:42424" $SRC_IA_FILE
check_logs "posixInput starting addr=[$addr_src]:42424" $SRC_IA_FILE
check_logs "posixOutput starting addr=$addr_src:42424" $SRC_IA_FILE
check_logs "posixInput starting addr=$addr_src:42424" $SRC_IA_FILE
bin/end2end_integration -src $SRC_IA -dst $DST_IA -attempts 1 -d -log.console=crit || local failed=$?
if [ -z ${failed+x} ]; then
echo "FAIL: Traffic still passes. End check_change_local_port"
Expand Down
2 changes: 1 addition & 1 deletion acceptance/topo_ps_reloads_br_acceptance/test
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test_run() {
sleep 6
./tools/dc exec_tester $SRC_IA_FILE bin/showpaths -srcIA $SRC_IA -dstIA $DST_IA -sciondFromIA || true
sleep 2
grep -q "\[TRACE\] \[Acceptance\] .*overlay=\[127\.42\.42\.42\]" "logs/ps$SRC_IA_FILE-1.log" || \
grep -q "\[TRACE\] \[Acceptance\] .*overlay=127\.42\.42\.42" "logs/ps$SRC_IA_FILE-1.log" || \
fail "Request to 127.42.42.42 not found in logs"
}

Expand Down
2 changes: 1 addition & 1 deletion acceptance/topo_ps_reloads_cs_acceptance/test
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test_run() {
# Wait for 1 (PS crypto push interval) + 1 (logging flush interval)
# + 1 to guarantee a push is seen
sleep 3
grep -q "\[TRACE\] \[Acceptance\] .*overlay=\[127\.42\.42\.42\]" "logs/ps$IA_FILE-1.log" || \
grep -q "\[TRACE\] \[Acceptance\] .*overlay=127\.42\.42\.42" "logs/ps$IA_FILE-1.log" || \
fail "Push request to 127.42.42.42 not found in logs"
}

Expand Down
2 changes: 1 addition & 1 deletion acceptance/topo_sd_reloads_cs_acceptance/test
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test_run() {
sleep 1
./tools/dc exec_tester $SRC_IA_FILE bin/showpaths -srcIA $SRC_IA -dstIA $DST_IA -sciondFromIA -refresh || true
sleep 2
grep -q "\[TRACE\] \[Acceptance\] .*overlay=\[127\.42\.42\.42\]" "logs/sd$SRC_IA_FILE.log" || \
grep -q "\[TRACE\] \[Acceptance\] .*overlay=127\.42\.42\.42" "logs/sd$SRC_IA_FILE.log" || \
fail "Request to 127.42.42.42 not found in logs"
}

Expand Down
2 changes: 1 addition & 1 deletion acceptance/topo_sd_reloads_ps_acceptance/test
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test_run() {
sleep 1
./tools/dc exec_tester $SRC_IA_FILE bin/showpaths -srcIA $SRC_IA -dstIA $DST_IA -sciondFromIA -refresh || true
sleep 2
grep -q "\[TRACE\] \[Acceptance\] .*overlay=\[127\.42\.42\.42\]" "logs/sd$SRC_IA_FILE.log" || \
grep -q "\[TRACE\] \[Acceptance\] .*overlay=127\.42\.42\.42" "logs/sd$SRC_IA_FILE.log" || \
fail "Request to 127.42.42.42 not found in logs"
}

Expand Down
1 change: 0 additions & 1 deletion go/beacon_srv/internal/beaconing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ go_test(
"//go/lib/infra/modules/itopo/itopotest:go_default_library",
"//go/lib/infra/modules/trust:go_default_library",
"//go/lib/log:go_default_library",
"//go/lib/overlay:go_default_library",
"//go/lib/scrypto:go_default_library",
"//go/lib/serrors:go_default_library",
"//go/lib/snet:go_default_library",
Expand Down
2 changes: 1 addition & 1 deletion go/beacon_srv/internal/beaconing/originator.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (o *beaconOriginator) originateBeacon(ctx context.Context) error {
return serrors.New("Interface does not exist")
}
topoInfo := intf.TopoInfo()
ov := topoInfo.InternalAddrs.PublicOverlay(topoInfo.InternalAddrs.Overlay)
ov := topoInfo.InternalAddrs.PublicOverlayUDP(topoInfo.InternalAddrs.Overlay)

bseg, err := o.createBeacon()
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions go/beacon_srv/internal/beaconing/originator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"errors"
"fmt"
"net"
"sync"
"testing"
"time"
Expand All @@ -33,7 +34,6 @@ import (
"github.com/scionproto/scion/go/lib/ctrl"
"github.com/scionproto/scion/go/lib/ctrl/seg"
"github.com/scionproto/scion/go/lib/infra/modules/itopo/itopotest"
"github.com/scionproto/scion/go/lib/overlay"
"github.com/scionproto/scion/go/lib/scrypto"
"github.com/scionproto/scion/go/lib/snet"
"github.com/scionproto/scion/go/lib/snet/mock_snet"
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestOriginatorRun(t *testing.T) {
defer msgsMtx.Unlock()
msgs = append(msgs, msg{
pkt: ipkt.(*snet.SCIONPacket),
ov: iov.(*overlay.OverlayAddr),
ov: iov.(*net.UDPAddr),
})
return nil
},
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestOriginatorRun(t *testing.T) {

type msg struct {
pkt *snet.SCIONPacket
ov *overlay.OverlayAddr
ov *net.UDPAddr
}

func checkMsg(t *testing.T, msg msg, pub common.RawBytes, infos topology.IfInfoMap) {
Expand All @@ -188,7 +188,8 @@ func checkMsg(t *testing.T, msg msg, pub common.RawBytes, infos topology.IfInfoM
xtest.FailOnErr(t, err)
SoMsg("Egress", hopF.ConsEgress, ShouldEqual, bHopF.ConsEgress)
brAddr := infos[hopF.ConsEgress].InternalAddrs
SoMsg("ov", msg.ov, ShouldResemble, brAddr.PublicOverlay(brAddr.Overlay))
SoMsg("ov", msg.ov, ShouldResemble,
brAddr.PublicOverlayUDP(brAddr.Overlay))
})
}

Expand Down
2 changes: 1 addition & 1 deletion go/beacon_srv/internal/beaconing/propagator.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (p *beaconPropagator) extendAndSend(ctx context.Context, bseg beacon.Beacon
return
}
topoInfo := intf.TopoInfo()
ov := topoInfo.InternalAddrs.PublicOverlay(topoInfo.InternalAddrs.Overlay)
ov := topoInfo.InternalAddrs.PublicOverlayUDP(topoInfo.InternalAddrs.Overlay)

err := p.beaconSender.Send(
ctx,
Expand Down
4 changes: 2 additions & 2 deletions go/beacon_srv/internal/beaconing/propagator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package beaconing
import (
"errors"
"fmt"
"net"
"sync"
"testing"
"time"
Expand All @@ -31,7 +32,6 @@ import (
"github.com/scionproto/scion/go/lib/addr"
"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/infra/modules/itopo/itopotest"
"github.com/scionproto/scion/go/lib/overlay"
"github.com/scionproto/scion/go/lib/scrypto"
"github.com/scionproto/scion/go/lib/snet"
"github.com/scionproto/scion/go/lib/snet/mock_snet"
Expand Down Expand Up @@ -196,7 +196,7 @@ func TestPropagatorRun(t *testing.T) {
defer msgsMtx.Unlock()
msgs = append(msgs, msg{
pkt: ipkt.(*snet.SCIONPacket),
ov: iov.(*overlay.OverlayAddr),
ov: iov.(*net.UDPAddr),
})
return nil
},
Expand Down
3 changes: 2 additions & 1 deletion go/beacon_srv/internal/beaconing/registrar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ func TestRegistrarRun(t *testing.T) {
SoMsg("HopField", []uint8(hopF.Pack()), ShouldResemble,
pseg.ASEntries[pseg.MaxAEIdx()].HopEntries[0].RawHopField)
a := topoProvider.Get().IFInfoMap()[hopF.ConsIngress].InternalAddrs
SoMsg("Next", s.Addr.NextHop, ShouldResemble, a.PublicOverlay(a.Overlay))
SoMsg("Next", s.Addr.NextHop, ShouldResemble,
a.PublicOverlayUDP(a.Overlay))
})
}
// The second run should not do anything, since the period has not passed.
Expand Down
2 changes: 1 addition & 1 deletion go/beacon_srv/internal/keepalive/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s *Sender) Run(ctx context.Context) {
InfoTime: time.Now(),
Pld: pld,
}
ov := intf.InternalAddrs.PublicOverlay(intf.InternalAddrs.Overlay)
ov := intf.InternalAddrs.PublicOverlayUDP(intf.InternalAddrs.Overlay)
if err := s.Send(msg, ov); err != nil {
logger.Error("[keepalive.Sender] Unable to send packet", "err", err)
metrics.Keepalive.Transmits(l).Inc()
Expand Down
2 changes: 0 additions & 2 deletions go/beacon_srv/internal/onehop/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ go_library(
"//go/lib/l4:go_default_library",
"//go/lib/layers:go_default_library",
"//go/lib/log:go_default_library",
"//go/lib/overlay:go_default_library",
"//go/lib/snet:go_default_library",
"//go/lib/spath:go_default_library",
],
Expand All @@ -33,7 +32,6 @@ go_test(
"//go/lib/common:go_default_library",
"//go/lib/l4:go_default_library",
"//go/lib/layers:go_default_library",
"//go/lib/overlay:go_default_library",
"//go/lib/scrypto:go_default_library",
"//go/lib/snet:go_default_library",
"//go/lib/snet/mock_snet:go_default_library",
Expand Down
6 changes: 3 additions & 3 deletions go/beacon_srv/internal/onehop/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
package onehop

import (
"net"
"time"

"github.com/scionproto/scion/go/lib/addr"
"github.com/scionproto/scion/go/lib/layers"
"github.com/scionproto/scion/go/lib/overlay"
"github.com/scionproto/scion/go/lib/snet"
)

Expand All @@ -32,7 +32,7 @@ type OHPPacketDispatcherService struct {
}

func (s *OHPPacketDispatcherService) RegisterTimeout(ia addr.IA, public *addr.AppAddr,
bind *overlay.OverlayAddr, svc addr.HostSVC,
bind *net.UDPAddr, svc addr.HostSVC,
timeout time.Duration) (snet.PacketConn, uint16, error) {

conn, port, err := s.PacketDispatcherService.RegisterTimeout(ia, public, bind, svc, timeout)
Expand All @@ -48,7 +48,7 @@ type ohpPacketConn struct {
snet.PacketConn
}

func (c *ohpPacketConn) WriteTo(pkt *snet.SCIONPacket, ov *overlay.OverlayAddr) error {
func (c *ohpPacketConn) WriteTo(pkt *snet.SCIONPacket, ov *net.UDPAddr) error {
return c.PacketConn.WriteTo(
&snet.SCIONPacket{
Bytes: pkt.Bytes,
Expand Down
7 changes: 3 additions & 4 deletions go/beacon_srv/internal/onehop/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/scionproto/scion/go/lib/l4"
"github.com/scionproto/scion/go/lib/layers"
"github.com/scionproto/scion/go/lib/log"
"github.com/scionproto/scion/go/lib/overlay"
"github.com/scionproto/scion/go/lib/snet"
"github.com/scionproto/scion/go/lib/spath"
)
Expand Down Expand Up @@ -72,7 +71,7 @@ type Sender struct {
}

// Send sends the payload on a one-hop path.
func (s *Sender) Send(msg *Msg, nextHop *overlay.OverlayAddr) error {
func (s *Sender) Send(msg *Msg, nextHop *net.UDPAddr) error {
pkt, err := s.CreatePkt(msg)
if err != nil {
return common.NewBasicError("Unable to create packet", err)
Expand Down Expand Up @@ -126,7 +125,7 @@ type BeaconSender struct {
// Send packs and sends out the beacon. QUIC is first attempted, and if that
// fails the method falls back on UDP.
func (s *BeaconSender) Send(ctx context.Context, bseg *seg.Beacon, ia addr.IA,
egIfid common.IFIDType, signer infra.Signer, ov *overlay.OverlayAddr) error {
egIfid common.IFIDType, signer infra.Signer, ov *net.UDPAddr) error {

path, err := s.CreatePath(egIfid, time.Now())
if err != nil {
Expand Down Expand Up @@ -167,7 +166,7 @@ func (s *BeaconSender) Send(ctx context.Context, bseg *seg.Beacon, ia addr.IA,
}

func (s *BeaconSender) attemptQUIC(ctx context.Context, ia addr.IA, path *spath.Path,
nextHop *overlay.OverlayAddr, bseg *seg.Beacon) (bool, error) {
nextHop *net.UDPAddr, bseg *seg.Beacon) (bool, error) {

if s.AddressRewriter == nil {
return false, nil
Expand Down
5 changes: 2 additions & 3 deletions go/beacon_srv/internal/onehop/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/l4"
"github.com/scionproto/scion/go/lib/layers"
"github.com/scionproto/scion/go/lib/overlay"
"github.com/scionproto/scion/go/lib/scrypto"
"github.com/scionproto/scion/go/lib/snet"
"github.com/scionproto/scion/go/lib/snet/mock_snet"
Expand Down Expand Up @@ -110,7 +109,7 @@ func TestSenderSend(t *testing.T) {
MAC: createMac(t),
}
// Read from connection to unblock sender.
ov := overlay.NewOverlayAddr(net.IP{127, 0, 0, 42}, 1337)
ov := &net.UDPAddr{IP: net.IP{127, 0, 0, 42}, Port: 1337}
var pkt *snet.SCIONPacket
conn.EXPECT().WriteTo(gomock.Any(), ov).DoAndReturn(
func(ipkt, _ interface{}) error {
Expand Down Expand Up @@ -159,7 +158,7 @@ type testConn struct {

func (conn *testConn) ReadFrom(b []byte) (int, net.Addr, error) {
n, _, err := conn.PacketConn.ReadFrom(b)
return n, &overlay.OverlayAddr{}, err
return n, &net.UDPAddr{}, err
}

func createMac(t *testing.T) hash.Hash {
Expand Down
3 changes: 2 additions & 1 deletion go/border/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ go_test(
"//go/lib/common:go_default_library",
"//go/lib/infra/modules/itopo:go_default_library",
"//go/lib/log:go_default_library",
"//go/lib/overlay:go_default_library",
"//go/lib/overlay/conn:go_default_library",
"//go/lib/overlay/conn/mock_conn:go_default_library",
"//go/lib/prom:go_default_library",
"//go/lib/ringbuf:go_default_library",
"//go/lib/topology:go_default_library",
"//go/lib/topology/overlay:go_default_library",
"//go/lib/xtest:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_smartystreets_goconvey//convey:go_default_library",
Expand Down
5 changes: 2 additions & 3 deletions go/border/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,8 @@ func (r *Router) posixPrepOutput(epkts ringbuf.EntryList, msgs []ipv4.Message,
msgs[i].Buffers[0] = rp.Raw
if !connected {
// Unconnected socket, use supplied address
uaddr := msgs[i].Addr.(*net.UDPAddr)
uaddr.IP = erp.Dst.L3().IP()
uaddr.Port = int(erp.Dst.L4())
msgs[i].Addr.(*net.UDPAddr).IP = erp.Dst.IP
msgs[i].Addr.(*net.UDPAddr).Port = int(erp.Dst.Port)
}
}
return epkts, true
Expand Down
9 changes: 6 additions & 3 deletions go/border/io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import (
"github.com/scionproto/scion/go/border/rctx"
"github.com/scionproto/scion/go/border/rpkt"
"github.com/scionproto/scion/go/lib/log"
"github.com/scionproto/scion/go/lib/overlay"
"github.com/scionproto/scion/go/lib/overlay/conn"
"github.com/scionproto/scion/go/lib/overlay/conn/mock_conn"
"github.com/scionproto/scion/go/lib/prom"
"github.com/scionproto/scion/go/lib/ringbuf"
"github.com/scionproto/scion/go/lib/topology"
)

func TestPosixOutputNoLeakNoErrors(t *testing.T) {
Expand Down Expand Up @@ -147,8 +147,11 @@ func newTestPktList(t *testing.T, length int) (ringbuf.EntryList, func(expected
}
}

func newTestDst(t *testing.T) *overlay.OverlayAddr {
return overlay.NewOverlayAddr(net.IP{127, 0, 0, 1}, overlay.EndhostPort)
func newTestDst(t *testing.T) *net.UDPAddr {
return &net.UDPAddr{
IP: net.IP{127, 0, 0, 1},
Port: topology.EndhostPort,
}
}

func newTestSock(r *Router, ringSize int, mconn conn.Conn) *rctx.Sock {
Expand Down
1 change: 0 additions & 1 deletion go/border/rctx/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ go_library(
"//go/lib/assert:go_default_library",
"//go/lib/common:go_default_library",
"//go/lib/log:go_default_library",
"//go/lib/overlay:go_default_library",
"//go/lib/overlay/conn:go_default_library",
"//go/lib/ringbuf:go_default_library",
"//go/lib/scrypto:go_default_library",
Expand Down
10 changes: 5 additions & 5 deletions go/border/rctx/rctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
package rctx

import (
"net"
"sync"
"sync/atomic"

"github.com/scionproto/scion/go/border/brconf"
"github.com/scionproto/scion/go/lib/addr"
"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/overlay"
"github.com/scionproto/scion/go/lib/scrypto"
)

Expand Down Expand Up @@ -74,26 +74,26 @@ func (ctx *Ctx) InitMacPool() error {
return nil
}

func (ctx *Ctx) ResolveSVC(svc addr.HostSVC) ([]*overlay.OverlayAddr, error) {
func (ctx *Ctx) ResolveSVC(svc addr.HostSVC) ([]*net.UDPAddr, error) {
if svc.IsMulticast() {
return ctx.ResolveSVCMulti(svc)
}
resolvedAddr, err := ctx.ResolveSVCAny(svc)
if err != nil {
return nil, err
}
return []*overlay.OverlayAddr{resolvedAddr}, nil
return []*net.UDPAddr{resolvedAddr}, nil
}

// ResolveSVCAny resolves an anycast SVC address (i.e. a single instance of a local
// infrastructure service).
func (ctx *Ctx) ResolveSVCAny(svc addr.HostSVC) (*overlay.OverlayAddr, error) {
func (ctx *Ctx) ResolveSVCAny(svc addr.HostSVC) (*net.UDPAddr, error) {
return ctx.Conf.Topo.OverlayAnycast(svc)
}

// ResolveSVCMulti resolves a multicast SVC address (i.e. one packet per machine hosting
// instances for a local infrastructure service).
func (ctx *Ctx) ResolveSVCMulti(svc addr.HostSVC) ([]*overlay.OverlayAddr, error) {
func (ctx *Ctx) ResolveSVCMulti(svc addr.HostSVC) ([]*net.UDPAddr, error) {
return ctx.Conf.Topo.OverlayMulticast(svc)
}

Expand Down
Loading

0 comments on commit 0e532f5

Please sign in to comment.