Repository: scionproto/scion
Pull request #3552 (2019-12-23 12:40:17)

Remove overlay.OverlayAddr
It was no longer used.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/scionproto/scion/3552)
<!-- Reviewable:end -->



Patch:
diff --git a/go/lib/topology/overlay/BUILD.bazel b/go/lib/topology/overlay/BUILD.bazel
index c8e2ccaa8..6a24f772b 100644
--- a/go/lib/topology/overlay/BUILD.bazel
+++ b/go/lib/topology/overlay/BUILD.bazel
@@ -2,14 +2,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
 
 go_library(
     name = "go_default_library",
-    srcs = [
-        "addr.go",
-        "defs.go",
-    ],
+    srcs = ["defs.go"],
     importpath = "github.com/scionproto/scion/go/lib/topology/overlay",
     visibility = ["//visibility:public"],
-    deps = [
-        "//go/lib/addr:go_default_library",
-        "//go/lib/common:go_default_library",
-    ],
+    deps = ["//go/lib/common:go_default_library"],
 )
diff --git a/go/lib/topology/overlay/addr.go b/go/lib/topology/overlay/addr.go
deleted file mode 100644
index 240848eab..000000000
--- a/go/lib/topology/overlay/addr.go
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright 2018 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 overlay
-
-import (
-	"fmt"
-	"net"
-
-	"github.com/scionproto/scion/go/lib/addr"
-)
-
-type OverlayAddr struct {
-	l3 net.IP
-	l4 uint16
-}
-
-func NewOverlayAddr(l3 net.IP, l4 uint16) *OverlayAddr {
-	if l3.To4() != nil {
-		l3 = l3.To4()
-	}
-	return &OverlayAddr{l3: copyIP(l3), l4: l4}
-}
-
-func (a *OverlayAddr) L3() addr.HostAddr {
-	return addr.HostFromIP(a.l3)
-}
-
-func (a *OverlayAddr) L4() uint16 {
-	return a.l4
-}
-
-func (a *OverlayAddr) Type() Type {
-	if a.l3.To4() != nil {
-		return UDPIPv4
-	}
-	return UDPIPv6
-}
-
-func (a *OverlayAddr) Copy() *OverlayAddr {
-	if a == nil {
-		return nil
-	}
-	return &OverlayAddr{l3: copyIP(a.l3), l4: a.l4}
-}
-
-func (a *OverlayAddr) Equal(o *OverlayAddr) bool {
-	if (a == nil) || (o == nil) {
-		return a == o
-	}
-	if a.l3 != nil {
-		if !a.l3.Equal(o.l3) {
-			return false
-		}
-	} else if o.l3 != nil {
-		if !o.l3.Equal(a.l3) {
-			return false
-		}
-	}
-	return o.l4 == a.l4
-}
-
-func (a *OverlayAddr) Network() string {
-	return a.Type().String()
-}
-
-func (a *OverlayAddr) String() string {
-	if a == nil {
-		return "<nil>"
-	}
-	return fmt.Sprintf("[%s]:%d", a.l3, a.l4)
-}
-
-func (a *OverlayAddr) ToUDPAddr() *net.UDPAddr {
-	return &net.UDPAddr{IP: copyIP(a.l3), Port: int(a.l4)}
-}
-
-// ShallowUDPAddr returns a net.UDPAddr interpretation of the overlay L3 address field. The IP is a
-// slice pointing to the same memory region as the overlay address, so it can be edited (note that
-// since the port is an integer and always copied, the port of the overlay address cannot be
-// edited).
-//
-// FIXME(scrye): This is used only for some unit tests which effect topology changes by editing an
-// address in-place. This should never be used and should be removed.
-func (a *OverlayAddr) ShallowUDPAddr() *net.UDPAddr {
-	return &net.UDPAddr{
-		IP:   a.l3,
-		Port: int(a.l4),
-	}
-}
-
-func copyIP(ip net.IP) net.IP {
-	return append(ip[:0:0], ip...)
-}
diff --git a/go/lib/topology/overlay/defs.go b/go/lib/topology/overlay/defs.go
index 4db7239ee..f1be3a501 100644
--- a/go/lib/topology/overlay/defs.go
+++ b/go/lib/topology/overlay/defs.go
@@ -17,7 +17,6 @@ package overlay
 import (
 	"encoding/json"
 	"fmt"
-	"net"
 	"strings"
 
 	"github.com/scionproto/scion/go/lib/common"
@@ -27,18 +26,12 @@ type Type int
 
 const (
 	Invalid Type = iota
-	IPv4
-	IPv6
-	IPv46
 	UDPIPv4
 	UDPIPv6
 	UDPIPv46
 )
 
 const (
-	IPv4Name     = "IPv4"
-	IPv6Name     = "IPv6"
-	IPv46Name    = "IPv4+6"
 	UDPIPv4Name  = "UDP/IPv4"
 	UDPIPv6Name  = "UDP/IPv6"
 	UDPIPv46Name = "UDP/IPv4+6"
@@ -52,12 +45,6 @@ const (
 
 func (o Type) String() string {
 	switch o {
-	case IPv4:
-		return IPv4Name
-	case IPv6:
-		return IPv6Name
-	case IPv46:
-		return IPv46Name
 	case UDPIPv4:
 		return UDPIPv4Name
 	case UDPIPv6:
@@ -71,12 +58,6 @@ func (o Type) String() string {
 
 func TypeFromString(s string) (Type, error) {
 	switch strings.ToLower(s) {
-	case strings.ToLower(IPv4Name):
-		return IPv4, nil
-	case strings.ToLower(IPv6Name):
-		return IPv6, nil
-	case strings.ToLower(IPv46Name):
-		return IPv46, nil
 	case strings.ToLower(UDPIPv4Name):
 		return UDPIPv4, nil
 	case strings.ToLower(UDPIPv6Name):
@@ -92,22 +73,6 @@ func (ot Type) MarshalJSON() ([]byte, error) {
 	return json.Marshal(ot.String())
 }
 
-func (ot Type) IsIPv4() bool {
-	switch ot {
-	case IPv4, IPv46, UDPIPv4, UDPIPv46:
-		return true
-	}
-	return false
-}
-
-func (ot Type) IsIPv6() bool {
-	switch ot {
-	case IPv6, IPv46, UDPIPv6, UDPIPv46:
-		return true
-	}
-	return false
-}
-
 func (ot Type) IsUDP() bool {
 	switch ot {
 	case UDPIPv4, UDPIPv6, UDPIPv46:
@@ -115,44 +80,3 @@ func (ot Type) IsUDP() bool {
 	}
 	return false
 }
-
-func (ot Type) ToIP() Type {
-	switch ot {
-	case UDPIPv4:
-		return IPv4
-	case UDPIPv6:
-		return IPv6
-	case UDPIPv46:
-		return IPv46
-	}
-	return ot
-}
-
-func (ot Type) To6() Type {
-	if ot.IsUDP() {
-		return UDPIPv6
-	}
-	return IPv6
-}
-
-func (ot Type) To4() Type {
-	if ot.IsUDP() {
-		return UDPIPv4
-	}
-	return IPv4
-}
-
-func OverlayFromIP(ip net.IP, ot Type) Type {
-	if ip.To4() != nil {
-		// Address is IPv4
-		if ot.IsUDP() {
-			return UDPIPv4
-		}
-		return IPv4
-	}
-	// Address is IPv6
-	if ot.IsUDP() {
-		return UDPIPv6
-	}
-	return IPv6
-}


Test patch:
diff --git a/go/lib/infra/modules/itopo/testdata/topo.json b/go/lib/infra/modules/itopo/testdata/topo.json
index 2e717a986..b7a1a7249 100644
--- a/go/lib/infra/modules/itopo/testdata/topo.json
+++ b/go/lib/infra/modules/itopo/testdata/topo.json
@@ -4,7 +4,7 @@
     "TTL": 3600,
     "ISD_AS": "1-ff00:0:311",
     "MTU": 1472,
-    "Overlay": "IPv4+6",
+    "Overlay": "UDP/IPv4+6",
     "Core": false,
     "BorderRouters": {
         "br1-ff00:0:311-1": {
diff --git a/go/lib/topology/json/json_test.go b/go/lib/topology/json/json_test.go
index 958102a6e..3e94d7295 100644
--- a/go/lib/topology/json/json_test.go
+++ b/go/lib/topology/json/json_test.go
@@ -40,7 +40,7 @@ func TestLoadRawFromFile(t *testing.T) {
 		IA:             "6-ff00:0:362",
 		MTU:            1472,
 		Core:           true,
-		Overlay:        overlay.IPv46Name,
+		Overlay:        overlay.UDPIPv46Name,
 		BorderRouters: map[string]*jsontopo.BRInfo{
 			"borderrouter6-f00:0:362-1": {
 				InternalAddrs: jsontopo.UnderlayAddressMap{
diff --git a/go/lib/topology/json/testdata/topology.json b/go/lib/topology/json/testdata/topology.json
index b41c30bcc..9f3a44273 100644
--- a/go/lib/topology/json/testdata/topology.json
+++ b/go/lib/topology/json/testdata/topology.json
@@ -3,7 +3,7 @@
     "TimestampHuman": "May  6 00:00:00 CET 1975",
     "TTL": 0,
     "ISD_AS": "6-ff00:0:362",
-    "Overlay": "IPv4+6",
+    "Overlay": "UDP/IPv4+6",
     "MTU": 1472,
     "Core": true,
     "BorderRouters": {
diff --git a/go/lib/topology/testdata/basic.json b/go/lib/topology/testdata/basic.json
index c0e9ca8a6..d063c18c3 100644
--- a/go/lib/topology/testdata/basic.json
+++ b/go/lib/topology/testdata/basic.json
@@ -4,7 +4,7 @@
     "TTL": 3600,
     "ISD_AS": "1-ff00:0:311",
     "MTU": 1472,
-    "Overlay": "IPv4+6",
+    "Overlay": "UDP/IPv4+6",
     "Core": false,
     "BorderRouters": {
         "br1-ff00:0:311-1": {
diff --git a/go/lib/topology/testdata/core.json b/go/lib/topology/testdata/core.json
index 40c38568c..0812870b8 100644
--- a/go/lib/topology/testdata/core.json
+++ b/go/lib/topology/testdata/core.json
@@ -4,7 +4,7 @@
     "ISD_AS": "6-ff00:0:362",
     "MTU": 1472,
     "Core": true,
-    "Overlay": "IPv4+6",
+    "Overlay": "UDP/IPv4+6",
     "BorderRouters": {
         "borderrouter6-ff00:0:362-1": {
             "InternalAddrs": {