From 45fe08485cb20db45ffec9fbce3b8eb1349b1792 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Hugly Date: Fri, 30 Aug 2024 14:28:41 +0200 Subject: [PATCH 1/4] Move IfIDType out of private/common and to its own package. Given that IfIDType represents generic interface IDs as used in segements distributed by the control service, it seems that it shouln't be private either, even if it currently can be. So the new package isn't private. --- control/beacon/beacondbtest/BUILD.bazel | 2 +- control/beacon/beacondbtest/beacondbtest.go | 8 +- control/beaconing/BUILD.bazel | 4 +- control/beaconing/export_test.go | 6 +- control/beaconing/staticinfo_config.go | 80 +++++------ control/beaconing/staticinfo_config_test.go | 136 +++++++++--------- control/beaconing/writer_test.go | 4 +- control/cmd/control/BUILD.bazel | 2 +- control/cmd/control/main.go | 4 +- daemon/internal/servers/BUILD.bazel | 2 +- daemon/internal/servers/grpc.go | 4 +- gateway/pathhealth/BUILD.bazel | 2 +- gateway/pathhealth/revocations_test.go | 6 +- pkg/daemon/BUILD.bazel | 2 +- pkg/daemon/grpc.go | 4 +- pkg/experimental/hiddenpath/BUILD.bazel | 2 +- .../hiddenpath/beaconwriter_test.go | 4 +- pkg/private/common/BUILD.bazel | 5 +- pkg/private/common/defs.go | 31 +--- pkg/private/common/defs_test.go | 32 +---- pkg/private/ctrl/path_mgmt/BUILD.bazel | 2 +- pkg/private/ctrl/path_mgmt/rev_info.go | 4 +- pkg/private/xtest/graph/BUILD.bazel | 2 +- pkg/private/xtest/graph/graph.go | 28 ++-- pkg/segment/extensions/staticinfo/BUILD.bazel | 4 +- .../extensions/staticinfo/staticinfo.go | 38 ++--- .../extensions/staticinfo/staticinfo_test.go | 12 +- pkg/segment/ifid/BUILD.bazel | 18 +++ pkg/segment/ifid/ifid.go | 45 ++++++ pkg/segment/ifid/ifid_test.go | 52 +++++++ pkg/snet/BUILD.bazel | 1 + pkg/snet/path.go | 4 +- pkg/snet/scmp.go | 6 +- private/path/combinator/BUILD.bazel | 4 +- private/path/combinator/combinator_test.go | 22 +-- private/path/combinator/graph.go | 18 +-- .../path/combinator/staticinfo_accumulator.go | 8 +- .../combinator/staticinfo_accumulator_test.go | 46 +++--- private/path/pathpol/BUILD.bazel | 4 +- private/path/pathpol/acl_test.go | 10 +- private/path/pathpol/hop_pred.go | 12 +- private/path/pathpol/hop_pred_test.go | 26 ++-- private/path/pathpol/policy_test.go | 4 +- private/path/pathpol/sequence.go | 4 +- private/pathdb/query/BUILD.bazel | 2 +- private/pathdb/query/query.go | 4 +- private/revcache/BUILD.bazel | 4 +- private/revcache/revcache.go | 8 +- private/revcache/revcachetest/BUILD.bazel | 2 +- private/revcache/revcachetest/revcachetest.go | 12 +- private/revcache/util.go | 6 +- private/revcache/util_test.go | 6 +- private/segment/segfetcher/BUILD.bazel | 2 +- private/segment/segfetcher/resolver_test.go | 8 +- private/storage/beacon/sqlite/BUILD.bazel | 2 +- private/storage/beacon/sqlite/db.go | 4 +- private/storage/path/dbtest/BUILD.bazel | 2 +- private/storage/path/dbtest/dbtest.go | 4 +- private/topology/BUILD.bazel | 4 +- private/topology/interface.go | 12 +- private/topology/json/BUILD.bazel | 4 +- private/topology/json/json.go | 18 +-- private/topology/json/json_test.go | 6 +- private/topology/mock_topology/BUILD.bazel | 2 +- private/topology/mock_topology/mock.go | 8 +- private/topology/reload.go | 6 +- private/topology/topology.go | 18 +-- private/topology/topology_test.go | 12 +- router/BUILD.bazel | 2 +- router/connector.go | 4 +- router/control/BUILD.bazel | 2 +- router/control/conf.go | 8 +- router/control/internal/metrics/BUILD.bazel | 2 +- router/control/internal/metrics/metrics.go | 4 +- scion/cmd/scion/BUILD.bazel | 2 +- scion/cmd/scion/common.go | 6 +- scion/showpaths/BUILD.bazel | 2 +- scion/showpaths/showpaths.go | 6 +- 78 files changed, 481 insertions(+), 427 deletions(-) create mode 100644 pkg/segment/ifid/BUILD.bazel create mode 100644 pkg/segment/ifid/ifid.go create mode 100644 pkg/segment/ifid/ifid_test.go diff --git a/control/beacon/beacondbtest/BUILD.bazel b/control/beacon/beacondbtest/BUILD.bazel index 602bd3962c..38577ecb7e 100644 --- a/control/beacon/beacondbtest/BUILD.bazel +++ b/control/beacon/beacondbtest/BUILD.bazel @@ -8,9 +8,9 @@ go_library( deps = [ "//control/beacon:go_default_library", "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/xtest/graph:go_default_library", "//pkg/segment:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/slayers/path:go_default_library", "@com_github_stretchr_testify//assert:go_default_library", "@com_github_stretchr_testify//require:go_default_library", diff --git a/control/beacon/beacondbtest/beacondbtest.go b/control/beacon/beacondbtest/beacondbtest.go index 4b3af82017..1dcf029ff6 100644 --- a/control/beacon/beacondbtest/beacondbtest.go +++ b/control/beacon/beacondbtest/beacondbtest.go @@ -24,9 +24,9 @@ import ( "github.com/scionproto/scion/control/beacon" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/xtest/graph" seg "github.com/scionproto/scion/pkg/segment" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/slayers/path" ) @@ -334,14 +334,14 @@ func InsertBeacon(t *testing.T, db beacon.DB, ases []IfInfo, type PeerEntry struct { IA addr.IA - Ingress common.IfIDType + Ingress ifid.IfIDType } type IfInfo struct { IA addr.IA Next addr.IA - Ingress common.IfIDType - Egress common.IfIDType + Ingress ifid.IfIDType + Egress ifid.IfIDType Peers []PeerEntry } diff --git a/control/beaconing/BUILD.bazel b/control/beaconing/BUILD.bazel index 2cae4b8238..5a4f564ab3 100644 --- a/control/beaconing/BUILD.bazel +++ b/control/beaconing/BUILD.bazel @@ -21,7 +21,6 @@ go_library( "//pkg/addr:go_default_library", "//pkg/log:go_default_library", "//pkg/metrics:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/prom:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", @@ -31,6 +30,7 @@ go_library( "//pkg/segment/extensions/digest:go_default_library", "//pkg/segment/extensions/epic:go_default_library", "//pkg/segment/extensions/staticinfo:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/snet:go_default_library", "//private/periodic:go_default_library", @@ -62,7 +62,6 @@ go_test( "//control/beaconing/mock_beaconing:go_default_library", "//control/ifstate:go_default_library", "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", "//pkg/private/xtest/graph:go_default_library", @@ -72,6 +71,7 @@ go_test( "//pkg/scrypto/signed:go_default_library", "//pkg/segment:go_default_library", "//pkg/segment/extensions/staticinfo:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/slayers/path/scion:go_default_library", "//pkg/snet:go_default_library", diff --git a/control/beaconing/export_test.go b/control/beaconing/export_test.go index 76db29854c..343760fce2 100644 --- a/control/beaconing/export_test.go +++ b/control/beaconing/export_test.go @@ -15,12 +15,12 @@ package beaconing import ( - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/segment/extensions/staticinfo" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/private/topology" ) -func (cfg StaticInfoCfg) TestGenerate(ifType map[common.IfIDType]topology.LinkType, - ingress, egress common.IfIDType) *staticinfo.Extension { +func (cfg StaticInfoCfg) TestGenerate(ifType map[ifid.IfIDType]topology.LinkType, + ingress, egress ifid.IfIDType) *staticinfo.Extension { return cfg.generate(ifType, ingress, egress) } diff --git a/control/beaconing/staticinfo_config.go b/control/beaconing/staticinfo_config.go index 34e485ad8a..4722fb4ac7 100644 --- a/control/beaconing/staticinfo_config.go +++ b/control/beaconing/staticinfo_config.go @@ -21,21 +21,21 @@ import ( "time" "github.com/scionproto/scion/control/ifstate" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" "github.com/scionproto/scion/pkg/private/util" "github.com/scionproto/scion/pkg/segment/extensions/staticinfo" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/private/topology" ) type InterfaceLatencies struct { - Inter util.DurWrap `json:"Inter"` - Intra map[common.IfIDType]util.DurWrap `json:"Intra"` + Inter util.DurWrap `json:"Inter"` + Intra map[ifid.IfIDType]util.DurWrap `json:"Intra"` } type InterfaceBandwidths struct { - Inter uint64 `json:"Inter"` - Intra map[common.IfIDType]uint64 `json:"Intra"` + Inter uint64 `json:"Inter"` + Intra map[ifid.IfIDType]uint64 `json:"Intra"` } type InterfaceGeodata struct { @@ -45,7 +45,7 @@ type InterfaceGeodata struct { } type InterfaceHops struct { - Intra map[common.IfIDType]uint32 `json:"Intra"` + Intra map[ifid.IfIDType]uint32 `json:"Intra"` } type LinkType staticinfo.LinkType @@ -79,12 +79,12 @@ func (l *LinkType) UnmarshalText(text []byte) error { // StaticInfoCfg is used to parse data from config.json. type StaticInfoCfg struct { - Latency map[common.IfIDType]InterfaceLatencies `json:"Latency"` - Bandwidth map[common.IfIDType]InterfaceBandwidths `json:"Bandwidth"` - LinkType map[common.IfIDType]LinkType `json:"LinkType"` - Geo map[common.IfIDType]InterfaceGeodata `json:"Geo"` - Hops map[common.IfIDType]InterfaceHops `json:"Hops"` - Note string `json:"Note"` + Latency map[ifid.IfIDType]InterfaceLatencies `json:"Latency"` + Bandwidth map[ifid.IfIDType]InterfaceBandwidths `json:"Bandwidth"` + LinkType map[ifid.IfIDType]LinkType `json:"LinkType"` + Geo map[ifid.IfIDType]InterfaceGeodata `json:"Geo"` + Hops map[ifid.IfIDType]InterfaceHops `json:"Hops"` + Note string `json:"Note"` } // ParseStaticInfoCfg parses data from a config file into a StaticInfoCfg struct. @@ -135,7 +135,7 @@ func (cfg *StaticInfoCfg) clean() { } // symmetrizeLatency makes the Intra latency values symmetric -func symmetrizeLatency(latency map[common.IfIDType]InterfaceLatencies) { +func symmetrizeLatency(latency map[ifid.IfIDType]InterfaceLatencies) { for i, sub := range latency { delete(sub.Intra, i) // Remove loopy entry for j, v := range sub.Intra { @@ -145,7 +145,7 @@ func symmetrizeLatency(latency map[common.IfIDType]InterfaceLatencies) { if latency[j].Intra == nil { latency[j] = InterfaceLatencies{ Inter: latency[j].Inter, - Intra: make(map[common.IfIDType]util.DurWrap), + Intra: make(map[ifid.IfIDType]util.DurWrap), } } vTransposed, ok := latency[j].Intra[i] @@ -158,7 +158,7 @@ func symmetrizeLatency(latency map[common.IfIDType]InterfaceLatencies) { } // symmetrizeBandwidth makes the Intra bandwidth values symmetric -func symmetrizeBandwidth(bandwidth map[common.IfIDType]InterfaceBandwidths) { +func symmetrizeBandwidth(bandwidth map[ifid.IfIDType]InterfaceBandwidths) { for i, sub := range bandwidth { delete(sub.Intra, i) // Remove loopy entry for j, v := range sub.Intra { @@ -168,7 +168,7 @@ func symmetrizeBandwidth(bandwidth map[common.IfIDType]InterfaceBandwidths) { if bandwidth[j].Intra == nil { bandwidth[j] = InterfaceBandwidths{ Inter: bandwidth[j].Inter, - Intra: make(map[common.IfIDType]uint64), + Intra: make(map[ifid.IfIDType]uint64), } } vTransposed, ok := bandwidth[j].Intra[i] @@ -181,13 +181,13 @@ func symmetrizeBandwidth(bandwidth map[common.IfIDType]InterfaceBandwidths) { } // symmetrizeHops makes the Intra hops values symmetric -func symmetrizeHops(hops map[common.IfIDType]InterfaceHops) { +func symmetrizeHops(hops map[ifid.IfIDType]InterfaceHops) { for i, sub := range hops { delete(sub.Intra, i) // Remove loopy entry for j, v := range sub.Intra { if _, ok := hops[j]; !ok { hops[j] = InterfaceHops{ - Intra: make(map[common.IfIDType]uint32), + Intra: make(map[ifid.IfIDType]uint32), } } vTransposed, ok := hops[j].Intra[i] @@ -205,11 +205,11 @@ func (cfg StaticInfoCfg) Generate(intfs *ifstate.Interfaces, ingress, egress uint16) *staticinfo.Extension { ifType := interfaceTypeTable(intfs) - return cfg.generate(ifType, common.IfIDType(ingress), common.IfIDType(egress)) + return cfg.generate(ifType, ifid.IfIDType(ingress), ifid.IfIDType(egress)) } -func (cfg StaticInfoCfg) generate(ifType map[common.IfIDType]topology.LinkType, - ingress, egress common.IfIDType) *staticinfo.Extension { +func (cfg StaticInfoCfg) generate(ifType map[ifid.IfIDType]topology.LinkType, + ingress, egress ifid.IfIDType) *staticinfo.Extension { return &staticinfo.Extension{ Latency: cfg.generateLatency(ifType, ingress, egress), @@ -223,12 +223,12 @@ func (cfg StaticInfoCfg) generate(ifType map[common.IfIDType]topology.LinkType, // generateLatency creates the LatencyInfo by extracting the relevant values from // the config. -func (cfg StaticInfoCfg) generateLatency(ifType map[common.IfIDType]topology.LinkType, - ingress, egress common.IfIDType) staticinfo.LatencyInfo { +func (cfg StaticInfoCfg) generateLatency(ifType map[ifid.IfIDType]topology.LinkType, + ingress, egress ifid.IfIDType) staticinfo.LatencyInfo { l := staticinfo.LatencyInfo{ - Intra: make(map[common.IfIDType]time.Duration), - Inter: make(map[common.IfIDType]time.Duration), + Intra: make(map[ifid.IfIDType]time.Duration), + Inter: make(map[ifid.IfIDType]time.Duration), } for ifID, v := range cfg.Latency[egress].Intra { if includeIntraInfo(ifType, ifID, ingress, egress) { @@ -246,12 +246,12 @@ func (cfg StaticInfoCfg) generateLatency(ifType map[common.IfIDType]topology.Lin // generateBandwidth creates the BandwidthInfo by extracting the relevant values // from the config. -func (cfg StaticInfoCfg) generateBandwidth(ifType map[common.IfIDType]topology.LinkType, - ingress, egress common.IfIDType) staticinfo.BandwidthInfo { +func (cfg StaticInfoCfg) generateBandwidth(ifType map[ifid.IfIDType]topology.LinkType, + ingress, egress ifid.IfIDType) staticinfo.BandwidthInfo { bw := staticinfo.BandwidthInfo{ - Intra: make(map[common.IfIDType]uint64), - Inter: make(map[common.IfIDType]uint64), + Intra: make(map[ifid.IfIDType]uint64), + Inter: make(map[ifid.IfIDType]uint64), } for ifID, v := range cfg.Bandwidth[egress].Intra { if includeIntraInfo(ifType, ifID, ingress, egress) { @@ -269,8 +269,8 @@ func (cfg StaticInfoCfg) generateBandwidth(ifType map[common.IfIDType]topology.L // generateLinkType creates the LinkTypeInfo by extracting the relevant values from // the config. -func (cfg StaticInfoCfg) generateLinkType(ifType map[common.IfIDType]topology.LinkType, - egress common.IfIDType) staticinfo.LinkTypeInfo { +func (cfg StaticInfoCfg) generateLinkType(ifType map[ifid.IfIDType]topology.LinkType, + egress ifid.IfIDType) staticinfo.LinkTypeInfo { lt := make(staticinfo.LinkTypeInfo) for ifID, intfLT := range cfg.LinkType { @@ -284,8 +284,8 @@ func (cfg StaticInfoCfg) generateLinkType(ifType map[common.IfIDType]topology.Li // generateInternalHops creates the InternalHopsInfo by extracting the relevant // values from the config. -func (cfg StaticInfoCfg) generateInternalHops(ifType map[common.IfIDType]topology.LinkType, - ingress, egress common.IfIDType) staticinfo.InternalHopsInfo { +func (cfg StaticInfoCfg) generateInternalHops(ifType map[ifid.IfIDType]topology.LinkType, + ingress, egress ifid.IfIDType) staticinfo.InternalHopsInfo { ihi := make(staticinfo.InternalHopsInfo) for ifID, v := range cfg.Hops[egress].Intra { @@ -298,8 +298,8 @@ func (cfg StaticInfoCfg) generateInternalHops(ifType map[common.IfIDType]topolog // generateGeo creates the GeoInfo by extracting the relevant values from // the config. -func (cfg StaticInfoCfg) generateGeo(ifType map[common.IfIDType]topology.LinkType, - ingress, egress common.IfIDType) staticinfo.GeoInfo { +func (cfg StaticInfoCfg) generateGeo(ifType map[ifid.IfIDType]topology.LinkType, + ingress, egress ifid.IfIDType) staticinfo.GeoInfo { gi := staticinfo.GeoInfo{} for ifID, loc := range cfg.Geo { @@ -331,8 +331,8 @@ func (cfg StaticInfoCfg) generateGeo(ifType map[common.IfIDType]topology.LinkTyp // AS needs to pick one consistently (or decide to just include the full // information all the time), otherwise information for cross-overs may // be missing. -func includeIntraInfo(ifType map[common.IfIDType]topology.LinkType, - ifID, ingress, egress common.IfIDType) bool { +func includeIntraInfo(ifType map[ifid.IfIDType]topology.LinkType, + ifID, ingress, egress ifid.IfIDType) bool { isCoreIngress := (ifType[ingress] == topology.Core || ingress == 0) isCoreEgress := (ifType[egress] == topology.Core || egress == 0) @@ -347,11 +347,11 @@ func includeIntraInfo(ifType map[common.IfIDType]topology.LinkType, t == topology.Peer } -func interfaceTypeTable(intfs *ifstate.Interfaces) map[common.IfIDType]topology.LinkType { +func interfaceTypeTable(intfs *ifstate.Interfaces) map[ifid.IfIDType]topology.LinkType { ifMap := intfs.All() - ifTypes := make(map[common.IfIDType]topology.LinkType, len(ifMap)) + ifTypes := make(map[ifid.IfIDType]topology.LinkType, len(ifMap)) for ifID, ifInfo := range ifMap { - ifTypes[common.IfIDType(ifID)] = ifInfo.TopoInfo().LinkType + ifTypes[ifid.IfIDType(ifID)] = ifInfo.TopoInfo().LinkType } return ifTypes } diff --git a/control/beaconing/staticinfo_config_test.go b/control/beaconing/staticinfo_config_test.go index 50dc57f9a1..4ee33da7e0 100644 --- a/control/beaconing/staticinfo_config_test.go +++ b/control/beaconing/staticinfo_config_test.go @@ -21,9 +21,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/scionproto/scion/control/beaconing" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/util" "github.com/scionproto/scion/pkg/segment/extensions/staticinfo" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/private/topology" ) @@ -95,10 +95,10 @@ func getTestConfigData() *beaconing.StaticInfoCfg { } return &beaconing.StaticInfoCfg{ - Latency: map[common.IfIDType]beaconing.InterfaceLatencies{ + Latency: map[ifid.IfIDType]beaconing.InterfaceLatencies{ 1: { Inter: w(latency_inter_1), - Intra: map[common.IfIDType]util.DurWrap{ + Intra: map[ifid.IfIDType]util.DurWrap{ 2: w(latency_intra_1_2), 3: w(latency_intra_1_3), 5: w(latency_intra_1_5), @@ -106,7 +106,7 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 2: { Inter: w(latency_inter_2), - Intra: map[common.IfIDType]util.DurWrap{ + Intra: map[ifid.IfIDType]util.DurWrap{ 1: w(latency_intra_1_2), 3: w(latency_intra_2_3), 5: w(latency_intra_2_5), @@ -114,7 +114,7 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 3: { Inter: w(latency_inter_3), - Intra: map[common.IfIDType]util.DurWrap{ + Intra: map[ifid.IfIDType]util.DurWrap{ 1: w(latency_intra_1_3), 2: w(latency_intra_2_3), 5: w(latency_intra_3_5), @@ -122,17 +122,17 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 5: { Inter: w(latency_inter_5), - Intra: map[common.IfIDType]util.DurWrap{ + Intra: map[ifid.IfIDType]util.DurWrap{ 1: w(latency_intra_1_5), 2: w(latency_intra_2_5), 3: w(latency_intra_3_5), }, }, }, - Bandwidth: map[common.IfIDType]beaconing.InterfaceBandwidths{ + Bandwidth: map[ifid.IfIDType]beaconing.InterfaceBandwidths{ 1: { Inter: bandwidth_inter_1, - Intra: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{ 2: bandwidth_intra_1_2, 3: bandwidth_intra_1_3, 5: bandwidth_intra_1_5, @@ -140,7 +140,7 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 2: { Inter: bandwidth_inter_2, - Intra: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{ 1: bandwidth_intra_1_2, 3: bandwidth_intra_2_3, 5: bandwidth_intra_2_5, @@ -148,7 +148,7 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 3: { Inter: bandwidth_inter_3, - Intra: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{ 1: bandwidth_intra_1_3, 2: bandwidth_intra_2_3, 5: bandwidth_intra_3_5, @@ -156,49 +156,49 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 5: { Inter: bandwidth_inter_5, - Intra: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{ 1: bandwidth_intra_1_5, 2: bandwidth_intra_2_5, 3: bandwidth_intra_3_5, }, }, }, - LinkType: map[common.IfIDType]beaconing.LinkType{ + LinkType: map[ifid.IfIDType]beaconing.LinkType{ 1: beaconing.LinkType(link_type_1), 2: beaconing.LinkType(link_type_2), 3: beaconing.LinkType(link_type_3), 5: beaconing.LinkType(link_type_5), }, - Geo: map[common.IfIDType]beaconing.InterfaceGeodata{ + Geo: map[ifid.IfIDType]beaconing.InterfaceGeodata{ 1: {geo_1.Longitude, geo_1.Latitude, geo_1.Address}, 2: {geo_2.Longitude, geo_2.Latitude, geo_2.Address}, 3: {geo_3.Longitude, geo_3.Latitude, geo_3.Address}, 5: {geo_5.Longitude, geo_5.Latitude, geo_5.Address}, }, - Hops: map[common.IfIDType]beaconing.InterfaceHops{ + Hops: map[ifid.IfIDType]beaconing.InterfaceHops{ 1: { - Intra: map[common.IfIDType]uint32{ + Intra: map[ifid.IfIDType]uint32{ 2: hops_intra_1_2, 3: hops_intra_1_3, 5: hops_intra_1_5, }, }, 2: { - Intra: map[common.IfIDType]uint32{ + Intra: map[ifid.IfIDType]uint32{ 1: hops_intra_1_2, 3: hops_intra_2_3, 5: hops_intra_2_5, }, }, 3: { - Intra: map[common.IfIDType]uint32{ + Intra: map[ifid.IfIDType]uint32{ 1: hops_intra_1_3, 2: hops_intra_2_3, 5: hops_intra_3_5, }, }, 5: { - Intra: map[common.IfIDType]uint32{ + Intra: map[ifid.IfIDType]uint32{ 1: hops_intra_1_5, 2: hops_intra_2_5, 3: hops_intra_3_5, @@ -221,14 +221,14 @@ func TestGenerateStaticInfo(t *testing.T) { cfg := getTestConfigData() // "topology" information for a non-core AS: - ifTypeNoncore := map[common.IfIDType]topology.LinkType{ + ifTypeNoncore := map[ifid.IfIDType]topology.LinkType{ 1: topology.Child, 2: topology.Child, 3: topology.Parent, 5: topology.Peer, } // "topology" information for a core AS: - ifTypeCore := map[common.IfIDType]topology.LinkType{ + ifTypeCore := map[ifid.IfIDType]topology.LinkType{ 1: topology.Core, 2: topology.Child, 3: topology.Core, @@ -237,9 +237,9 @@ func TestGenerateStaticInfo(t *testing.T) { testCases := []struct { name string - ingress common.IfIDType - egress common.IfIDType - ifType map[common.IfIDType]topology.LinkType + ingress ifid.IfIDType + egress ifid.IfIDType + ifType map[ifid.IfIDType]topology.LinkType expected staticinfo.Extension }{ { @@ -249,23 +249,23 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[common.IfIDType]time.Duration{ + Intra: map[ifid.IfIDType]time.Duration{ 2: latency_intra_1_2, 3: latency_intra_1_3, 5: latency_intra_1_5, }, - Inter: map[common.IfIDType]time.Duration{ + Inter: map[ifid.IfIDType]time.Duration{ 1: latency_inter_1, 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{ 2: bandwidth_intra_1_2, 3: bandwidth_intra_1_3, 5: bandwidth_intra_1_5, }, - Inter: map[common.IfIDType]uint64{ + Inter: map[ifid.IfIDType]uint64{ 1: bandwidth_inter_1, 5: bandwidth_inter_5, }, @@ -279,7 +279,7 @@ func TestGenerateStaticInfo(t *testing.T) { 1: link_type_1, 5: link_type_5, }, - InternalHops: map[common.IfIDType]uint32{ + InternalHops: map[ifid.IfIDType]uint32{ 2: hops_intra_1_2, 3: hops_intra_1_3, 5: hops_intra_1_5, @@ -294,21 +294,21 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[common.IfIDType]time.Duration{ + Intra: map[ifid.IfIDType]time.Duration{ 3: latency_intra_2_3, 5: latency_intra_2_5, }, - Inter: map[common.IfIDType]time.Duration{ + Inter: map[ifid.IfIDType]time.Duration{ 2: latency_inter_2, 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{ 3: bandwidth_intra_2_3, 5: bandwidth_intra_2_5, }, - Inter: map[common.IfIDType]uint64{ + Inter: map[ifid.IfIDType]uint64{ 2: bandwidth_inter_2, 5: bandwidth_inter_5, }, @@ -322,7 +322,7 @@ func TestGenerateStaticInfo(t *testing.T) { 2: link_type_2, 5: link_type_5, }, - InternalHops: map[common.IfIDType]uint32{ + InternalHops: map[ifid.IfIDType]uint32{ 3: hops_intra_2_3, 5: hops_intra_2_5, }, @@ -336,14 +336,14 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[common.IfIDType]time.Duration{}, - Inter: map[common.IfIDType]time.Duration{ + Intra: map[ifid.IfIDType]time.Duration{}, + Inter: map[ifid.IfIDType]time.Duration{ 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[common.IfIDType]uint64{}, - Inter: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{}, + Inter: map[ifid.IfIDType]uint64{ 5: bandwidth_inter_5, }, }, @@ -354,7 +354,7 @@ func TestGenerateStaticInfo(t *testing.T) { LinkType: staticinfo.LinkTypeInfo{ 5: link_type_5, }, - InternalHops: map[common.IfIDType]uint32{}, + InternalHops: map[ifid.IfIDType]uint32{}, Note: note, }, }, @@ -365,21 +365,21 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[common.IfIDType]time.Duration{ + Intra: map[ifid.IfIDType]time.Duration{ 2: latency_intra_1_2, 5: latency_intra_1_5, }, - Inter: map[common.IfIDType]time.Duration{ + Inter: map[ifid.IfIDType]time.Duration{ 1: latency_inter_1, 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{ 2: bandwidth_intra_1_2, 5: bandwidth_intra_1_5, }, - Inter: map[common.IfIDType]uint64{ + Inter: map[ifid.IfIDType]uint64{ 1: bandwidth_inter_1, 5: bandwidth_inter_5, }, @@ -392,7 +392,7 @@ func TestGenerateStaticInfo(t *testing.T) { 1: link_type_1, 5: link_type_5, }, - InternalHops: map[common.IfIDType]uint32{ + InternalHops: map[ifid.IfIDType]uint32{ 2: hops_intra_1_2, 5: hops_intra_1_5, }, @@ -406,19 +406,19 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[common.IfIDType]time.Duration{ + Intra: map[ifid.IfIDType]time.Duration{ 5: latency_intra_2_5, }, - Inter: map[common.IfIDType]time.Duration{ + Inter: map[ifid.IfIDType]time.Duration{ 2: latency_inter_2, 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{ 5: bandwidth_intra_2_5, }, - Inter: map[common.IfIDType]uint64{ + Inter: map[ifid.IfIDType]uint64{ 2: bandwidth_inter_2, 5: bandwidth_inter_5, }, @@ -431,7 +431,7 @@ func TestGenerateStaticInfo(t *testing.T) { 2: link_type_2, 5: link_type_5, }, - InternalHops: map[common.IfIDType]uint32{ + InternalHops: map[ifid.IfIDType]uint32{ 5: hops_intra_2_5, }, Note: note, @@ -444,22 +444,22 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeCore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[common.IfIDType]time.Duration{ + Intra: map[ifid.IfIDType]time.Duration{ 1: latency_intra_1_2, 3: latency_intra_2_3, 5: latency_intra_2_5, }, - Inter: map[common.IfIDType]time.Duration{ + Inter: map[ifid.IfIDType]time.Duration{ 2: latency_inter_2, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{ 1: bandwidth_intra_1_2, 3: bandwidth_intra_2_3, 5: bandwidth_intra_2_5, }, - Inter: map[common.IfIDType]uint64{ + Inter: map[ifid.IfIDType]uint64{ 2: bandwidth_inter_2, }, }, @@ -469,7 +469,7 @@ func TestGenerateStaticInfo(t *testing.T) { LinkType: staticinfo.LinkTypeInfo{ 2: link_type_2, }, - InternalHops: map[common.IfIDType]uint32{ + InternalHops: map[ifid.IfIDType]uint32{ 1: hops_intra_1_2, 3: hops_intra_2_3, 5: hops_intra_2_5, @@ -484,14 +484,14 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeCore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[common.IfIDType]time.Duration{}, - Inter: map[common.IfIDType]time.Duration{ + Intra: map[ifid.IfIDType]time.Duration{}, + Inter: map[ifid.IfIDType]time.Duration{ 1: latency_inter_1, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[common.IfIDType]uint64{}, - Inter: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{}, + Inter: map[ifid.IfIDType]uint64{ 1: bandwidth_inter_1, }, }, @@ -501,7 +501,7 @@ func TestGenerateStaticInfo(t *testing.T) { LinkType: staticinfo.LinkTypeInfo{ 1: link_type_1, }, - InternalHops: map[common.IfIDType]uint32{}, + InternalHops: map[ifid.IfIDType]uint32{}, Note: note, }, }, @@ -512,18 +512,18 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeCore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[common.IfIDType]time.Duration{ + Intra: map[ifid.IfIDType]time.Duration{ 3: latency_intra_1_3, }, - Inter: map[common.IfIDType]time.Duration{ + Inter: map[ifid.IfIDType]time.Duration{ 1: latency_inter_1, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{ 3: bandwidth_intra_1_3, }, - Inter: map[common.IfIDType]uint64{ + Inter: map[ifid.IfIDType]uint64{ 1: bandwidth_inter_1, }, }, @@ -534,7 +534,7 @@ func TestGenerateStaticInfo(t *testing.T) { LinkType: staticinfo.LinkTypeInfo{ 1: link_type_1, }, - InternalHops: map[common.IfIDType]uint32{ + InternalHops: map[ifid.IfIDType]uint32{ 3: hops_intra_1_3, }, Note: note, @@ -547,18 +547,18 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeCore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[common.IfIDType]time.Duration{}, - Inter: map[common.IfIDType]time.Duration{}, + Intra: map[ifid.IfIDType]time.Duration{}, + Inter: map[ifid.IfIDType]time.Duration{}, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[common.IfIDType]uint64{}, - Inter: map[common.IfIDType]uint64{}, + Intra: map[ifid.IfIDType]uint64{}, + Inter: map[ifid.IfIDType]uint64{}, }, Geo: staticinfo.GeoInfo{ 3: geo_3, }, LinkType: staticinfo.LinkTypeInfo{}, - InternalHops: map[common.IfIDType]uint32{}, + InternalHops: map[ifid.IfIDType]uint32{}, Note: note, }, }, diff --git a/control/beaconing/writer_test.go b/control/beaconing/writer_test.go index 508b00849c..e9c56b1ac1 100644 --- a/control/beaconing/writer_test.go +++ b/control/beaconing/writer_test.go @@ -37,12 +37,12 @@ import ( "github.com/scionproto/scion/control/beaconing/mock_beaconing" "github.com/scionproto/scion/control/ifstate" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/xtest/graph" "github.com/scionproto/scion/pkg/scrypto" "github.com/scionproto/scion/pkg/scrypto/cppki" "github.com/scionproto/scion/pkg/scrypto/signed" seg "github.com/scionproto/scion/pkg/segment" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/slayers/path/scion" "github.com/scionproto/scion/pkg/snet" "github.com/scionproto/scion/pkg/snet/addrutil" @@ -377,7 +377,7 @@ type topoWrap struct { } func (w topoWrap) UnderlayNextHop(id uint16) *net.UDPAddr { - a, _ := w.Topo.UnderlayNextHop(common.IfIDType(id)) + a, _ := w.Topo.UnderlayNextHop(ifid.IfIDType(id)) return a } diff --git a/control/cmd/control/BUILD.bazel b/control/cmd/control/BUILD.bazel index 9bf133cb52..ab11521517 100644 --- a/control/cmd/control/BUILD.bazel +++ b/control/cmd/control/BUILD.bazel @@ -30,13 +30,13 @@ go_library( "//pkg/grpc:go_default_library", "//pkg/log:go_default_library", "//pkg/metrics:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/prom:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/proto/control_plane:go_default_library", "//pkg/proto/discovery:go_default_library", "//pkg/scrypto:go_default_library", "//pkg/scrypto/cppki:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/snet:go_default_library", "//private/app:go_default_library", "//private/app/appnet:go_default_library", diff --git a/control/cmd/control/main.go b/control/cmd/control/main.go index 78be343ead..afb073c89e 100644 --- a/control/cmd/control/main.go +++ b/control/cmd/control/main.go @@ -56,13 +56,13 @@ import ( libgrpc "github.com/scionproto/scion/pkg/grpc" "github.com/scionproto/scion/pkg/log" libmetrics "github.com/scionproto/scion/pkg/metrics" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/prom" "github.com/scionproto/scion/pkg/private/serrors" cppb "github.com/scionproto/scion/pkg/proto/control_plane" dpb "github.com/scionproto/scion/pkg/proto/discovery" "github.com/scionproto/scion/pkg/scrypto" "github.com/scionproto/scion/pkg/scrypto/cppki" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/snet" "github.com/scionproto/scion/private/app" infraenv "github.com/scionproto/scion/private/app/appnet" @@ -852,7 +852,7 @@ func createBeaconStore( return store, *policies.Prop.Filter.AllowIsdLoop, err } -func adaptInterfaceMap(in map[common.IfIDType]topology.IFInfo) map[uint16]ifstate.InterfaceInfo { +func adaptInterfaceMap(in map[ifid.IfIDType]topology.IFInfo) map[uint16]ifstate.InterfaceInfo { converted := make(map[uint16]ifstate.InterfaceInfo, len(in)) for id, info := range in { converted[uint16(id)] = ifstate.InterfaceInfo{ diff --git a/daemon/internal/servers/BUILD.bazel b/daemon/internal/servers/BUILD.bazel index 9bf6640324..580a4546f3 100644 --- a/daemon/internal/servers/BUILD.bazel +++ b/daemon/internal/servers/BUILD.bazel @@ -15,13 +15,13 @@ go_library( "//pkg/drkey:go_default_library", "//pkg/log:go_default_library", "//pkg/metrics:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/ctrl/path_mgmt:go_default_library", "//pkg/private/ctrl/path_mgmt/proto:go_default_library", "//pkg/private/prom:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", "//pkg/proto/daemon:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/snet:go_default_library", "//pkg/snet/path:go_default_library", "//private/revcache:go_default_library", diff --git a/daemon/internal/servers/grpc.go b/daemon/internal/servers/grpc.go index 58f8a59837..76e35d517c 100644 --- a/daemon/internal/servers/grpc.go +++ b/daemon/internal/servers/grpc.go @@ -31,7 +31,6 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/drkey" "github.com/scionproto/scion/pkg/log" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt/proto" "github.com/scionproto/scion/pkg/private/prom" @@ -39,6 +38,7 @@ import ( "github.com/scionproto/scion/pkg/private/util" pb_daemon "github.com/scionproto/scion/pkg/proto/daemon" sdpb "github.com/scionproto/scion/pkg/proto/daemon" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/snet" snetpath "github.com/scionproto/scion/pkg/snet/path" "github.com/scionproto/scion/private/revcache" @@ -337,7 +337,7 @@ func (s *DaemonServer) notifyInterfaceDown(ctx context.Context, revInfo := &path_mgmt.RevInfo{ RawIsdas: addr.IA(req.IsdAs), - IfID: common.IfIDType(req.Id), + IfID: ifid.IfIDType(req.Id), LinkType: proto.LinkType_core, RawTTL: 10, RawTimestamp: util.TimeToSecs(time.Now()), diff --git a/gateway/pathhealth/BUILD.bazel b/gateway/pathhealth/BUILD.bazel index 96a0dc6a51..f497e9b642 100644 --- a/gateway/pathhealth/BUILD.bazel +++ b/gateway/pathhealth/BUILD.bazel @@ -33,9 +33,9 @@ go_test( deps = [ ":go_default_library", "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/ctrl/path_mgmt:go_default_library", "//pkg/private/util:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/snet:go_default_library", "//pkg/snet/mock_snet:go_default_library", "@com_github_golang_mock//gomock:go_default_library", diff --git a/gateway/pathhealth/revocations_test.go b/gateway/pathhealth/revocations_test.go index 8698fe891f..fbf891289f 100644 --- a/gateway/pathhealth/revocations_test.go +++ b/gateway/pathhealth/revocations_test.go @@ -24,9 +24,9 @@ import ( "github.com/scionproto/scion/gateway/pathhealth" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt" "github.com/scionproto/scion/pkg/private/util" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/snet" "github.com/scionproto/scion/pkg/snet/mock_snet" ) @@ -69,7 +69,7 @@ func TestExpiredRevocation(t *testing.T) { s.Cleanup(context.Background()) } -func createMockPath(ctrl *gomock.Controller, ia addr.IA, ifID common.IfIDType) snet.Path { +func createMockPath(ctrl *gomock.Controller, ia addr.IA, ifID ifid.IfIDType) snet.Path { path := mock_snet.NewMockPath(ctrl) path.EXPECT().Metadata().Return(&snet.PathMetadata{ Interfaces: []snet.PathInterface{{IA: ia, ID: ifID}}, @@ -77,7 +77,7 @@ func createMockPath(ctrl *gomock.Controller, ia addr.IA, ifID common.IfIDType) s return path } -func createRevInfo(ia addr.IA, ifID common.IfIDType, expired bool) *path_mgmt.RevInfo { +func createRevInfo(ia addr.IA, ifID ifid.IfIDType, expired bool) *path_mgmt.RevInfo { ri := &path_mgmt.RevInfo{ RawIsdas: ia, IfID: ifID, diff --git a/pkg/daemon/BUILD.bazel b/pkg/daemon/BUILD.bazel index 8a8ca23be8..825487a360 100644 --- a/pkg/daemon/BUILD.bazel +++ b/pkg/daemon/BUILD.bazel @@ -16,13 +16,13 @@ go_library( "//pkg/drkey:go_default_library", "//pkg/grpc:go_default_library", "//pkg/metrics:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/ctrl/path_mgmt:go_default_library", "//pkg/private/prom:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/proto/daemon:go_default_library", "//pkg/proto/drkey:go_default_library", "//pkg/scrypto/cppki:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/snet:go_default_library", "//pkg/snet/path:go_default_library", "//private/topology:go_default_library", diff --git a/pkg/daemon/grpc.go b/pkg/daemon/grpc.go index 92e4bb7507..c31e648dfb 100644 --- a/pkg/daemon/grpc.go +++ b/pkg/daemon/grpc.go @@ -27,12 +27,12 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/drkey" libgrpc "github.com/scionproto/scion/pkg/grpc" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt" "github.com/scionproto/scion/pkg/private/serrors" sdpb "github.com/scionproto/scion/pkg/proto/daemon" dkpb "github.com/scionproto/scion/pkg/proto/drkey" "github.com/scionproto/scion/pkg/scrypto/cppki" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/snet" "github.com/scionproto/scion/pkg/snet/path" "github.com/scionproto/scion/private/topology" @@ -260,7 +260,7 @@ func convertPath(p *sdpb.Path, dst addr.IA) (path.Path, error) { interfaces := make([]snet.PathInterface, len(p.Interfaces)) for i, pi := range p.Interfaces { interfaces[i] = snet.PathInterface{ - ID: common.IfIDType(pi.Id), + ID: ifid.IfIDType(pi.Id), IA: addr.IA(pi.IsdAs), } } diff --git a/pkg/experimental/hiddenpath/BUILD.bazel b/pkg/experimental/hiddenpath/BUILD.bazel index 3962a4665e..aba51abbb9 100644 --- a/pkg/experimental/hiddenpath/BUILD.bazel +++ b/pkg/experimental/hiddenpath/BUILD.bazel @@ -55,7 +55,6 @@ go_test( "//control/ifstate:go_default_library", "//pkg/addr:go_default_library", "//pkg/experimental/hiddenpath/mock_hiddenpath:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/xtest:go_default_library", "//pkg/private/xtest/graph:go_default_library", @@ -64,6 +63,7 @@ go_test( "//pkg/scrypto/cppki:go_default_library", "//pkg/scrypto/signed:go_default_library", "//pkg/segment:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/slayers/path/scion:go_default_library", "//pkg/snet:go_default_library", diff --git a/pkg/experimental/hiddenpath/beaconwriter_test.go b/pkg/experimental/hiddenpath/beaconwriter_test.go index d68c0b19c0..4cdacedb0b 100644 --- a/pkg/experimental/hiddenpath/beaconwriter_test.go +++ b/pkg/experimental/hiddenpath/beaconwriter_test.go @@ -37,7 +37,6 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/experimental/hiddenpath" "github.com/scionproto/scion/pkg/experimental/hiddenpath/mock_hiddenpath" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/xtest" "github.com/scionproto/scion/pkg/private/xtest/graph" cryptopb "github.com/scionproto/scion/pkg/proto/crypto" @@ -45,6 +44,7 @@ import ( "github.com/scionproto/scion/pkg/scrypto/cppki" "github.com/scionproto/scion/pkg/scrypto/signed" seg "github.com/scionproto/scion/pkg/segment" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/slayers/path/scion" "github.com/scionproto/scion/pkg/snet" "github.com/scionproto/scion/pkg/snet/addrutil" @@ -348,7 +348,7 @@ type topoWrap struct { } func (w topoWrap) UnderlayNextHop(id uint16) *net.UDPAddr { - a, _ := w.Topo.UnderlayNextHop(common.IfIDType(id)) + a, _ := w.Topo.UnderlayNextHop(ifid.IfIDType(id)) return a } diff --git a/pkg/private/common/BUILD.bazel b/pkg/private/common/BUILD.bazel index 36602cce10..5f6307f772 100644 --- a/pkg/private/common/BUILD.bazel +++ b/pkg/private/common/BUILD.bazel @@ -17,8 +17,5 @@ go_test( "errors_test.go", ], embed = [":go_default_library"], - deps = [ - "@com_github_stretchr_testify//assert:go_default_library", - "@com_github_stretchr_testify//require:go_default_library", - ], + deps = ["@com_github_stretchr_testify//assert:go_default_library"], ) diff --git a/pkg/private/common/defs.go b/pkg/private/common/defs.go index ae00ad94c7..59bf1e5f1d 100644 --- a/pkg/private/common/defs.go +++ b/pkg/private/common/defs.go @@ -15,11 +15,7 @@ package common -import ( - "reflect" - "strconv" - "strings" -) +import "reflect" const ( MinMTU = 1280 @@ -32,31 +28,6 @@ const ( TimeFmtSecs = "2006-01-02 15:04:05-0700" ) -// IfIDType is the type for interface IDs. -// -// Deprecated: with version 2 of the SCION header, there is no interface ID type anymore. -// Use the appropriate type depending on the path type. -type IfIDType uint64 - -func (ifID IfIDType) String() string { - return strconv.FormatUint(uint64(ifID), 10) -} - -// UnmarshalJSON unmarshals the JSON data into the IfID. -func (ifID *IfIDType) UnmarshalJSON(data []byte) error { - return ifID.UnmarshalText(data) -} - -// UnmarshalText unmarshals the text into the IfID. -func (ifID *IfIDType) UnmarshalText(text []byte) error { - i, err := strconv.ParseUint(strings.ReplaceAll(string(text), "\"", ""), 10, 64) - if err != nil { - return err - } - *ifID = IfIDType(i) - return nil -} - func TypeOf(v interface{}) string { t := reflect.TypeOf(v) if t != nil { diff --git a/pkg/private/common/defs_test.go b/pkg/private/common/defs_test.go index 218181b201..046d2ae334 100644 --- a/pkg/private/common/defs_test.go +++ b/pkg/private/common/defs_test.go @@ -15,13 +15,10 @@ package common_test import ( - "encoding/json" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/scionproto/scion/pkg/private/common" + "github.com/stretchr/testify/assert" ) func TestTypeOf(t *testing.T) { @@ -40,30 +37,3 @@ func TestTypeOf(t *testing.T) { }) } } - -func TestIfIDTypeUnmarshalJSON(t *testing.T) { - t.Run("Simple Value", func(t *testing.T) { - type exampleStruct struct { - IfID common.IfIDType `json:"if_id"` - } - j := `{"if_id": 5}` - var f exampleStruct - require.NoError(t, json.Unmarshal([]byte(j), &f)) - assert.Equal(t, exampleStruct{IfID: 5}, f) - }) - t.Run("Map keys", func(t *testing.T) { - type exampleStruct struct { - IfMap map[common.IfIDType]string `json:"if_map"` - } - j := `{"if_map": {"5": "foo"}}` - var f exampleStruct - require.NoError(t, json.Unmarshal([]byte(j), &f)) - assert.Equal(t, exampleStruct{IfMap: map[common.IfIDType]string{5: "foo"}}, f) - }) -} - -func TestIfIDTypeUnmarshalText(t *testing.T) { - var id common.IfIDType - assert.NoError(t, id.UnmarshalText([]byte("1"))) - assert.Equal(t, common.IfIDType(1), id) -} diff --git a/pkg/private/ctrl/path_mgmt/BUILD.bazel b/pkg/private/ctrl/path_mgmt/BUILD.bazel index 921b088259..7fbea1ceee 100644 --- a/pkg/private/ctrl/path_mgmt/BUILD.bazel +++ b/pkg/private/ctrl/path_mgmt/BUILD.bazel @@ -7,9 +7,9 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/ctrl/path_mgmt/proto:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", + "//pkg/segment/ifid:go_default_library", ], ) diff --git a/pkg/private/ctrl/path_mgmt/rev_info.go b/pkg/private/ctrl/path_mgmt/rev_info.go index 45b75ff82f..70b0fa65be 100644 --- a/pkg/private/ctrl/path_mgmt/rev_info.go +++ b/pkg/private/ctrl/path_mgmt/rev_info.go @@ -22,10 +22,10 @@ import ( "time" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt/proto" "github.com/scionproto/scion/pkg/private/serrors" "github.com/scionproto/scion/pkg/private/util" + "github.com/scionproto/scion/pkg/segment/ifid" ) const MinRevTTL = 10 * time.Second // MinRevTTL is the minimum lifetime of a revocation @@ -47,7 +47,7 @@ func (ee RevTimeError) Error() string { } type RevInfo struct { - IfID common.IfIDType + IfID ifid.IfIDType RawIsdas addr.IA // LinkType of revocation LinkType proto.LinkType diff --git a/pkg/private/xtest/graph/BUILD.bazel b/pkg/private/xtest/graph/BUILD.bazel index d5907cf9e5..f5c502c2c4 100644 --- a/pkg/private/xtest/graph/BUILD.bazel +++ b/pkg/private/xtest/graph/BUILD.bazel @@ -10,7 +10,6 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/proto/control_plane:go_default_library", "//pkg/proto/crypto:go_default_library", @@ -18,6 +17,7 @@ go_library( "//pkg/scrypto/signed:go_default_library", "//pkg/segment:go_default_library", "//pkg/segment/extensions/staticinfo:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/slayers/path:go_default_library", "@com_github_golang_mock//gomock:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", diff --git a/pkg/private/xtest/graph/graph.go b/pkg/private/xtest/graph/graph.go index a79a6063e4..9f0b72d14c 100644 --- a/pkg/private/xtest/graph/graph.go +++ b/pkg/private/xtest/graph/graph.go @@ -37,7 +37,6 @@ import ( "google.golang.org/protobuf/proto" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" cppb "github.com/scionproto/scion/pkg/proto/control_plane" cryptopb "github.com/scionproto/scion/pkg/proto/crypto" @@ -45,6 +44,7 @@ import ( "github.com/scionproto/scion/pkg/scrypto/signed" seg "github.com/scionproto/scion/pkg/segment" "github.com/scionproto/scion/pkg/segment/extensions/staticinfo" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/slayers/path" ) @@ -603,55 +603,55 @@ func generateStaticInfo(g *Graph, ia addr.IA, inIF, outIF uint16) *staticinfo.Ex latency := staticinfo.LatencyInfo{} if outIF != 0 { - latency.Intra = make(map[common.IfIDType]time.Duration) - latency.Inter = make(map[common.IfIDType]time.Duration) + latency.Intra = make(map[ifid.IfIDType]time.Duration) + latency.Inter = make(map[ifid.IfIDType]time.Duration) for ifID := range as.IfIDs { if ifID != outIF { // Note: the test graph does not distinguish between parent/child or // core interfaces. // Otherwise, we could skip the parent interfaces and half of the // sibling interfaces here. - latency.Intra[common.IfIDType(ifID)] = g.Latency(ifID, outIF) + latency.Intra[ifid.IfIDType(ifID)] = g.Latency(ifID, outIF) } if ifID == outIF || g.isPeer[ifID] { - latency.Inter[common.IfIDType(ifID)] = g.Latency(ifID, g.links[ifID]) + latency.Inter[ifid.IfIDType(ifID)] = g.Latency(ifID, g.links[ifID]) } } } bandwidth := staticinfo.BandwidthInfo{} if outIF != 0 { - bandwidth.Intra = make(map[common.IfIDType]uint64) - bandwidth.Inter = make(map[common.IfIDType]uint64) + bandwidth.Intra = make(map[ifid.IfIDType]uint64) + bandwidth.Inter = make(map[ifid.IfIDType]uint64) for ifID := range as.IfIDs { if ifID != outIF { - bandwidth.Intra[common.IfIDType(ifID)] = g.Bandwidth(ifID, outIF) + bandwidth.Intra[ifid.IfIDType(ifID)] = g.Bandwidth(ifID, outIF) } if ifID == outIF || g.isPeer[ifID] { - bandwidth.Inter[common.IfIDType(ifID)] = g.Bandwidth(ifID, g.links[ifID]) + bandwidth.Inter[ifid.IfIDType(ifID)] = g.Bandwidth(ifID, g.links[ifID]) } } } geo := make(staticinfo.GeoInfo) for ifID := range as.IfIDs { - geo[common.IfIDType(ifID)] = g.GeoCoordinates(ifID) + geo[ifid.IfIDType(ifID)] = g.GeoCoordinates(ifID) } linkType := make(staticinfo.LinkTypeInfo) for ifID := range as.IfIDs { - linkType[common.IfIDType(ifID)] = g.LinkType(ifID, g.links[ifID]) + linkType[ifid.IfIDType(ifID)] = g.LinkType(ifID, g.links[ifID]) } var internalHops staticinfo.InternalHopsInfo if outIF != 0 { - internalHops = make(map[common.IfIDType]uint32) + internalHops = make(map[ifid.IfIDType]uint32) if inIF != 0 { - internalHops[common.IfIDType(inIF)] = g.InternalHops(inIF, outIF) + internalHops[ifid.IfIDType(inIF)] = g.InternalHops(inIF, outIF) } for ifID := range as.IfIDs { if ifID != outIF && ifID != inIF { - internalHops[common.IfIDType(ifID)] = g.InternalHops(ifID, outIF) + internalHops[ifid.IfIDType(ifID)] = g.InternalHops(ifID, outIF) } } } diff --git a/pkg/segment/extensions/staticinfo/BUILD.bazel b/pkg/segment/extensions/staticinfo/BUILD.bazel index b41404d42e..3debee5c35 100644 --- a/pkg/segment/extensions/staticinfo/BUILD.bazel +++ b/pkg/segment/extensions/staticinfo/BUILD.bazel @@ -6,8 +6,8 @@ go_library( importpath = "github.com/scionproto/scion/pkg/segment/extensions/staticinfo", visibility = ["//visibility:public"], deps = [ - "//pkg/private/common:go_default_library", "//pkg/proto/control_plane:go_default_library", + "//pkg/segment/ifid:go_default_library", ], ) @@ -16,7 +16,7 @@ go_test( srcs = ["staticinfo_test.go"], deps = [ ":go_default_library", - "//pkg/private/common:go_default_library", + "//pkg/segment/ifid:go_default_library", "@com_github_stretchr_testify//assert:go_default_library", ], ) diff --git a/pkg/segment/extensions/staticinfo/staticinfo.go b/pkg/segment/extensions/staticinfo/staticinfo.go index 83c7073151..6fb9d06eac 100644 --- a/pkg/segment/extensions/staticinfo/staticinfo.go +++ b/pkg/segment/extensions/staticinfo/staticinfo.go @@ -21,8 +21,8 @@ package staticinfo import ( "time" - "github.com/scionproto/scion/pkg/private/common" cppb "github.com/scionproto/scion/pkg/proto/control_plane" + "github.com/scionproto/scion/pkg/segment/ifid" ) // Extension is the internal repesentation of the StaticInfoExtension path @@ -39,20 +39,20 @@ type Extension struct { // LatencyInfo is the internal repesentation of `latency` in the // StaticInfoExtension. type LatencyInfo struct { - Intra map[common.IfIDType]time.Duration - Inter map[common.IfIDType]time.Duration + Intra map[ifid.IfIDType]time.Duration + Inter map[ifid.IfIDType]time.Duration } // BandwidthInfo is the internal repesentation of `bandwidth` in the // StaticInfoExtension. type BandwidthInfo struct { - Intra map[common.IfIDType]uint64 - Inter map[common.IfIDType]uint64 + Intra map[ifid.IfIDType]uint64 + Inter map[ifid.IfIDType]uint64 } // GeoInfo is the internal repesentation of `geo` in the // StaticInfoExtension. -type GeoInfo map[common.IfIDType]GeoCoordinates +type GeoInfo map[ifid.IfIDType]GeoCoordinates // GeoCoordinates is the internal repesentation of the GeoCoordinates in the // StaticInfoExtension. @@ -76,11 +76,11 @@ const ( // LinkTypeInfo is the internal representation of `link_type` in the // StaticInfoExtension. -type LinkTypeInfo map[common.IfIDType]LinkType +type LinkTypeInfo map[ifid.IfIDType]LinkType // InternalHopsInfo is the internal representation of `internal_hops` in the // StaticInfoExtension. -type InternalHopsInfo map[common.IfIDType]uint32 +type InternalHopsInfo map[ifid.IfIDType]uint32 // FromPB creates the staticinfo Extension from the protobuf representation. func FromPB(pb *cppb.StaticInfoExtension) *Extension { @@ -101,13 +101,13 @@ func latencyInfoFromPB(pb *cppb.LatencyInfo) LatencyInfo { if pb == nil || len(pb.Intra) == 0 && len(pb.Inter) == 0 { return LatencyInfo{} } - intra := make(map[common.IfIDType]time.Duration, len(pb.Intra)) + intra := make(map[ifid.IfIDType]time.Duration, len(pb.Intra)) for ifID, v := range pb.Intra { - intra[common.IfIDType(ifID)] = time.Duration(v) * time.Microsecond + intra[ifid.IfIDType(ifID)] = time.Duration(v) * time.Microsecond } - inter := make(map[common.IfIDType]time.Duration, len(pb.Inter)) + inter := make(map[ifid.IfIDType]time.Duration, len(pb.Inter)) for ifID, v := range pb.Inter { - inter[common.IfIDType(ifID)] = time.Duration(v) * time.Microsecond + inter[ifid.IfIDType(ifID)] = time.Duration(v) * time.Microsecond } return LatencyInfo{ Intra: intra, @@ -119,13 +119,13 @@ func bandwidthInfoFromPB(pb *cppb.BandwidthInfo) BandwidthInfo { if pb == nil || len(pb.Intra) == 0 && len(pb.Inter) == 0 { return BandwidthInfo{} } - intra := make(map[common.IfIDType]uint64, len(pb.Intra)) + intra := make(map[ifid.IfIDType]uint64, len(pb.Intra)) for ifID, v := range pb.Intra { - intra[common.IfIDType(ifID)] = v + intra[ifid.IfIDType(ifID)] = v } - inter := make(map[common.IfIDType]uint64, len(pb.Inter)) + inter := make(map[ifid.IfIDType]uint64, len(pb.Inter)) for ifID, v := range pb.Inter { - inter[common.IfIDType(ifID)] = v + inter[ifid.IfIDType(ifID)] = v } return BandwidthInfo{ Intra: intra, @@ -139,7 +139,7 @@ func geoInfoFromPB(pb map[uint64]*cppb.GeoCoordinates) GeoInfo { } gi := make(GeoInfo, len(pb)) for ifID, v := range pb { - gi[common.IfIDType(ifID)] = GeoCoordinates{ + gi[ifid.IfIDType(ifID)] = GeoCoordinates{ Latitude: v.Latitude, Longitude: v.Longitude, Address: v.Address, @@ -167,7 +167,7 @@ func linkTypeInfoFromPB(pb map[uint64]cppb.LinkType) LinkTypeInfo { default: continue } - lti[common.IfIDType(ifID)] = v + lti[ifid.IfIDType(ifID)] = v } return lti } @@ -178,7 +178,7 @@ func internalHopsInfoFromPB(pb map[uint64]uint32) InternalHopsInfo { } ihi := make(InternalHopsInfo, len(pb)) for ifID, v := range pb { - ihi[common.IfIDType(ifID)] = v + ihi[ifid.IfIDType(ifID)] = v } return ihi } diff --git a/pkg/segment/extensions/staticinfo/staticinfo_test.go b/pkg/segment/extensions/staticinfo/staticinfo_test.go index 42c9bff6bf..a81a6194d8 100644 --- a/pkg/segment/extensions/staticinfo/staticinfo_test.go +++ b/pkg/segment/extensions/staticinfo/staticinfo_test.go @@ -20,8 +20,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/segment/extensions/staticinfo" + "github.com/scionproto/scion/pkg/segment/ifid" ) func TestRoundtripStaticInfoExtension(t *testing.T) { @@ -34,22 +34,22 @@ func TestRoundtripStaticInfoExtension(t *testing.T) { }, "latency": { Latency: staticinfo.LatencyInfo{ - Intra: map[common.IfIDType]time.Duration{ + Intra: map[ifid.IfIDType]time.Duration{ 10: 10 * time.Millisecond, 11: 11 * time.Millisecond, }, - Inter: map[common.IfIDType]time.Duration{ + Inter: map[ifid.IfIDType]time.Duration{ 11: 111 * time.Millisecond, }, }, }, "bandwidth": { Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[common.IfIDType]uint64{ + Intra: map[ifid.IfIDType]uint64{ 10: 1, // 1Kbit/s 11: 10_000_000_000, // 10Tbit/s }, - Inter: map[common.IfIDType]uint64{ + Inter: map[ifid.IfIDType]uint64{ 11: 2_000_000, }, }, @@ -71,7 +71,7 @@ func TestRoundtripStaticInfoExtension(t *testing.T) { }, }, "internal_hops": { - InternalHops: map[common.IfIDType]uint32{ + InternalHops: map[ifid.IfIDType]uint32{ 10: 2, 11: 3, }, diff --git a/pkg/segment/ifid/BUILD.bazel b/pkg/segment/ifid/BUILD.bazel new file mode 100644 index 0000000000..57ca66d351 --- /dev/null +++ b/pkg/segment/ifid/BUILD.bazel @@ -0,0 +1,18 @@ +load("//tools/lint:go.bzl", "go_library", "go_test") + +go_library( + name = "go_default_library", + srcs = ["ifid.go"], + importpath = "github.com/scionproto/scion/pkg/segment/ifid", + visibility = ["//visibility:public"], +) + +go_test( + name = "go_default_test", + srcs = ["ifid_test.go"], + deps = [ + ":go_default_library", + "@com_github_stretchr_testify//assert:go_default_library", + "@com_github_stretchr_testify//require:go_default_library", + ], +) diff --git a/pkg/segment/ifid/ifid.go b/pkg/segment/ifid/ifid.go new file mode 100644 index 0000000000..56f365be19 --- /dev/null +++ b/pkg/segment/ifid/ifid.go @@ -0,0 +1,45 @@ +// Copyright 2016 ETH Zurich +// Copyright 2018 ETH Zurich, Anapaya Systems +// +// 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 ifid + +import ( + "strconv" + "strings" +) + +// IfIDType is the path-type-independant type for interface IDs. Interface IDs must fit in +// 64 bits. There is a lot of path-type-independant code that manipulates interface IDs without +// interpreting them. This type is a container for them. +type IfIDType uint64 + +func (ifID IfIDType) String() string { + return strconv.FormatUint(uint64(ifID), 10) +} + +// UnmarshalJSON unmarshals the JSON data into the IfID. +func (ifID *IfIDType) UnmarshalJSON(data []byte) error { + return ifID.UnmarshalText(data) +} + +// UnmarshalText unmarshals the text into the IfID. +func (ifID *IfIDType) UnmarshalText(text []byte) error { + i, err := strconv.ParseUint(strings.ReplaceAll(string(text), "\"", ""), 10, 64) + if err != nil { + return err + } + *ifID = IfIDType(i) + return nil +} diff --git a/pkg/segment/ifid/ifid_test.go b/pkg/segment/ifid/ifid_test.go new file mode 100644 index 0000000000..7991a18d44 --- /dev/null +++ b/pkg/segment/ifid/ifid_test.go @@ -0,0 +1,52 @@ +// Copyright 2024 SCION Association +// +// 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 ifid_test + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/scionproto/scion/pkg/segment/ifid" +) + +func TestIfIDTypeUnmarshalJSON(t *testing.T) { + t.Run("Simple Value", func(t *testing.T) { + type exampleStruct struct { + IfID ifid.IfIDType `json:"if_id"` + } + j := `{"if_id": 5}` + var f exampleStruct + require.NoError(t, json.Unmarshal([]byte(j), &f)) + assert.Equal(t, exampleStruct{IfID: 5}, f) + }) + t.Run("Map keys", func(t *testing.T) { + type exampleStruct struct { + IfMap map[ifid.IfIDType]string `json:"if_map"` + } + j := `{"if_map": {"5": "foo"}}` + var f exampleStruct + require.NoError(t, json.Unmarshal([]byte(j), &f)) + assert.Equal(t, exampleStruct{IfMap: map[ifid.IfIDType]string{5: "foo"}}, f) + }) +} + +func TestIfIDTypeUnmarshalText(t *testing.T) { + var id ifid.IfIDType + assert.NoError(t, id.UnmarshalText([]byte("1"))) + assert.Equal(t, ifid.IfIDType(1), id) +} diff --git a/pkg/snet/BUILD.bazel b/pkg/snet/BUILD.bazel index 0c07539843..032d60980d 100644 --- a/pkg/snet/BUILD.bazel +++ b/pkg/snet/BUILD.bazel @@ -27,6 +27,7 @@ go_library( "//pkg/private/ctrl/path_mgmt:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/slayers:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/slayers/path/empty:go_default_library", diff --git a/pkg/snet/path.go b/pkg/snet/path.go index b6c48df30f..1507e41131 100644 --- a/pkg/snet/path.go +++ b/pkg/snet/path.go @@ -22,7 +22,7 @@ import ( "time" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/slayers" ) @@ -70,7 +70,7 @@ type Path interface { // PathInterface is an interface of the path. type PathInterface struct { // ID is the ID of the interface. - ID common.IfIDType + ID ifid.IfIDType // IA is the ISD AS identifier of the interface. IA addr.IA } diff --git a/pkg/snet/scmp.go b/pkg/snet/scmp.go index e759d057c0..ea830976b4 100644 --- a/pkg/snet/scmp.go +++ b/pkg/snet/scmp.go @@ -20,10 +20,10 @@ import ( "github.com/scionproto/scion/pkg/log" "github.com/scionproto/scion/pkg/metrics/v2" - "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/private/util" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/slayers" ) @@ -73,7 +73,7 @@ func (h DefaultSCMPHandler) Handle(pkt *Packet) error { case slayers.SCMPTypeExternalInterfaceDown: msg := pkt.Payload.(SCMPExternalInterfaceDown) return h.handleSCMPRev(typeCode, &path_mgmt.RevInfo{ - IfID: common.IfIDType(msg.Interface), + IfID: ifid.IfIDType(msg.Interface), RawIsdas: msg.IA, RawTimestamp: util.TimeToSecs(time.Now()), RawTTL: 10, @@ -81,7 +81,7 @@ func (h DefaultSCMPHandler) Handle(pkt *Packet) error { case slayers.SCMPTypeInternalConnectivityDown: msg := pkt.Payload.(SCMPInternalConnectivityDown) return h.handleSCMPRev(typeCode, &path_mgmt.RevInfo{ - IfID: common.IfIDType(msg.Egress), + IfID: ifid.IfIDType(msg.Egress), RawIsdas: msg.IA, RawTimestamp: util.TimeToSecs(time.Now()), RawTTL: 10, diff --git a/private/path/combinator/BUILD.bazel b/private/path/combinator/BUILD.bazel index fdd55e4adf..b972044c14 100644 --- a/private/path/combinator/BUILD.bazel +++ b/private/path/combinator/BUILD.bazel @@ -11,11 +11,11 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/ctrl/path_mgmt/proto:go_default_library", "//pkg/private/util:go_default_library", "//pkg/segment:go_default_library", "//pkg/segment/extensions/staticinfo:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/slayers/path/scion:go_default_library", "//pkg/snet:go_default_library", @@ -35,10 +35,10 @@ go_test( embed = [":go_default_library"], deps = [ "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/xtest:go_default_library", "//pkg/private/xtest/graph:go_default_library", "//pkg/segment:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/slayers/path/scion:go_default_library", "//pkg/snet:go_default_library", diff --git a/private/path/combinator/combinator_test.go b/private/path/combinator/combinator_test.go index 15bb1b6d4e..dfa9728be5 100644 --- a/private/path/combinator/combinator_test.go +++ b/private/path/combinator/combinator_test.go @@ -28,10 +28,10 @@ import ( "github.com/stretchr/testify/require" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/xtest" "github.com/scionproto/scion/pkg/private/xtest/graph" seg "github.com/scionproto/scion/pkg/segment" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/slayers/path" "github.com/scionproto/scion/pkg/slayers/path/scion" "github.com/scionproto/scion/pkg/snet" @@ -547,20 +547,20 @@ func TestFilterDuplicates(t *testing.T) { // These look somewhat valid, but that doesn't matter at all -- we only look // at the fingerprint anyway. path0 := []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:110"), ID: common.IfIDType(10)}, - {IA: addr.MustParseIA("1-ff00:0:111"), ID: common.IfIDType(10)}, + {IA: addr.MustParseIA("1-ff00:0:110"), ID: ifid.IfIDType(10)}, + {IA: addr.MustParseIA("1-ff00:0:111"), ID: ifid.IfIDType(10)}, } path1 := []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:110"), ID: common.IfIDType(11)}, - {IA: addr.MustParseIA("1-ff00:0:112"), ID: common.IfIDType(11)}, - {IA: addr.MustParseIA("1-ff00:0:112"), ID: common.IfIDType(12)}, - {IA: addr.MustParseIA("1-ff00:0:111"), ID: common.IfIDType(12)}, + {IA: addr.MustParseIA("1-ff00:0:110"), ID: ifid.IfIDType(11)}, + {IA: addr.MustParseIA("1-ff00:0:112"), ID: ifid.IfIDType(11)}, + {IA: addr.MustParseIA("1-ff00:0:112"), ID: ifid.IfIDType(12)}, + {IA: addr.MustParseIA("1-ff00:0:111"), ID: ifid.IfIDType(12)}, } path2 := []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:110"), ID: common.IfIDType(11)}, - {IA: addr.MustParseIA("1-ff00:0:112"), ID: common.IfIDType(11)}, - {IA: addr.MustParseIA("1-ff00:0:112"), ID: common.IfIDType(22)}, - {IA: addr.MustParseIA("1-ff00:0:111"), ID: common.IfIDType(22)}, + {IA: addr.MustParseIA("1-ff00:0:110"), ID: ifid.IfIDType(11)}, + {IA: addr.MustParseIA("1-ff00:0:112"), ID: ifid.IfIDType(11)}, + {IA: addr.MustParseIA("1-ff00:0:112"), ID: ifid.IfIDType(22)}, + {IA: addr.MustParseIA("1-ff00:0:111"), ID: ifid.IfIDType(22)}, } // Define two expiry times for the paths: paths with latest expiry will be kept diff --git a/private/path/combinator/graph.go b/private/path/combinator/graph.go index 447c2a97bc..e436bea84c 100644 --- a/private/path/combinator/graph.go +++ b/private/path/combinator/graph.go @@ -23,10 +23,10 @@ import ( "time" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt/proto" "github.com/scionproto/scion/pkg/private/util" seg "github.com/scionproto/scion/pkg/segment" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/slayers/path" "github.com/scionproto/scion/pkg/slayers/path/scion" "github.com/scionproto/scion/pkg/snet" @@ -146,8 +146,8 @@ func (g *dmg) traverseSegment(segment *inputSegment) { } for peerEntryIdx, peer := range asEntries[asEntryIndex].PeerEntries { - ingress := common.IfIDType(peer.HopField.ConsIngress) - remote := common.IfIDType(peer.PeerInterface) + ingress := ifid.IfIDType(peer.HopField.ConsIngress) + remote := ifid.IfIDType(peer.PeerInterface) tuples = append(tuples, Tuple{ Src: vertexFromIA(pinnedIA), Dst: vertexFromPeering(currentIA, ingress, peer.Peer, remote), @@ -259,17 +259,17 @@ func (s *inputSegment) IsDownSeg() bool { type vertex struct { IA addr.IA UpIA addr.IA - UpIfID common.IfIDType + UpIfID ifid.IfIDType DownIA addr.IA - DownIfID common.IfIDType + DownIfID ifid.IfIDType } func vertexFromIA(ia addr.IA) vertex { return vertex{IA: ia} } -func vertexFromPeering(upIA addr.IA, upIfID common.IfIDType, - downIA addr.IA, downIfID common.IfIDType) vertex { +func vertexFromPeering(upIA addr.IA, upIfID ifid.IfIDType, + downIA addr.IA, downIfID ifid.IfIDType) vertex { return vertex{UpIA: upIA, UpIfID: upIfID, DownIA: downIA, DownIfID: downIfID} } @@ -365,14 +365,14 @@ func (solution *pathSolution) Path() Path { if hopField.ConsEgress != 0 { intfs = append(intfs, snet.PathInterface{ IA: asEntry.Local, - ID: common.IfIDType(hopField.ConsEgress), + ID: ifid.IfIDType(hopField.ConsEgress), }) } // In a non-peer shortcut the AS is not traversed completely. if hopField.ConsIngress != 0 && (!isShortcut || isPeer) { intfs = append(intfs, snet.PathInterface{ IA: asEntry.Local, - ID: common.IfIDType(hopField.ConsIngress), + ID: ifid.IfIDType(hopField.ConsIngress), }) } hops = append(hops, hopField) diff --git a/private/path/combinator/staticinfo_accumulator.go b/private/path/combinator/staticinfo_accumulator.go index 383bead4e0..cbddf0c6f8 100644 --- a/private/path/combinator/staticinfo_accumulator.go +++ b/private/path/combinator/staticinfo_accumulator.go @@ -19,9 +19,9 @@ import ( "time" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" seg "github.com/scionproto/scion/pkg/segment" "github.com/scionproto/scion/pkg/segment/extensions/staticinfo" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/snet" ) @@ -85,7 +85,7 @@ func collectLatency(p pathInfo) []time.Duration { } egIF := snet.PathInterface{ IA: asEntry.Local, - ID: common.IfIDType(asEntry.HopEntry.HopField.ConsEgress), + ID: ifid.IfIDType(asEntry.HopEntry.HopField.ConsEgress), } latency := staticInfo.Latency // Egress to sibling child, core or peer interfaces @@ -140,7 +140,7 @@ func collectBandwidth(p pathInfo) []uint64 { } egIF := snet.PathInterface{ IA: asEntry.Local, - ID: common.IfIDType(asEntry.HopEntry.HopField.ConsEgress), + ID: ifid.IfIDType(asEntry.HopEntry.HopField.ConsEgress), } bandwidth := staticInfo.Bandwidth // Egress to other local interfaces @@ -265,7 +265,7 @@ func collectInternalHops(p pathInfo) []uint32 { } egIF := snet.PathInterface{ IA: asEntry.Local, - ID: common.IfIDType(asEntry.HopEntry.HopField.ConsEgress), + ID: ifid.IfIDType(asEntry.HopEntry.HopField.ConsEgress), } internalHops := staticInfo.InternalHops for ifID, v := range internalHops { diff --git a/private/path/combinator/staticinfo_accumulator_test.go b/private/path/combinator/staticinfo_accumulator_test.go index 1bfe056356..a3ba14c5a1 100644 --- a/private/path/combinator/staticinfo_accumulator_test.go +++ b/private/path/combinator/staticinfo_accumulator_test.go @@ -23,9 +23,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/xtest/graph" seg "github.com/scionproto/scion/pkg/segment" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/snet" ) @@ -42,12 +42,12 @@ func TestStaticinfo(t *testing.T) { { Name: "#0 simple up-core-down", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:131"), ID: common.IfIDType(graph.If_131_X_130_A)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: common.IfIDType(graph.If_130_A_131_X)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: common.IfIDType(graph.If_130_B_120_A)}, - {IA: addr.MustParseIA("1-ff00:0:120"), ID: common.IfIDType(graph.If_120_A_130_B)}, - {IA: addr.MustParseIA("1-ff00:0:120"), ID: common.IfIDType(graph.If_120_X_111_B)}, - {IA: addr.MustParseIA("1-ff00:0:111"), ID: common.IfIDType(graph.If_111_B_120_X)}, + {IA: addr.MustParseIA("1-ff00:0:131"), ID: ifid.IfIDType(graph.If_131_X_130_A)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: ifid.IfIDType(graph.If_130_A_131_X)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: ifid.IfIDType(graph.If_130_B_120_A)}, + {IA: addr.MustParseIA("1-ff00:0:120"), ID: ifid.IfIDType(graph.If_120_A_130_B)}, + {IA: addr.MustParseIA("1-ff00:0:120"), ID: ifid.IfIDType(graph.If_120_X_111_B)}, + {IA: addr.MustParseIA("1-ff00:0:111"), ID: ifid.IfIDType(graph.If_111_B_120_X)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_130_A_131_X}, @@ -58,10 +58,10 @@ func TestStaticinfo(t *testing.T) { { Name: "#1 simple up-core", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:131"), ID: common.IfIDType(graph.If_131_X_130_A)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: common.IfIDType(graph.If_130_A_131_X)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: common.IfIDType(graph.If_130_A_110_X)}, - {IA: addr.MustParseIA("1-ff00:0:110"), ID: common.IfIDType(graph.If_110_X_130_A)}, + {IA: addr.MustParseIA("1-ff00:0:131"), ID: ifid.IfIDType(graph.If_131_X_130_A)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: ifid.IfIDType(graph.If_130_A_131_X)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: ifid.IfIDType(graph.If_130_A_110_X)}, + {IA: addr.MustParseIA("1-ff00:0:110"), ID: ifid.IfIDType(graph.If_110_X_130_A)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_130_A_131_X}, @@ -72,8 +72,8 @@ func TestStaticinfo(t *testing.T) { { Name: "#2 simple up only", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:131"), ID: common.IfIDType(graph.If_131_X_130_A)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: common.IfIDType(graph.If_130_A_131_X)}, + {IA: addr.MustParseIA("1-ff00:0:131"), ID: ifid.IfIDType(graph.If_131_X_130_A)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: ifid.IfIDType(graph.If_130_A_131_X)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_130_A_131_X}, @@ -84,10 +84,10 @@ func TestStaticinfo(t *testing.T) { { Name: "#14 shortcut, common upstream", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("2-ff00:0:212"), ID: common.IfIDType(graph.If_212_X_211_A1)}, - {IA: addr.MustParseIA("2-ff00:0:211"), ID: common.IfIDType(graph.If_211_A1_212_X)}, - {IA: addr.MustParseIA("2-ff00:0:211"), ID: common.IfIDType(graph.If_211_A_222_X)}, - {IA: addr.MustParseIA("2-ff00:0:222"), ID: common.IfIDType(graph.If_222_X_211_A)}, + {IA: addr.MustParseIA("2-ff00:0:212"), ID: ifid.IfIDType(graph.If_212_X_211_A1)}, + {IA: addr.MustParseIA("2-ff00:0:211"), ID: ifid.IfIDType(graph.If_211_A1_212_X)}, + {IA: addr.MustParseIA("2-ff00:0:211"), ID: ifid.IfIDType(graph.If_211_A_222_X)}, + {IA: addr.MustParseIA("2-ff00:0:222"), ID: ifid.IfIDType(graph.If_222_X_211_A)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_210_X1_211_A, graph.If_211_A1_212_X}, @@ -98,12 +98,12 @@ func TestStaticinfo(t *testing.T) { { Name: "#15 go through peer", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("2-ff00:0:212"), ID: common.IfIDType(graph.If_212_X_211_A1)}, - {IA: addr.MustParseIA("2-ff00:0:211"), ID: common.IfIDType(graph.If_211_A1_212_X)}, - {IA: addr.MustParseIA("2-ff00:0:211"), ID: common.IfIDType(graph.If_211_A_221_X)}, - {IA: addr.MustParseIA("2-ff00:0:221"), ID: common.IfIDType(graph.If_221_X_211_A)}, - {IA: addr.MustParseIA("2-ff00:0:221"), ID: common.IfIDType(graph.If_221_X_222_X)}, - {IA: addr.MustParseIA("2-ff00:0:222"), ID: common.IfIDType(graph.If_222_X_221_X)}, + {IA: addr.MustParseIA("2-ff00:0:212"), ID: ifid.IfIDType(graph.If_212_X_211_A1)}, + {IA: addr.MustParseIA("2-ff00:0:211"), ID: ifid.IfIDType(graph.If_211_A1_212_X)}, + {IA: addr.MustParseIA("2-ff00:0:211"), ID: ifid.IfIDType(graph.If_211_A_221_X)}, + {IA: addr.MustParseIA("2-ff00:0:221"), ID: ifid.IfIDType(graph.If_221_X_211_A)}, + {IA: addr.MustParseIA("2-ff00:0:221"), ID: ifid.IfIDType(graph.If_221_X_222_X)}, + {IA: addr.MustParseIA("2-ff00:0:222"), ID: ifid.IfIDType(graph.If_222_X_221_X)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_210_X1_211_A, graph.If_211_A1_212_X}, diff --git a/private/path/pathpol/BUILD.bazel b/private/path/pathpol/BUILD.bazel index a85b5f97a0..74e6af2762 100644 --- a/private/path/pathpol/BUILD.bazel +++ b/private/path/pathpol/BUILD.bazel @@ -16,8 +16,8 @@ go_library( "//antlr/sequence:go_default_library", "//pkg/addr:go_default_library", "//pkg/log:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/serrors:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/snet:go_default_library", "@com_github_antlr_antlr4_runtime_go_antlr//:go_default_library", ], @@ -36,8 +36,8 @@ go_test( embed = [":go_default_library"], deps = [ "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/xtest/graph:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/snet:go_default_library", "//pkg/snet/mock_snet:go_default_library", "//pkg/snet/path:go_default_library", diff --git a/private/path/pathpol/acl_test.go b/private/path/pathpol/acl_test.go index 1bdb412832..9e97fd6f38 100644 --- a/private/path/pathpol/acl_test.go +++ b/private/path/pathpol/acl_test.go @@ -23,7 +23,7 @@ import ( "gopkg.in/yaml.v2" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" + "github.com/scionproto/scion/pkg/segment/ifid" ) func TestNewACL(t *testing.T) { @@ -113,7 +113,7 @@ func TestACLEntryLoadFromString(t *testing.T) { String: "+ 0", ACLEntry: ACLEntry{ Action: Allow, - Rule: &HopPredicate{IfIDs: []common.IfIDType{0}}, + Rule: &HopPredicate{IfIDs: []ifid.IfIDType{0}}, }, ErrorAssertion: assert.NoError, }, @@ -121,7 +121,7 @@ func TestACLEntryLoadFromString(t *testing.T) { String: "+ 1-2#3", ACLEntry: ACLEntry{ Action: Allow, - Rule: &HopPredicate{ISD: 1, AS: 2, IfIDs: []common.IfIDType{3}}, + Rule: &HopPredicate{ISD: 1, AS: 2, IfIDs: []ifid.IfIDType{3}}, }, ErrorAssertion: assert.NoError, }, @@ -134,7 +134,7 @@ func TestACLEntryLoadFromString(t *testing.T) { String: "- 0", ACLEntry: ACLEntry{ Action: Deny, - Rule: &HopPredicate{IfIDs: []common.IfIDType{0}}, + Rule: &HopPredicate{IfIDs: []ifid.IfIDType{0}}, }, ErrorAssertion: assert.NoError, }, @@ -161,7 +161,7 @@ func TestACLEntryLoadFromString(t *testing.T) { func TestACLEntryString(t *testing.T) { aclEntryString := "+ 0-0#0" - aclEntry := &ACLEntry{Action: true, Rule: &HopPredicate{IfIDs: []common.IfIDType{0}}} + aclEntry := &ACLEntry{Action: true, Rule: &HopPredicate{IfIDs: []ifid.IfIDType{0}}} assert.Equal(t, aclEntryString, aclEntry.String()) } diff --git a/private/path/pathpol/hop_pred.go b/private/path/pathpol/hop_pred.go index 28980c8296..e7920d8234 100644 --- a/private/path/pathpol/hop_pred.go +++ b/private/path/pathpol/hop_pred.go @@ -22,8 +22,8 @@ import ( "strings" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/snet" ) @@ -32,11 +32,11 @@ import ( type HopPredicate struct { ISD addr.ISD AS addr.AS - IfIDs []common.IfIDType + IfIDs []ifid.IfIDType } func NewHopPredicate() *HopPredicate { - return &HopPredicate{IfIDs: make([]common.IfIDType, 1)} + return &HopPredicate{IfIDs: make([]ifid.IfIDType, 1)} } func HopPredicateFromString(str string) (*HopPredicate, error) { @@ -44,7 +44,7 @@ func HopPredicateFromString(str string) (*HopPredicate, error) { if err = validateHopPredStr(str); err != nil { return &HopPredicate{}, err } - var ifIDs = make([]common.IfIDType, 1) + var ifIDs = make([]ifid.IfIDType, 1) // Parse ISD dashParts := strings.Split(str, "-") isd, err := addr.ParseISD(dashParts[0]) @@ -136,12 +136,12 @@ func (hp *HopPredicate) UnmarshalJSON(b []byte) error { return err } -func parseIfID(str string) (common.IfIDType, error) { +func parseIfID(str string) (ifid.IfIDType, error) { ifID, err := strconv.ParseUint(str, 10, 64) if err != nil { return 0, err } - return common.IfIDType(ifID), nil + return ifid.IfIDType(ifID), nil } // validateHopPredStr checks if str has the correct amount of delimiters diff --git a/private/path/pathpol/hop_pred_test.go b/private/path/pathpol/hop_pred_test.go index fa2cd76e70..a0ced32546 100644 --- a/private/path/pathpol/hop_pred_test.go +++ b/private/path/pathpol/hop_pred_test.go @@ -21,7 +21,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/scionproto/scion/pkg/private/common" + "github.com/scionproto/scion/pkg/segment/ifid" ) func TestNewHopPredicate(t *testing.T) { @@ -32,22 +32,22 @@ func TestNewHopPredicate(t *testing.T) { }{ "ISD wildcard": { In: "0", - HP: &HopPredicate{ISD: 0, AS: 0, IfIDs: []common.IfIDType{0}}, + HP: &HopPredicate{ISD: 0, AS: 0, IfIDs: []ifid.IfIDType{0}}, Valid: true, }, "AS, IF wildcard omitted": { In: "1", - HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []common.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []ifid.IfIDType{0}}, Valid: true, }, "IF wildcard omitted": { In: "1-0", - HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []common.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []ifid.IfIDType{0}}, Valid: true, }, "basic wildcard": { In: "1-0#0", - HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []common.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []ifid.IfIDType{0}}, Valid: true, }, "AS wildcard, interface set": { @@ -56,27 +56,27 @@ func TestNewHopPredicate(t *testing.T) { }, "ISD wildcard, AS set": { In: "0-1#0", - HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []common.IfIDType{0}}, + HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []ifid.IfIDType{0}}, Valid: true, }, "ISD wildcard, AS set, interface set": { In: "0-1#2", - HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []common.IfIDType{2}}, + HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []ifid.IfIDType{2}}, Valid: true, }, "ISD wildcard, AS set and interface omitted": { In: "0-1", - HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []common.IfIDType{0}}, + HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []ifid.IfIDType{0}}, Valid: true, }, "IF wildcard omitted, AS set": { In: "1-2", - HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []common.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []ifid.IfIDType{0}}, Valid: true, }, "two IfIDs": { In: "1-2#3,4", - HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []common.IfIDType{3, 4}}, + HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []ifid.IfIDType{3, 4}}, Valid: true, }, "three IfIDs": { @@ -140,13 +140,13 @@ func TestJsonConversion(t *testing.T) { HP *HopPredicate }{ "Normal predicate": { - HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []common.IfIDType{1, 2}}, + HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []ifid.IfIDType{1, 2}}, }, "wildcard predicate": { - HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []common.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []ifid.IfIDType{0}}, }, "only ifIDs": { - HP: &HopPredicate{IfIDs: []common.IfIDType{0}}, + HP: &HopPredicate{IfIDs: []ifid.IfIDType{0}}, }, } for name, test := range tests { diff --git a/private/path/pathpol/policy_test.go b/private/path/pathpol/policy_test.go index 5e07e38508..d9edfc57c9 100644 --- a/private/path/pathpol/policy_test.go +++ b/private/path/pathpol/policy_test.go @@ -24,8 +24,8 @@ import ( "github.com/stretchr/testify/require" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/xtest/graph" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/snet" snetpath "github.com/scionproto/scion/pkg/snet/path" ) @@ -648,7 +648,7 @@ func (p PathProvider) GetPaths(src, dst addr.IA) []snet.Path { ia := p.g.GetParent(ifID) pathIntfs = append(pathIntfs, snet.PathInterface{ IA: ia, - ID: common.IfIDType(ifID), + ID: ifid.IfIDType(ifID), }) } var srcIA, dstIA addr.IA diff --git a/private/path/pathpol/sequence.go b/private/path/pathpol/sequence.go index ab178d87b4..ed5a793269 100644 --- a/private/path/pathpol/sequence.go +++ b/private/path/pathpol/sequence.go @@ -28,8 +28,8 @@ import ( "github.com/scionproto/scion/antlr/sequence" "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/log" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/snet" ) @@ -294,7 +294,7 @@ func (l *sequenceListener) ExitIFace(c *sequence.IFaceContext) { l.push(re) } -func hop(ia addr.IA, ingress, egress common.IfIDType) string { +func hop(ia addr.IA, ingress, egress ifid.IfIDType) string { return fmt.Sprintf("%s#%d,%d", ia, ingress, egress) } diff --git a/private/pathdb/query/BUILD.bazel b/private/pathdb/query/BUILD.bazel index 949c446ed2..28664bf1ac 100644 --- a/private/pathdb/query/BUILD.bazel +++ b/private/pathdb/query/BUILD.bazel @@ -7,7 +7,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/segment:go_default_library", + "//pkg/segment/ifid:go_default_library", ], ) diff --git a/private/pathdb/query/query.go b/private/pathdb/query/query.go index d8013fb606..4532797271 100644 --- a/private/pathdb/query/query.go +++ b/private/pathdb/query/query.go @@ -20,13 +20,13 @@ import ( "time" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" seg "github.com/scionproto/scion/pkg/segment" + "github.com/scionproto/scion/pkg/segment/ifid" ) type IntfSpec struct { IA addr.IA - IfID common.IfIDType + IfID ifid.IfIDType } type Params struct { diff --git a/private/revcache/BUILD.bazel b/private/revcache/BUILD.bazel index 99bea4419e..7a13272cbf 100644 --- a/private/revcache/BUILD.bazel +++ b/private/revcache/BUILD.bazel @@ -10,9 +10,9 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/ctrl/path_mgmt:go_default_library", "//pkg/segment:go_default_library", + "//pkg/segment/ifid:go_default_library", "//private/storage/cleaner:go_default_library", "//private/storage/db:go_default_library", ], @@ -24,13 +24,13 @@ go_test( deps = [ ":go_default_library", "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/ctrl/path_mgmt:go_default_library", "//pkg/private/ctrl/path_mgmt/proto:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", "//pkg/private/xtest/graph:go_default_library", "//pkg/segment:go_default_library", + "//pkg/segment/ifid:go_default_library", "//private/revcache/mock_revcache:go_default_library", "@com_github_golang_mock//gomock:go_default_library", "@com_github_stretchr_testify//assert:go_default_library", diff --git a/private/revcache/revcache.go b/private/revcache/revcache.go index 0e8f061080..21a3d0a659 100644 --- a/private/revcache/revcache.go +++ b/private/revcache/revcache.go @@ -20,19 +20,19 @@ import ( "io" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/private/storage/db" ) // Key denotes the key for the revocation cache. type Key struct { IA addr.IA - IfID common.IfIDType + IfID ifid.IfIDType } // NewKey creates a new key for the revocation cache. -func NewKey(ia addr.IA, ifID common.IfIDType) Key { +func NewKey(ia addr.IA, ifID ifid.IfIDType) Key { return Key{ IA: ia, IfID: ifID, @@ -47,7 +47,7 @@ func (k Key) String() string { type KeySet map[Key]struct{} // SingleKey is a convenience function to return a KeySet with a single key. -func SingleKey(ia addr.IA, ifID common.IfIDType) KeySet { +func SingleKey(ia addr.IA, ifID ifid.IfIDType) KeySet { return KeySet{Key{IA: ia, IfID: ifID}: {}} } diff --git a/private/revcache/revcachetest/BUILD.bazel b/private/revcache/revcachetest/BUILD.bazel index 19a4187eee..c8b032b299 100644 --- a/private/revcache/revcachetest/BUILD.bazel +++ b/private/revcache/revcachetest/BUILD.bazel @@ -7,10 +7,10 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/ctrl/path_mgmt:go_default_library", "//pkg/private/ctrl/path_mgmt/proto:go_default_library", "//pkg/private/util:go_default_library", + "//pkg/segment/ifid:go_default_library", "//private/revcache:go_default_library", "@com_github_stretchr_testify//assert:go_default_library", "@com_github_stretchr_testify//require:go_default_library", diff --git a/private/revcache/revcachetest/revcachetest.go b/private/revcache/revcachetest/revcachetest.go index 76e02c2044..91fb8b5b0a 100644 --- a/private/revcache/revcachetest/revcachetest.go +++ b/private/revcache/revcachetest/revcachetest.go @@ -24,18 +24,18 @@ import ( "github.com/stretchr/testify/require" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt/proto" "github.com/scionproto/scion/pkg/private/util" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/private/revcache" ) var ( ia110 = addr.MustParseIA("1-ff00:0:110") ia120 = addr.MustParseIA("1-ff00:0:120") - ifID15 = common.IfIDType(15) - ifID19 = common.IfIDType(19) + ifID15 = ifid.IfIDType(15) + ifID19 = ifid.IfIDType(19) TimeOut = 5 * time.Second ) @@ -101,7 +101,7 @@ func testGetMultikey(t *testing.T, revCache TestableRevCache) { rev1 := defaultRevInfo(ia110, ifID15) rev2 := defaultRevInfo(ia110, ifID19) rev3 := defaultRevInfo(ia120, ifID15) - rev4 := defaultRevInfo(ia120, common.IfIDType(10)) + rev4 := defaultRevInfo(ia120, ifid.IfIDType(10)) ctx, cancelF := context.WithTimeout(context.Background(), TimeOut) defer cancelF() @@ -152,7 +152,7 @@ func testGetAll(t *testing.T, revCache TestableRevCache) { rev1 := defaultRevInfo(ia110, ifID15) rev2 := defaultRevInfo(ia110, ifID19) rev3 := defaultRevInfo(ia120, ifID15) - rev4 := defaultRevInfo(ia120, common.IfIDType(20)) + rev4 := defaultRevInfo(ia120, ifid.IfIDType(20)) _, err = revCache.Insert(ctx, rev1) require.NoError(t, err) _, err = revCache.Insert(ctx, rev2) @@ -309,7 +309,7 @@ func testDeleteExpired(t *testing.T, revCache TestableRevCache) { assert.EqualValues(t, 0, del, "DeleteExpired should delete 0 if entry is not expired") } -func defaultRevInfo(ia addr.IA, ifID common.IfIDType) *path_mgmt.RevInfo { +func defaultRevInfo(ia addr.IA, ifID ifid.IfIDType) *path_mgmt.RevInfo { return &path_mgmt.RevInfo{ IfID: ifID, RawIsdas: ia, diff --git a/private/revcache/util.go b/private/revcache/util.go index db0e1894e1..3bf8ea5ee3 100644 --- a/private/revcache/util.go +++ b/private/revcache/util.go @@ -18,8 +18,8 @@ import ( "context" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" seg "github.com/scionproto/scion/pkg/segment" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/private/storage/cleaner" ) @@ -46,10 +46,10 @@ func NoRevokedHopIntf(ctx context.Context, revCache RevCache, func addRevKeys(segs []*seg.PathSegment, keys KeySet, hopOnly bool) { addIntfs := func(ia addr.IA, ingress, egress uint16) { if ingress != 0 { - keys[Key{IA: ia, IfID: common.IfIDType(ingress)}] = struct{}{} + keys[Key{IA: ia, IfID: ifid.IfIDType(ingress)}] = struct{}{} } if egress != 0 { - keys[Key{IA: ia, IfID: common.IfIDType(egress)}] = struct{}{} + keys[Key{IA: ia, IfID: ifid.IfIDType(egress)}] = struct{}{} } } for _, s := range segs { diff --git a/private/revcache/util_test.go b/private/revcache/util_test.go index 94e92f1651..859b5268db 100644 --- a/private/revcache/util_test.go +++ b/private/revcache/util_test.go @@ -23,13 +23,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt/proto" "github.com/scionproto/scion/pkg/private/serrors" "github.com/scionproto/scion/pkg/private/util" "github.com/scionproto/scion/pkg/private/xtest/graph" seg "github.com/scionproto/scion/pkg/segment" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/private/revcache" "github.com/scionproto/scion/private/revcache/mock_revcache" ) @@ -60,7 +60,7 @@ func TestNoRevokedHopIntf(t *testing.T) { revCache.EXPECT().Get(gomock.Eq(ctx), gomock.Any()).Return( revcache.Revocations{ revcache.Key{IA: addr.MustParseIA("2-ff00:0:211"), - IfID: common.IfIDType(graph.If_210_X_211_A)}: sRev, + IfID: ifid.IfIDType(graph.If_210_X_211_A)}: sRev, }, nil, ) noR, err := revcache.NoRevokedHopIntf(ctx, revCache, seg210_222_1) @@ -79,7 +79,7 @@ func TestNoRevokedHopIntf(t *testing.T) { func defaultRevInfo(ia addr.IA, ifID uint16, ts time.Time) *path_mgmt.RevInfo { return &path_mgmt.RevInfo{ - IfID: common.IfIDType(ifID), + IfID: ifid.IfIDType(ifID), RawIsdas: ia, LinkType: proto.LinkType_core, RawTimestamp: util.TimeToSecs(ts), diff --git a/private/segment/segfetcher/BUILD.bazel b/private/segment/segfetcher/BUILD.bazel index faf6e1c34d..5cdbfbf9e1 100644 --- a/private/segment/segfetcher/BUILD.bazel +++ b/private/segment/segfetcher/BUILD.bazel @@ -49,12 +49,12 @@ go_test( embed = [":go_default_library"], deps = [ "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/ctrl/path_mgmt:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/xtest/graph:go_default_library", "//pkg/private/xtest/matchers:go_default_library", "//pkg/segment:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/snet:go_default_library", "//private/pathdb/mock_pathdb:go_default_library", "//private/pathdb/query:go_default_library", diff --git a/private/segment/segfetcher/resolver_test.go b/private/segment/segfetcher/resolver_test.go index d452476fd9..d42af57f7a 100644 --- a/private/segment/segfetcher/resolver_test.go +++ b/private/segment/segfetcher/resolver_test.go @@ -24,11 +24,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt" "github.com/scionproto/scion/pkg/private/xtest/graph" "github.com/scionproto/scion/pkg/private/xtest/matchers" seg "github.com/scionproto/scion/pkg/segment" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/private/pathdb/mock_pathdb" "github.com/scionproto/scion/private/pathdb/query" "github.com/scionproto/scion/private/revcache" @@ -411,11 +411,11 @@ func TestResolverWithRevocations(t *testing.T) { ExpectRevcache: func(t *testing.T, revCache *mock_revcache.MockRevCache) { key111_120 := revcache.Key{ IA: non_core_111, - IfID: common.IfIDType(graph.If_111_B_120_X), + IfID: ifid.IfIDType(graph.If_111_B_120_X), } key111_130 := revcache.Key{ IA: non_core_111, - IfID: common.IfIDType(graph.If_111_A_130_B), + IfID: ifid.IfIDType(graph.If_111_A_130_B), } revoke(t, revCache, key111_120) revoke(t, revCache, key111_130) @@ -446,7 +446,7 @@ func TestResolverWithRevocations(t *testing.T) { db.EXPECT().Get(gomock.Any(), gomock.Any()).Times(2) }, ExpectRevcache: func(t *testing.T, revCache *mock_revcache.MockRevCache) { - key110 := revcache.Key{IA: core_110, IfID: common.IfIDType(graph.If_110_X_130_A)} + key110 := revcache.Key{IA: core_110, IfID: ifid.IfIDType(graph.If_110_X_130_A)} ksMatcher := keySetContains{keys: []revcache.Key{key110}} rev := &path_mgmt.RevInfo{} revCache.EXPECT().Get(gomock.Any(), ksMatcher).Return(revcache.Revocations{ diff --git a/private/storage/beacon/sqlite/BUILD.bazel b/private/storage/beacon/sqlite/BUILD.bazel index eaf01f3a92..3ee02dd931 100644 --- a/private/storage/beacon/sqlite/BUILD.bazel +++ b/private/storage/beacon/sqlite/BUILD.bazel @@ -11,9 +11,9 @@ go_library( deps = [ "//control/beacon:go_default_library", "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", + "//pkg/segment/ifid:go_default_library", "//private/storage/beacon:go_default_library", "//private/storage/db:go_default_library", ], diff --git a/private/storage/beacon/sqlite/db.go b/private/storage/beacon/sqlite/db.go index dc92b5a7a9..cecc8bbdaf 100644 --- a/private/storage/beacon/sqlite/db.go +++ b/private/storage/beacon/sqlite/db.go @@ -24,9 +24,9 @@ import ( "github.com/scionproto/scion/control/beacon" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" "github.com/scionproto/scion/pkg/private/util" + "github.com/scionproto/scion/pkg/segment/ifid" storagebeacon "github.com/scionproto/scion/private/storage/beacon" "github.com/scionproto/scion/private/storage/db" ) @@ -140,7 +140,7 @@ func (e *executor) CandidateBeacons( beacons := make([]beacon.Beacon, 0, setSize) for rows.Next() { var rawBeacon sql.RawBytes - var inIfID common.IfIDType + var inIfID ifid.IfIDType if err = rows.Scan(&rawBeacon, &inIfID); err != nil { return nil, db.NewReadError(beacon.ErrReadingRows, err) } diff --git a/private/storage/path/dbtest/BUILD.bazel b/private/storage/path/dbtest/BUILD.bazel index dd03cd363a..d92fb9d0ab 100644 --- a/private/storage/path/dbtest/BUILD.bazel +++ b/private/storage/path/dbtest/BUILD.bazel @@ -7,9 +7,9 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/xtest/graph:go_default_library", "//pkg/segment:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/slayers/path:go_default_library", "//private/pathdb:go_default_library", "//private/pathdb/query:go_default_library", diff --git a/private/storage/path/dbtest/dbtest.go b/private/storage/path/dbtest/dbtest.go index d8e474eca6..e0061fdecc 100644 --- a/private/storage/path/dbtest/dbtest.go +++ b/private/storage/path/dbtest/dbtest.go @@ -27,9 +27,9 @@ import ( "github.com/stretchr/testify/require" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/xtest/graph" seg "github.com/scionproto/scion/pkg/segment" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/slayers/path" "github.com/scionproto/scion/private/pathdb" "github.com/scionproto/scion/private/pathdb/query" @@ -603,7 +603,7 @@ func checkInterface(t *testing.T, ctx context.Context, ia addr.IA, ifID uint16, Intfs: []*query.IntfSpec{ { IA: ia, - IfID: common.IfIDType(ifID), + IfID: ifid.IfIDType(ifID), }, }, }) diff --git a/private/topology/BUILD.bazel b/private/topology/BUILD.bazel index 685c2313a0..7db5d90478 100644 --- a/private/topology/BUILD.bazel +++ b/private/topology/BUILD.bazel @@ -18,8 +18,8 @@ go_library( "//pkg/addr:go_default_library", "//pkg/log:go_default_library", "//pkg/metrics:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/serrors:go_default_library", + "//pkg/segment/ifid:go_default_library", "//private/topology/json:go_default_library", "//private/topology/underlay:go_default_library", ], @@ -41,9 +41,9 @@ go_test( deps = [ "//pkg/addr:go_default_library", "//pkg/metrics/mock_metrics:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/ctrl/path_mgmt/proto:go_default_library", "//pkg/private/xtest:go_default_library", + "//pkg/segment/ifid:go_default_library", "//private/topology/json:go_default_library", "//private/topology/mock_topology:go_default_library", "@com_github_golang_mock//gomock:go_default_library", diff --git a/private/topology/interface.go b/private/topology/interface.go index ca61eb1597..5dfba721b0 100644 --- a/private/topology/interface.go +++ b/private/topology/interface.go @@ -22,8 +22,8 @@ import ( "sort" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" + "github.com/scionproto/scion/pkg/segment/ifid" ) // Topology is the topology type for applications and libraries that only need read access to AS @@ -39,7 +39,7 @@ type Topology interface { // Core returns whether the local AS is core. Core() bool // InterfaceIDs returns all interface IDS from the local AS. - IfIDs() []common.IfIDType + IfIDs() []ifid.IfIDType // PortRange returns the first and last ports of the port range (both included), // in which endhost listen for SCION/UDP application using the UDP/IP underlay. PortRange() (uint16, uint16) @@ -59,7 +59,7 @@ type Topology interface { UnderlayMulticast(svc addr.SVC) ([]*net.UDPAddr, error) // UnderlayNextHop returns the internal underlay address of the router // containing the interface ID. - UnderlayNextHop(ifID common.IfIDType) (*net.UDPAddr, bool) + UnderlayNextHop(ifID ifid.IfIDType) (*net.UDPAddr, bool) // MakeHostInfos returns the underlay addresses of all services for the specified service type. MakeHostInfos(st ServiceType) ([]*net.UDPAddr, error) @@ -144,8 +144,8 @@ func (t *topologyS) MTU() uint16 { return uint16(t.Topology.MTU) } -func (t *topologyS) IfIDs() []common.IfIDType { - intfs := make([]common.IfIDType, 0, len(t.Topology.IFInfoMap)) +func (t *topologyS) IfIDs() []ifid.IfIDType { + intfs := make([]ifid.IfIDType, 0, len(t.Topology.IFInfoMap)) for ifID := range t.Topology.IFInfoMap { intfs = append(intfs, ifID) } @@ -156,7 +156,7 @@ func (t *topologyS) PortRange() (uint16, uint16) { return t.Topology.DispatchedPortStart, t.Topology.DispatchedPortEnd } -func (t *topologyS) UnderlayNextHop(ifID common.IfIDType) (*net.UDPAddr, bool) { +func (t *topologyS) UnderlayNextHop(ifID ifid.IfIDType) (*net.UDPAddr, bool) { ifInfo, ok := t.Topology.IFInfoMap[ifID] if !ok { return nil, false diff --git a/private/topology/json/BUILD.bazel b/private/topology/json/BUILD.bazel index 6c018fec49..f4c37b34fc 100644 --- a/private/topology/json/BUILD.bazel +++ b/private/topology/json/BUILD.bazel @@ -7,9 +7,9 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/log:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", + "//pkg/segment/ifid:go_default_library", ], ) @@ -19,9 +19,9 @@ go_test( data = glob(["testdata/**"]), deps = [ ":go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/util:go_default_library", "//pkg/private/xtest:go_default_library", + "//pkg/segment/ifid:go_default_library", "@com_github_stretchr_testify//assert:go_default_library", "@com_github_stretchr_testify//require:go_default_library", ], diff --git a/private/topology/json/json.go b/private/topology/json/json.go index f620d51e83..207e18590b 100644 --- a/private/topology/json/json.go +++ b/private/topology/json/json.go @@ -24,9 +24,9 @@ import ( "strings" "github.com/scionproto/scion/pkg/log" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" "github.com/scionproto/scion/pkg/private/util" + "github.com/scionproto/scion/pkg/segment/ifid" ) // Attribute indicates the capability of a primary AS. @@ -93,8 +93,8 @@ type ServerInfo struct { // BRInfo contains Border Router specific information. type BRInfo struct { - InternalAddr string `json:"internal_addr"` - Interfaces map[common.IfIDType]*BRInterface `json:"interfaces"` + InternalAddr string `json:"internal_addr"` + Interfaces map[ifid.IfIDType]*BRInterface `json:"interfaces"` } // GatewayInfo contains SCION gateway information. @@ -108,12 +108,12 @@ type GatewayInfo struct { // BRInterface contains the information for an data-plane BR socket that is external (i.e., facing // the neighboring AS). type BRInterface struct { - Underlay Underlay `json:"underlay,omitempty"` - IA string `json:"isd_as"` - LinkTo string `json:"link_to"` - MTU int `json:"mtu"` - BFD *BFD `json:"bfd,omitempty"` - RemoteIfID common.IfIDType `json:"remote_interface_id,omitempty"` + Underlay Underlay `json:"underlay,omitempty"` + IA string `json:"isd_as"` + LinkTo string `json:"link_to"` + MTU int `json:"mtu"` + BFD *BFD `json:"bfd,omitempty"` + RemoteIfID ifid.IfIDType `json:"remote_interface_id,omitempty"` } // Underlay is the underlay information for a BR interface. diff --git a/private/topology/json/json_test.go b/private/topology/json/json_test.go index 25f590e771..fc6688c2af 100644 --- a/private/topology/json/json_test.go +++ b/private/topology/json/json_test.go @@ -25,9 +25,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/util" "github.com/scionproto/scion/pkg/private/xtest" + "github.com/scionproto/scion/pkg/segment/ifid" jsontopo "github.com/scionproto/scion/private/topology/json" ) @@ -46,7 +46,7 @@ func TestLoadRawFromFile(t *testing.T) { BorderRouters: map[string]*jsontopo.BRInfo{ "borderrouter6-f00:0:362-1": { InternalAddr: "10.1.0.1:0", - Interfaces: map[common.IfIDType]*jsontopo.BRInterface{ + Interfaces: map[ifid.IfIDType]*jsontopo.BRInterface{ 91: { Underlay: jsontopo.Underlay{ Local: "192.0.2.1:4997", @@ -65,7 +65,7 @@ func TestLoadRawFromFile(t *testing.T) { }, "borderrouter6-f00:0:362-9": { InternalAddr: "[2001:db8:a0b:12f0::2]:0", - Interfaces: map[common.IfIDType]*jsontopo.BRInterface{ + Interfaces: map[ifid.IfIDType]*jsontopo.BRInterface{ 32: { Underlay: jsontopo.Underlay{ Local: "[2001:db8:a0b:12f0::1]:4997", diff --git a/private/topology/mock_topology/BUILD.bazel b/private/topology/mock_topology/BUILD.bazel index c211287a4f..0020b4db97 100644 --- a/private/topology/mock_topology/BUILD.bazel +++ b/private/topology/mock_topology/BUILD.bazel @@ -19,7 +19,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/addr:go_default_library", - "//pkg/private/common:go_default_library", + "//pkg/segment/ifid:go_default_library", "//private/topology:go_default_library", "@com_github_golang_mock//gomock:go_default_library", ], diff --git a/private/topology/mock_topology/mock.go b/private/topology/mock_topology/mock.go index c141aaec03..9386750cd4 100644 --- a/private/topology/mock_topology/mock.go +++ b/private/topology/mock_topology/mock.go @@ -10,7 +10,7 @@ import ( gomock "github.com/golang/mock/gomock" addr "github.com/scionproto/scion/pkg/addr" - common "github.com/scionproto/scion/pkg/private/common" + common "github.com/scionproto/scion/pkg/segment/ifid" topology "github.com/scionproto/scion/private/topology" ) @@ -125,10 +125,10 @@ func (mr *MockTopologyMockRecorder) IFInfoMap() *gomock.Call { } // IfIDs mocks base method. -func (m *MockTopology) IfIDs() []common.IfIDType { +func (m *MockTopology) IfIDs() []ifid.IfIDType { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IfIDs") - ret0, _ := ret[0].([]common.IfIDType) + ret0, _ := ret[0].([]ifid.IfIDType) return ret0 } @@ -256,7 +256,7 @@ func (mr *MockTopologyMockRecorder) UnderlayMulticast(arg0 interface{}) *gomock. } // UnderlayNextHop mocks base method. -func (m *MockTopology) UnderlayNextHop(arg0 common.IfIDType) (*net.UDPAddr, bool) { +func (m *MockTopology) UnderlayNextHop(arg0 ifid.IfIDType) (*net.UDPAddr, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UnderlayNextHop", arg0) ret0, _ := ret[0].(*net.UDPAddr) diff --git a/private/topology/reload.go b/private/topology/reload.go index e5ff58c2fc..d52ecb7464 100644 --- a/private/topology/reload.go +++ b/private/topology/reload.go @@ -26,8 +26,8 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/log" "github.com/scionproto/scion/pkg/metrics" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" + "github.com/scionproto/scion/pkg/segment/ifid" ) // Validator is used to validate that the topology update is permissible. @@ -133,7 +133,7 @@ func (l *Loader) UnderlayNextHop(ifID uint16) *net.UDPAddr { l.mtx.Lock() defer l.mtx.Unlock() - addr, _ := l.topo.UnderlayNextHop(common.IfIDType(ifID)) + addr, _ := l.topo.UnderlayNextHop(ifid.IfIDType(ifID)) return addr } @@ -182,7 +182,7 @@ func (l *Loader) Gateways() ([]GatewayInfo, error) { return l.topo.Gateways() } -func (l *Loader) InterfaceInfoMap() map[common.IfIDType]IFInfo { +func (l *Loader) InterfaceInfoMap() map[ifid.IfIDType]IFInfo { l.mtx.Lock() defer l.mtx.Unlock() diff --git a/private/topology/topology.go b/private/topology/topology.go index ef1234a602..bccd95955d 100644 --- a/private/topology/topology.go +++ b/private/topology/topology.go @@ -29,8 +29,8 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/log" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" + "github.com/scionproto/scion/pkg/segment/ifid" jsontopo "github.com/scionproto/scion/private/topology/json" "github.com/scionproto/scion/private/topology/underlay" ) @@ -95,25 +95,25 @@ type ( // InternalAddr is the local data-plane address. InternalAddr netip.AddrPort // IfIDs is a sorted list of the interface IDs. - IfIDs []common.IfIDType + IfIDs []ifid.IfIDType // IFs is a map of interface IDs. - IFs map[common.IfIDType]*IFInfo + IFs map[ifid.IfIDType]*IFInfo } // IfInfoMap maps interface ids to the interface information. - IfInfoMap map[common.IfIDType]IFInfo + IfInfoMap map[ifid.IfIDType]IFInfo // IFInfo describes a border router link to another AS, including the internal data-plane // address applications should send traffic to and information about the link itself and the // remote side of it. IFInfo struct { // ID is the interface ID. It is unique per AS. - ID common.IfIDType + ID ifid.IfIDType BRName string InternalAddr netip.AddrPort Local netip.AddrPort Remote netip.AddrPort - RemoteIfID common.IfIDType + RemoteIfID ifid.IfIDType IA addr.IA LinkType LinkType MTU int @@ -267,7 +267,7 @@ func (t *RWTopology) populateBR(raw *jsontopo.Topology) error { brInfo := BRInfo{ Name: name, InternalAddr: intAddr, - IFs: make(map[common.IfIDType]*IFInfo), + IFs: make(map[ifid.IfIDType]*IFInfo), } for ifID, rawIntf := range rawBr.Interfaces { var err error @@ -474,11 +474,11 @@ func (i *BRInfo) copy() *BRInfo { } } -func copyIFsMap(m map[common.IfIDType]*IFInfo) map[common.IfIDType]*IFInfo { +func copyIFsMap(m map[ifid.IfIDType]*IFInfo) map[ifid.IfIDType]*IFInfo { if m == nil { return nil } - newM := make(map[common.IfIDType]*IFInfo) + newM := make(map[ifid.IfIDType]*IFInfo) for k, v := range m { newM[k] = v.copy() } diff --git a/private/topology/topology_test.go b/private/topology/topology_test.go index 5830dc9b39..3eabba48b2 100644 --- a/private/topology/topology_test.go +++ b/private/topology/topology_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" + "github.com/scionproto/scion/pkg/segment/ifid" jsontopo "github.com/scionproto/scion/private/topology/json" ) @@ -58,10 +58,10 @@ func TestBRs(t *testing.T) { brs := map[string]BRInfo{ "br1-ff00:0:311-1": { - IfIDs: []common.IfIDType{1, 3, 8}, + IfIDs: []ifid.IfIDType{1, 3, 8}, }, "br1-ff00:0:311-2": { - IfIDs: []common.IfIDType{11}, + IfIDs: []ifid.IfIDType{11}, }, } @@ -312,10 +312,10 @@ func TestBRsCoreAS(t *testing.T) { c := MustLoadTopo(t, "testdata/core.json") brCases := []struct { name string - interfaces []common.IfIDType + interfaces []ifid.IfIDType }{ - {name: "borderrouter6-ff00:0:362-1", interfaces: []common.IfIDType{91}}, - {name: "borderrouter6-ff00:0:362-9", interfaces: []common.IfIDType{32}}, + {name: "borderrouter6-ff00:0:362-1", interfaces: []ifid.IfIDType{91}}, + {name: "borderrouter6-ff00:0:362-9", interfaces: []ifid.IfIDType{32}}, } for _, test := range brCases { t.Run(test.name, func(t *testing.T) { diff --git a/router/BUILD.bazel b/router/BUILD.bazel index 332a12f3b5..d1b9c4bca2 100644 --- a/router/BUILD.bazel +++ b/router/BUILD.bazel @@ -16,11 +16,11 @@ go_library( "//pkg/drkey:go_default_library", "//pkg/experimental/epic:go_default_library", "//pkg/log:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/processmetrics:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", "//pkg/scrypto:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/slayers:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/slayers/path/empty:go_default_library", diff --git a/router/connector.go b/router/connector.go index e1b48efffa..8c5893a441 100644 --- a/router/connector.go +++ b/router/connector.go @@ -20,8 +20,8 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/log" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/private/underlay/conn" "github.com/scionproto/scion/router/config" "github.com/scionproto/scion/router/control" @@ -80,7 +80,7 @@ func (c *Connector) AddInternalInterface(ia addr.IA, local netip.AddrPort) error } // AddExternalInterface adds a link between the local and remote address. -func (c *Connector) AddExternalInterface(localIfID common.IfIDType, link control.LinkInfo, +func (c *Connector) AddExternalInterface(localIfID ifid.IfIDType, link control.LinkInfo, owned bool) error { c.mtx.Lock() diff --git a/router/control/BUILD.bazel b/router/control/BUILD.bazel index 5cd4a3bee5..2156ae9ac9 100644 --- a/router/control/BUILD.bazel +++ b/router/control/BUILD.bazel @@ -11,8 +11,8 @@ go_library( deps = [ "//pkg/addr:go_default_library", "//pkg/log:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/serrors:go_default_library", + "//pkg/segment/ifid:go_default_library", "//private/keyconf:go_default_library", "//private/topology:go_default_library", "@org_golang_x_crypto//pbkdf2:go_default_library", diff --git a/router/control/conf.go b/router/control/conf.go index f9676c12ea..0e4057a9e8 100644 --- a/router/control/conf.go +++ b/router/control/conf.go @@ -22,8 +22,8 @@ import ( "golang.org/x/crypto/pbkdf2" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/private/topology" ) @@ -32,7 +32,7 @@ import ( type Dataplane interface { CreateIACtx(ia addr.IA) error AddInternalInterface(ia addr.IA, local netip.AddrPort) error - AddExternalInterface(localIfID common.IfIDType, info LinkInfo, owned bool) error + AddExternalInterface(localIfID ifid.IfIDType, info LinkInfo, owned bool) error AddSvc(ia addr.IA, svc addr.SVC, a netip.AddrPort) error DelSvc(ia addr.IA, svc addr.SVC, a netip.AddrPort) error SetKey(ia addr.IA, index int, key []byte) error @@ -57,7 +57,7 @@ type LinkInfo struct { type LinkEnd struct { IA addr.IA Addr netip.AddrPort - IfID common.IfIDType + IfID ifid.IfIDType } type ObservableDataplane interface { @@ -169,7 +169,7 @@ func confExternalInterfaces(dp Dataplane, cfg *Config) error { // nothing to do return nil } - ifIDs := []common.IfIDType{} + ifIDs := []ifid.IfIDType{} for k := range infoMap { ifIDs = append(ifIDs, k) } diff --git a/router/control/internal/metrics/BUILD.bazel b/router/control/internal/metrics/BUILD.bazel index a19d47f963..c112db37d6 100644 --- a/router/control/internal/metrics/BUILD.bazel +++ b/router/control/internal/metrics/BUILD.bazel @@ -9,8 +9,8 @@ go_library( importpath = "github.com/scionproto/scion/router/control/internal/metrics", visibility = ["//router/control:__subpackages__"], deps = [ - "//pkg/private/common:go_default_library", "//pkg/private/prom:go_default_library", + "//pkg/segment/ifid:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", ], ) diff --git a/router/control/internal/metrics/metrics.go b/router/control/internal/metrics/metrics.go index d33f57af83..f3d079bb92 100644 --- a/router/control/internal/metrics/metrics.go +++ b/router/control/internal/metrics/metrics.go @@ -17,8 +17,8 @@ package metrics import ( - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/prom" + "github.com/scionproto/scion/pkg/segment/ifid" ) const Namespace = "br" @@ -65,7 +65,7 @@ func (l IntfLabels) Values() []string { return []string{l.Intf, l.NeighIA} } -func IntfToLabel(ifID common.IfIDType) string { +func IntfToLabel(ifID ifid.IfIDType) string { if ifID == 0 { return "loc" } diff --git a/scion/cmd/scion/BUILD.bazel b/scion/cmd/scion/BUILD.bazel index db17255736..a11ac9aa66 100644 --- a/scion/cmd/scion/BUILD.bazel +++ b/scion/cmd/scion/BUILD.bazel @@ -19,8 +19,8 @@ go_library( "//pkg/addr:go_default_library", "//pkg/daemon:go_default_library", "//pkg/log:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/serrors:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/snet:go_default_library", "//pkg/snet/addrutil:go_default_library", "//pkg/snet/path:go_default_library", diff --git a/scion/cmd/scion/common.go b/scion/cmd/scion/common.go index edf290ed8d..2f20556972 100644 --- a/scion/cmd/scion/common.go +++ b/scion/cmd/scion/common.go @@ -23,8 +23,8 @@ import ( "time" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/snet" ) @@ -43,8 +43,8 @@ type Path struct { // Hop represents an hop on the path. type Hop struct { - ID common.IfIDType `json:"interface" yaml:"interface"` - IA addr.IA `json:"isd_as" yaml:"isd_as"` + ID ifid.IfIDType `json:"interface" yaml:"interface"` + IA addr.IA `json:"isd_as" yaml:"isd_as"` } // getHops constructs a list of snet path interfaces from an snet path diff --git a/scion/showpaths/BUILD.bazel b/scion/showpaths/BUILD.bazel index 8f3139a275..b77b1b8d28 100644 --- a/scion/showpaths/BUILD.bazel +++ b/scion/showpaths/BUILD.bazel @@ -11,8 +11,8 @@ go_library( deps = [ "//pkg/addr:go_default_library", "//pkg/daemon:go_default_library", - "//pkg/private/common:go_default_library", "//pkg/private/serrors:go_default_library", + "//pkg/segment/ifid:go_default_library", "//pkg/snet:go_default_library", "//private/app/path:go_default_library", "//private/app/path/pathprobe:go_default_library", diff --git a/scion/showpaths/showpaths.go b/scion/showpaths/showpaths.go index 7f5457279e..d3f3993e76 100644 --- a/scion/showpaths/showpaths.go +++ b/scion/showpaths/showpaths.go @@ -26,8 +26,8 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/daemon" - "github.com/scionproto/scion/pkg/private/common" "github.com/scionproto/scion/pkg/private/serrors" + "github.com/scionproto/scion/pkg/segment/ifid" "github.com/scionproto/scion/pkg/snet" "github.com/scionproto/scion/private/app/path" "github.com/scionproto/scion/private/app/path/pathprobe" @@ -58,8 +58,8 @@ type Path struct { // Hop represents an hop on the path. type Hop struct { - IfID common.IfIDType `json:"interface"` - IA addr.IA `json:"isd_as"` + IfID ifid.IfIDType `json:"interface"` + IA addr.IA `json:"isd_as"` } // Human writes human readable output to the writer. From f5c9c5cc700c5861378f7afb58969deeed5ea52a Mon Sep 17 00:00:00 2001 From: Jean-Christophe Hugly Date: Fri, 30 Aug 2024 15:47:41 +0200 Subject: [PATCH 2/4] Renamed pkg ifid to iface. There was no way to convince forbidigo that our strict naming rules for interface id (which explcitly forbid lower case "ifid") that it was ok for a package name. --- control/beacon/beacondbtest/BUILD.bazel | 2 +- control/beacon/beacondbtest/beacondbtest.go | 8 +- control/beaconing/BUILD.bazel | 4 +- control/beaconing/export_test.go | 6 +- control/beaconing/staticinfo_config.go | 80 +++++------ control/beaconing/staticinfo_config_test.go | 136 +++++++++--------- control/beaconing/writer_test.go | 4 +- control/cmd/control/BUILD.bazel | 2 +- control/cmd/control/main.go | 4 +- daemon/internal/servers/BUILD.bazel | 2 +- daemon/internal/servers/grpc.go | 4 +- gateway/pathhealth/BUILD.bazel | 2 +- gateway/pathhealth/revocations_test.go | 6 +- pkg/daemon/BUILD.bazel | 2 +- pkg/daemon/grpc.go | 4 +- pkg/experimental/hiddenpath/BUILD.bazel | 2 +- .../hiddenpath/beaconwriter_test.go | 4 +- pkg/private/common/defs_test.go | 3 +- pkg/private/ctrl/path_mgmt/BUILD.bazel | 2 +- pkg/private/ctrl/path_mgmt/rev_info.go | 4 +- pkg/private/xtest/graph/BUILD.bazel | 2 +- pkg/private/xtest/graph/graph.go | 28 ++-- pkg/segment/extensions/staticinfo/BUILD.bazel | 4 +- .../extensions/staticinfo/staticinfo.go | 38 ++--- .../extensions/staticinfo/staticinfo_test.go | 12 +- pkg/segment/{ifid => iface}/BUILD.bazel | 6 +- pkg/segment/{ifid/ifid.go => iface/iface.go} | 6 +- .../ifid_test.go => iface/iface_test.go} | 14 +- pkg/snet/BUILD.bazel | 2 +- pkg/snet/path.go | 4 +- pkg/snet/scmp.go | 6 +- private/path/combinator/BUILD.bazel | 4 +- private/path/combinator/combinator_test.go | 22 +-- private/path/combinator/graph.go | 18 +-- .../path/combinator/staticinfo_accumulator.go | 8 +- .../combinator/staticinfo_accumulator_test.go | 46 +++--- private/path/pathpol/BUILD.bazel | 4 +- private/path/pathpol/acl_test.go | 10 +- private/path/pathpol/hop_pred.go | 12 +- private/path/pathpol/hop_pred_test.go | 26 ++-- private/path/pathpol/policy_test.go | 4 +- private/path/pathpol/sequence.go | 4 +- private/pathdb/query/BUILD.bazel | 2 +- private/pathdb/query/query.go | 4 +- private/revcache/BUILD.bazel | 4 +- private/revcache/revcache.go | 8 +- private/revcache/revcachetest/BUILD.bazel | 2 +- private/revcache/revcachetest/revcachetest.go | 12 +- private/revcache/util.go | 6 +- private/revcache/util_test.go | 6 +- private/segment/segfetcher/BUILD.bazel | 2 +- private/segment/segfetcher/resolver_test.go | 8 +- private/storage/beacon/sqlite/BUILD.bazel | 2 +- private/storage/beacon/sqlite/db.go | 4 +- private/storage/path/dbtest/BUILD.bazel | 2 +- private/storage/path/dbtest/dbtest.go | 4 +- private/topology/BUILD.bazel | 4 +- private/topology/interface.go | 12 +- private/topology/json/BUILD.bazel | 4 +- private/topology/json/json.go | 18 +-- private/topology/json/json_test.go | 6 +- private/topology/mock_topology/BUILD.bazel | 2 +- private/topology/mock_topology/mock.go | 8 +- private/topology/reload.go | 6 +- private/topology/topology.go | 18 +-- private/topology/topology_test.go | 12 +- router/BUILD.bazel | 2 +- router/connector.go | 4 +- router/control/BUILD.bazel | 2 +- router/control/conf.go | 8 +- router/control/internal/metrics/BUILD.bazel | 2 +- router/control/internal/metrics/metrics.go | 4 +- scion/cmd/scion/BUILD.bazel | 2 +- scion/cmd/scion/common.go | 6 +- scion/showpaths/BUILD.bazel | 2 +- scion/showpaths/showpaths.go | 6 +- 76 files changed, 378 insertions(+), 377 deletions(-) rename pkg/segment/{ifid => iface}/BUILD.bazel (75%) rename pkg/segment/{ifid/ifid.go => iface/iface.go} (90%) rename pkg/segment/{ifid/ifid_test.go => iface/iface_test.go} (80%) diff --git a/control/beacon/beacondbtest/BUILD.bazel b/control/beacon/beacondbtest/BUILD.bazel index 38577ecb7e..9190dcf17a 100644 --- a/control/beacon/beacondbtest/BUILD.bazel +++ b/control/beacon/beacondbtest/BUILD.bazel @@ -10,7 +10,7 @@ go_library( "//pkg/addr:go_default_library", "//pkg/private/xtest/graph:go_default_library", "//pkg/segment:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/slayers/path:go_default_library", "@com_github_stretchr_testify//assert:go_default_library", "@com_github_stretchr_testify//require:go_default_library", diff --git a/control/beacon/beacondbtest/beacondbtest.go b/control/beacon/beacondbtest/beacondbtest.go index 1dcf029ff6..a953478703 100644 --- a/control/beacon/beacondbtest/beacondbtest.go +++ b/control/beacon/beacondbtest/beacondbtest.go @@ -26,7 +26,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/private/xtest/graph" seg "github.com/scionproto/scion/pkg/segment" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/slayers/path" ) @@ -334,14 +334,14 @@ func InsertBeacon(t *testing.T, db beacon.DB, ases []IfInfo, type PeerEntry struct { IA addr.IA - Ingress ifid.IfIDType + Ingress iface.IfIDType } type IfInfo struct { IA addr.IA Next addr.IA - Ingress ifid.IfIDType - Egress ifid.IfIDType + Ingress iface.IfIDType + Egress iface.IfIDType Peers []PeerEntry } diff --git a/control/beaconing/BUILD.bazel b/control/beaconing/BUILD.bazel index 5a4f564ab3..5076ce08a4 100644 --- a/control/beaconing/BUILD.bazel +++ b/control/beaconing/BUILD.bazel @@ -30,7 +30,7 @@ go_library( "//pkg/segment/extensions/digest:go_default_library", "//pkg/segment/extensions/epic:go_default_library", "//pkg/segment/extensions/staticinfo:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/snet:go_default_library", "//private/periodic:go_default_library", @@ -71,7 +71,7 @@ go_test( "//pkg/scrypto/signed:go_default_library", "//pkg/segment:go_default_library", "//pkg/segment/extensions/staticinfo:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/slayers/path/scion:go_default_library", "//pkg/snet:go_default_library", diff --git a/control/beaconing/export_test.go b/control/beaconing/export_test.go index 343760fce2..c3d3653da2 100644 --- a/control/beaconing/export_test.go +++ b/control/beaconing/export_test.go @@ -16,11 +16,11 @@ package beaconing import ( "github.com/scionproto/scion/pkg/segment/extensions/staticinfo" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/private/topology" ) -func (cfg StaticInfoCfg) TestGenerate(ifType map[ifid.IfIDType]topology.LinkType, - ingress, egress ifid.IfIDType) *staticinfo.Extension { +func (cfg StaticInfoCfg) TestGenerate(ifType map[iface.IfIDType]topology.LinkType, + ingress, egress iface.IfIDType) *staticinfo.Extension { return cfg.generate(ifType, ingress, egress) } diff --git a/control/beaconing/staticinfo_config.go b/control/beaconing/staticinfo_config.go index 4722fb4ac7..cc0494178c 100644 --- a/control/beaconing/staticinfo_config.go +++ b/control/beaconing/staticinfo_config.go @@ -24,18 +24,18 @@ import ( "github.com/scionproto/scion/pkg/private/serrors" "github.com/scionproto/scion/pkg/private/util" "github.com/scionproto/scion/pkg/segment/extensions/staticinfo" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/private/topology" ) type InterfaceLatencies struct { - Inter util.DurWrap `json:"Inter"` - Intra map[ifid.IfIDType]util.DurWrap `json:"Intra"` + Inter util.DurWrap `json:"Inter"` + Intra map[iface.IfIDType]util.DurWrap `json:"Intra"` } type InterfaceBandwidths struct { - Inter uint64 `json:"Inter"` - Intra map[ifid.IfIDType]uint64 `json:"Intra"` + Inter uint64 `json:"Inter"` + Intra map[iface.IfIDType]uint64 `json:"Intra"` } type InterfaceGeodata struct { @@ -45,7 +45,7 @@ type InterfaceGeodata struct { } type InterfaceHops struct { - Intra map[ifid.IfIDType]uint32 `json:"Intra"` + Intra map[iface.IfIDType]uint32 `json:"Intra"` } type LinkType staticinfo.LinkType @@ -79,12 +79,12 @@ func (l *LinkType) UnmarshalText(text []byte) error { // StaticInfoCfg is used to parse data from config.json. type StaticInfoCfg struct { - Latency map[ifid.IfIDType]InterfaceLatencies `json:"Latency"` - Bandwidth map[ifid.IfIDType]InterfaceBandwidths `json:"Bandwidth"` - LinkType map[ifid.IfIDType]LinkType `json:"LinkType"` - Geo map[ifid.IfIDType]InterfaceGeodata `json:"Geo"` - Hops map[ifid.IfIDType]InterfaceHops `json:"Hops"` - Note string `json:"Note"` + Latency map[iface.IfIDType]InterfaceLatencies `json:"Latency"` + Bandwidth map[iface.IfIDType]InterfaceBandwidths `json:"Bandwidth"` + LinkType map[iface.IfIDType]LinkType `json:"LinkType"` + Geo map[iface.IfIDType]InterfaceGeodata `json:"Geo"` + Hops map[iface.IfIDType]InterfaceHops `json:"Hops"` + Note string `json:"Note"` } // ParseStaticInfoCfg parses data from a config file into a StaticInfoCfg struct. @@ -135,7 +135,7 @@ func (cfg *StaticInfoCfg) clean() { } // symmetrizeLatency makes the Intra latency values symmetric -func symmetrizeLatency(latency map[ifid.IfIDType]InterfaceLatencies) { +func symmetrizeLatency(latency map[iface.IfIDType]InterfaceLatencies) { for i, sub := range latency { delete(sub.Intra, i) // Remove loopy entry for j, v := range sub.Intra { @@ -145,7 +145,7 @@ func symmetrizeLatency(latency map[ifid.IfIDType]InterfaceLatencies) { if latency[j].Intra == nil { latency[j] = InterfaceLatencies{ Inter: latency[j].Inter, - Intra: make(map[ifid.IfIDType]util.DurWrap), + Intra: make(map[iface.IfIDType]util.DurWrap), } } vTransposed, ok := latency[j].Intra[i] @@ -158,7 +158,7 @@ func symmetrizeLatency(latency map[ifid.IfIDType]InterfaceLatencies) { } // symmetrizeBandwidth makes the Intra bandwidth values symmetric -func symmetrizeBandwidth(bandwidth map[ifid.IfIDType]InterfaceBandwidths) { +func symmetrizeBandwidth(bandwidth map[iface.IfIDType]InterfaceBandwidths) { for i, sub := range bandwidth { delete(sub.Intra, i) // Remove loopy entry for j, v := range sub.Intra { @@ -168,7 +168,7 @@ func symmetrizeBandwidth(bandwidth map[ifid.IfIDType]InterfaceBandwidths) { if bandwidth[j].Intra == nil { bandwidth[j] = InterfaceBandwidths{ Inter: bandwidth[j].Inter, - Intra: make(map[ifid.IfIDType]uint64), + Intra: make(map[iface.IfIDType]uint64), } } vTransposed, ok := bandwidth[j].Intra[i] @@ -181,13 +181,13 @@ func symmetrizeBandwidth(bandwidth map[ifid.IfIDType]InterfaceBandwidths) { } // symmetrizeHops makes the Intra hops values symmetric -func symmetrizeHops(hops map[ifid.IfIDType]InterfaceHops) { +func symmetrizeHops(hops map[iface.IfIDType]InterfaceHops) { for i, sub := range hops { delete(sub.Intra, i) // Remove loopy entry for j, v := range sub.Intra { if _, ok := hops[j]; !ok { hops[j] = InterfaceHops{ - Intra: make(map[ifid.IfIDType]uint32), + Intra: make(map[iface.IfIDType]uint32), } } vTransposed, ok := hops[j].Intra[i] @@ -205,11 +205,11 @@ func (cfg StaticInfoCfg) Generate(intfs *ifstate.Interfaces, ingress, egress uint16) *staticinfo.Extension { ifType := interfaceTypeTable(intfs) - return cfg.generate(ifType, ifid.IfIDType(ingress), ifid.IfIDType(egress)) + return cfg.generate(ifType, iface.IfIDType(ingress), iface.IfIDType(egress)) } -func (cfg StaticInfoCfg) generate(ifType map[ifid.IfIDType]topology.LinkType, - ingress, egress ifid.IfIDType) *staticinfo.Extension { +func (cfg StaticInfoCfg) generate(ifType map[iface.IfIDType]topology.LinkType, + ingress, egress iface.IfIDType) *staticinfo.Extension { return &staticinfo.Extension{ Latency: cfg.generateLatency(ifType, ingress, egress), @@ -223,12 +223,12 @@ func (cfg StaticInfoCfg) generate(ifType map[ifid.IfIDType]topology.LinkType, // generateLatency creates the LatencyInfo by extracting the relevant values from // the config. -func (cfg StaticInfoCfg) generateLatency(ifType map[ifid.IfIDType]topology.LinkType, - ingress, egress ifid.IfIDType) staticinfo.LatencyInfo { +func (cfg StaticInfoCfg) generateLatency(ifType map[iface.IfIDType]topology.LinkType, + ingress, egress iface.IfIDType) staticinfo.LatencyInfo { l := staticinfo.LatencyInfo{ - Intra: make(map[ifid.IfIDType]time.Duration), - Inter: make(map[ifid.IfIDType]time.Duration), + Intra: make(map[iface.IfIDType]time.Duration), + Inter: make(map[iface.IfIDType]time.Duration), } for ifID, v := range cfg.Latency[egress].Intra { if includeIntraInfo(ifType, ifID, ingress, egress) { @@ -246,12 +246,12 @@ func (cfg StaticInfoCfg) generateLatency(ifType map[ifid.IfIDType]topology.LinkT // generateBandwidth creates the BandwidthInfo by extracting the relevant values // from the config. -func (cfg StaticInfoCfg) generateBandwidth(ifType map[ifid.IfIDType]topology.LinkType, - ingress, egress ifid.IfIDType) staticinfo.BandwidthInfo { +func (cfg StaticInfoCfg) generateBandwidth(ifType map[iface.IfIDType]topology.LinkType, + ingress, egress iface.IfIDType) staticinfo.BandwidthInfo { bw := staticinfo.BandwidthInfo{ - Intra: make(map[ifid.IfIDType]uint64), - Inter: make(map[ifid.IfIDType]uint64), + Intra: make(map[iface.IfIDType]uint64), + Inter: make(map[iface.IfIDType]uint64), } for ifID, v := range cfg.Bandwidth[egress].Intra { if includeIntraInfo(ifType, ifID, ingress, egress) { @@ -269,8 +269,8 @@ func (cfg StaticInfoCfg) generateBandwidth(ifType map[ifid.IfIDType]topology.Lin // generateLinkType creates the LinkTypeInfo by extracting the relevant values from // the config. -func (cfg StaticInfoCfg) generateLinkType(ifType map[ifid.IfIDType]topology.LinkType, - egress ifid.IfIDType) staticinfo.LinkTypeInfo { +func (cfg StaticInfoCfg) generateLinkType(ifType map[iface.IfIDType]topology.LinkType, + egress iface.IfIDType) staticinfo.LinkTypeInfo { lt := make(staticinfo.LinkTypeInfo) for ifID, intfLT := range cfg.LinkType { @@ -284,8 +284,8 @@ func (cfg StaticInfoCfg) generateLinkType(ifType map[ifid.IfIDType]topology.Link // generateInternalHops creates the InternalHopsInfo by extracting the relevant // values from the config. -func (cfg StaticInfoCfg) generateInternalHops(ifType map[ifid.IfIDType]topology.LinkType, - ingress, egress ifid.IfIDType) staticinfo.InternalHopsInfo { +func (cfg StaticInfoCfg) generateInternalHops(ifType map[iface.IfIDType]topology.LinkType, + ingress, egress iface.IfIDType) staticinfo.InternalHopsInfo { ihi := make(staticinfo.InternalHopsInfo) for ifID, v := range cfg.Hops[egress].Intra { @@ -298,8 +298,8 @@ func (cfg StaticInfoCfg) generateInternalHops(ifType map[ifid.IfIDType]topology. // generateGeo creates the GeoInfo by extracting the relevant values from // the config. -func (cfg StaticInfoCfg) generateGeo(ifType map[ifid.IfIDType]topology.LinkType, - ingress, egress ifid.IfIDType) staticinfo.GeoInfo { +func (cfg StaticInfoCfg) generateGeo(ifType map[iface.IfIDType]topology.LinkType, + ingress, egress iface.IfIDType) staticinfo.GeoInfo { gi := staticinfo.GeoInfo{} for ifID, loc := range cfg.Geo { @@ -331,8 +331,8 @@ func (cfg StaticInfoCfg) generateGeo(ifType map[ifid.IfIDType]topology.LinkType, // AS needs to pick one consistently (or decide to just include the full // information all the time), otherwise information for cross-overs may // be missing. -func includeIntraInfo(ifType map[ifid.IfIDType]topology.LinkType, - ifID, ingress, egress ifid.IfIDType) bool { +func includeIntraInfo(ifType map[iface.IfIDType]topology.LinkType, + ifID, ingress, egress iface.IfIDType) bool { isCoreIngress := (ifType[ingress] == topology.Core || ingress == 0) isCoreEgress := (ifType[egress] == topology.Core || egress == 0) @@ -347,11 +347,11 @@ func includeIntraInfo(ifType map[ifid.IfIDType]topology.LinkType, t == topology.Peer } -func interfaceTypeTable(intfs *ifstate.Interfaces) map[ifid.IfIDType]topology.LinkType { +func interfaceTypeTable(intfs *ifstate.Interfaces) map[iface.IfIDType]topology.LinkType { ifMap := intfs.All() - ifTypes := make(map[ifid.IfIDType]topology.LinkType, len(ifMap)) + ifTypes := make(map[iface.IfIDType]topology.LinkType, len(ifMap)) for ifID, ifInfo := range ifMap { - ifTypes[ifid.IfIDType(ifID)] = ifInfo.TopoInfo().LinkType + ifTypes[iface.IfIDType(ifID)] = ifInfo.TopoInfo().LinkType } return ifTypes } diff --git a/control/beaconing/staticinfo_config_test.go b/control/beaconing/staticinfo_config_test.go index 4ee33da7e0..8d540ce111 100644 --- a/control/beaconing/staticinfo_config_test.go +++ b/control/beaconing/staticinfo_config_test.go @@ -23,7 +23,7 @@ import ( "github.com/scionproto/scion/control/beaconing" "github.com/scionproto/scion/pkg/private/util" "github.com/scionproto/scion/pkg/segment/extensions/staticinfo" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/private/topology" ) @@ -95,10 +95,10 @@ func getTestConfigData() *beaconing.StaticInfoCfg { } return &beaconing.StaticInfoCfg{ - Latency: map[ifid.IfIDType]beaconing.InterfaceLatencies{ + Latency: map[iface.IfIDType]beaconing.InterfaceLatencies{ 1: { Inter: w(latency_inter_1), - Intra: map[ifid.IfIDType]util.DurWrap{ + Intra: map[iface.IfIDType]util.DurWrap{ 2: w(latency_intra_1_2), 3: w(latency_intra_1_3), 5: w(latency_intra_1_5), @@ -106,7 +106,7 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 2: { Inter: w(latency_inter_2), - Intra: map[ifid.IfIDType]util.DurWrap{ + Intra: map[iface.IfIDType]util.DurWrap{ 1: w(latency_intra_1_2), 3: w(latency_intra_2_3), 5: w(latency_intra_2_5), @@ -114,7 +114,7 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 3: { Inter: w(latency_inter_3), - Intra: map[ifid.IfIDType]util.DurWrap{ + Intra: map[iface.IfIDType]util.DurWrap{ 1: w(latency_intra_1_3), 2: w(latency_intra_2_3), 5: w(latency_intra_3_5), @@ -122,17 +122,17 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 5: { Inter: w(latency_inter_5), - Intra: map[ifid.IfIDType]util.DurWrap{ + Intra: map[iface.IfIDType]util.DurWrap{ 1: w(latency_intra_1_5), 2: w(latency_intra_2_5), 3: w(latency_intra_3_5), }, }, }, - Bandwidth: map[ifid.IfIDType]beaconing.InterfaceBandwidths{ + Bandwidth: map[iface.IfIDType]beaconing.InterfaceBandwidths{ 1: { Inter: bandwidth_inter_1, - Intra: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{ 2: bandwidth_intra_1_2, 3: bandwidth_intra_1_3, 5: bandwidth_intra_1_5, @@ -140,7 +140,7 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 2: { Inter: bandwidth_inter_2, - Intra: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{ 1: bandwidth_intra_1_2, 3: bandwidth_intra_2_3, 5: bandwidth_intra_2_5, @@ -148,7 +148,7 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 3: { Inter: bandwidth_inter_3, - Intra: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{ 1: bandwidth_intra_1_3, 2: bandwidth_intra_2_3, 5: bandwidth_intra_3_5, @@ -156,49 +156,49 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 5: { Inter: bandwidth_inter_5, - Intra: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{ 1: bandwidth_intra_1_5, 2: bandwidth_intra_2_5, 3: bandwidth_intra_3_5, }, }, }, - LinkType: map[ifid.IfIDType]beaconing.LinkType{ + LinkType: map[iface.IfIDType]beaconing.LinkType{ 1: beaconing.LinkType(link_type_1), 2: beaconing.LinkType(link_type_2), 3: beaconing.LinkType(link_type_3), 5: beaconing.LinkType(link_type_5), }, - Geo: map[ifid.IfIDType]beaconing.InterfaceGeodata{ + Geo: map[iface.IfIDType]beaconing.InterfaceGeodata{ 1: {geo_1.Longitude, geo_1.Latitude, geo_1.Address}, 2: {geo_2.Longitude, geo_2.Latitude, geo_2.Address}, 3: {geo_3.Longitude, geo_3.Latitude, geo_3.Address}, 5: {geo_5.Longitude, geo_5.Latitude, geo_5.Address}, }, - Hops: map[ifid.IfIDType]beaconing.InterfaceHops{ + Hops: map[iface.IfIDType]beaconing.InterfaceHops{ 1: { - Intra: map[ifid.IfIDType]uint32{ + Intra: map[iface.IfIDType]uint32{ 2: hops_intra_1_2, 3: hops_intra_1_3, 5: hops_intra_1_5, }, }, 2: { - Intra: map[ifid.IfIDType]uint32{ + Intra: map[iface.IfIDType]uint32{ 1: hops_intra_1_2, 3: hops_intra_2_3, 5: hops_intra_2_5, }, }, 3: { - Intra: map[ifid.IfIDType]uint32{ + Intra: map[iface.IfIDType]uint32{ 1: hops_intra_1_3, 2: hops_intra_2_3, 5: hops_intra_3_5, }, }, 5: { - Intra: map[ifid.IfIDType]uint32{ + Intra: map[iface.IfIDType]uint32{ 1: hops_intra_1_5, 2: hops_intra_2_5, 3: hops_intra_3_5, @@ -221,14 +221,14 @@ func TestGenerateStaticInfo(t *testing.T) { cfg := getTestConfigData() // "topology" information for a non-core AS: - ifTypeNoncore := map[ifid.IfIDType]topology.LinkType{ + ifTypeNoncore := map[iface.IfIDType]topology.LinkType{ 1: topology.Child, 2: topology.Child, 3: topology.Parent, 5: topology.Peer, } // "topology" information for a core AS: - ifTypeCore := map[ifid.IfIDType]topology.LinkType{ + ifTypeCore := map[iface.IfIDType]topology.LinkType{ 1: topology.Core, 2: topology.Child, 3: topology.Core, @@ -237,9 +237,9 @@ func TestGenerateStaticInfo(t *testing.T) { testCases := []struct { name string - ingress ifid.IfIDType - egress ifid.IfIDType - ifType map[ifid.IfIDType]topology.LinkType + ingress iface.IfIDType + egress iface.IfIDType + ifType map[iface.IfIDType]topology.LinkType expected staticinfo.Extension }{ { @@ -249,23 +249,23 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[ifid.IfIDType]time.Duration{ + Intra: map[iface.IfIDType]time.Duration{ 2: latency_intra_1_2, 3: latency_intra_1_3, 5: latency_intra_1_5, }, - Inter: map[ifid.IfIDType]time.Duration{ + Inter: map[iface.IfIDType]time.Duration{ 1: latency_inter_1, 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{ 2: bandwidth_intra_1_2, 3: bandwidth_intra_1_3, 5: bandwidth_intra_1_5, }, - Inter: map[ifid.IfIDType]uint64{ + Inter: map[iface.IfIDType]uint64{ 1: bandwidth_inter_1, 5: bandwidth_inter_5, }, @@ -279,7 +279,7 @@ func TestGenerateStaticInfo(t *testing.T) { 1: link_type_1, 5: link_type_5, }, - InternalHops: map[ifid.IfIDType]uint32{ + InternalHops: map[iface.IfIDType]uint32{ 2: hops_intra_1_2, 3: hops_intra_1_3, 5: hops_intra_1_5, @@ -294,21 +294,21 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[ifid.IfIDType]time.Duration{ + Intra: map[iface.IfIDType]time.Duration{ 3: latency_intra_2_3, 5: latency_intra_2_5, }, - Inter: map[ifid.IfIDType]time.Duration{ + Inter: map[iface.IfIDType]time.Duration{ 2: latency_inter_2, 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{ 3: bandwidth_intra_2_3, 5: bandwidth_intra_2_5, }, - Inter: map[ifid.IfIDType]uint64{ + Inter: map[iface.IfIDType]uint64{ 2: bandwidth_inter_2, 5: bandwidth_inter_5, }, @@ -322,7 +322,7 @@ func TestGenerateStaticInfo(t *testing.T) { 2: link_type_2, 5: link_type_5, }, - InternalHops: map[ifid.IfIDType]uint32{ + InternalHops: map[iface.IfIDType]uint32{ 3: hops_intra_2_3, 5: hops_intra_2_5, }, @@ -336,14 +336,14 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[ifid.IfIDType]time.Duration{}, - Inter: map[ifid.IfIDType]time.Duration{ + Intra: map[iface.IfIDType]time.Duration{}, + Inter: map[iface.IfIDType]time.Duration{ 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[ifid.IfIDType]uint64{}, - Inter: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{}, + Inter: map[iface.IfIDType]uint64{ 5: bandwidth_inter_5, }, }, @@ -354,7 +354,7 @@ func TestGenerateStaticInfo(t *testing.T) { LinkType: staticinfo.LinkTypeInfo{ 5: link_type_5, }, - InternalHops: map[ifid.IfIDType]uint32{}, + InternalHops: map[iface.IfIDType]uint32{}, Note: note, }, }, @@ -365,21 +365,21 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[ifid.IfIDType]time.Duration{ + Intra: map[iface.IfIDType]time.Duration{ 2: latency_intra_1_2, 5: latency_intra_1_5, }, - Inter: map[ifid.IfIDType]time.Duration{ + Inter: map[iface.IfIDType]time.Duration{ 1: latency_inter_1, 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{ 2: bandwidth_intra_1_2, 5: bandwidth_intra_1_5, }, - Inter: map[ifid.IfIDType]uint64{ + Inter: map[iface.IfIDType]uint64{ 1: bandwidth_inter_1, 5: bandwidth_inter_5, }, @@ -392,7 +392,7 @@ func TestGenerateStaticInfo(t *testing.T) { 1: link_type_1, 5: link_type_5, }, - InternalHops: map[ifid.IfIDType]uint32{ + InternalHops: map[iface.IfIDType]uint32{ 2: hops_intra_1_2, 5: hops_intra_1_5, }, @@ -406,19 +406,19 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[ifid.IfIDType]time.Duration{ + Intra: map[iface.IfIDType]time.Duration{ 5: latency_intra_2_5, }, - Inter: map[ifid.IfIDType]time.Duration{ + Inter: map[iface.IfIDType]time.Duration{ 2: latency_inter_2, 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{ 5: bandwidth_intra_2_5, }, - Inter: map[ifid.IfIDType]uint64{ + Inter: map[iface.IfIDType]uint64{ 2: bandwidth_inter_2, 5: bandwidth_inter_5, }, @@ -431,7 +431,7 @@ func TestGenerateStaticInfo(t *testing.T) { 2: link_type_2, 5: link_type_5, }, - InternalHops: map[ifid.IfIDType]uint32{ + InternalHops: map[iface.IfIDType]uint32{ 5: hops_intra_2_5, }, Note: note, @@ -444,22 +444,22 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeCore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[ifid.IfIDType]time.Duration{ + Intra: map[iface.IfIDType]time.Duration{ 1: latency_intra_1_2, 3: latency_intra_2_3, 5: latency_intra_2_5, }, - Inter: map[ifid.IfIDType]time.Duration{ + Inter: map[iface.IfIDType]time.Duration{ 2: latency_inter_2, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{ 1: bandwidth_intra_1_2, 3: bandwidth_intra_2_3, 5: bandwidth_intra_2_5, }, - Inter: map[ifid.IfIDType]uint64{ + Inter: map[iface.IfIDType]uint64{ 2: bandwidth_inter_2, }, }, @@ -469,7 +469,7 @@ func TestGenerateStaticInfo(t *testing.T) { LinkType: staticinfo.LinkTypeInfo{ 2: link_type_2, }, - InternalHops: map[ifid.IfIDType]uint32{ + InternalHops: map[iface.IfIDType]uint32{ 1: hops_intra_1_2, 3: hops_intra_2_3, 5: hops_intra_2_5, @@ -484,14 +484,14 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeCore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[ifid.IfIDType]time.Duration{}, - Inter: map[ifid.IfIDType]time.Duration{ + Intra: map[iface.IfIDType]time.Duration{}, + Inter: map[iface.IfIDType]time.Duration{ 1: latency_inter_1, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[ifid.IfIDType]uint64{}, - Inter: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{}, + Inter: map[iface.IfIDType]uint64{ 1: bandwidth_inter_1, }, }, @@ -501,7 +501,7 @@ func TestGenerateStaticInfo(t *testing.T) { LinkType: staticinfo.LinkTypeInfo{ 1: link_type_1, }, - InternalHops: map[ifid.IfIDType]uint32{}, + InternalHops: map[iface.IfIDType]uint32{}, Note: note, }, }, @@ -512,18 +512,18 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeCore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[ifid.IfIDType]time.Duration{ + Intra: map[iface.IfIDType]time.Duration{ 3: latency_intra_1_3, }, - Inter: map[ifid.IfIDType]time.Duration{ + Inter: map[iface.IfIDType]time.Duration{ 1: latency_inter_1, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{ 3: bandwidth_intra_1_3, }, - Inter: map[ifid.IfIDType]uint64{ + Inter: map[iface.IfIDType]uint64{ 1: bandwidth_inter_1, }, }, @@ -534,7 +534,7 @@ func TestGenerateStaticInfo(t *testing.T) { LinkType: staticinfo.LinkTypeInfo{ 1: link_type_1, }, - InternalHops: map[ifid.IfIDType]uint32{ + InternalHops: map[iface.IfIDType]uint32{ 3: hops_intra_1_3, }, Note: note, @@ -547,18 +547,18 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeCore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[ifid.IfIDType]time.Duration{}, - Inter: map[ifid.IfIDType]time.Duration{}, + Intra: map[iface.IfIDType]time.Duration{}, + Inter: map[iface.IfIDType]time.Duration{}, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[ifid.IfIDType]uint64{}, - Inter: map[ifid.IfIDType]uint64{}, + Intra: map[iface.IfIDType]uint64{}, + Inter: map[iface.IfIDType]uint64{}, }, Geo: staticinfo.GeoInfo{ 3: geo_3, }, LinkType: staticinfo.LinkTypeInfo{}, - InternalHops: map[ifid.IfIDType]uint32{}, + InternalHops: map[iface.IfIDType]uint32{}, Note: note, }, }, diff --git a/control/beaconing/writer_test.go b/control/beaconing/writer_test.go index e9c56b1ac1..197aacf453 100644 --- a/control/beaconing/writer_test.go +++ b/control/beaconing/writer_test.go @@ -42,7 +42,7 @@ import ( "github.com/scionproto/scion/pkg/scrypto/cppki" "github.com/scionproto/scion/pkg/scrypto/signed" seg "github.com/scionproto/scion/pkg/segment" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/slayers/path/scion" "github.com/scionproto/scion/pkg/snet" "github.com/scionproto/scion/pkg/snet/addrutil" @@ -377,7 +377,7 @@ type topoWrap struct { } func (w topoWrap) UnderlayNextHop(id uint16) *net.UDPAddr { - a, _ := w.Topo.UnderlayNextHop(ifid.IfIDType(id)) + a, _ := w.Topo.UnderlayNextHop(iface.IfIDType(id)) return a } diff --git a/control/cmd/control/BUILD.bazel b/control/cmd/control/BUILD.bazel index ab11521517..88600bb13b 100644 --- a/control/cmd/control/BUILD.bazel +++ b/control/cmd/control/BUILD.bazel @@ -36,7 +36,7 @@ go_library( "//pkg/proto/discovery:go_default_library", "//pkg/scrypto:go_default_library", "//pkg/scrypto/cppki:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/snet:go_default_library", "//private/app:go_default_library", "//private/app/appnet:go_default_library", diff --git a/control/cmd/control/main.go b/control/cmd/control/main.go index afb073c89e..23446769b7 100644 --- a/control/cmd/control/main.go +++ b/control/cmd/control/main.go @@ -62,7 +62,7 @@ import ( dpb "github.com/scionproto/scion/pkg/proto/discovery" "github.com/scionproto/scion/pkg/scrypto" "github.com/scionproto/scion/pkg/scrypto/cppki" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/snet" "github.com/scionproto/scion/private/app" infraenv "github.com/scionproto/scion/private/app/appnet" @@ -852,7 +852,7 @@ func createBeaconStore( return store, *policies.Prop.Filter.AllowIsdLoop, err } -func adaptInterfaceMap(in map[ifid.IfIDType]topology.IFInfo) map[uint16]ifstate.InterfaceInfo { +func adaptInterfaceMap(in map[iface.IfIDType]topology.IFInfo) map[uint16]ifstate.InterfaceInfo { converted := make(map[uint16]ifstate.InterfaceInfo, len(in)) for id, info := range in { converted[uint16(id)] = ifstate.InterfaceInfo{ diff --git a/daemon/internal/servers/BUILD.bazel b/daemon/internal/servers/BUILD.bazel index 580a4546f3..df44d0fd83 100644 --- a/daemon/internal/servers/BUILD.bazel +++ b/daemon/internal/servers/BUILD.bazel @@ -21,7 +21,7 @@ go_library( "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", "//pkg/proto/daemon:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/snet:go_default_library", "//pkg/snet/path:go_default_library", "//private/revcache:go_default_library", diff --git a/daemon/internal/servers/grpc.go b/daemon/internal/servers/grpc.go index 76e35d517c..4e7b89cd19 100644 --- a/daemon/internal/servers/grpc.go +++ b/daemon/internal/servers/grpc.go @@ -38,7 +38,7 @@ import ( "github.com/scionproto/scion/pkg/private/util" pb_daemon "github.com/scionproto/scion/pkg/proto/daemon" sdpb "github.com/scionproto/scion/pkg/proto/daemon" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/snet" snetpath "github.com/scionproto/scion/pkg/snet/path" "github.com/scionproto/scion/private/revcache" @@ -337,7 +337,7 @@ func (s *DaemonServer) notifyInterfaceDown(ctx context.Context, revInfo := &path_mgmt.RevInfo{ RawIsdas: addr.IA(req.IsdAs), - IfID: ifid.IfIDType(req.Id), + IfID: iface.IfIDType(req.Id), LinkType: proto.LinkType_core, RawTTL: 10, RawTimestamp: util.TimeToSecs(time.Now()), diff --git a/gateway/pathhealth/BUILD.bazel b/gateway/pathhealth/BUILD.bazel index f497e9b642..74062c75d0 100644 --- a/gateway/pathhealth/BUILD.bazel +++ b/gateway/pathhealth/BUILD.bazel @@ -35,7 +35,7 @@ go_test( "//pkg/addr:go_default_library", "//pkg/private/ctrl/path_mgmt:go_default_library", "//pkg/private/util:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/snet:go_default_library", "//pkg/snet/mock_snet:go_default_library", "@com_github_golang_mock//gomock:go_default_library", diff --git a/gateway/pathhealth/revocations_test.go b/gateway/pathhealth/revocations_test.go index fbf891289f..5b5c86dffb 100644 --- a/gateway/pathhealth/revocations_test.go +++ b/gateway/pathhealth/revocations_test.go @@ -26,7 +26,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt" "github.com/scionproto/scion/pkg/private/util" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/snet" "github.com/scionproto/scion/pkg/snet/mock_snet" ) @@ -69,7 +69,7 @@ func TestExpiredRevocation(t *testing.T) { s.Cleanup(context.Background()) } -func createMockPath(ctrl *gomock.Controller, ia addr.IA, ifID ifid.IfIDType) snet.Path { +func createMockPath(ctrl *gomock.Controller, ia addr.IA, ifID iface.IfIDType) snet.Path { path := mock_snet.NewMockPath(ctrl) path.EXPECT().Metadata().Return(&snet.PathMetadata{ Interfaces: []snet.PathInterface{{IA: ia, ID: ifID}}, @@ -77,7 +77,7 @@ func createMockPath(ctrl *gomock.Controller, ia addr.IA, ifID ifid.IfIDType) sne return path } -func createRevInfo(ia addr.IA, ifID ifid.IfIDType, expired bool) *path_mgmt.RevInfo { +func createRevInfo(ia addr.IA, ifID iface.IfIDType, expired bool) *path_mgmt.RevInfo { ri := &path_mgmt.RevInfo{ RawIsdas: ia, IfID: ifID, diff --git a/pkg/daemon/BUILD.bazel b/pkg/daemon/BUILD.bazel index 825487a360..ad0a44f9db 100644 --- a/pkg/daemon/BUILD.bazel +++ b/pkg/daemon/BUILD.bazel @@ -22,7 +22,7 @@ go_library( "//pkg/proto/daemon:go_default_library", "//pkg/proto/drkey:go_default_library", "//pkg/scrypto/cppki:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/snet:go_default_library", "//pkg/snet/path:go_default_library", "//private/topology:go_default_library", diff --git a/pkg/daemon/grpc.go b/pkg/daemon/grpc.go index c31e648dfb..6dbae22872 100644 --- a/pkg/daemon/grpc.go +++ b/pkg/daemon/grpc.go @@ -32,7 +32,7 @@ import ( sdpb "github.com/scionproto/scion/pkg/proto/daemon" dkpb "github.com/scionproto/scion/pkg/proto/drkey" "github.com/scionproto/scion/pkg/scrypto/cppki" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/snet" "github.com/scionproto/scion/pkg/snet/path" "github.com/scionproto/scion/private/topology" @@ -260,7 +260,7 @@ func convertPath(p *sdpb.Path, dst addr.IA) (path.Path, error) { interfaces := make([]snet.PathInterface, len(p.Interfaces)) for i, pi := range p.Interfaces { interfaces[i] = snet.PathInterface{ - ID: ifid.IfIDType(pi.Id), + ID: iface.IfIDType(pi.Id), IA: addr.IA(pi.IsdAs), } } diff --git a/pkg/experimental/hiddenpath/BUILD.bazel b/pkg/experimental/hiddenpath/BUILD.bazel index aba51abbb9..1ff9dc2d72 100644 --- a/pkg/experimental/hiddenpath/BUILD.bazel +++ b/pkg/experimental/hiddenpath/BUILD.bazel @@ -63,7 +63,7 @@ go_test( "//pkg/scrypto/cppki:go_default_library", "//pkg/scrypto/signed:go_default_library", "//pkg/segment:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/slayers/path/scion:go_default_library", "//pkg/snet:go_default_library", diff --git a/pkg/experimental/hiddenpath/beaconwriter_test.go b/pkg/experimental/hiddenpath/beaconwriter_test.go index 4cdacedb0b..d028fe0a27 100644 --- a/pkg/experimental/hiddenpath/beaconwriter_test.go +++ b/pkg/experimental/hiddenpath/beaconwriter_test.go @@ -44,7 +44,7 @@ import ( "github.com/scionproto/scion/pkg/scrypto/cppki" "github.com/scionproto/scion/pkg/scrypto/signed" seg "github.com/scionproto/scion/pkg/segment" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/slayers/path/scion" "github.com/scionproto/scion/pkg/snet" "github.com/scionproto/scion/pkg/snet/addrutil" @@ -348,7 +348,7 @@ type topoWrap struct { } func (w topoWrap) UnderlayNextHop(id uint16) *net.UDPAddr { - a, _ := w.Topo.UnderlayNextHop(ifid.IfIDType(id)) + a, _ := w.Topo.UnderlayNextHop(iface.IfIDType(id)) return a } diff --git a/pkg/private/common/defs_test.go b/pkg/private/common/defs_test.go index 046d2ae334..cd13c2fe65 100644 --- a/pkg/private/common/defs_test.go +++ b/pkg/private/common/defs_test.go @@ -17,8 +17,9 @@ package common_test import ( "testing" - "github.com/scionproto/scion/pkg/private/common" "github.com/stretchr/testify/assert" + + "github.com/scionproto/scion/pkg/private/common" ) func TestTypeOf(t *testing.T) { diff --git a/pkg/private/ctrl/path_mgmt/BUILD.bazel b/pkg/private/ctrl/path_mgmt/BUILD.bazel index 7fbea1ceee..98ccf0d48f 100644 --- a/pkg/private/ctrl/path_mgmt/BUILD.bazel +++ b/pkg/private/ctrl/path_mgmt/BUILD.bazel @@ -10,6 +10,6 @@ go_library( "//pkg/private/ctrl/path_mgmt/proto:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", ], ) diff --git a/pkg/private/ctrl/path_mgmt/rev_info.go b/pkg/private/ctrl/path_mgmt/rev_info.go index 70b0fa65be..b2e61cbc1d 100644 --- a/pkg/private/ctrl/path_mgmt/rev_info.go +++ b/pkg/private/ctrl/path_mgmt/rev_info.go @@ -25,7 +25,7 @@ import ( "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt/proto" "github.com/scionproto/scion/pkg/private/serrors" "github.com/scionproto/scion/pkg/private/util" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" ) const MinRevTTL = 10 * time.Second // MinRevTTL is the minimum lifetime of a revocation @@ -47,7 +47,7 @@ func (ee RevTimeError) Error() string { } type RevInfo struct { - IfID ifid.IfIDType + IfID iface.IfIDType RawIsdas addr.IA // LinkType of revocation LinkType proto.LinkType diff --git a/pkg/private/xtest/graph/BUILD.bazel b/pkg/private/xtest/graph/BUILD.bazel index f5c502c2c4..521908ddbe 100644 --- a/pkg/private/xtest/graph/BUILD.bazel +++ b/pkg/private/xtest/graph/BUILD.bazel @@ -17,7 +17,7 @@ go_library( "//pkg/scrypto/signed:go_default_library", "//pkg/segment:go_default_library", "//pkg/segment/extensions/staticinfo:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/slayers/path:go_default_library", "@com_github_golang_mock//gomock:go_default_library", "@org_golang_google_protobuf//proto:go_default_library", diff --git a/pkg/private/xtest/graph/graph.go b/pkg/private/xtest/graph/graph.go index 9f0b72d14c..e9da602ea0 100644 --- a/pkg/private/xtest/graph/graph.go +++ b/pkg/private/xtest/graph/graph.go @@ -44,7 +44,7 @@ import ( "github.com/scionproto/scion/pkg/scrypto/signed" seg "github.com/scionproto/scion/pkg/segment" "github.com/scionproto/scion/pkg/segment/extensions/staticinfo" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/slayers/path" ) @@ -603,55 +603,55 @@ func generateStaticInfo(g *Graph, ia addr.IA, inIF, outIF uint16) *staticinfo.Ex latency := staticinfo.LatencyInfo{} if outIF != 0 { - latency.Intra = make(map[ifid.IfIDType]time.Duration) - latency.Inter = make(map[ifid.IfIDType]time.Duration) + latency.Intra = make(map[iface.IfIDType]time.Duration) + latency.Inter = make(map[iface.IfIDType]time.Duration) for ifID := range as.IfIDs { if ifID != outIF { // Note: the test graph does not distinguish between parent/child or // core interfaces. // Otherwise, we could skip the parent interfaces and half of the // sibling interfaces here. - latency.Intra[ifid.IfIDType(ifID)] = g.Latency(ifID, outIF) + latency.Intra[iface.IfIDType(ifID)] = g.Latency(ifID, outIF) } if ifID == outIF || g.isPeer[ifID] { - latency.Inter[ifid.IfIDType(ifID)] = g.Latency(ifID, g.links[ifID]) + latency.Inter[iface.IfIDType(ifID)] = g.Latency(ifID, g.links[ifID]) } } } bandwidth := staticinfo.BandwidthInfo{} if outIF != 0 { - bandwidth.Intra = make(map[ifid.IfIDType]uint64) - bandwidth.Inter = make(map[ifid.IfIDType]uint64) + bandwidth.Intra = make(map[iface.IfIDType]uint64) + bandwidth.Inter = make(map[iface.IfIDType]uint64) for ifID := range as.IfIDs { if ifID != outIF { - bandwidth.Intra[ifid.IfIDType(ifID)] = g.Bandwidth(ifID, outIF) + bandwidth.Intra[iface.IfIDType(ifID)] = g.Bandwidth(ifID, outIF) } if ifID == outIF || g.isPeer[ifID] { - bandwidth.Inter[ifid.IfIDType(ifID)] = g.Bandwidth(ifID, g.links[ifID]) + bandwidth.Inter[iface.IfIDType(ifID)] = g.Bandwidth(ifID, g.links[ifID]) } } } geo := make(staticinfo.GeoInfo) for ifID := range as.IfIDs { - geo[ifid.IfIDType(ifID)] = g.GeoCoordinates(ifID) + geo[iface.IfIDType(ifID)] = g.GeoCoordinates(ifID) } linkType := make(staticinfo.LinkTypeInfo) for ifID := range as.IfIDs { - linkType[ifid.IfIDType(ifID)] = g.LinkType(ifID, g.links[ifID]) + linkType[iface.IfIDType(ifID)] = g.LinkType(ifID, g.links[ifID]) } var internalHops staticinfo.InternalHopsInfo if outIF != 0 { - internalHops = make(map[ifid.IfIDType]uint32) + internalHops = make(map[iface.IfIDType]uint32) if inIF != 0 { - internalHops[ifid.IfIDType(inIF)] = g.InternalHops(inIF, outIF) + internalHops[iface.IfIDType(inIF)] = g.InternalHops(inIF, outIF) } for ifID := range as.IfIDs { if ifID != outIF && ifID != inIF { - internalHops[ifid.IfIDType(ifID)] = g.InternalHops(ifID, outIF) + internalHops[iface.IfIDType(ifID)] = g.InternalHops(ifID, outIF) } } } diff --git a/pkg/segment/extensions/staticinfo/BUILD.bazel b/pkg/segment/extensions/staticinfo/BUILD.bazel index 3debee5c35..f453b792bb 100644 --- a/pkg/segment/extensions/staticinfo/BUILD.bazel +++ b/pkg/segment/extensions/staticinfo/BUILD.bazel @@ -7,7 +7,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/proto/control_plane:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", ], ) @@ -16,7 +16,7 @@ go_test( srcs = ["staticinfo_test.go"], deps = [ ":go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "@com_github_stretchr_testify//assert:go_default_library", ], ) diff --git a/pkg/segment/extensions/staticinfo/staticinfo.go b/pkg/segment/extensions/staticinfo/staticinfo.go index 6fb9d06eac..80d43abd46 100644 --- a/pkg/segment/extensions/staticinfo/staticinfo.go +++ b/pkg/segment/extensions/staticinfo/staticinfo.go @@ -22,7 +22,7 @@ import ( "time" cppb "github.com/scionproto/scion/pkg/proto/control_plane" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" ) // Extension is the internal repesentation of the StaticInfoExtension path @@ -39,20 +39,20 @@ type Extension struct { // LatencyInfo is the internal repesentation of `latency` in the // StaticInfoExtension. type LatencyInfo struct { - Intra map[ifid.IfIDType]time.Duration - Inter map[ifid.IfIDType]time.Duration + Intra map[iface.IfIDType]time.Duration + Inter map[iface.IfIDType]time.Duration } // BandwidthInfo is the internal repesentation of `bandwidth` in the // StaticInfoExtension. type BandwidthInfo struct { - Intra map[ifid.IfIDType]uint64 - Inter map[ifid.IfIDType]uint64 + Intra map[iface.IfIDType]uint64 + Inter map[iface.IfIDType]uint64 } // GeoInfo is the internal repesentation of `geo` in the // StaticInfoExtension. -type GeoInfo map[ifid.IfIDType]GeoCoordinates +type GeoInfo map[iface.IfIDType]GeoCoordinates // GeoCoordinates is the internal repesentation of the GeoCoordinates in the // StaticInfoExtension. @@ -76,11 +76,11 @@ const ( // LinkTypeInfo is the internal representation of `link_type` in the // StaticInfoExtension. -type LinkTypeInfo map[ifid.IfIDType]LinkType +type LinkTypeInfo map[iface.IfIDType]LinkType // InternalHopsInfo is the internal representation of `internal_hops` in the // StaticInfoExtension. -type InternalHopsInfo map[ifid.IfIDType]uint32 +type InternalHopsInfo map[iface.IfIDType]uint32 // FromPB creates the staticinfo Extension from the protobuf representation. func FromPB(pb *cppb.StaticInfoExtension) *Extension { @@ -101,13 +101,13 @@ func latencyInfoFromPB(pb *cppb.LatencyInfo) LatencyInfo { if pb == nil || len(pb.Intra) == 0 && len(pb.Inter) == 0 { return LatencyInfo{} } - intra := make(map[ifid.IfIDType]time.Duration, len(pb.Intra)) + intra := make(map[iface.IfIDType]time.Duration, len(pb.Intra)) for ifID, v := range pb.Intra { - intra[ifid.IfIDType(ifID)] = time.Duration(v) * time.Microsecond + intra[iface.IfIDType(ifID)] = time.Duration(v) * time.Microsecond } - inter := make(map[ifid.IfIDType]time.Duration, len(pb.Inter)) + inter := make(map[iface.IfIDType]time.Duration, len(pb.Inter)) for ifID, v := range pb.Inter { - inter[ifid.IfIDType(ifID)] = time.Duration(v) * time.Microsecond + inter[iface.IfIDType(ifID)] = time.Duration(v) * time.Microsecond } return LatencyInfo{ Intra: intra, @@ -119,13 +119,13 @@ func bandwidthInfoFromPB(pb *cppb.BandwidthInfo) BandwidthInfo { if pb == nil || len(pb.Intra) == 0 && len(pb.Inter) == 0 { return BandwidthInfo{} } - intra := make(map[ifid.IfIDType]uint64, len(pb.Intra)) + intra := make(map[iface.IfIDType]uint64, len(pb.Intra)) for ifID, v := range pb.Intra { - intra[ifid.IfIDType(ifID)] = v + intra[iface.IfIDType(ifID)] = v } - inter := make(map[ifid.IfIDType]uint64, len(pb.Inter)) + inter := make(map[iface.IfIDType]uint64, len(pb.Inter)) for ifID, v := range pb.Inter { - inter[ifid.IfIDType(ifID)] = v + inter[iface.IfIDType(ifID)] = v } return BandwidthInfo{ Intra: intra, @@ -139,7 +139,7 @@ func geoInfoFromPB(pb map[uint64]*cppb.GeoCoordinates) GeoInfo { } gi := make(GeoInfo, len(pb)) for ifID, v := range pb { - gi[ifid.IfIDType(ifID)] = GeoCoordinates{ + gi[iface.IfIDType(ifID)] = GeoCoordinates{ Latitude: v.Latitude, Longitude: v.Longitude, Address: v.Address, @@ -167,7 +167,7 @@ func linkTypeInfoFromPB(pb map[uint64]cppb.LinkType) LinkTypeInfo { default: continue } - lti[ifid.IfIDType(ifID)] = v + lti[iface.IfIDType(ifID)] = v } return lti } @@ -178,7 +178,7 @@ func internalHopsInfoFromPB(pb map[uint64]uint32) InternalHopsInfo { } ihi := make(InternalHopsInfo, len(pb)) for ifID, v := range pb { - ihi[ifid.IfIDType(ifID)] = v + ihi[iface.IfIDType(ifID)] = v } return ihi } diff --git a/pkg/segment/extensions/staticinfo/staticinfo_test.go b/pkg/segment/extensions/staticinfo/staticinfo_test.go index a81a6194d8..539d28d1dc 100644 --- a/pkg/segment/extensions/staticinfo/staticinfo_test.go +++ b/pkg/segment/extensions/staticinfo/staticinfo_test.go @@ -21,7 +21,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/scionproto/scion/pkg/segment/extensions/staticinfo" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" ) func TestRoundtripStaticInfoExtension(t *testing.T) { @@ -34,22 +34,22 @@ func TestRoundtripStaticInfoExtension(t *testing.T) { }, "latency": { Latency: staticinfo.LatencyInfo{ - Intra: map[ifid.IfIDType]time.Duration{ + Intra: map[iface.IfIDType]time.Duration{ 10: 10 * time.Millisecond, 11: 11 * time.Millisecond, }, - Inter: map[ifid.IfIDType]time.Duration{ + Inter: map[iface.IfIDType]time.Duration{ 11: 111 * time.Millisecond, }, }, }, "bandwidth": { Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[ifid.IfIDType]uint64{ + Intra: map[iface.IfIDType]uint64{ 10: 1, // 1Kbit/s 11: 10_000_000_000, // 10Tbit/s }, - Inter: map[ifid.IfIDType]uint64{ + Inter: map[iface.IfIDType]uint64{ 11: 2_000_000, }, }, @@ -71,7 +71,7 @@ func TestRoundtripStaticInfoExtension(t *testing.T) { }, }, "internal_hops": { - InternalHops: map[ifid.IfIDType]uint32{ + InternalHops: map[iface.IfIDType]uint32{ 10: 2, 11: 3, }, diff --git a/pkg/segment/ifid/BUILD.bazel b/pkg/segment/iface/BUILD.bazel similarity index 75% rename from pkg/segment/ifid/BUILD.bazel rename to pkg/segment/iface/BUILD.bazel index 57ca66d351..d050cfa30f 100644 --- a/pkg/segment/ifid/BUILD.bazel +++ b/pkg/segment/iface/BUILD.bazel @@ -2,14 +2,14 @@ load("//tools/lint:go.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = ["ifid.go"], - importpath = "github.com/scionproto/scion/pkg/segment/ifid", + srcs = ["iface.go"], + importpath = "github.com/scionproto/scion/pkg/segment/iface", visibility = ["//visibility:public"], ) go_test( name = "go_default_test", - srcs = ["ifid_test.go"], + srcs = ["iface_test.go"], deps = [ ":go_default_library", "@com_github_stretchr_testify//assert:go_default_library", diff --git a/pkg/segment/ifid/ifid.go b/pkg/segment/iface/iface.go similarity index 90% rename from pkg/segment/ifid/ifid.go rename to pkg/segment/iface/iface.go index 56f365be19..0d1a5c4464 100644 --- a/pkg/segment/ifid/ifid.go +++ b/pkg/segment/iface/iface.go @@ -13,15 +13,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -package ifid +package iface import ( "strconv" "strings" ) -// IfIDType is the path-type-independant type for interface IDs. Interface IDs must fit in -// 64 bits. There is a lot of path-type-independant code that manipulates interface IDs without +// IfIDType is the path-type-independent type for interface IDs. Interface IDs must fit in +// 64 bits. There is a lot of path-type-independent code that manipulates interface IDs without // interpreting them. This type is a container for them. type IfIDType uint64 diff --git a/pkg/segment/ifid/ifid_test.go b/pkg/segment/iface/iface_test.go similarity index 80% rename from pkg/segment/ifid/ifid_test.go rename to pkg/segment/iface/iface_test.go index 7991a18d44..6e5fb310ae 100644 --- a/pkg/segment/ifid/ifid_test.go +++ b/pkg/segment/iface/iface_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package ifid_test +package iface_test import ( "encoding/json" @@ -21,13 +21,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" ) func TestIfIDTypeUnmarshalJSON(t *testing.T) { t.Run("Simple Value", func(t *testing.T) { type exampleStruct struct { - IfID ifid.IfIDType `json:"if_id"` + IfID iface.IfIDType `json:"if_id"` } j := `{"if_id": 5}` var f exampleStruct @@ -36,17 +36,17 @@ func TestIfIDTypeUnmarshalJSON(t *testing.T) { }) t.Run("Map keys", func(t *testing.T) { type exampleStruct struct { - IfMap map[ifid.IfIDType]string `json:"if_map"` + IfMap map[iface.IfIDType]string `json:"if_map"` } j := `{"if_map": {"5": "foo"}}` var f exampleStruct require.NoError(t, json.Unmarshal([]byte(j), &f)) - assert.Equal(t, exampleStruct{IfMap: map[ifid.IfIDType]string{5: "foo"}}, f) + assert.Equal(t, exampleStruct{IfMap: map[iface.IfIDType]string{5: "foo"}}, f) }) } func TestIfIDTypeUnmarshalText(t *testing.T) { - var id ifid.IfIDType + var id iface.IfIDType assert.NoError(t, id.UnmarshalText([]byte("1"))) - assert.Equal(t, ifid.IfIDType(1), id) + assert.Equal(t, iface.IfIDType(1), id) } diff --git a/pkg/snet/BUILD.bazel b/pkg/snet/BUILD.bazel index 032d60980d..f0f8a2a654 100644 --- a/pkg/snet/BUILD.bazel +++ b/pkg/snet/BUILD.bazel @@ -27,7 +27,7 @@ go_library( "//pkg/private/ctrl/path_mgmt:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/slayers:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/slayers/path/empty:go_default_library", diff --git a/pkg/snet/path.go b/pkg/snet/path.go index 1507e41131..cf3a38413e 100644 --- a/pkg/snet/path.go +++ b/pkg/snet/path.go @@ -22,7 +22,7 @@ import ( "time" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/slayers" ) @@ -70,7 +70,7 @@ type Path interface { // PathInterface is an interface of the path. type PathInterface struct { // ID is the ID of the interface. - ID ifid.IfIDType + ID iface.IfIDType // IA is the ISD AS identifier of the interface. IA addr.IA } diff --git a/pkg/snet/scmp.go b/pkg/snet/scmp.go index ea830976b4..641a0192be 100644 --- a/pkg/snet/scmp.go +++ b/pkg/snet/scmp.go @@ -23,7 +23,7 @@ import ( "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt" "github.com/scionproto/scion/pkg/private/serrors" "github.com/scionproto/scion/pkg/private/util" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/slayers" ) @@ -73,7 +73,7 @@ func (h DefaultSCMPHandler) Handle(pkt *Packet) error { case slayers.SCMPTypeExternalInterfaceDown: msg := pkt.Payload.(SCMPExternalInterfaceDown) return h.handleSCMPRev(typeCode, &path_mgmt.RevInfo{ - IfID: ifid.IfIDType(msg.Interface), + IfID: iface.IfIDType(msg.Interface), RawIsdas: msg.IA, RawTimestamp: util.TimeToSecs(time.Now()), RawTTL: 10, @@ -81,7 +81,7 @@ func (h DefaultSCMPHandler) Handle(pkt *Packet) error { case slayers.SCMPTypeInternalConnectivityDown: msg := pkt.Payload.(SCMPInternalConnectivityDown) return h.handleSCMPRev(typeCode, &path_mgmt.RevInfo{ - IfID: ifid.IfIDType(msg.Egress), + IfID: iface.IfIDType(msg.Egress), RawIsdas: msg.IA, RawTimestamp: util.TimeToSecs(time.Now()), RawTTL: 10, diff --git a/private/path/combinator/BUILD.bazel b/private/path/combinator/BUILD.bazel index b972044c14..19daa965fd 100644 --- a/private/path/combinator/BUILD.bazel +++ b/private/path/combinator/BUILD.bazel @@ -15,7 +15,7 @@ go_library( "//pkg/private/util:go_default_library", "//pkg/segment:go_default_library", "//pkg/segment/extensions/staticinfo:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/slayers/path/scion:go_default_library", "//pkg/snet:go_default_library", @@ -38,7 +38,7 @@ go_test( "//pkg/private/xtest:go_default_library", "//pkg/private/xtest/graph:go_default_library", "//pkg/segment:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/slayers/path/scion:go_default_library", "//pkg/snet:go_default_library", diff --git a/private/path/combinator/combinator_test.go b/private/path/combinator/combinator_test.go index dfa9728be5..42705d123d 100644 --- a/private/path/combinator/combinator_test.go +++ b/private/path/combinator/combinator_test.go @@ -31,7 +31,7 @@ import ( "github.com/scionproto/scion/pkg/private/xtest" "github.com/scionproto/scion/pkg/private/xtest/graph" seg "github.com/scionproto/scion/pkg/segment" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/slayers/path" "github.com/scionproto/scion/pkg/slayers/path/scion" "github.com/scionproto/scion/pkg/snet" @@ -547,20 +547,20 @@ func TestFilterDuplicates(t *testing.T) { // These look somewhat valid, but that doesn't matter at all -- we only look // at the fingerprint anyway. path0 := []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:110"), ID: ifid.IfIDType(10)}, - {IA: addr.MustParseIA("1-ff00:0:111"), ID: ifid.IfIDType(10)}, + {IA: addr.MustParseIA("1-ff00:0:110"), ID: iface.IfIDType(10)}, + {IA: addr.MustParseIA("1-ff00:0:111"), ID: iface.IfIDType(10)}, } path1 := []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:110"), ID: ifid.IfIDType(11)}, - {IA: addr.MustParseIA("1-ff00:0:112"), ID: ifid.IfIDType(11)}, - {IA: addr.MustParseIA("1-ff00:0:112"), ID: ifid.IfIDType(12)}, - {IA: addr.MustParseIA("1-ff00:0:111"), ID: ifid.IfIDType(12)}, + {IA: addr.MustParseIA("1-ff00:0:110"), ID: iface.IfIDType(11)}, + {IA: addr.MustParseIA("1-ff00:0:112"), ID: iface.IfIDType(11)}, + {IA: addr.MustParseIA("1-ff00:0:112"), ID: iface.IfIDType(12)}, + {IA: addr.MustParseIA("1-ff00:0:111"), ID: iface.IfIDType(12)}, } path2 := []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:110"), ID: ifid.IfIDType(11)}, - {IA: addr.MustParseIA("1-ff00:0:112"), ID: ifid.IfIDType(11)}, - {IA: addr.MustParseIA("1-ff00:0:112"), ID: ifid.IfIDType(22)}, - {IA: addr.MustParseIA("1-ff00:0:111"), ID: ifid.IfIDType(22)}, + {IA: addr.MustParseIA("1-ff00:0:110"), ID: iface.IfIDType(11)}, + {IA: addr.MustParseIA("1-ff00:0:112"), ID: iface.IfIDType(11)}, + {IA: addr.MustParseIA("1-ff00:0:112"), ID: iface.IfIDType(22)}, + {IA: addr.MustParseIA("1-ff00:0:111"), ID: iface.IfIDType(22)}, } // Define two expiry times for the paths: paths with latest expiry will be kept diff --git a/private/path/combinator/graph.go b/private/path/combinator/graph.go index e436bea84c..3633a1d898 100644 --- a/private/path/combinator/graph.go +++ b/private/path/combinator/graph.go @@ -26,7 +26,7 @@ import ( "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt/proto" "github.com/scionproto/scion/pkg/private/util" seg "github.com/scionproto/scion/pkg/segment" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/slayers/path" "github.com/scionproto/scion/pkg/slayers/path/scion" "github.com/scionproto/scion/pkg/snet" @@ -146,8 +146,8 @@ func (g *dmg) traverseSegment(segment *inputSegment) { } for peerEntryIdx, peer := range asEntries[asEntryIndex].PeerEntries { - ingress := ifid.IfIDType(peer.HopField.ConsIngress) - remote := ifid.IfIDType(peer.PeerInterface) + ingress := iface.IfIDType(peer.HopField.ConsIngress) + remote := iface.IfIDType(peer.PeerInterface) tuples = append(tuples, Tuple{ Src: vertexFromIA(pinnedIA), Dst: vertexFromPeering(currentIA, ingress, peer.Peer, remote), @@ -259,17 +259,17 @@ func (s *inputSegment) IsDownSeg() bool { type vertex struct { IA addr.IA UpIA addr.IA - UpIfID ifid.IfIDType + UpIfID iface.IfIDType DownIA addr.IA - DownIfID ifid.IfIDType + DownIfID iface.IfIDType } func vertexFromIA(ia addr.IA) vertex { return vertex{IA: ia} } -func vertexFromPeering(upIA addr.IA, upIfID ifid.IfIDType, - downIA addr.IA, downIfID ifid.IfIDType) vertex { +func vertexFromPeering(upIA addr.IA, upIfID iface.IfIDType, + downIA addr.IA, downIfID iface.IfIDType) vertex { return vertex{UpIA: upIA, UpIfID: upIfID, DownIA: downIA, DownIfID: downIfID} } @@ -365,14 +365,14 @@ func (solution *pathSolution) Path() Path { if hopField.ConsEgress != 0 { intfs = append(intfs, snet.PathInterface{ IA: asEntry.Local, - ID: ifid.IfIDType(hopField.ConsEgress), + ID: iface.IfIDType(hopField.ConsEgress), }) } // In a non-peer shortcut the AS is not traversed completely. if hopField.ConsIngress != 0 && (!isShortcut || isPeer) { intfs = append(intfs, snet.PathInterface{ IA: asEntry.Local, - ID: ifid.IfIDType(hopField.ConsIngress), + ID: iface.IfIDType(hopField.ConsIngress), }) } hops = append(hops, hopField) diff --git a/private/path/combinator/staticinfo_accumulator.go b/private/path/combinator/staticinfo_accumulator.go index cbddf0c6f8..8e76869c14 100644 --- a/private/path/combinator/staticinfo_accumulator.go +++ b/private/path/combinator/staticinfo_accumulator.go @@ -21,7 +21,7 @@ import ( "github.com/scionproto/scion/pkg/addr" seg "github.com/scionproto/scion/pkg/segment" "github.com/scionproto/scion/pkg/segment/extensions/staticinfo" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/snet" ) @@ -85,7 +85,7 @@ func collectLatency(p pathInfo) []time.Duration { } egIF := snet.PathInterface{ IA: asEntry.Local, - ID: ifid.IfIDType(asEntry.HopEntry.HopField.ConsEgress), + ID: iface.IfIDType(asEntry.HopEntry.HopField.ConsEgress), } latency := staticInfo.Latency // Egress to sibling child, core or peer interfaces @@ -140,7 +140,7 @@ func collectBandwidth(p pathInfo) []uint64 { } egIF := snet.PathInterface{ IA: asEntry.Local, - ID: ifid.IfIDType(asEntry.HopEntry.HopField.ConsEgress), + ID: iface.IfIDType(asEntry.HopEntry.HopField.ConsEgress), } bandwidth := staticInfo.Bandwidth // Egress to other local interfaces @@ -265,7 +265,7 @@ func collectInternalHops(p pathInfo) []uint32 { } egIF := snet.PathInterface{ IA: asEntry.Local, - ID: ifid.IfIDType(asEntry.HopEntry.HopField.ConsEgress), + ID: iface.IfIDType(asEntry.HopEntry.HopField.ConsEgress), } internalHops := staticInfo.InternalHops for ifID, v := range internalHops { diff --git a/private/path/combinator/staticinfo_accumulator_test.go b/private/path/combinator/staticinfo_accumulator_test.go index a3ba14c5a1..4cc43885d8 100644 --- a/private/path/combinator/staticinfo_accumulator_test.go +++ b/private/path/combinator/staticinfo_accumulator_test.go @@ -25,7 +25,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/private/xtest/graph" seg "github.com/scionproto/scion/pkg/segment" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/snet" ) @@ -42,12 +42,12 @@ func TestStaticinfo(t *testing.T) { { Name: "#0 simple up-core-down", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:131"), ID: ifid.IfIDType(graph.If_131_X_130_A)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: ifid.IfIDType(graph.If_130_A_131_X)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: ifid.IfIDType(graph.If_130_B_120_A)}, - {IA: addr.MustParseIA("1-ff00:0:120"), ID: ifid.IfIDType(graph.If_120_A_130_B)}, - {IA: addr.MustParseIA("1-ff00:0:120"), ID: ifid.IfIDType(graph.If_120_X_111_B)}, - {IA: addr.MustParseIA("1-ff00:0:111"), ID: ifid.IfIDType(graph.If_111_B_120_X)}, + {IA: addr.MustParseIA("1-ff00:0:131"), ID: iface.IfIDType(graph.If_131_X_130_A)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.IfIDType(graph.If_130_A_131_X)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.IfIDType(graph.If_130_B_120_A)}, + {IA: addr.MustParseIA("1-ff00:0:120"), ID: iface.IfIDType(graph.If_120_A_130_B)}, + {IA: addr.MustParseIA("1-ff00:0:120"), ID: iface.IfIDType(graph.If_120_X_111_B)}, + {IA: addr.MustParseIA("1-ff00:0:111"), ID: iface.IfIDType(graph.If_111_B_120_X)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_130_A_131_X}, @@ -58,10 +58,10 @@ func TestStaticinfo(t *testing.T) { { Name: "#1 simple up-core", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:131"), ID: ifid.IfIDType(graph.If_131_X_130_A)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: ifid.IfIDType(graph.If_130_A_131_X)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: ifid.IfIDType(graph.If_130_A_110_X)}, - {IA: addr.MustParseIA("1-ff00:0:110"), ID: ifid.IfIDType(graph.If_110_X_130_A)}, + {IA: addr.MustParseIA("1-ff00:0:131"), ID: iface.IfIDType(graph.If_131_X_130_A)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.IfIDType(graph.If_130_A_131_X)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.IfIDType(graph.If_130_A_110_X)}, + {IA: addr.MustParseIA("1-ff00:0:110"), ID: iface.IfIDType(graph.If_110_X_130_A)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_130_A_131_X}, @@ -72,8 +72,8 @@ func TestStaticinfo(t *testing.T) { { Name: "#2 simple up only", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:131"), ID: ifid.IfIDType(graph.If_131_X_130_A)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: ifid.IfIDType(graph.If_130_A_131_X)}, + {IA: addr.MustParseIA("1-ff00:0:131"), ID: iface.IfIDType(graph.If_131_X_130_A)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.IfIDType(graph.If_130_A_131_X)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_130_A_131_X}, @@ -84,10 +84,10 @@ func TestStaticinfo(t *testing.T) { { Name: "#14 shortcut, common upstream", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("2-ff00:0:212"), ID: ifid.IfIDType(graph.If_212_X_211_A1)}, - {IA: addr.MustParseIA("2-ff00:0:211"), ID: ifid.IfIDType(graph.If_211_A1_212_X)}, - {IA: addr.MustParseIA("2-ff00:0:211"), ID: ifid.IfIDType(graph.If_211_A_222_X)}, - {IA: addr.MustParseIA("2-ff00:0:222"), ID: ifid.IfIDType(graph.If_222_X_211_A)}, + {IA: addr.MustParseIA("2-ff00:0:212"), ID: iface.IfIDType(graph.If_212_X_211_A1)}, + {IA: addr.MustParseIA("2-ff00:0:211"), ID: iface.IfIDType(graph.If_211_A1_212_X)}, + {IA: addr.MustParseIA("2-ff00:0:211"), ID: iface.IfIDType(graph.If_211_A_222_X)}, + {IA: addr.MustParseIA("2-ff00:0:222"), ID: iface.IfIDType(graph.If_222_X_211_A)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_210_X1_211_A, graph.If_211_A1_212_X}, @@ -98,12 +98,12 @@ func TestStaticinfo(t *testing.T) { { Name: "#15 go through peer", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("2-ff00:0:212"), ID: ifid.IfIDType(graph.If_212_X_211_A1)}, - {IA: addr.MustParseIA("2-ff00:0:211"), ID: ifid.IfIDType(graph.If_211_A1_212_X)}, - {IA: addr.MustParseIA("2-ff00:0:211"), ID: ifid.IfIDType(graph.If_211_A_221_X)}, - {IA: addr.MustParseIA("2-ff00:0:221"), ID: ifid.IfIDType(graph.If_221_X_211_A)}, - {IA: addr.MustParseIA("2-ff00:0:221"), ID: ifid.IfIDType(graph.If_221_X_222_X)}, - {IA: addr.MustParseIA("2-ff00:0:222"), ID: ifid.IfIDType(graph.If_222_X_221_X)}, + {IA: addr.MustParseIA("2-ff00:0:212"), ID: iface.IfIDType(graph.If_212_X_211_A1)}, + {IA: addr.MustParseIA("2-ff00:0:211"), ID: iface.IfIDType(graph.If_211_A1_212_X)}, + {IA: addr.MustParseIA("2-ff00:0:211"), ID: iface.IfIDType(graph.If_211_A_221_X)}, + {IA: addr.MustParseIA("2-ff00:0:221"), ID: iface.IfIDType(graph.If_221_X_211_A)}, + {IA: addr.MustParseIA("2-ff00:0:221"), ID: iface.IfIDType(graph.If_221_X_222_X)}, + {IA: addr.MustParseIA("2-ff00:0:222"), ID: iface.IfIDType(graph.If_222_X_221_X)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_210_X1_211_A, graph.If_211_A1_212_X}, diff --git a/private/path/pathpol/BUILD.bazel b/private/path/pathpol/BUILD.bazel index 74e6af2762..116d06a2c9 100644 --- a/private/path/pathpol/BUILD.bazel +++ b/private/path/pathpol/BUILD.bazel @@ -17,7 +17,7 @@ go_library( "//pkg/addr:go_default_library", "//pkg/log:go_default_library", "//pkg/private/serrors:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/snet:go_default_library", "@com_github_antlr_antlr4_runtime_go_antlr//:go_default_library", ], @@ -37,7 +37,7 @@ go_test( deps = [ "//pkg/addr:go_default_library", "//pkg/private/xtest/graph:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/snet:go_default_library", "//pkg/snet/mock_snet:go_default_library", "//pkg/snet/path:go_default_library", diff --git a/private/path/pathpol/acl_test.go b/private/path/pathpol/acl_test.go index 9e97fd6f38..ce6ddf98f9 100644 --- a/private/path/pathpol/acl_test.go +++ b/private/path/pathpol/acl_test.go @@ -23,7 +23,7 @@ import ( "gopkg.in/yaml.v2" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" ) func TestNewACL(t *testing.T) { @@ -113,7 +113,7 @@ func TestACLEntryLoadFromString(t *testing.T) { String: "+ 0", ACLEntry: ACLEntry{ Action: Allow, - Rule: &HopPredicate{IfIDs: []ifid.IfIDType{0}}, + Rule: &HopPredicate{IfIDs: []iface.IfIDType{0}}, }, ErrorAssertion: assert.NoError, }, @@ -121,7 +121,7 @@ func TestACLEntryLoadFromString(t *testing.T) { String: "+ 1-2#3", ACLEntry: ACLEntry{ Action: Allow, - Rule: &HopPredicate{ISD: 1, AS: 2, IfIDs: []ifid.IfIDType{3}}, + Rule: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.IfIDType{3}}, }, ErrorAssertion: assert.NoError, }, @@ -134,7 +134,7 @@ func TestACLEntryLoadFromString(t *testing.T) { String: "- 0", ACLEntry: ACLEntry{ Action: Deny, - Rule: &HopPredicate{IfIDs: []ifid.IfIDType{0}}, + Rule: &HopPredicate{IfIDs: []iface.IfIDType{0}}, }, ErrorAssertion: assert.NoError, }, @@ -161,7 +161,7 @@ func TestACLEntryLoadFromString(t *testing.T) { func TestACLEntryString(t *testing.T) { aclEntryString := "+ 0-0#0" - aclEntry := &ACLEntry{Action: true, Rule: &HopPredicate{IfIDs: []ifid.IfIDType{0}}} + aclEntry := &ACLEntry{Action: true, Rule: &HopPredicate{IfIDs: []iface.IfIDType{0}}} assert.Equal(t, aclEntryString, aclEntry.String()) } diff --git a/private/path/pathpol/hop_pred.go b/private/path/pathpol/hop_pred.go index e7920d8234..8e97209e6e 100644 --- a/private/path/pathpol/hop_pred.go +++ b/private/path/pathpol/hop_pred.go @@ -23,7 +23,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/private/serrors" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/snet" ) @@ -32,11 +32,11 @@ import ( type HopPredicate struct { ISD addr.ISD AS addr.AS - IfIDs []ifid.IfIDType + IfIDs []iface.IfIDType } func NewHopPredicate() *HopPredicate { - return &HopPredicate{IfIDs: make([]ifid.IfIDType, 1)} + return &HopPredicate{IfIDs: make([]iface.IfIDType, 1)} } func HopPredicateFromString(str string) (*HopPredicate, error) { @@ -44,7 +44,7 @@ func HopPredicateFromString(str string) (*HopPredicate, error) { if err = validateHopPredStr(str); err != nil { return &HopPredicate{}, err } - var ifIDs = make([]ifid.IfIDType, 1) + var ifIDs = make([]iface.IfIDType, 1) // Parse ISD dashParts := strings.Split(str, "-") isd, err := addr.ParseISD(dashParts[0]) @@ -136,12 +136,12 @@ func (hp *HopPredicate) UnmarshalJSON(b []byte) error { return err } -func parseIfID(str string) (ifid.IfIDType, error) { +func parseIfID(str string) (iface.IfIDType, error) { ifID, err := strconv.ParseUint(str, 10, 64) if err != nil { return 0, err } - return ifid.IfIDType(ifID), nil + return iface.IfIDType(ifID), nil } // validateHopPredStr checks if str has the correct amount of delimiters diff --git a/private/path/pathpol/hop_pred_test.go b/private/path/pathpol/hop_pred_test.go index a0ced32546..77047429f4 100644 --- a/private/path/pathpol/hop_pred_test.go +++ b/private/path/pathpol/hop_pred_test.go @@ -21,7 +21,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" ) func TestNewHopPredicate(t *testing.T) { @@ -32,22 +32,22 @@ func TestNewHopPredicate(t *testing.T) { }{ "ISD wildcard": { In: "0", - HP: &HopPredicate{ISD: 0, AS: 0, IfIDs: []ifid.IfIDType{0}}, + HP: &HopPredicate{ISD: 0, AS: 0, IfIDs: []iface.IfIDType{0}}, Valid: true, }, "AS, IF wildcard omitted": { In: "1", - HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []ifid.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []iface.IfIDType{0}}, Valid: true, }, "IF wildcard omitted": { In: "1-0", - HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []ifid.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []iface.IfIDType{0}}, Valid: true, }, "basic wildcard": { In: "1-0#0", - HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []ifid.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []iface.IfIDType{0}}, Valid: true, }, "AS wildcard, interface set": { @@ -56,27 +56,27 @@ func TestNewHopPredicate(t *testing.T) { }, "ISD wildcard, AS set": { In: "0-1#0", - HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []ifid.IfIDType{0}}, + HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []iface.IfIDType{0}}, Valid: true, }, "ISD wildcard, AS set, interface set": { In: "0-1#2", - HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []ifid.IfIDType{2}}, + HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []iface.IfIDType{2}}, Valid: true, }, "ISD wildcard, AS set and interface omitted": { In: "0-1", - HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []ifid.IfIDType{0}}, + HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []iface.IfIDType{0}}, Valid: true, }, "IF wildcard omitted, AS set": { In: "1-2", - HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []ifid.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.IfIDType{0}}, Valid: true, }, "two IfIDs": { In: "1-2#3,4", - HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []ifid.IfIDType{3, 4}}, + HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.IfIDType{3, 4}}, Valid: true, }, "three IfIDs": { @@ -140,13 +140,13 @@ func TestJsonConversion(t *testing.T) { HP *HopPredicate }{ "Normal predicate": { - HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []ifid.IfIDType{1, 2}}, + HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.IfIDType{1, 2}}, }, "wildcard predicate": { - HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []ifid.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.IfIDType{0}}, }, "only ifIDs": { - HP: &HopPredicate{IfIDs: []ifid.IfIDType{0}}, + HP: &HopPredicate{IfIDs: []iface.IfIDType{0}}, }, } for name, test := range tests { diff --git a/private/path/pathpol/policy_test.go b/private/path/pathpol/policy_test.go index d9edfc57c9..635558cbbd 100644 --- a/private/path/pathpol/policy_test.go +++ b/private/path/pathpol/policy_test.go @@ -25,7 +25,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/private/xtest/graph" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/snet" snetpath "github.com/scionproto/scion/pkg/snet/path" ) @@ -648,7 +648,7 @@ func (p PathProvider) GetPaths(src, dst addr.IA) []snet.Path { ia := p.g.GetParent(ifID) pathIntfs = append(pathIntfs, snet.PathInterface{ IA: ia, - ID: ifid.IfIDType(ifID), + ID: iface.IfIDType(ifID), }) } var srcIA, dstIA addr.IA diff --git a/private/path/pathpol/sequence.go b/private/path/pathpol/sequence.go index ed5a793269..120d19aadd 100644 --- a/private/path/pathpol/sequence.go +++ b/private/path/pathpol/sequence.go @@ -29,7 +29,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/log" "github.com/scionproto/scion/pkg/private/serrors" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/snet" ) @@ -294,7 +294,7 @@ func (l *sequenceListener) ExitIFace(c *sequence.IFaceContext) { l.push(re) } -func hop(ia addr.IA, ingress, egress ifid.IfIDType) string { +func hop(ia addr.IA, ingress, egress iface.IfIDType) string { return fmt.Sprintf("%s#%d,%d", ia, ingress, egress) } diff --git a/private/pathdb/query/BUILD.bazel b/private/pathdb/query/BUILD.bazel index 28664bf1ac..73977233d1 100644 --- a/private/pathdb/query/BUILD.bazel +++ b/private/pathdb/query/BUILD.bazel @@ -8,6 +8,6 @@ go_library( deps = [ "//pkg/addr:go_default_library", "//pkg/segment:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", ], ) diff --git a/private/pathdb/query/query.go b/private/pathdb/query/query.go index 4532797271..e73a6b26a6 100644 --- a/private/pathdb/query/query.go +++ b/private/pathdb/query/query.go @@ -21,12 +21,12 @@ import ( "github.com/scionproto/scion/pkg/addr" seg "github.com/scionproto/scion/pkg/segment" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" ) type IntfSpec struct { IA addr.IA - IfID ifid.IfIDType + IfID iface.IfIDType } type Params struct { diff --git a/private/revcache/BUILD.bazel b/private/revcache/BUILD.bazel index 7a13272cbf..84940f9448 100644 --- a/private/revcache/BUILD.bazel +++ b/private/revcache/BUILD.bazel @@ -12,7 +12,7 @@ go_library( "//pkg/addr:go_default_library", "//pkg/private/ctrl/path_mgmt:go_default_library", "//pkg/segment:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//private/storage/cleaner:go_default_library", "//private/storage/db:go_default_library", ], @@ -30,7 +30,7 @@ go_test( "//pkg/private/util:go_default_library", "//pkg/private/xtest/graph:go_default_library", "//pkg/segment:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//private/revcache/mock_revcache:go_default_library", "@com_github_golang_mock//gomock:go_default_library", "@com_github_stretchr_testify//assert:go_default_library", diff --git a/private/revcache/revcache.go b/private/revcache/revcache.go index 21a3d0a659..aec0387b66 100644 --- a/private/revcache/revcache.go +++ b/private/revcache/revcache.go @@ -21,18 +21,18 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/private/storage/db" ) // Key denotes the key for the revocation cache. type Key struct { IA addr.IA - IfID ifid.IfIDType + IfID iface.IfIDType } // NewKey creates a new key for the revocation cache. -func NewKey(ia addr.IA, ifID ifid.IfIDType) Key { +func NewKey(ia addr.IA, ifID iface.IfIDType) Key { return Key{ IA: ia, IfID: ifID, @@ -47,7 +47,7 @@ func (k Key) String() string { type KeySet map[Key]struct{} // SingleKey is a convenience function to return a KeySet with a single key. -func SingleKey(ia addr.IA, ifID ifid.IfIDType) KeySet { +func SingleKey(ia addr.IA, ifID iface.IfIDType) KeySet { return KeySet{Key{IA: ia, IfID: ifID}: {}} } diff --git a/private/revcache/revcachetest/BUILD.bazel b/private/revcache/revcachetest/BUILD.bazel index c8b032b299..48e153dde3 100644 --- a/private/revcache/revcachetest/BUILD.bazel +++ b/private/revcache/revcachetest/BUILD.bazel @@ -10,7 +10,7 @@ go_library( "//pkg/private/ctrl/path_mgmt:go_default_library", "//pkg/private/ctrl/path_mgmt/proto:go_default_library", "//pkg/private/util:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//private/revcache:go_default_library", "@com_github_stretchr_testify//assert:go_default_library", "@com_github_stretchr_testify//require:go_default_library", diff --git a/private/revcache/revcachetest/revcachetest.go b/private/revcache/revcachetest/revcachetest.go index 91fb8b5b0a..065815ec66 100644 --- a/private/revcache/revcachetest/revcachetest.go +++ b/private/revcache/revcachetest/revcachetest.go @@ -27,15 +27,15 @@ import ( "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt" "github.com/scionproto/scion/pkg/private/ctrl/path_mgmt/proto" "github.com/scionproto/scion/pkg/private/util" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/private/revcache" ) var ( ia110 = addr.MustParseIA("1-ff00:0:110") ia120 = addr.MustParseIA("1-ff00:0:120") - ifID15 = ifid.IfIDType(15) - ifID19 = ifid.IfIDType(19) + ifID15 = iface.IfIDType(15) + ifID19 = iface.IfIDType(19) TimeOut = 5 * time.Second ) @@ -101,7 +101,7 @@ func testGetMultikey(t *testing.T, revCache TestableRevCache) { rev1 := defaultRevInfo(ia110, ifID15) rev2 := defaultRevInfo(ia110, ifID19) rev3 := defaultRevInfo(ia120, ifID15) - rev4 := defaultRevInfo(ia120, ifid.IfIDType(10)) + rev4 := defaultRevInfo(ia120, iface.IfIDType(10)) ctx, cancelF := context.WithTimeout(context.Background(), TimeOut) defer cancelF() @@ -152,7 +152,7 @@ func testGetAll(t *testing.T, revCache TestableRevCache) { rev1 := defaultRevInfo(ia110, ifID15) rev2 := defaultRevInfo(ia110, ifID19) rev3 := defaultRevInfo(ia120, ifID15) - rev4 := defaultRevInfo(ia120, ifid.IfIDType(20)) + rev4 := defaultRevInfo(ia120, iface.IfIDType(20)) _, err = revCache.Insert(ctx, rev1) require.NoError(t, err) _, err = revCache.Insert(ctx, rev2) @@ -309,7 +309,7 @@ func testDeleteExpired(t *testing.T, revCache TestableRevCache) { assert.EqualValues(t, 0, del, "DeleteExpired should delete 0 if entry is not expired") } -func defaultRevInfo(ia addr.IA, ifID ifid.IfIDType) *path_mgmt.RevInfo { +func defaultRevInfo(ia addr.IA, ifID iface.IfIDType) *path_mgmt.RevInfo { return &path_mgmt.RevInfo{ IfID: ifID, RawIsdas: ia, diff --git a/private/revcache/util.go b/private/revcache/util.go index 3bf8ea5ee3..c2e6660120 100644 --- a/private/revcache/util.go +++ b/private/revcache/util.go @@ -19,7 +19,7 @@ import ( "github.com/scionproto/scion/pkg/addr" seg "github.com/scionproto/scion/pkg/segment" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/private/storage/cleaner" ) @@ -46,10 +46,10 @@ func NoRevokedHopIntf(ctx context.Context, revCache RevCache, func addRevKeys(segs []*seg.PathSegment, keys KeySet, hopOnly bool) { addIntfs := func(ia addr.IA, ingress, egress uint16) { if ingress != 0 { - keys[Key{IA: ia, IfID: ifid.IfIDType(ingress)}] = struct{}{} + keys[Key{IA: ia, IfID: iface.IfIDType(ingress)}] = struct{}{} } if egress != 0 { - keys[Key{IA: ia, IfID: ifid.IfIDType(egress)}] = struct{}{} + keys[Key{IA: ia, IfID: iface.IfIDType(egress)}] = struct{}{} } } for _, s := range segs { diff --git a/private/revcache/util_test.go b/private/revcache/util_test.go index 859b5268db..25c23d44e3 100644 --- a/private/revcache/util_test.go +++ b/private/revcache/util_test.go @@ -29,7 +29,7 @@ import ( "github.com/scionproto/scion/pkg/private/util" "github.com/scionproto/scion/pkg/private/xtest/graph" seg "github.com/scionproto/scion/pkg/segment" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/private/revcache" "github.com/scionproto/scion/private/revcache/mock_revcache" ) @@ -60,7 +60,7 @@ func TestNoRevokedHopIntf(t *testing.T) { revCache.EXPECT().Get(gomock.Eq(ctx), gomock.Any()).Return( revcache.Revocations{ revcache.Key{IA: addr.MustParseIA("2-ff00:0:211"), - IfID: ifid.IfIDType(graph.If_210_X_211_A)}: sRev, + IfID: iface.IfIDType(graph.If_210_X_211_A)}: sRev, }, nil, ) noR, err := revcache.NoRevokedHopIntf(ctx, revCache, seg210_222_1) @@ -79,7 +79,7 @@ func TestNoRevokedHopIntf(t *testing.T) { func defaultRevInfo(ia addr.IA, ifID uint16, ts time.Time) *path_mgmt.RevInfo { return &path_mgmt.RevInfo{ - IfID: ifid.IfIDType(ifID), + IfID: iface.IfIDType(ifID), RawIsdas: ia, LinkType: proto.LinkType_core, RawTimestamp: util.TimeToSecs(ts), diff --git a/private/segment/segfetcher/BUILD.bazel b/private/segment/segfetcher/BUILD.bazel index 5cdbfbf9e1..21a22d4a67 100644 --- a/private/segment/segfetcher/BUILD.bazel +++ b/private/segment/segfetcher/BUILD.bazel @@ -54,7 +54,7 @@ go_test( "//pkg/private/xtest/graph:go_default_library", "//pkg/private/xtest/matchers:go_default_library", "//pkg/segment:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/snet:go_default_library", "//private/pathdb/mock_pathdb:go_default_library", "//private/pathdb/query:go_default_library", diff --git a/private/segment/segfetcher/resolver_test.go b/private/segment/segfetcher/resolver_test.go index d42af57f7a..85b41c687c 100644 --- a/private/segment/segfetcher/resolver_test.go +++ b/private/segment/segfetcher/resolver_test.go @@ -28,7 +28,7 @@ import ( "github.com/scionproto/scion/pkg/private/xtest/graph" "github.com/scionproto/scion/pkg/private/xtest/matchers" seg "github.com/scionproto/scion/pkg/segment" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/private/pathdb/mock_pathdb" "github.com/scionproto/scion/private/pathdb/query" "github.com/scionproto/scion/private/revcache" @@ -411,11 +411,11 @@ func TestResolverWithRevocations(t *testing.T) { ExpectRevcache: func(t *testing.T, revCache *mock_revcache.MockRevCache) { key111_120 := revcache.Key{ IA: non_core_111, - IfID: ifid.IfIDType(graph.If_111_B_120_X), + IfID: iface.IfIDType(graph.If_111_B_120_X), } key111_130 := revcache.Key{ IA: non_core_111, - IfID: ifid.IfIDType(graph.If_111_A_130_B), + IfID: iface.IfIDType(graph.If_111_A_130_B), } revoke(t, revCache, key111_120) revoke(t, revCache, key111_130) @@ -446,7 +446,7 @@ func TestResolverWithRevocations(t *testing.T) { db.EXPECT().Get(gomock.Any(), gomock.Any()).Times(2) }, ExpectRevcache: func(t *testing.T, revCache *mock_revcache.MockRevCache) { - key110 := revcache.Key{IA: core_110, IfID: ifid.IfIDType(graph.If_110_X_130_A)} + key110 := revcache.Key{IA: core_110, IfID: iface.IfIDType(graph.If_110_X_130_A)} ksMatcher := keySetContains{keys: []revcache.Key{key110}} rev := &path_mgmt.RevInfo{} revCache.EXPECT().Get(gomock.Any(), ksMatcher).Return(revcache.Revocations{ diff --git a/private/storage/beacon/sqlite/BUILD.bazel b/private/storage/beacon/sqlite/BUILD.bazel index 3ee02dd931..7820d33ccd 100644 --- a/private/storage/beacon/sqlite/BUILD.bazel +++ b/private/storage/beacon/sqlite/BUILD.bazel @@ -13,7 +13,7 @@ go_library( "//pkg/addr:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//private/storage/beacon:go_default_library", "//private/storage/db:go_default_library", ], diff --git a/private/storage/beacon/sqlite/db.go b/private/storage/beacon/sqlite/db.go index cecc8bbdaf..a0fc57dda8 100644 --- a/private/storage/beacon/sqlite/db.go +++ b/private/storage/beacon/sqlite/db.go @@ -26,7 +26,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/private/serrors" "github.com/scionproto/scion/pkg/private/util" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" storagebeacon "github.com/scionproto/scion/private/storage/beacon" "github.com/scionproto/scion/private/storage/db" ) @@ -140,7 +140,7 @@ func (e *executor) CandidateBeacons( beacons := make([]beacon.Beacon, 0, setSize) for rows.Next() { var rawBeacon sql.RawBytes - var inIfID ifid.IfIDType + var inIfID iface.IfIDType if err = rows.Scan(&rawBeacon, &inIfID); err != nil { return nil, db.NewReadError(beacon.ErrReadingRows, err) } diff --git a/private/storage/path/dbtest/BUILD.bazel b/private/storage/path/dbtest/BUILD.bazel index d92fb9d0ab..54a02f46ee 100644 --- a/private/storage/path/dbtest/BUILD.bazel +++ b/private/storage/path/dbtest/BUILD.bazel @@ -9,7 +9,7 @@ go_library( "//pkg/addr:go_default_library", "//pkg/private/xtest/graph:go_default_library", "//pkg/segment:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/slayers/path:go_default_library", "//private/pathdb:go_default_library", "//private/pathdb/query:go_default_library", diff --git a/private/storage/path/dbtest/dbtest.go b/private/storage/path/dbtest/dbtest.go index e0061fdecc..276f7979bf 100644 --- a/private/storage/path/dbtest/dbtest.go +++ b/private/storage/path/dbtest/dbtest.go @@ -29,7 +29,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/private/xtest/graph" seg "github.com/scionproto/scion/pkg/segment" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/slayers/path" "github.com/scionproto/scion/private/pathdb" "github.com/scionproto/scion/private/pathdb/query" @@ -603,7 +603,7 @@ func checkInterface(t *testing.T, ctx context.Context, ia addr.IA, ifID uint16, Intfs: []*query.IntfSpec{ { IA: ia, - IfID: ifid.IfIDType(ifID), + IfID: iface.IfIDType(ifID), }, }, }) diff --git a/private/topology/BUILD.bazel b/private/topology/BUILD.bazel index 7db5d90478..a8a38baf97 100644 --- a/private/topology/BUILD.bazel +++ b/private/topology/BUILD.bazel @@ -19,7 +19,7 @@ go_library( "//pkg/log:go_default_library", "//pkg/metrics:go_default_library", "//pkg/private/serrors:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//private/topology/json:go_default_library", "//private/topology/underlay:go_default_library", ], @@ -43,7 +43,7 @@ go_test( "//pkg/metrics/mock_metrics:go_default_library", "//pkg/private/ctrl/path_mgmt/proto:go_default_library", "//pkg/private/xtest:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//private/topology/json:go_default_library", "//private/topology/mock_topology:go_default_library", "@com_github_golang_mock//gomock:go_default_library", diff --git a/private/topology/interface.go b/private/topology/interface.go index 5dfba721b0..957c04d46a 100644 --- a/private/topology/interface.go +++ b/private/topology/interface.go @@ -23,7 +23,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/private/serrors" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" ) // Topology is the topology type for applications and libraries that only need read access to AS @@ -39,7 +39,7 @@ type Topology interface { // Core returns whether the local AS is core. Core() bool // InterfaceIDs returns all interface IDS from the local AS. - IfIDs() []ifid.IfIDType + IfIDs() []iface.IfIDType // PortRange returns the first and last ports of the port range (both included), // in which endhost listen for SCION/UDP application using the UDP/IP underlay. PortRange() (uint16, uint16) @@ -59,7 +59,7 @@ type Topology interface { UnderlayMulticast(svc addr.SVC) ([]*net.UDPAddr, error) // UnderlayNextHop returns the internal underlay address of the router // containing the interface ID. - UnderlayNextHop(ifID ifid.IfIDType) (*net.UDPAddr, bool) + UnderlayNextHop(ifID iface.IfIDType) (*net.UDPAddr, bool) // MakeHostInfos returns the underlay addresses of all services for the specified service type. MakeHostInfos(st ServiceType) ([]*net.UDPAddr, error) @@ -144,8 +144,8 @@ func (t *topologyS) MTU() uint16 { return uint16(t.Topology.MTU) } -func (t *topologyS) IfIDs() []ifid.IfIDType { - intfs := make([]ifid.IfIDType, 0, len(t.Topology.IFInfoMap)) +func (t *topologyS) IfIDs() []iface.IfIDType { + intfs := make([]iface.IfIDType, 0, len(t.Topology.IFInfoMap)) for ifID := range t.Topology.IFInfoMap { intfs = append(intfs, ifID) } @@ -156,7 +156,7 @@ func (t *topologyS) PortRange() (uint16, uint16) { return t.Topology.DispatchedPortStart, t.Topology.DispatchedPortEnd } -func (t *topologyS) UnderlayNextHop(ifID ifid.IfIDType) (*net.UDPAddr, bool) { +func (t *topologyS) UnderlayNextHop(ifID iface.IfIDType) (*net.UDPAddr, bool) { ifInfo, ok := t.Topology.IFInfoMap[ifID] if !ok { return nil, false diff --git a/private/topology/json/BUILD.bazel b/private/topology/json/BUILD.bazel index f4c37b34fc..98c4cfddbd 100644 --- a/private/topology/json/BUILD.bazel +++ b/private/topology/json/BUILD.bazel @@ -9,7 +9,7 @@ go_library( "//pkg/log:go_default_library", "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", ], ) @@ -21,7 +21,7 @@ go_test( ":go_default_library", "//pkg/private/util:go_default_library", "//pkg/private/xtest:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "@com_github_stretchr_testify//assert:go_default_library", "@com_github_stretchr_testify//require:go_default_library", ], diff --git a/private/topology/json/json.go b/private/topology/json/json.go index 207e18590b..9aec94730e 100644 --- a/private/topology/json/json.go +++ b/private/topology/json/json.go @@ -26,7 +26,7 @@ import ( "github.com/scionproto/scion/pkg/log" "github.com/scionproto/scion/pkg/private/serrors" "github.com/scionproto/scion/pkg/private/util" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" ) // Attribute indicates the capability of a primary AS. @@ -93,8 +93,8 @@ type ServerInfo struct { // BRInfo contains Border Router specific information. type BRInfo struct { - InternalAddr string `json:"internal_addr"` - Interfaces map[ifid.IfIDType]*BRInterface `json:"interfaces"` + InternalAddr string `json:"internal_addr"` + Interfaces map[iface.IfIDType]*BRInterface `json:"interfaces"` } // GatewayInfo contains SCION gateway information. @@ -108,12 +108,12 @@ type GatewayInfo struct { // BRInterface contains the information for an data-plane BR socket that is external (i.e., facing // the neighboring AS). type BRInterface struct { - Underlay Underlay `json:"underlay,omitempty"` - IA string `json:"isd_as"` - LinkTo string `json:"link_to"` - MTU int `json:"mtu"` - BFD *BFD `json:"bfd,omitempty"` - RemoteIfID ifid.IfIDType `json:"remote_interface_id,omitempty"` + Underlay Underlay `json:"underlay,omitempty"` + IA string `json:"isd_as"` + LinkTo string `json:"link_to"` + MTU int `json:"mtu"` + BFD *BFD `json:"bfd,omitempty"` + RemoteIfID iface.IfIDType `json:"remote_interface_id,omitempty"` } // Underlay is the underlay information for a BR interface. diff --git a/private/topology/json/json_test.go b/private/topology/json/json_test.go index fc6688c2af..b5c2e4e677 100644 --- a/private/topology/json/json_test.go +++ b/private/topology/json/json_test.go @@ -27,7 +27,7 @@ import ( "github.com/scionproto/scion/pkg/private/util" "github.com/scionproto/scion/pkg/private/xtest" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" jsontopo "github.com/scionproto/scion/private/topology/json" ) @@ -46,7 +46,7 @@ func TestLoadRawFromFile(t *testing.T) { BorderRouters: map[string]*jsontopo.BRInfo{ "borderrouter6-f00:0:362-1": { InternalAddr: "10.1.0.1:0", - Interfaces: map[ifid.IfIDType]*jsontopo.BRInterface{ + Interfaces: map[iface.IfIDType]*jsontopo.BRInterface{ 91: { Underlay: jsontopo.Underlay{ Local: "192.0.2.1:4997", @@ -65,7 +65,7 @@ func TestLoadRawFromFile(t *testing.T) { }, "borderrouter6-f00:0:362-9": { InternalAddr: "[2001:db8:a0b:12f0::2]:0", - Interfaces: map[ifid.IfIDType]*jsontopo.BRInterface{ + Interfaces: map[iface.IfIDType]*jsontopo.BRInterface{ 32: { Underlay: jsontopo.Underlay{ Local: "[2001:db8:a0b:12f0::1]:4997", diff --git a/private/topology/mock_topology/BUILD.bazel b/private/topology/mock_topology/BUILD.bazel index 0020b4db97..07635fe2c7 100644 --- a/private/topology/mock_topology/BUILD.bazel +++ b/private/topology/mock_topology/BUILD.bazel @@ -19,7 +19,7 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/addr:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//private/topology:go_default_library", "@com_github_golang_mock//gomock:go_default_library", ], diff --git a/private/topology/mock_topology/mock.go b/private/topology/mock_topology/mock.go index 9386750cd4..dfdebc66da 100644 --- a/private/topology/mock_topology/mock.go +++ b/private/topology/mock_topology/mock.go @@ -10,7 +10,7 @@ import ( gomock "github.com/golang/mock/gomock" addr "github.com/scionproto/scion/pkg/addr" - common "github.com/scionproto/scion/pkg/segment/ifid" + iface "github.com/scionproto/scion/pkg/segment/iface" topology "github.com/scionproto/scion/private/topology" ) @@ -125,10 +125,10 @@ func (mr *MockTopologyMockRecorder) IFInfoMap() *gomock.Call { } // IfIDs mocks base method. -func (m *MockTopology) IfIDs() []ifid.IfIDType { +func (m *MockTopology) IfIDs() []iface.IfIDType { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IfIDs") - ret0, _ := ret[0].([]ifid.IfIDType) + ret0, _ := ret[0].([]iface.IfIDType) return ret0 } @@ -256,7 +256,7 @@ func (mr *MockTopologyMockRecorder) UnderlayMulticast(arg0 interface{}) *gomock. } // UnderlayNextHop mocks base method. -func (m *MockTopology) UnderlayNextHop(arg0 ifid.IfIDType) (*net.UDPAddr, bool) { +func (m *MockTopology) UnderlayNextHop(arg0 iface.IfIDType) (*net.UDPAddr, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UnderlayNextHop", arg0) ret0, _ := ret[0].(*net.UDPAddr) diff --git a/private/topology/reload.go b/private/topology/reload.go index d52ecb7464..6da1b56da3 100644 --- a/private/topology/reload.go +++ b/private/topology/reload.go @@ -27,7 +27,7 @@ import ( "github.com/scionproto/scion/pkg/log" "github.com/scionproto/scion/pkg/metrics" "github.com/scionproto/scion/pkg/private/serrors" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" ) // Validator is used to validate that the topology update is permissible. @@ -133,7 +133,7 @@ func (l *Loader) UnderlayNextHop(ifID uint16) *net.UDPAddr { l.mtx.Lock() defer l.mtx.Unlock() - addr, _ := l.topo.UnderlayNextHop(ifid.IfIDType(ifID)) + addr, _ := l.topo.UnderlayNextHop(iface.IfIDType(ifID)) return addr } @@ -182,7 +182,7 @@ func (l *Loader) Gateways() ([]GatewayInfo, error) { return l.topo.Gateways() } -func (l *Loader) InterfaceInfoMap() map[ifid.IfIDType]IFInfo { +func (l *Loader) InterfaceInfoMap() map[iface.IfIDType]IFInfo { l.mtx.Lock() defer l.mtx.Unlock() diff --git a/private/topology/topology.go b/private/topology/topology.go index bccd95955d..67ff3967b5 100644 --- a/private/topology/topology.go +++ b/private/topology/topology.go @@ -30,7 +30,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/log" "github.com/scionproto/scion/pkg/private/serrors" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" jsontopo "github.com/scionproto/scion/private/topology/json" "github.com/scionproto/scion/private/topology/underlay" ) @@ -95,25 +95,25 @@ type ( // InternalAddr is the local data-plane address. InternalAddr netip.AddrPort // IfIDs is a sorted list of the interface IDs. - IfIDs []ifid.IfIDType + IfIDs []iface.IfIDType // IFs is a map of interface IDs. - IFs map[ifid.IfIDType]*IFInfo + IFs map[iface.IfIDType]*IFInfo } // IfInfoMap maps interface ids to the interface information. - IfInfoMap map[ifid.IfIDType]IFInfo + IfInfoMap map[iface.IfIDType]IFInfo // IFInfo describes a border router link to another AS, including the internal data-plane // address applications should send traffic to and information about the link itself and the // remote side of it. IFInfo struct { // ID is the interface ID. It is unique per AS. - ID ifid.IfIDType + ID iface.IfIDType BRName string InternalAddr netip.AddrPort Local netip.AddrPort Remote netip.AddrPort - RemoteIfID ifid.IfIDType + RemoteIfID iface.IfIDType IA addr.IA LinkType LinkType MTU int @@ -267,7 +267,7 @@ func (t *RWTopology) populateBR(raw *jsontopo.Topology) error { brInfo := BRInfo{ Name: name, InternalAddr: intAddr, - IFs: make(map[ifid.IfIDType]*IFInfo), + IFs: make(map[iface.IfIDType]*IFInfo), } for ifID, rawIntf := range rawBr.Interfaces { var err error @@ -474,11 +474,11 @@ func (i *BRInfo) copy() *BRInfo { } } -func copyIFsMap(m map[ifid.IfIDType]*IFInfo) map[ifid.IfIDType]*IFInfo { +func copyIFsMap(m map[iface.IfIDType]*IFInfo) map[iface.IfIDType]*IFInfo { if m == nil { return nil } - newM := make(map[ifid.IfIDType]*IFInfo) + newM := make(map[iface.IfIDType]*IFInfo) for k, v := range m { newM[k] = v.copy() } diff --git a/private/topology/topology_test.go b/private/topology/topology_test.go index 3eabba48b2..0f934267d6 100644 --- a/private/topology/topology_test.go +++ b/private/topology/topology_test.go @@ -25,7 +25,7 @@ import ( "github.com/stretchr/testify/require" "github.com/scionproto/scion/pkg/addr" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" jsontopo "github.com/scionproto/scion/private/topology/json" ) @@ -58,10 +58,10 @@ func TestBRs(t *testing.T) { brs := map[string]BRInfo{ "br1-ff00:0:311-1": { - IfIDs: []ifid.IfIDType{1, 3, 8}, + IfIDs: []iface.IfIDType{1, 3, 8}, }, "br1-ff00:0:311-2": { - IfIDs: []ifid.IfIDType{11}, + IfIDs: []iface.IfIDType{11}, }, } @@ -312,10 +312,10 @@ func TestBRsCoreAS(t *testing.T) { c := MustLoadTopo(t, "testdata/core.json") brCases := []struct { name string - interfaces []ifid.IfIDType + interfaces []iface.IfIDType }{ - {name: "borderrouter6-ff00:0:362-1", interfaces: []ifid.IfIDType{91}}, - {name: "borderrouter6-ff00:0:362-9", interfaces: []ifid.IfIDType{32}}, + {name: "borderrouter6-ff00:0:362-1", interfaces: []iface.IfIDType{91}}, + {name: "borderrouter6-ff00:0:362-9", interfaces: []iface.IfIDType{32}}, } for _, test := range brCases { t.Run(test.name, func(t *testing.T) { diff --git a/router/BUILD.bazel b/router/BUILD.bazel index d1b9c4bca2..caf311a7f1 100644 --- a/router/BUILD.bazel +++ b/router/BUILD.bazel @@ -20,7 +20,7 @@ go_library( "//pkg/private/serrors:go_default_library", "//pkg/private/util:go_default_library", "//pkg/scrypto:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/slayers:go_default_library", "//pkg/slayers/path:go_default_library", "//pkg/slayers/path/empty:go_default_library", diff --git a/router/connector.go b/router/connector.go index 8c5893a441..52a318c9ed 100644 --- a/router/connector.go +++ b/router/connector.go @@ -21,7 +21,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/log" "github.com/scionproto/scion/pkg/private/serrors" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/private/underlay/conn" "github.com/scionproto/scion/router/config" "github.com/scionproto/scion/router/control" @@ -80,7 +80,7 @@ func (c *Connector) AddInternalInterface(ia addr.IA, local netip.AddrPort) error } // AddExternalInterface adds a link between the local and remote address. -func (c *Connector) AddExternalInterface(localIfID ifid.IfIDType, link control.LinkInfo, +func (c *Connector) AddExternalInterface(localIfID iface.IfIDType, link control.LinkInfo, owned bool) error { c.mtx.Lock() diff --git a/router/control/BUILD.bazel b/router/control/BUILD.bazel index 2156ae9ac9..18865cdb10 100644 --- a/router/control/BUILD.bazel +++ b/router/control/BUILD.bazel @@ -12,7 +12,7 @@ go_library( "//pkg/addr:go_default_library", "//pkg/log:go_default_library", "//pkg/private/serrors:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//private/keyconf:go_default_library", "//private/topology:go_default_library", "@org_golang_x_crypto//pbkdf2:go_default_library", diff --git a/router/control/conf.go b/router/control/conf.go index 0e4057a9e8..456de4b8ab 100644 --- a/router/control/conf.go +++ b/router/control/conf.go @@ -23,7 +23,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/private/serrors" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/private/topology" ) @@ -32,7 +32,7 @@ import ( type Dataplane interface { CreateIACtx(ia addr.IA) error AddInternalInterface(ia addr.IA, local netip.AddrPort) error - AddExternalInterface(localIfID ifid.IfIDType, info LinkInfo, owned bool) error + AddExternalInterface(localIfID iface.IfIDType, info LinkInfo, owned bool) error AddSvc(ia addr.IA, svc addr.SVC, a netip.AddrPort) error DelSvc(ia addr.IA, svc addr.SVC, a netip.AddrPort) error SetKey(ia addr.IA, index int, key []byte) error @@ -57,7 +57,7 @@ type LinkInfo struct { type LinkEnd struct { IA addr.IA Addr netip.AddrPort - IfID ifid.IfIDType + IfID iface.IfIDType } type ObservableDataplane interface { @@ -169,7 +169,7 @@ func confExternalInterfaces(dp Dataplane, cfg *Config) error { // nothing to do return nil } - ifIDs := []ifid.IfIDType{} + ifIDs := []iface.IfIDType{} for k := range infoMap { ifIDs = append(ifIDs, k) } diff --git a/router/control/internal/metrics/BUILD.bazel b/router/control/internal/metrics/BUILD.bazel index c112db37d6..7839e0dcf3 100644 --- a/router/control/internal/metrics/BUILD.bazel +++ b/router/control/internal/metrics/BUILD.bazel @@ -10,7 +10,7 @@ go_library( visibility = ["//router/control:__subpackages__"], deps = [ "//pkg/private/prom:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "@com_github_prometheus_client_golang//prometheus:go_default_library", ], ) diff --git a/router/control/internal/metrics/metrics.go b/router/control/internal/metrics/metrics.go index f3d079bb92..79c50d883b 100644 --- a/router/control/internal/metrics/metrics.go +++ b/router/control/internal/metrics/metrics.go @@ -18,7 +18,7 @@ package metrics import ( "github.com/scionproto/scion/pkg/private/prom" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" ) const Namespace = "br" @@ -65,7 +65,7 @@ func (l IntfLabels) Values() []string { return []string{l.Intf, l.NeighIA} } -func IntfToLabel(ifID ifid.IfIDType) string { +func IntfToLabel(ifID iface.IfIDType) string { if ifID == 0 { return "loc" } diff --git a/scion/cmd/scion/BUILD.bazel b/scion/cmd/scion/BUILD.bazel index a11ac9aa66..ad3d2d27d9 100644 --- a/scion/cmd/scion/BUILD.bazel +++ b/scion/cmd/scion/BUILD.bazel @@ -20,7 +20,7 @@ go_library( "//pkg/daemon:go_default_library", "//pkg/log:go_default_library", "//pkg/private/serrors:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/snet:go_default_library", "//pkg/snet/addrutil:go_default_library", "//pkg/snet/path:go_default_library", diff --git a/scion/cmd/scion/common.go b/scion/cmd/scion/common.go index 2f20556972..7db29d1331 100644 --- a/scion/cmd/scion/common.go +++ b/scion/cmd/scion/common.go @@ -24,7 +24,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/private/serrors" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/snet" ) @@ -43,8 +43,8 @@ type Path struct { // Hop represents an hop on the path. type Hop struct { - ID ifid.IfIDType `json:"interface" yaml:"interface"` - IA addr.IA `json:"isd_as" yaml:"isd_as"` + ID iface.IfIDType `json:"interface" yaml:"interface"` + IA addr.IA `json:"isd_as" yaml:"isd_as"` } // getHops constructs a list of snet path interfaces from an snet path diff --git a/scion/showpaths/BUILD.bazel b/scion/showpaths/BUILD.bazel index b77b1b8d28..a2367409aa 100644 --- a/scion/showpaths/BUILD.bazel +++ b/scion/showpaths/BUILD.bazel @@ -12,7 +12,7 @@ go_library( "//pkg/addr:go_default_library", "//pkg/daemon:go_default_library", "//pkg/private/serrors:go_default_library", - "//pkg/segment/ifid:go_default_library", + "//pkg/segment/iface:go_default_library", "//pkg/snet:go_default_library", "//private/app/path:go_default_library", "//private/app/path/pathprobe:go_default_library", diff --git a/scion/showpaths/showpaths.go b/scion/showpaths/showpaths.go index d3f3993e76..ccb6fef357 100644 --- a/scion/showpaths/showpaths.go +++ b/scion/showpaths/showpaths.go @@ -27,7 +27,7 @@ import ( "github.com/scionproto/scion/pkg/addr" "github.com/scionproto/scion/pkg/daemon" "github.com/scionproto/scion/pkg/private/serrors" - "github.com/scionproto/scion/pkg/segment/ifid" + "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/pkg/snet" "github.com/scionproto/scion/private/app/path" "github.com/scionproto/scion/private/app/path/pathprobe" @@ -58,8 +58,8 @@ type Path struct { // Hop represents an hop on the path. type Hop struct { - IfID ifid.IfIDType `json:"interface"` - IA addr.IA `json:"isd_as"` + IfID iface.IfIDType `json:"interface"` + IA addr.IA `json:"isd_as"` } // Human writes human readable output to the writer. From 6cb6c393c9e99ac8e774eff69b08d7b6e56b1478 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Hugly Date: Tue, 17 Sep 2024 19:22:20 +0200 Subject: [PATCH 3/4] Fix merge. --- private/revcache/util.go | 1 - 1 file changed, 1 deletion(-) diff --git a/private/revcache/util.go b/private/revcache/util.go index 6b52b31ab8..2a0bc9126c 100644 --- a/private/revcache/util.go +++ b/private/revcache/util.go @@ -17,7 +17,6 @@ package revcache import ( "context" - "github.com/scionproto/scion/pkg/addr" seg "github.com/scionproto/scion/pkg/segment" "github.com/scionproto/scion/pkg/segment/iface" "github.com/scionproto/scion/private/storage/cleaner" From 9a0fd2e71c0450216a613adc1c5c240cca78e06f Mon Sep 17 00:00:00 2001 From: Jean-Christophe Hugly Date: Wed, 18 Sep 2024 10:33:54 +0200 Subject: [PATCH 4/4] Rename iface.IfIDType to iface.ID --- control/beacon/beacondbtest/beacondbtest.go | 6 +- control/beaconing/export_test.go | 4 +- control/beaconing/staticinfo_config.go | 78 +++++----- control/beaconing/staticinfo_config_test.go | 134 +++++++++--------- control/beaconing/writer_test.go | 2 +- control/cmd/control/main.go | 2 +- daemon/internal/servers/grpc.go | 2 +- gateway/pathhealth/revocations_test.go | 4 +- pkg/daemon/grpc.go | 2 +- .../hiddenpath/beaconwriter_test.go | 2 +- pkg/private/ctrl/path_mgmt/rev_info.go | 2 +- pkg/private/xtest/graph/graph.go | 26 ++-- .../extensions/staticinfo/staticinfo.go | 36 ++--- .../extensions/staticinfo/staticinfo_test.go | 10 +- pkg/segment/iface/iface.go | 10 +- pkg/segment/iface/iface_test.go | 10 +- pkg/snet/path.go | 2 +- pkg/snet/scmp.go | 4 +- private/path/combinator/combinator_test.go | 20 +-- private/path/combinator/graph.go | 16 +-- .../path/combinator/staticinfo_accumulator.go | 6 +- .../combinator/staticinfo_accumulator_test.go | 44 +++--- private/path/pathpol/acl_test.go | 8 +- private/path/pathpol/hop_pred.go | 10 +- private/path/pathpol/hop_pred_test.go | 24 ++-- private/path/pathpol/policy_test.go | 2 +- private/path/pathpol/sequence.go | 2 +- private/pathdb/query/query.go | 2 +- private/revcache/revcache.go | 4 +- private/revcache/revcachetest/revcachetest.go | 10 +- private/revcache/util.go | 4 +- private/revcache/util_test.go | 4 +- private/segment/segfetcher/resolver_test.go | 6 +- private/storage/beacon/sqlite/db.go | 2 +- private/storage/path/dbtest/dbtest.go | 2 +- private/topology/interface.go | 10 +- private/topology/json/json.go | 16 +-- private/topology/json/json_test.go | 4 +- private/topology/mock_topology/mock.go | 6 +- private/topology/reload.go | 4 +- private/topology/topology.go | 16 +-- private/topology/topology_test.go | 10 +- router/connector.go | 2 +- router/control/conf.go | 6 +- router/control/internal/metrics/metrics.go | 2 +- scion/cmd/scion/common.go | 4 +- scion/showpaths/showpaths.go | 4 +- 47 files changed, 293 insertions(+), 293 deletions(-) diff --git a/control/beacon/beacondbtest/beacondbtest.go b/control/beacon/beacondbtest/beacondbtest.go index a953478703..32e379b7ca 100644 --- a/control/beacon/beacondbtest/beacondbtest.go +++ b/control/beacon/beacondbtest/beacondbtest.go @@ -334,14 +334,14 @@ func InsertBeacon(t *testing.T, db beacon.DB, ases []IfInfo, type PeerEntry struct { IA addr.IA - Ingress iface.IfIDType + Ingress iface.ID } type IfInfo struct { IA addr.IA Next addr.IA - Ingress iface.IfIDType - Egress iface.IfIDType + Ingress iface.ID + Egress iface.ID Peers []PeerEntry } diff --git a/control/beaconing/export_test.go b/control/beaconing/export_test.go index c3d3653da2..12b0c76e8f 100644 --- a/control/beaconing/export_test.go +++ b/control/beaconing/export_test.go @@ -20,7 +20,7 @@ import ( "github.com/scionproto/scion/private/topology" ) -func (cfg StaticInfoCfg) TestGenerate(ifType map[iface.IfIDType]topology.LinkType, - ingress, egress iface.IfIDType) *staticinfo.Extension { +func (cfg StaticInfoCfg) TestGenerate(ifType map[iface.ID]topology.LinkType, + ingress, egress iface.ID) *staticinfo.Extension { return cfg.generate(ifType, ingress, egress) } diff --git a/control/beaconing/staticinfo_config.go b/control/beaconing/staticinfo_config.go index cc0494178c..fab14eb9ca 100644 --- a/control/beaconing/staticinfo_config.go +++ b/control/beaconing/staticinfo_config.go @@ -29,13 +29,13 @@ import ( ) type InterfaceLatencies struct { - Inter util.DurWrap `json:"Inter"` - Intra map[iface.IfIDType]util.DurWrap `json:"Intra"` + Inter util.DurWrap `json:"Inter"` + Intra map[iface.ID]util.DurWrap `json:"Intra"` } type InterfaceBandwidths struct { - Inter uint64 `json:"Inter"` - Intra map[iface.IfIDType]uint64 `json:"Intra"` + Inter uint64 `json:"Inter"` + Intra map[iface.ID]uint64 `json:"Intra"` } type InterfaceGeodata struct { @@ -45,7 +45,7 @@ type InterfaceGeodata struct { } type InterfaceHops struct { - Intra map[iface.IfIDType]uint32 `json:"Intra"` + Intra map[iface.ID]uint32 `json:"Intra"` } type LinkType staticinfo.LinkType @@ -79,12 +79,12 @@ func (l *LinkType) UnmarshalText(text []byte) error { // StaticInfoCfg is used to parse data from config.json. type StaticInfoCfg struct { - Latency map[iface.IfIDType]InterfaceLatencies `json:"Latency"` - Bandwidth map[iface.IfIDType]InterfaceBandwidths `json:"Bandwidth"` - LinkType map[iface.IfIDType]LinkType `json:"LinkType"` - Geo map[iface.IfIDType]InterfaceGeodata `json:"Geo"` - Hops map[iface.IfIDType]InterfaceHops `json:"Hops"` - Note string `json:"Note"` + Latency map[iface.ID]InterfaceLatencies `json:"Latency"` + Bandwidth map[iface.ID]InterfaceBandwidths `json:"Bandwidth"` + LinkType map[iface.ID]LinkType `json:"LinkType"` + Geo map[iface.ID]InterfaceGeodata `json:"Geo"` + Hops map[iface.ID]InterfaceHops `json:"Hops"` + Note string `json:"Note"` } // ParseStaticInfoCfg parses data from a config file into a StaticInfoCfg struct. @@ -135,7 +135,7 @@ func (cfg *StaticInfoCfg) clean() { } // symmetrizeLatency makes the Intra latency values symmetric -func symmetrizeLatency(latency map[iface.IfIDType]InterfaceLatencies) { +func symmetrizeLatency(latency map[iface.ID]InterfaceLatencies) { for i, sub := range latency { delete(sub.Intra, i) // Remove loopy entry for j, v := range sub.Intra { @@ -145,7 +145,7 @@ func symmetrizeLatency(latency map[iface.IfIDType]InterfaceLatencies) { if latency[j].Intra == nil { latency[j] = InterfaceLatencies{ Inter: latency[j].Inter, - Intra: make(map[iface.IfIDType]util.DurWrap), + Intra: make(map[iface.ID]util.DurWrap), } } vTransposed, ok := latency[j].Intra[i] @@ -158,7 +158,7 @@ func symmetrizeLatency(latency map[iface.IfIDType]InterfaceLatencies) { } // symmetrizeBandwidth makes the Intra bandwidth values symmetric -func symmetrizeBandwidth(bandwidth map[iface.IfIDType]InterfaceBandwidths) { +func symmetrizeBandwidth(bandwidth map[iface.ID]InterfaceBandwidths) { for i, sub := range bandwidth { delete(sub.Intra, i) // Remove loopy entry for j, v := range sub.Intra { @@ -168,7 +168,7 @@ func symmetrizeBandwidth(bandwidth map[iface.IfIDType]InterfaceBandwidths) { if bandwidth[j].Intra == nil { bandwidth[j] = InterfaceBandwidths{ Inter: bandwidth[j].Inter, - Intra: make(map[iface.IfIDType]uint64), + Intra: make(map[iface.ID]uint64), } } vTransposed, ok := bandwidth[j].Intra[i] @@ -181,13 +181,13 @@ func symmetrizeBandwidth(bandwidth map[iface.IfIDType]InterfaceBandwidths) { } // symmetrizeHops makes the Intra hops values symmetric -func symmetrizeHops(hops map[iface.IfIDType]InterfaceHops) { +func symmetrizeHops(hops map[iface.ID]InterfaceHops) { for i, sub := range hops { delete(sub.Intra, i) // Remove loopy entry for j, v := range sub.Intra { if _, ok := hops[j]; !ok { hops[j] = InterfaceHops{ - Intra: make(map[iface.IfIDType]uint32), + Intra: make(map[iface.ID]uint32), } } vTransposed, ok := hops[j].Intra[i] @@ -205,11 +205,11 @@ func (cfg StaticInfoCfg) Generate(intfs *ifstate.Interfaces, ingress, egress uint16) *staticinfo.Extension { ifType := interfaceTypeTable(intfs) - return cfg.generate(ifType, iface.IfIDType(ingress), iface.IfIDType(egress)) + return cfg.generate(ifType, iface.ID(ingress), iface.ID(egress)) } -func (cfg StaticInfoCfg) generate(ifType map[iface.IfIDType]topology.LinkType, - ingress, egress iface.IfIDType) *staticinfo.Extension { +func (cfg StaticInfoCfg) generate(ifType map[iface.ID]topology.LinkType, + ingress, egress iface.ID) *staticinfo.Extension { return &staticinfo.Extension{ Latency: cfg.generateLatency(ifType, ingress, egress), @@ -223,12 +223,12 @@ func (cfg StaticInfoCfg) generate(ifType map[iface.IfIDType]topology.LinkType, // generateLatency creates the LatencyInfo by extracting the relevant values from // the config. -func (cfg StaticInfoCfg) generateLatency(ifType map[iface.IfIDType]topology.LinkType, - ingress, egress iface.IfIDType) staticinfo.LatencyInfo { +func (cfg StaticInfoCfg) generateLatency(ifType map[iface.ID]topology.LinkType, + ingress, egress iface.ID) staticinfo.LatencyInfo { l := staticinfo.LatencyInfo{ - Intra: make(map[iface.IfIDType]time.Duration), - Inter: make(map[iface.IfIDType]time.Duration), + Intra: make(map[iface.ID]time.Duration), + Inter: make(map[iface.ID]time.Duration), } for ifID, v := range cfg.Latency[egress].Intra { if includeIntraInfo(ifType, ifID, ingress, egress) { @@ -246,12 +246,12 @@ func (cfg StaticInfoCfg) generateLatency(ifType map[iface.IfIDType]topology.Link // generateBandwidth creates the BandwidthInfo by extracting the relevant values // from the config. -func (cfg StaticInfoCfg) generateBandwidth(ifType map[iface.IfIDType]topology.LinkType, - ingress, egress iface.IfIDType) staticinfo.BandwidthInfo { +func (cfg StaticInfoCfg) generateBandwidth(ifType map[iface.ID]topology.LinkType, + ingress, egress iface.ID) staticinfo.BandwidthInfo { bw := staticinfo.BandwidthInfo{ - Intra: make(map[iface.IfIDType]uint64), - Inter: make(map[iface.IfIDType]uint64), + Intra: make(map[iface.ID]uint64), + Inter: make(map[iface.ID]uint64), } for ifID, v := range cfg.Bandwidth[egress].Intra { if includeIntraInfo(ifType, ifID, ingress, egress) { @@ -269,8 +269,8 @@ func (cfg StaticInfoCfg) generateBandwidth(ifType map[iface.IfIDType]topology.Li // generateLinkType creates the LinkTypeInfo by extracting the relevant values from // the config. -func (cfg StaticInfoCfg) generateLinkType(ifType map[iface.IfIDType]topology.LinkType, - egress iface.IfIDType) staticinfo.LinkTypeInfo { +func (cfg StaticInfoCfg) generateLinkType(ifType map[iface.ID]topology.LinkType, + egress iface.ID) staticinfo.LinkTypeInfo { lt := make(staticinfo.LinkTypeInfo) for ifID, intfLT := range cfg.LinkType { @@ -284,8 +284,8 @@ func (cfg StaticInfoCfg) generateLinkType(ifType map[iface.IfIDType]topology.Lin // generateInternalHops creates the InternalHopsInfo by extracting the relevant // values from the config. -func (cfg StaticInfoCfg) generateInternalHops(ifType map[iface.IfIDType]topology.LinkType, - ingress, egress iface.IfIDType) staticinfo.InternalHopsInfo { +func (cfg StaticInfoCfg) generateInternalHops(ifType map[iface.ID]topology.LinkType, + ingress, egress iface.ID) staticinfo.InternalHopsInfo { ihi := make(staticinfo.InternalHopsInfo) for ifID, v := range cfg.Hops[egress].Intra { @@ -298,8 +298,8 @@ func (cfg StaticInfoCfg) generateInternalHops(ifType map[iface.IfIDType]topology // generateGeo creates the GeoInfo by extracting the relevant values from // the config. -func (cfg StaticInfoCfg) generateGeo(ifType map[iface.IfIDType]topology.LinkType, - ingress, egress iface.IfIDType) staticinfo.GeoInfo { +func (cfg StaticInfoCfg) generateGeo(ifType map[iface.ID]topology.LinkType, + ingress, egress iface.ID) staticinfo.GeoInfo { gi := staticinfo.GeoInfo{} for ifID, loc := range cfg.Geo { @@ -331,8 +331,8 @@ func (cfg StaticInfoCfg) generateGeo(ifType map[iface.IfIDType]topology.LinkType // AS needs to pick one consistently (or decide to just include the full // information all the time), otherwise information for cross-overs may // be missing. -func includeIntraInfo(ifType map[iface.IfIDType]topology.LinkType, - ifID, ingress, egress iface.IfIDType) bool { +func includeIntraInfo(ifType map[iface.ID]topology.LinkType, + ifID, ingress, egress iface.ID) bool { isCoreIngress := (ifType[ingress] == topology.Core || ingress == 0) isCoreEgress := (ifType[egress] == topology.Core || egress == 0) @@ -347,11 +347,11 @@ func includeIntraInfo(ifType map[iface.IfIDType]topology.LinkType, t == topology.Peer } -func interfaceTypeTable(intfs *ifstate.Interfaces) map[iface.IfIDType]topology.LinkType { +func interfaceTypeTable(intfs *ifstate.Interfaces) map[iface.ID]topology.LinkType { ifMap := intfs.All() - ifTypes := make(map[iface.IfIDType]topology.LinkType, len(ifMap)) + ifTypes := make(map[iface.ID]topology.LinkType, len(ifMap)) for ifID, ifInfo := range ifMap { - ifTypes[iface.IfIDType(ifID)] = ifInfo.TopoInfo().LinkType + ifTypes[iface.ID(ifID)] = ifInfo.TopoInfo().LinkType } return ifTypes } diff --git a/control/beaconing/staticinfo_config_test.go b/control/beaconing/staticinfo_config_test.go index 8d540ce111..a95775a097 100644 --- a/control/beaconing/staticinfo_config_test.go +++ b/control/beaconing/staticinfo_config_test.go @@ -95,10 +95,10 @@ func getTestConfigData() *beaconing.StaticInfoCfg { } return &beaconing.StaticInfoCfg{ - Latency: map[iface.IfIDType]beaconing.InterfaceLatencies{ + Latency: map[iface.ID]beaconing.InterfaceLatencies{ 1: { Inter: w(latency_inter_1), - Intra: map[iface.IfIDType]util.DurWrap{ + Intra: map[iface.ID]util.DurWrap{ 2: w(latency_intra_1_2), 3: w(latency_intra_1_3), 5: w(latency_intra_1_5), @@ -106,7 +106,7 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 2: { Inter: w(latency_inter_2), - Intra: map[iface.IfIDType]util.DurWrap{ + Intra: map[iface.ID]util.DurWrap{ 1: w(latency_intra_1_2), 3: w(latency_intra_2_3), 5: w(latency_intra_2_5), @@ -114,7 +114,7 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 3: { Inter: w(latency_inter_3), - Intra: map[iface.IfIDType]util.DurWrap{ + Intra: map[iface.ID]util.DurWrap{ 1: w(latency_intra_1_3), 2: w(latency_intra_2_3), 5: w(latency_intra_3_5), @@ -122,17 +122,17 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 5: { Inter: w(latency_inter_5), - Intra: map[iface.IfIDType]util.DurWrap{ + Intra: map[iface.ID]util.DurWrap{ 1: w(latency_intra_1_5), 2: w(latency_intra_2_5), 3: w(latency_intra_3_5), }, }, }, - Bandwidth: map[iface.IfIDType]beaconing.InterfaceBandwidths{ + Bandwidth: map[iface.ID]beaconing.InterfaceBandwidths{ 1: { Inter: bandwidth_inter_1, - Intra: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{ 2: bandwidth_intra_1_2, 3: bandwidth_intra_1_3, 5: bandwidth_intra_1_5, @@ -140,7 +140,7 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 2: { Inter: bandwidth_inter_2, - Intra: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{ 1: bandwidth_intra_1_2, 3: bandwidth_intra_2_3, 5: bandwidth_intra_2_5, @@ -148,7 +148,7 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 3: { Inter: bandwidth_inter_3, - Intra: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{ 1: bandwidth_intra_1_3, 2: bandwidth_intra_2_3, 5: bandwidth_intra_3_5, @@ -156,49 +156,49 @@ func getTestConfigData() *beaconing.StaticInfoCfg { }, 5: { Inter: bandwidth_inter_5, - Intra: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{ 1: bandwidth_intra_1_5, 2: bandwidth_intra_2_5, 3: bandwidth_intra_3_5, }, }, }, - LinkType: map[iface.IfIDType]beaconing.LinkType{ + LinkType: map[iface.ID]beaconing.LinkType{ 1: beaconing.LinkType(link_type_1), 2: beaconing.LinkType(link_type_2), 3: beaconing.LinkType(link_type_3), 5: beaconing.LinkType(link_type_5), }, - Geo: map[iface.IfIDType]beaconing.InterfaceGeodata{ + Geo: map[iface.ID]beaconing.InterfaceGeodata{ 1: {geo_1.Longitude, geo_1.Latitude, geo_1.Address}, 2: {geo_2.Longitude, geo_2.Latitude, geo_2.Address}, 3: {geo_3.Longitude, geo_3.Latitude, geo_3.Address}, 5: {geo_5.Longitude, geo_5.Latitude, geo_5.Address}, }, - Hops: map[iface.IfIDType]beaconing.InterfaceHops{ + Hops: map[iface.ID]beaconing.InterfaceHops{ 1: { - Intra: map[iface.IfIDType]uint32{ + Intra: map[iface.ID]uint32{ 2: hops_intra_1_2, 3: hops_intra_1_3, 5: hops_intra_1_5, }, }, 2: { - Intra: map[iface.IfIDType]uint32{ + Intra: map[iface.ID]uint32{ 1: hops_intra_1_2, 3: hops_intra_2_3, 5: hops_intra_2_5, }, }, 3: { - Intra: map[iface.IfIDType]uint32{ + Intra: map[iface.ID]uint32{ 1: hops_intra_1_3, 2: hops_intra_2_3, 5: hops_intra_3_5, }, }, 5: { - Intra: map[iface.IfIDType]uint32{ + Intra: map[iface.ID]uint32{ 1: hops_intra_1_5, 2: hops_intra_2_5, 3: hops_intra_3_5, @@ -221,14 +221,14 @@ func TestGenerateStaticInfo(t *testing.T) { cfg := getTestConfigData() // "topology" information for a non-core AS: - ifTypeNoncore := map[iface.IfIDType]topology.LinkType{ + ifTypeNoncore := map[iface.ID]topology.LinkType{ 1: topology.Child, 2: topology.Child, 3: topology.Parent, 5: topology.Peer, } // "topology" information for a core AS: - ifTypeCore := map[iface.IfIDType]topology.LinkType{ + ifTypeCore := map[iface.ID]topology.LinkType{ 1: topology.Core, 2: topology.Child, 3: topology.Core, @@ -237,9 +237,9 @@ func TestGenerateStaticInfo(t *testing.T) { testCases := []struct { name string - ingress iface.IfIDType - egress iface.IfIDType - ifType map[iface.IfIDType]topology.LinkType + ingress iface.ID + egress iface.ID + ifType map[iface.ID]topology.LinkType expected staticinfo.Extension }{ { @@ -249,23 +249,23 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[iface.IfIDType]time.Duration{ + Intra: map[iface.ID]time.Duration{ 2: latency_intra_1_2, 3: latency_intra_1_3, 5: latency_intra_1_5, }, - Inter: map[iface.IfIDType]time.Duration{ + Inter: map[iface.ID]time.Duration{ 1: latency_inter_1, 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{ 2: bandwidth_intra_1_2, 3: bandwidth_intra_1_3, 5: bandwidth_intra_1_5, }, - Inter: map[iface.IfIDType]uint64{ + Inter: map[iface.ID]uint64{ 1: bandwidth_inter_1, 5: bandwidth_inter_5, }, @@ -279,7 +279,7 @@ func TestGenerateStaticInfo(t *testing.T) { 1: link_type_1, 5: link_type_5, }, - InternalHops: map[iface.IfIDType]uint32{ + InternalHops: map[iface.ID]uint32{ 2: hops_intra_1_2, 3: hops_intra_1_3, 5: hops_intra_1_5, @@ -294,21 +294,21 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[iface.IfIDType]time.Duration{ + Intra: map[iface.ID]time.Duration{ 3: latency_intra_2_3, 5: latency_intra_2_5, }, - Inter: map[iface.IfIDType]time.Duration{ + Inter: map[iface.ID]time.Duration{ 2: latency_inter_2, 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{ 3: bandwidth_intra_2_3, 5: bandwidth_intra_2_5, }, - Inter: map[iface.IfIDType]uint64{ + Inter: map[iface.ID]uint64{ 2: bandwidth_inter_2, 5: bandwidth_inter_5, }, @@ -322,7 +322,7 @@ func TestGenerateStaticInfo(t *testing.T) { 2: link_type_2, 5: link_type_5, }, - InternalHops: map[iface.IfIDType]uint32{ + InternalHops: map[iface.ID]uint32{ 3: hops_intra_2_3, 5: hops_intra_2_5, }, @@ -336,14 +336,14 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[iface.IfIDType]time.Duration{}, - Inter: map[iface.IfIDType]time.Duration{ + Intra: map[iface.ID]time.Duration{}, + Inter: map[iface.ID]time.Duration{ 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[iface.IfIDType]uint64{}, - Inter: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{}, + Inter: map[iface.ID]uint64{ 5: bandwidth_inter_5, }, }, @@ -354,7 +354,7 @@ func TestGenerateStaticInfo(t *testing.T) { LinkType: staticinfo.LinkTypeInfo{ 5: link_type_5, }, - InternalHops: map[iface.IfIDType]uint32{}, + InternalHops: map[iface.ID]uint32{}, Note: note, }, }, @@ -365,21 +365,21 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[iface.IfIDType]time.Duration{ + Intra: map[iface.ID]time.Duration{ 2: latency_intra_1_2, 5: latency_intra_1_5, }, - Inter: map[iface.IfIDType]time.Duration{ + Inter: map[iface.ID]time.Duration{ 1: latency_inter_1, 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{ 2: bandwidth_intra_1_2, 5: bandwidth_intra_1_5, }, - Inter: map[iface.IfIDType]uint64{ + Inter: map[iface.ID]uint64{ 1: bandwidth_inter_1, 5: bandwidth_inter_5, }, @@ -392,7 +392,7 @@ func TestGenerateStaticInfo(t *testing.T) { 1: link_type_1, 5: link_type_5, }, - InternalHops: map[iface.IfIDType]uint32{ + InternalHops: map[iface.ID]uint32{ 2: hops_intra_1_2, 5: hops_intra_1_5, }, @@ -406,19 +406,19 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeNoncore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[iface.IfIDType]time.Duration{ + Intra: map[iface.ID]time.Duration{ 5: latency_intra_2_5, }, - Inter: map[iface.IfIDType]time.Duration{ + Inter: map[iface.ID]time.Duration{ 2: latency_inter_2, 5: latency_inter_5, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{ 5: bandwidth_intra_2_5, }, - Inter: map[iface.IfIDType]uint64{ + Inter: map[iface.ID]uint64{ 2: bandwidth_inter_2, 5: bandwidth_inter_5, }, @@ -431,7 +431,7 @@ func TestGenerateStaticInfo(t *testing.T) { 2: link_type_2, 5: link_type_5, }, - InternalHops: map[iface.IfIDType]uint32{ + InternalHops: map[iface.ID]uint32{ 5: hops_intra_2_5, }, Note: note, @@ -444,22 +444,22 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeCore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[iface.IfIDType]time.Duration{ + Intra: map[iface.ID]time.Duration{ 1: latency_intra_1_2, 3: latency_intra_2_3, 5: latency_intra_2_5, }, - Inter: map[iface.IfIDType]time.Duration{ + Inter: map[iface.ID]time.Duration{ 2: latency_inter_2, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{ 1: bandwidth_intra_1_2, 3: bandwidth_intra_2_3, 5: bandwidth_intra_2_5, }, - Inter: map[iface.IfIDType]uint64{ + Inter: map[iface.ID]uint64{ 2: bandwidth_inter_2, }, }, @@ -469,7 +469,7 @@ func TestGenerateStaticInfo(t *testing.T) { LinkType: staticinfo.LinkTypeInfo{ 2: link_type_2, }, - InternalHops: map[iface.IfIDType]uint32{ + InternalHops: map[iface.ID]uint32{ 1: hops_intra_1_2, 3: hops_intra_2_3, 5: hops_intra_2_5, @@ -484,14 +484,14 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeCore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[iface.IfIDType]time.Duration{}, - Inter: map[iface.IfIDType]time.Duration{ + Intra: map[iface.ID]time.Duration{}, + Inter: map[iface.ID]time.Duration{ 1: latency_inter_1, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[iface.IfIDType]uint64{}, - Inter: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{}, + Inter: map[iface.ID]uint64{ 1: bandwidth_inter_1, }, }, @@ -501,7 +501,7 @@ func TestGenerateStaticInfo(t *testing.T) { LinkType: staticinfo.LinkTypeInfo{ 1: link_type_1, }, - InternalHops: map[iface.IfIDType]uint32{}, + InternalHops: map[iface.ID]uint32{}, Note: note, }, }, @@ -512,18 +512,18 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeCore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[iface.IfIDType]time.Duration{ + Intra: map[iface.ID]time.Duration{ 3: latency_intra_1_3, }, - Inter: map[iface.IfIDType]time.Duration{ + Inter: map[iface.ID]time.Duration{ 1: latency_inter_1, }, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{ 3: bandwidth_intra_1_3, }, - Inter: map[iface.IfIDType]uint64{ + Inter: map[iface.ID]uint64{ 1: bandwidth_inter_1, }, }, @@ -534,7 +534,7 @@ func TestGenerateStaticInfo(t *testing.T) { LinkType: staticinfo.LinkTypeInfo{ 1: link_type_1, }, - InternalHops: map[iface.IfIDType]uint32{ + InternalHops: map[iface.ID]uint32{ 3: hops_intra_1_3, }, Note: note, @@ -547,18 +547,18 @@ func TestGenerateStaticInfo(t *testing.T) { ifType: ifTypeCore, expected: staticinfo.Extension{ Latency: staticinfo.LatencyInfo{ - Intra: map[iface.IfIDType]time.Duration{}, - Inter: map[iface.IfIDType]time.Duration{}, + Intra: map[iface.ID]time.Duration{}, + Inter: map[iface.ID]time.Duration{}, }, Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[iface.IfIDType]uint64{}, - Inter: map[iface.IfIDType]uint64{}, + Intra: map[iface.ID]uint64{}, + Inter: map[iface.ID]uint64{}, }, Geo: staticinfo.GeoInfo{ 3: geo_3, }, LinkType: staticinfo.LinkTypeInfo{}, - InternalHops: map[iface.IfIDType]uint32{}, + InternalHops: map[iface.ID]uint32{}, Note: note, }, }, diff --git a/control/beaconing/writer_test.go b/control/beaconing/writer_test.go index 197aacf453..5307ae857b 100644 --- a/control/beaconing/writer_test.go +++ b/control/beaconing/writer_test.go @@ -377,7 +377,7 @@ type topoWrap struct { } func (w topoWrap) UnderlayNextHop(id uint16) *net.UDPAddr { - a, _ := w.Topo.UnderlayNextHop(iface.IfIDType(id)) + a, _ := w.Topo.UnderlayNextHop(iface.ID(id)) return a } diff --git a/control/cmd/control/main.go b/control/cmd/control/main.go index 23446769b7..7168c789c9 100644 --- a/control/cmd/control/main.go +++ b/control/cmd/control/main.go @@ -852,7 +852,7 @@ func createBeaconStore( return store, *policies.Prop.Filter.AllowIsdLoop, err } -func adaptInterfaceMap(in map[iface.IfIDType]topology.IFInfo) map[uint16]ifstate.InterfaceInfo { +func adaptInterfaceMap(in map[iface.ID]topology.IFInfo) map[uint16]ifstate.InterfaceInfo { converted := make(map[uint16]ifstate.InterfaceInfo, len(in)) for id, info := range in { converted[uint16(id)] = ifstate.InterfaceInfo{ diff --git a/daemon/internal/servers/grpc.go b/daemon/internal/servers/grpc.go index 4e7b89cd19..1caf06581f 100644 --- a/daemon/internal/servers/grpc.go +++ b/daemon/internal/servers/grpc.go @@ -337,7 +337,7 @@ func (s *DaemonServer) notifyInterfaceDown(ctx context.Context, revInfo := &path_mgmt.RevInfo{ RawIsdas: addr.IA(req.IsdAs), - IfID: iface.IfIDType(req.Id), + IfID: iface.ID(req.Id), LinkType: proto.LinkType_core, RawTTL: 10, RawTimestamp: util.TimeToSecs(time.Now()), diff --git a/gateway/pathhealth/revocations_test.go b/gateway/pathhealth/revocations_test.go index 5b5c86dffb..0b2a518937 100644 --- a/gateway/pathhealth/revocations_test.go +++ b/gateway/pathhealth/revocations_test.go @@ -69,7 +69,7 @@ func TestExpiredRevocation(t *testing.T) { s.Cleanup(context.Background()) } -func createMockPath(ctrl *gomock.Controller, ia addr.IA, ifID iface.IfIDType) snet.Path { +func createMockPath(ctrl *gomock.Controller, ia addr.IA, ifID iface.ID) snet.Path { path := mock_snet.NewMockPath(ctrl) path.EXPECT().Metadata().Return(&snet.PathMetadata{ Interfaces: []snet.PathInterface{{IA: ia, ID: ifID}}, @@ -77,7 +77,7 @@ func createMockPath(ctrl *gomock.Controller, ia addr.IA, ifID iface.IfIDType) sn return path } -func createRevInfo(ia addr.IA, ifID iface.IfIDType, expired bool) *path_mgmt.RevInfo { +func createRevInfo(ia addr.IA, ifID iface.ID, expired bool) *path_mgmt.RevInfo { ri := &path_mgmt.RevInfo{ RawIsdas: ia, IfID: ifID, diff --git a/pkg/daemon/grpc.go b/pkg/daemon/grpc.go index 6dbae22872..e501a5517d 100644 --- a/pkg/daemon/grpc.go +++ b/pkg/daemon/grpc.go @@ -260,7 +260,7 @@ func convertPath(p *sdpb.Path, dst addr.IA) (path.Path, error) { interfaces := make([]snet.PathInterface, len(p.Interfaces)) for i, pi := range p.Interfaces { interfaces[i] = snet.PathInterface{ - ID: iface.IfIDType(pi.Id), + ID: iface.ID(pi.Id), IA: addr.IA(pi.IsdAs), } } diff --git a/pkg/experimental/hiddenpath/beaconwriter_test.go b/pkg/experimental/hiddenpath/beaconwriter_test.go index d028fe0a27..ce44d72fce 100644 --- a/pkg/experimental/hiddenpath/beaconwriter_test.go +++ b/pkg/experimental/hiddenpath/beaconwriter_test.go @@ -348,7 +348,7 @@ type topoWrap struct { } func (w topoWrap) UnderlayNextHop(id uint16) *net.UDPAddr { - a, _ := w.Topo.UnderlayNextHop(iface.IfIDType(id)) + a, _ := w.Topo.UnderlayNextHop(iface.ID(id)) return a } diff --git a/pkg/private/ctrl/path_mgmt/rev_info.go b/pkg/private/ctrl/path_mgmt/rev_info.go index b2e61cbc1d..9b1c083dd2 100644 --- a/pkg/private/ctrl/path_mgmt/rev_info.go +++ b/pkg/private/ctrl/path_mgmt/rev_info.go @@ -47,7 +47,7 @@ func (ee RevTimeError) Error() string { } type RevInfo struct { - IfID iface.IfIDType + IfID iface.ID RawIsdas addr.IA // LinkType of revocation LinkType proto.LinkType diff --git a/pkg/private/xtest/graph/graph.go b/pkg/private/xtest/graph/graph.go index e9da602ea0..a80b87baa6 100644 --- a/pkg/private/xtest/graph/graph.go +++ b/pkg/private/xtest/graph/graph.go @@ -603,55 +603,55 @@ func generateStaticInfo(g *Graph, ia addr.IA, inIF, outIF uint16) *staticinfo.Ex latency := staticinfo.LatencyInfo{} if outIF != 0 { - latency.Intra = make(map[iface.IfIDType]time.Duration) - latency.Inter = make(map[iface.IfIDType]time.Duration) + latency.Intra = make(map[iface.ID]time.Duration) + latency.Inter = make(map[iface.ID]time.Duration) for ifID := range as.IfIDs { if ifID != outIF { // Note: the test graph does not distinguish between parent/child or // core interfaces. // Otherwise, we could skip the parent interfaces and half of the // sibling interfaces here. - latency.Intra[iface.IfIDType(ifID)] = g.Latency(ifID, outIF) + latency.Intra[iface.ID(ifID)] = g.Latency(ifID, outIF) } if ifID == outIF || g.isPeer[ifID] { - latency.Inter[iface.IfIDType(ifID)] = g.Latency(ifID, g.links[ifID]) + latency.Inter[iface.ID(ifID)] = g.Latency(ifID, g.links[ifID]) } } } bandwidth := staticinfo.BandwidthInfo{} if outIF != 0 { - bandwidth.Intra = make(map[iface.IfIDType]uint64) - bandwidth.Inter = make(map[iface.IfIDType]uint64) + bandwidth.Intra = make(map[iface.ID]uint64) + bandwidth.Inter = make(map[iface.ID]uint64) for ifID := range as.IfIDs { if ifID != outIF { - bandwidth.Intra[iface.IfIDType(ifID)] = g.Bandwidth(ifID, outIF) + bandwidth.Intra[iface.ID(ifID)] = g.Bandwidth(ifID, outIF) } if ifID == outIF || g.isPeer[ifID] { - bandwidth.Inter[iface.IfIDType(ifID)] = g.Bandwidth(ifID, g.links[ifID]) + bandwidth.Inter[iface.ID(ifID)] = g.Bandwidth(ifID, g.links[ifID]) } } } geo := make(staticinfo.GeoInfo) for ifID := range as.IfIDs { - geo[iface.IfIDType(ifID)] = g.GeoCoordinates(ifID) + geo[iface.ID(ifID)] = g.GeoCoordinates(ifID) } linkType := make(staticinfo.LinkTypeInfo) for ifID := range as.IfIDs { - linkType[iface.IfIDType(ifID)] = g.LinkType(ifID, g.links[ifID]) + linkType[iface.ID(ifID)] = g.LinkType(ifID, g.links[ifID]) } var internalHops staticinfo.InternalHopsInfo if outIF != 0 { - internalHops = make(map[iface.IfIDType]uint32) + internalHops = make(map[iface.ID]uint32) if inIF != 0 { - internalHops[iface.IfIDType(inIF)] = g.InternalHops(inIF, outIF) + internalHops[iface.ID(inIF)] = g.InternalHops(inIF, outIF) } for ifID := range as.IfIDs { if ifID != outIF && ifID != inIF { - internalHops[iface.IfIDType(ifID)] = g.InternalHops(ifID, outIF) + internalHops[iface.ID(ifID)] = g.InternalHops(ifID, outIF) } } } diff --git a/pkg/segment/extensions/staticinfo/staticinfo.go b/pkg/segment/extensions/staticinfo/staticinfo.go index 80d43abd46..6141441864 100644 --- a/pkg/segment/extensions/staticinfo/staticinfo.go +++ b/pkg/segment/extensions/staticinfo/staticinfo.go @@ -39,20 +39,20 @@ type Extension struct { // LatencyInfo is the internal repesentation of `latency` in the // StaticInfoExtension. type LatencyInfo struct { - Intra map[iface.IfIDType]time.Duration - Inter map[iface.IfIDType]time.Duration + Intra map[iface.ID]time.Duration + Inter map[iface.ID]time.Duration } // BandwidthInfo is the internal repesentation of `bandwidth` in the // StaticInfoExtension. type BandwidthInfo struct { - Intra map[iface.IfIDType]uint64 - Inter map[iface.IfIDType]uint64 + Intra map[iface.ID]uint64 + Inter map[iface.ID]uint64 } // GeoInfo is the internal repesentation of `geo` in the // StaticInfoExtension. -type GeoInfo map[iface.IfIDType]GeoCoordinates +type GeoInfo map[iface.ID]GeoCoordinates // GeoCoordinates is the internal repesentation of the GeoCoordinates in the // StaticInfoExtension. @@ -76,11 +76,11 @@ const ( // LinkTypeInfo is the internal representation of `link_type` in the // StaticInfoExtension. -type LinkTypeInfo map[iface.IfIDType]LinkType +type LinkTypeInfo map[iface.ID]LinkType // InternalHopsInfo is the internal representation of `internal_hops` in the // StaticInfoExtension. -type InternalHopsInfo map[iface.IfIDType]uint32 +type InternalHopsInfo map[iface.ID]uint32 // FromPB creates the staticinfo Extension from the protobuf representation. func FromPB(pb *cppb.StaticInfoExtension) *Extension { @@ -101,13 +101,13 @@ func latencyInfoFromPB(pb *cppb.LatencyInfo) LatencyInfo { if pb == nil || len(pb.Intra) == 0 && len(pb.Inter) == 0 { return LatencyInfo{} } - intra := make(map[iface.IfIDType]time.Duration, len(pb.Intra)) + intra := make(map[iface.ID]time.Duration, len(pb.Intra)) for ifID, v := range pb.Intra { - intra[iface.IfIDType(ifID)] = time.Duration(v) * time.Microsecond + intra[iface.ID(ifID)] = time.Duration(v) * time.Microsecond } - inter := make(map[iface.IfIDType]time.Duration, len(pb.Inter)) + inter := make(map[iface.ID]time.Duration, len(pb.Inter)) for ifID, v := range pb.Inter { - inter[iface.IfIDType(ifID)] = time.Duration(v) * time.Microsecond + inter[iface.ID(ifID)] = time.Duration(v) * time.Microsecond } return LatencyInfo{ Intra: intra, @@ -119,13 +119,13 @@ func bandwidthInfoFromPB(pb *cppb.BandwidthInfo) BandwidthInfo { if pb == nil || len(pb.Intra) == 0 && len(pb.Inter) == 0 { return BandwidthInfo{} } - intra := make(map[iface.IfIDType]uint64, len(pb.Intra)) + intra := make(map[iface.ID]uint64, len(pb.Intra)) for ifID, v := range pb.Intra { - intra[iface.IfIDType(ifID)] = v + intra[iface.ID(ifID)] = v } - inter := make(map[iface.IfIDType]uint64, len(pb.Inter)) + inter := make(map[iface.ID]uint64, len(pb.Inter)) for ifID, v := range pb.Inter { - inter[iface.IfIDType(ifID)] = v + inter[iface.ID(ifID)] = v } return BandwidthInfo{ Intra: intra, @@ -139,7 +139,7 @@ func geoInfoFromPB(pb map[uint64]*cppb.GeoCoordinates) GeoInfo { } gi := make(GeoInfo, len(pb)) for ifID, v := range pb { - gi[iface.IfIDType(ifID)] = GeoCoordinates{ + gi[iface.ID(ifID)] = GeoCoordinates{ Latitude: v.Latitude, Longitude: v.Longitude, Address: v.Address, @@ -167,7 +167,7 @@ func linkTypeInfoFromPB(pb map[uint64]cppb.LinkType) LinkTypeInfo { default: continue } - lti[iface.IfIDType(ifID)] = v + lti[iface.ID(ifID)] = v } return lti } @@ -178,7 +178,7 @@ func internalHopsInfoFromPB(pb map[uint64]uint32) InternalHopsInfo { } ihi := make(InternalHopsInfo, len(pb)) for ifID, v := range pb { - ihi[iface.IfIDType(ifID)] = v + ihi[iface.ID(ifID)] = v } return ihi } diff --git a/pkg/segment/extensions/staticinfo/staticinfo_test.go b/pkg/segment/extensions/staticinfo/staticinfo_test.go index 539d28d1dc..42a2b1abf4 100644 --- a/pkg/segment/extensions/staticinfo/staticinfo_test.go +++ b/pkg/segment/extensions/staticinfo/staticinfo_test.go @@ -34,22 +34,22 @@ func TestRoundtripStaticInfoExtension(t *testing.T) { }, "latency": { Latency: staticinfo.LatencyInfo{ - Intra: map[iface.IfIDType]time.Duration{ + Intra: map[iface.ID]time.Duration{ 10: 10 * time.Millisecond, 11: 11 * time.Millisecond, }, - Inter: map[iface.IfIDType]time.Duration{ + Inter: map[iface.ID]time.Duration{ 11: 111 * time.Millisecond, }, }, }, "bandwidth": { Bandwidth: staticinfo.BandwidthInfo{ - Intra: map[iface.IfIDType]uint64{ + Intra: map[iface.ID]uint64{ 10: 1, // 1Kbit/s 11: 10_000_000_000, // 10Tbit/s }, - Inter: map[iface.IfIDType]uint64{ + Inter: map[iface.ID]uint64{ 11: 2_000_000, }, }, @@ -71,7 +71,7 @@ func TestRoundtripStaticInfoExtension(t *testing.T) { }, }, "internal_hops": { - InternalHops: map[iface.IfIDType]uint32{ + InternalHops: map[iface.ID]uint32{ 10: 2, 11: 3, }, diff --git a/pkg/segment/iface/iface.go b/pkg/segment/iface/iface.go index 0d1a5c4464..fc4186ae07 100644 --- a/pkg/segment/iface/iface.go +++ b/pkg/segment/iface/iface.go @@ -23,23 +23,23 @@ import ( // IfIDType is the path-type-independent type for interface IDs. Interface IDs must fit in // 64 bits. There is a lot of path-type-independent code that manipulates interface IDs without // interpreting them. This type is a container for them. -type IfIDType uint64 +type ID uint64 -func (ifID IfIDType) String() string { +func (ifID ID) String() string { return strconv.FormatUint(uint64(ifID), 10) } // UnmarshalJSON unmarshals the JSON data into the IfID. -func (ifID *IfIDType) UnmarshalJSON(data []byte) error { +func (ifID *ID) UnmarshalJSON(data []byte) error { return ifID.UnmarshalText(data) } // UnmarshalText unmarshals the text into the IfID. -func (ifID *IfIDType) UnmarshalText(text []byte) error { +func (ifID *ID) UnmarshalText(text []byte) error { i, err := strconv.ParseUint(strings.ReplaceAll(string(text), "\"", ""), 10, 64) if err != nil { return err } - *ifID = IfIDType(i) + *ifID = ID(i) return nil } diff --git a/pkg/segment/iface/iface_test.go b/pkg/segment/iface/iface_test.go index 6e5fb310ae..12616e4a3f 100644 --- a/pkg/segment/iface/iface_test.go +++ b/pkg/segment/iface/iface_test.go @@ -27,7 +27,7 @@ import ( func TestIfIDTypeUnmarshalJSON(t *testing.T) { t.Run("Simple Value", func(t *testing.T) { type exampleStruct struct { - IfID iface.IfIDType `json:"if_id"` + IfID iface.ID `json:"if_id"` } j := `{"if_id": 5}` var f exampleStruct @@ -36,17 +36,17 @@ func TestIfIDTypeUnmarshalJSON(t *testing.T) { }) t.Run("Map keys", func(t *testing.T) { type exampleStruct struct { - IfMap map[iface.IfIDType]string `json:"if_map"` + IfMap map[iface.ID]string `json:"if_map"` } j := `{"if_map": {"5": "foo"}}` var f exampleStruct require.NoError(t, json.Unmarshal([]byte(j), &f)) - assert.Equal(t, exampleStruct{IfMap: map[iface.IfIDType]string{5: "foo"}}, f) + assert.Equal(t, exampleStruct{IfMap: map[iface.ID]string{5: "foo"}}, f) }) } func TestIfIDTypeUnmarshalText(t *testing.T) { - var id iface.IfIDType + var id iface.ID assert.NoError(t, id.UnmarshalText([]byte("1"))) - assert.Equal(t, iface.IfIDType(1), id) + assert.Equal(t, iface.ID(1), id) } diff --git a/pkg/snet/path.go b/pkg/snet/path.go index cf3a38413e..37e00682eb 100644 --- a/pkg/snet/path.go +++ b/pkg/snet/path.go @@ -70,7 +70,7 @@ type Path interface { // PathInterface is an interface of the path. type PathInterface struct { // ID is the ID of the interface. - ID iface.IfIDType + ID iface.ID // IA is the ISD AS identifier of the interface. IA addr.IA } diff --git a/pkg/snet/scmp.go b/pkg/snet/scmp.go index 641a0192be..cc0f43d240 100644 --- a/pkg/snet/scmp.go +++ b/pkg/snet/scmp.go @@ -73,7 +73,7 @@ func (h DefaultSCMPHandler) Handle(pkt *Packet) error { case slayers.SCMPTypeExternalInterfaceDown: msg := pkt.Payload.(SCMPExternalInterfaceDown) return h.handleSCMPRev(typeCode, &path_mgmt.RevInfo{ - IfID: iface.IfIDType(msg.Interface), + IfID: iface.ID(msg.Interface), RawIsdas: msg.IA, RawTimestamp: util.TimeToSecs(time.Now()), RawTTL: 10, @@ -81,7 +81,7 @@ func (h DefaultSCMPHandler) Handle(pkt *Packet) error { case slayers.SCMPTypeInternalConnectivityDown: msg := pkt.Payload.(SCMPInternalConnectivityDown) return h.handleSCMPRev(typeCode, &path_mgmt.RevInfo{ - IfID: iface.IfIDType(msg.Egress), + IfID: iface.ID(msg.Egress), RawIsdas: msg.IA, RawTimestamp: util.TimeToSecs(time.Now()), RawTTL: 10, diff --git a/private/path/combinator/combinator_test.go b/private/path/combinator/combinator_test.go index 437a2a9e71..f65e629986 100644 --- a/private/path/combinator/combinator_test.go +++ b/private/path/combinator/combinator_test.go @@ -568,20 +568,20 @@ func TestFilterDuplicates(t *testing.T) { // These look somewhat valid, but that doesn't matter at all -- we only look // at the fingerprint anyway. path0 := []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:110"), ID: iface.IfIDType(10)}, - {IA: addr.MustParseIA("1-ff00:0:111"), ID: iface.IfIDType(10)}, + {IA: addr.MustParseIA("1-ff00:0:110"), ID: iface.ID(10)}, + {IA: addr.MustParseIA("1-ff00:0:111"), ID: iface.ID(10)}, } path1 := []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:110"), ID: iface.IfIDType(11)}, - {IA: addr.MustParseIA("1-ff00:0:112"), ID: iface.IfIDType(11)}, - {IA: addr.MustParseIA("1-ff00:0:112"), ID: iface.IfIDType(12)}, - {IA: addr.MustParseIA("1-ff00:0:111"), ID: iface.IfIDType(12)}, + {IA: addr.MustParseIA("1-ff00:0:110"), ID: iface.ID(11)}, + {IA: addr.MustParseIA("1-ff00:0:112"), ID: iface.ID(11)}, + {IA: addr.MustParseIA("1-ff00:0:112"), ID: iface.ID(12)}, + {IA: addr.MustParseIA("1-ff00:0:111"), ID: iface.ID(12)}, } path2 := []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:110"), ID: iface.IfIDType(11)}, - {IA: addr.MustParseIA("1-ff00:0:112"), ID: iface.IfIDType(11)}, - {IA: addr.MustParseIA("1-ff00:0:112"), ID: iface.IfIDType(22)}, - {IA: addr.MustParseIA("1-ff00:0:111"), ID: iface.IfIDType(22)}, + {IA: addr.MustParseIA("1-ff00:0:110"), ID: iface.ID(11)}, + {IA: addr.MustParseIA("1-ff00:0:112"), ID: iface.ID(11)}, + {IA: addr.MustParseIA("1-ff00:0:112"), ID: iface.ID(22)}, + {IA: addr.MustParseIA("1-ff00:0:111"), ID: iface.ID(22)}, } // Define two expiry times for the paths: paths with latest expiry will be kept diff --git a/private/path/combinator/graph.go b/private/path/combinator/graph.go index 3633a1d898..2531c77b78 100644 --- a/private/path/combinator/graph.go +++ b/private/path/combinator/graph.go @@ -146,8 +146,8 @@ func (g *dmg) traverseSegment(segment *inputSegment) { } for peerEntryIdx, peer := range asEntries[asEntryIndex].PeerEntries { - ingress := iface.IfIDType(peer.HopField.ConsIngress) - remote := iface.IfIDType(peer.PeerInterface) + ingress := iface.ID(peer.HopField.ConsIngress) + remote := iface.ID(peer.PeerInterface) tuples = append(tuples, Tuple{ Src: vertexFromIA(pinnedIA), Dst: vertexFromPeering(currentIA, ingress, peer.Peer, remote), @@ -259,17 +259,17 @@ func (s *inputSegment) IsDownSeg() bool { type vertex struct { IA addr.IA UpIA addr.IA - UpIfID iface.IfIDType + UpIfID iface.ID DownIA addr.IA - DownIfID iface.IfIDType + DownIfID iface.ID } func vertexFromIA(ia addr.IA) vertex { return vertex{IA: ia} } -func vertexFromPeering(upIA addr.IA, upIfID iface.IfIDType, - downIA addr.IA, downIfID iface.IfIDType) vertex { +func vertexFromPeering(upIA addr.IA, upIfID iface.ID, + downIA addr.IA, downIfID iface.ID) vertex { return vertex{UpIA: upIA, UpIfID: upIfID, DownIA: downIA, DownIfID: downIfID} } @@ -365,14 +365,14 @@ func (solution *pathSolution) Path() Path { if hopField.ConsEgress != 0 { intfs = append(intfs, snet.PathInterface{ IA: asEntry.Local, - ID: iface.IfIDType(hopField.ConsEgress), + ID: iface.ID(hopField.ConsEgress), }) } // In a non-peer shortcut the AS is not traversed completely. if hopField.ConsIngress != 0 && (!isShortcut || isPeer) { intfs = append(intfs, snet.PathInterface{ IA: asEntry.Local, - ID: iface.IfIDType(hopField.ConsIngress), + ID: iface.ID(hopField.ConsIngress), }) } hops = append(hops, hopField) diff --git a/private/path/combinator/staticinfo_accumulator.go b/private/path/combinator/staticinfo_accumulator.go index 8e76869c14..11ce952eb6 100644 --- a/private/path/combinator/staticinfo_accumulator.go +++ b/private/path/combinator/staticinfo_accumulator.go @@ -85,7 +85,7 @@ func collectLatency(p pathInfo) []time.Duration { } egIF := snet.PathInterface{ IA: asEntry.Local, - ID: iface.IfIDType(asEntry.HopEntry.HopField.ConsEgress), + ID: iface.ID(asEntry.HopEntry.HopField.ConsEgress), } latency := staticInfo.Latency // Egress to sibling child, core or peer interfaces @@ -140,7 +140,7 @@ func collectBandwidth(p pathInfo) []uint64 { } egIF := snet.PathInterface{ IA: asEntry.Local, - ID: iface.IfIDType(asEntry.HopEntry.HopField.ConsEgress), + ID: iface.ID(asEntry.HopEntry.HopField.ConsEgress), } bandwidth := staticInfo.Bandwidth // Egress to other local interfaces @@ -265,7 +265,7 @@ func collectInternalHops(p pathInfo) []uint32 { } egIF := snet.PathInterface{ IA: asEntry.Local, - ID: iface.IfIDType(asEntry.HopEntry.HopField.ConsEgress), + ID: iface.ID(asEntry.HopEntry.HopField.ConsEgress), } internalHops := staticInfo.InternalHops for ifID, v := range internalHops { diff --git a/private/path/combinator/staticinfo_accumulator_test.go b/private/path/combinator/staticinfo_accumulator_test.go index 4cc43885d8..ee144b708a 100644 --- a/private/path/combinator/staticinfo_accumulator_test.go +++ b/private/path/combinator/staticinfo_accumulator_test.go @@ -42,12 +42,12 @@ func TestStaticinfo(t *testing.T) { { Name: "#0 simple up-core-down", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:131"), ID: iface.IfIDType(graph.If_131_X_130_A)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.IfIDType(graph.If_130_A_131_X)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.IfIDType(graph.If_130_B_120_A)}, - {IA: addr.MustParseIA("1-ff00:0:120"), ID: iface.IfIDType(graph.If_120_A_130_B)}, - {IA: addr.MustParseIA("1-ff00:0:120"), ID: iface.IfIDType(graph.If_120_X_111_B)}, - {IA: addr.MustParseIA("1-ff00:0:111"), ID: iface.IfIDType(graph.If_111_B_120_X)}, + {IA: addr.MustParseIA("1-ff00:0:131"), ID: iface.ID(graph.If_131_X_130_A)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.ID(graph.If_130_A_131_X)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.ID(graph.If_130_B_120_A)}, + {IA: addr.MustParseIA("1-ff00:0:120"), ID: iface.ID(graph.If_120_A_130_B)}, + {IA: addr.MustParseIA("1-ff00:0:120"), ID: iface.ID(graph.If_120_X_111_B)}, + {IA: addr.MustParseIA("1-ff00:0:111"), ID: iface.ID(graph.If_111_B_120_X)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_130_A_131_X}, @@ -58,10 +58,10 @@ func TestStaticinfo(t *testing.T) { { Name: "#1 simple up-core", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:131"), ID: iface.IfIDType(graph.If_131_X_130_A)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.IfIDType(graph.If_130_A_131_X)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.IfIDType(graph.If_130_A_110_X)}, - {IA: addr.MustParseIA("1-ff00:0:110"), ID: iface.IfIDType(graph.If_110_X_130_A)}, + {IA: addr.MustParseIA("1-ff00:0:131"), ID: iface.ID(graph.If_131_X_130_A)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.ID(graph.If_130_A_131_X)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.ID(graph.If_130_A_110_X)}, + {IA: addr.MustParseIA("1-ff00:0:110"), ID: iface.ID(graph.If_110_X_130_A)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_130_A_131_X}, @@ -72,8 +72,8 @@ func TestStaticinfo(t *testing.T) { { Name: "#2 simple up only", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("1-ff00:0:131"), ID: iface.IfIDType(graph.If_131_X_130_A)}, - {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.IfIDType(graph.If_130_A_131_X)}, + {IA: addr.MustParseIA("1-ff00:0:131"), ID: iface.ID(graph.If_131_X_130_A)}, + {IA: addr.MustParseIA("1-ff00:0:130"), ID: iface.ID(graph.If_130_A_131_X)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_130_A_131_X}, @@ -84,10 +84,10 @@ func TestStaticinfo(t *testing.T) { { Name: "#14 shortcut, common upstream", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("2-ff00:0:212"), ID: iface.IfIDType(graph.If_212_X_211_A1)}, - {IA: addr.MustParseIA("2-ff00:0:211"), ID: iface.IfIDType(graph.If_211_A1_212_X)}, - {IA: addr.MustParseIA("2-ff00:0:211"), ID: iface.IfIDType(graph.If_211_A_222_X)}, - {IA: addr.MustParseIA("2-ff00:0:222"), ID: iface.IfIDType(graph.If_222_X_211_A)}, + {IA: addr.MustParseIA("2-ff00:0:212"), ID: iface.ID(graph.If_212_X_211_A1)}, + {IA: addr.MustParseIA("2-ff00:0:211"), ID: iface.ID(graph.If_211_A1_212_X)}, + {IA: addr.MustParseIA("2-ff00:0:211"), ID: iface.ID(graph.If_211_A_222_X)}, + {IA: addr.MustParseIA("2-ff00:0:222"), ID: iface.ID(graph.If_222_X_211_A)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_210_X1_211_A, graph.If_211_A1_212_X}, @@ -98,12 +98,12 @@ func TestStaticinfo(t *testing.T) { { Name: "#15 go through peer", Path: []snet.PathInterface{ - {IA: addr.MustParseIA("2-ff00:0:212"), ID: iface.IfIDType(graph.If_212_X_211_A1)}, - {IA: addr.MustParseIA("2-ff00:0:211"), ID: iface.IfIDType(graph.If_211_A1_212_X)}, - {IA: addr.MustParseIA("2-ff00:0:211"), ID: iface.IfIDType(graph.If_211_A_221_X)}, - {IA: addr.MustParseIA("2-ff00:0:221"), ID: iface.IfIDType(graph.If_221_X_211_A)}, - {IA: addr.MustParseIA("2-ff00:0:221"), ID: iface.IfIDType(graph.If_221_X_222_X)}, - {IA: addr.MustParseIA("2-ff00:0:222"), ID: iface.IfIDType(graph.If_222_X_221_X)}, + {IA: addr.MustParseIA("2-ff00:0:212"), ID: iface.ID(graph.If_212_X_211_A1)}, + {IA: addr.MustParseIA("2-ff00:0:211"), ID: iface.ID(graph.If_211_A1_212_X)}, + {IA: addr.MustParseIA("2-ff00:0:211"), ID: iface.ID(graph.If_211_A_221_X)}, + {IA: addr.MustParseIA("2-ff00:0:221"), ID: iface.ID(graph.If_221_X_211_A)}, + {IA: addr.MustParseIA("2-ff00:0:221"), ID: iface.ID(graph.If_221_X_222_X)}, + {IA: addr.MustParseIA("2-ff00:0:222"), ID: iface.ID(graph.If_222_X_221_X)}, }, ASEntries: concatBeaconASEntries(g, []uint16{graph.If_210_X1_211_A, graph.If_211_A1_212_X}, diff --git a/private/path/pathpol/acl_test.go b/private/path/pathpol/acl_test.go index ce6ddf98f9..3bf6d4db71 100644 --- a/private/path/pathpol/acl_test.go +++ b/private/path/pathpol/acl_test.go @@ -113,7 +113,7 @@ func TestACLEntryLoadFromString(t *testing.T) { String: "+ 0", ACLEntry: ACLEntry{ Action: Allow, - Rule: &HopPredicate{IfIDs: []iface.IfIDType{0}}, + Rule: &HopPredicate{IfIDs: []iface.ID{0}}, }, ErrorAssertion: assert.NoError, }, @@ -121,7 +121,7 @@ func TestACLEntryLoadFromString(t *testing.T) { String: "+ 1-2#3", ACLEntry: ACLEntry{ Action: Allow, - Rule: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.IfIDType{3}}, + Rule: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.ID{3}}, }, ErrorAssertion: assert.NoError, }, @@ -134,7 +134,7 @@ func TestACLEntryLoadFromString(t *testing.T) { String: "- 0", ACLEntry: ACLEntry{ Action: Deny, - Rule: &HopPredicate{IfIDs: []iface.IfIDType{0}}, + Rule: &HopPredicate{IfIDs: []iface.ID{0}}, }, ErrorAssertion: assert.NoError, }, @@ -161,7 +161,7 @@ func TestACLEntryLoadFromString(t *testing.T) { func TestACLEntryString(t *testing.T) { aclEntryString := "+ 0-0#0" - aclEntry := &ACLEntry{Action: true, Rule: &HopPredicate{IfIDs: []iface.IfIDType{0}}} + aclEntry := &ACLEntry{Action: true, Rule: &HopPredicate{IfIDs: []iface.ID{0}}} assert.Equal(t, aclEntryString, aclEntry.String()) } diff --git a/private/path/pathpol/hop_pred.go b/private/path/pathpol/hop_pred.go index 8e97209e6e..70904a29c6 100644 --- a/private/path/pathpol/hop_pred.go +++ b/private/path/pathpol/hop_pred.go @@ -32,11 +32,11 @@ import ( type HopPredicate struct { ISD addr.ISD AS addr.AS - IfIDs []iface.IfIDType + IfIDs []iface.ID } func NewHopPredicate() *HopPredicate { - return &HopPredicate{IfIDs: make([]iface.IfIDType, 1)} + return &HopPredicate{IfIDs: make([]iface.ID, 1)} } func HopPredicateFromString(str string) (*HopPredicate, error) { @@ -44,7 +44,7 @@ func HopPredicateFromString(str string) (*HopPredicate, error) { if err = validateHopPredStr(str); err != nil { return &HopPredicate{}, err } - var ifIDs = make([]iface.IfIDType, 1) + var ifIDs = make([]iface.ID, 1) // Parse ISD dashParts := strings.Split(str, "-") isd, err := addr.ParseISD(dashParts[0]) @@ -136,12 +136,12 @@ func (hp *HopPredicate) UnmarshalJSON(b []byte) error { return err } -func parseIfID(str string) (iface.IfIDType, error) { +func parseIfID(str string) (iface.ID, error) { ifID, err := strconv.ParseUint(str, 10, 64) if err != nil { return 0, err } - return iface.IfIDType(ifID), nil + return iface.ID(ifID), nil } // validateHopPredStr checks if str has the correct amount of delimiters diff --git a/private/path/pathpol/hop_pred_test.go b/private/path/pathpol/hop_pred_test.go index 77047429f4..6380b62071 100644 --- a/private/path/pathpol/hop_pred_test.go +++ b/private/path/pathpol/hop_pred_test.go @@ -32,22 +32,22 @@ func TestNewHopPredicate(t *testing.T) { }{ "ISD wildcard": { In: "0", - HP: &HopPredicate{ISD: 0, AS: 0, IfIDs: []iface.IfIDType{0}}, + HP: &HopPredicate{ISD: 0, AS: 0, IfIDs: []iface.ID{0}}, Valid: true, }, "AS, IF wildcard omitted": { In: "1", - HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []iface.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []iface.ID{0}}, Valid: true, }, "IF wildcard omitted": { In: "1-0", - HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []iface.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []iface.ID{0}}, Valid: true, }, "basic wildcard": { In: "1-0#0", - HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []iface.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 0, IfIDs: []iface.ID{0}}, Valid: true, }, "AS wildcard, interface set": { @@ -56,27 +56,27 @@ func TestNewHopPredicate(t *testing.T) { }, "ISD wildcard, AS set": { In: "0-1#0", - HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []iface.IfIDType{0}}, + HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []iface.ID{0}}, Valid: true, }, "ISD wildcard, AS set, interface set": { In: "0-1#2", - HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []iface.IfIDType{2}}, + HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []iface.ID{2}}, Valid: true, }, "ISD wildcard, AS set and interface omitted": { In: "0-1", - HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []iface.IfIDType{0}}, + HP: &HopPredicate{ISD: 0, AS: 1, IfIDs: []iface.ID{0}}, Valid: true, }, "IF wildcard omitted, AS set": { In: "1-2", - HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.ID{0}}, Valid: true, }, "two IfIDs": { In: "1-2#3,4", - HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.IfIDType{3, 4}}, + HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.ID{3, 4}}, Valid: true, }, "three IfIDs": { @@ -140,13 +140,13 @@ func TestJsonConversion(t *testing.T) { HP *HopPredicate }{ "Normal predicate": { - HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.IfIDType{1, 2}}, + HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.ID{1, 2}}, }, "wildcard predicate": { - HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.IfIDType{0}}, + HP: &HopPredicate{ISD: 1, AS: 2, IfIDs: []iface.ID{0}}, }, "only ifIDs": { - HP: &HopPredicate{IfIDs: []iface.IfIDType{0}}, + HP: &HopPredicate{IfIDs: []iface.ID{0}}, }, } for name, test := range tests { diff --git a/private/path/pathpol/policy_test.go b/private/path/pathpol/policy_test.go index 635558cbbd..0251f062a7 100644 --- a/private/path/pathpol/policy_test.go +++ b/private/path/pathpol/policy_test.go @@ -648,7 +648,7 @@ func (p PathProvider) GetPaths(src, dst addr.IA) []snet.Path { ia := p.g.GetParent(ifID) pathIntfs = append(pathIntfs, snet.PathInterface{ IA: ia, - ID: iface.IfIDType(ifID), + ID: iface.ID(ifID), }) } var srcIA, dstIA addr.IA diff --git a/private/path/pathpol/sequence.go b/private/path/pathpol/sequence.go index 120d19aadd..a2bfc81ed0 100644 --- a/private/path/pathpol/sequence.go +++ b/private/path/pathpol/sequence.go @@ -294,7 +294,7 @@ func (l *sequenceListener) ExitIFace(c *sequence.IFaceContext) { l.push(re) } -func hop(ia addr.IA, ingress, egress iface.IfIDType) string { +func hop(ia addr.IA, ingress, egress iface.ID) string { return fmt.Sprintf("%s#%d,%d", ia, ingress, egress) } diff --git a/private/pathdb/query/query.go b/private/pathdb/query/query.go index e73a6b26a6..d8796a9c3c 100644 --- a/private/pathdb/query/query.go +++ b/private/pathdb/query/query.go @@ -26,7 +26,7 @@ import ( type IntfSpec struct { IA addr.IA - IfID iface.IfIDType + IfID iface.ID } type Params struct { diff --git a/private/revcache/revcache.go b/private/revcache/revcache.go index 85cf6bd1f3..903f39d943 100644 --- a/private/revcache/revcache.go +++ b/private/revcache/revcache.go @@ -28,11 +28,11 @@ import ( // Key denotes the key for the revocation cache. type Key struct { IA addr.IA - IfID iface.IfIDType + IfID iface.ID } // NewKey creates a new key for the revocation cache. -func NewKey(ia addr.IA, ifID iface.IfIDType) Key { +func NewKey(ia addr.IA, ifID iface.ID) Key { return Key{ IA: ia, IfID: ifID, diff --git a/private/revcache/revcachetest/revcachetest.go b/private/revcache/revcachetest/revcachetest.go index 99517ec53e..042075742a 100644 --- a/private/revcache/revcachetest/revcachetest.go +++ b/private/revcache/revcachetest/revcachetest.go @@ -34,8 +34,8 @@ import ( var ( ia110 = addr.MustParseIA("1-ff00:0:110") ia120 = addr.MustParseIA("1-ff00:0:120") - ifID15 = iface.IfIDType(15) - ifID19 = iface.IfIDType(19) + ifID15 = iface.ID(15) + ifID19 = iface.ID(19) TimeOut = 5 * time.Second ) @@ -100,7 +100,7 @@ func testGetMultikey(t *testing.T, revCache TestableRevCache) { rev1 := defaultRevInfo(ia110, ifID15) rev2 := defaultRevInfo(ia110, ifID19) rev3 := defaultRevInfo(ia120, ifID15) - rev4 := defaultRevInfo(ia120, iface.IfIDType(10)) + rev4 := defaultRevInfo(ia120, iface.ID(10)) ctx, cancelF := context.WithTimeout(context.Background(), TimeOut) defer cancelF() @@ -143,7 +143,7 @@ func testGetAll(t *testing.T, revCache TestableRevCache) { rev1 := defaultRevInfo(ia110, ifID15) rev2 := defaultRevInfo(ia110, ifID19) rev3 := defaultRevInfo(ia120, ifID15) - rev4 := defaultRevInfo(ia120, iface.IfIDType(20)) + rev4 := defaultRevInfo(ia120, iface.ID(20)) _, err = revCache.Insert(ctx, rev1) require.NoError(t, err) _, err = revCache.Insert(ctx, rev2) @@ -298,7 +298,7 @@ func testDeleteExpired(t *testing.T, revCache TestableRevCache) { assert.EqualValues(t, 0, del, "DeleteExpired should delete 0 if entry is not expired") } -func defaultRevInfo(ia addr.IA, ifID iface.IfIDType) *path_mgmt.RevInfo { +func defaultRevInfo(ia addr.IA, ifID iface.ID) *path_mgmt.RevInfo { return &path_mgmt.RevInfo{ IfID: ifID, RawIsdas: ia, diff --git a/private/revcache/util.go b/private/revcache/util.go index 2a0bc9126c..36f1b115c1 100644 --- a/private/revcache/util.go +++ b/private/revcache/util.go @@ -37,8 +37,8 @@ func NoRevokedHopIntf(ctx context.Context, revCache RevCache, for _, asEntry := range s.ASEntries { hop := asEntry.HopEntry.HopField for _, key := range [2]Key{ - {IA: asEntry.Local, IfID: iface.IfIDType(hop.ConsIngress)}, - {IA: asEntry.Local, IfID: iface.IfIDType(hop.ConsEgress)}, + {IA: asEntry.Local, IfID: iface.ID(hop.ConsIngress)}, + {IA: asEntry.Local, IfID: iface.ID(hop.ConsEgress)}, } { rev, err := revCache.Get(ctx, key) if err != nil || rev != nil { diff --git a/private/revcache/util_test.go b/private/revcache/util_test.go index 690eadc5b7..3e73cf403f 100644 --- a/private/revcache/util_test.go +++ b/private/revcache/util_test.go @@ -61,7 +61,7 @@ func TestNoRevokedHopIntf(t *testing.T) { func(_ context.Context, key revcache.Key) (*path_mgmt.RevInfo, error) { iaFmt := key.IA.String() _ = iaFmt - if key.IA == ia211 && key.IfID == iface.IfIDType(graph.If_211_A_210_X) { + if key.IA == ia211 && key.IfID == iface.ID(graph.If_211_A_210_X) { return sRev, nil } return nil, nil @@ -83,7 +83,7 @@ func TestNoRevokedHopIntf(t *testing.T) { func defaultRevInfo(ia addr.IA, ifID uint16, ts time.Time) *path_mgmt.RevInfo { return &path_mgmt.RevInfo{ - IfID: iface.IfIDType(ifID), + IfID: iface.ID(ifID), RawIsdas: ia, LinkType: proto.LinkType_core, RawTimestamp: util.TimeToSecs(ts), diff --git a/private/segment/segfetcher/resolver_test.go b/private/segment/segfetcher/resolver_test.go index 5b7f7529c3..85a00e03b4 100644 --- a/private/segment/segfetcher/resolver_test.go +++ b/private/segment/segfetcher/resolver_test.go @@ -409,11 +409,11 @@ func TestResolverWithRevocations(t *testing.T) { ExpectRevcache: func(t *testing.T, revCache *mock_revcache.MockRevCache) { key111_120 := revcache.Key{ IA: non_core_111, - IfID: iface.IfIDType(graph.If_111_B_120_X), + IfID: iface.ID(graph.If_111_B_120_X), } key111_130 := revcache.Key{ IA: non_core_111, - IfID: iface.IfIDType(graph.If_111_A_130_B), + IfID: iface.ID(graph.If_111_A_130_B), } revoke(t, revCache, key111_120) revoke(t, revCache, key111_130) @@ -444,7 +444,7 @@ func TestResolverWithRevocations(t *testing.T) { db.EXPECT().Get(gomock.Any(), gomock.Any()).Times(2) }, ExpectRevcache: func(t *testing.T, revCache *mock_revcache.MockRevCache) { - key110 := revcache.Key{IA: core_110, IfID: iface.IfIDType(graph.If_110_X_130_A)} + key110 := revcache.Key{IA: core_110, IfID: iface.ID(graph.If_110_X_130_A)} rev := &path_mgmt.RevInfo{} revCache.EXPECT().Get(gomock.Any(), key110).Return(rev, nil) revCache.EXPECT().Get(gomock.Any(), gomock.Any()).AnyTimes() diff --git a/private/storage/beacon/sqlite/db.go b/private/storage/beacon/sqlite/db.go index a0fc57dda8..69f90bfcea 100644 --- a/private/storage/beacon/sqlite/db.go +++ b/private/storage/beacon/sqlite/db.go @@ -140,7 +140,7 @@ func (e *executor) CandidateBeacons( beacons := make([]beacon.Beacon, 0, setSize) for rows.Next() { var rawBeacon sql.RawBytes - var inIfID iface.IfIDType + var inIfID iface.ID if err = rows.Scan(&rawBeacon, &inIfID); err != nil { return nil, db.NewReadError(beacon.ErrReadingRows, err) } diff --git a/private/storage/path/dbtest/dbtest.go b/private/storage/path/dbtest/dbtest.go index 276f7979bf..920cbe499e 100644 --- a/private/storage/path/dbtest/dbtest.go +++ b/private/storage/path/dbtest/dbtest.go @@ -603,7 +603,7 @@ func checkInterface(t *testing.T, ctx context.Context, ia addr.IA, ifID uint16, Intfs: []*query.IntfSpec{ { IA: ia, - IfID: iface.IfIDType(ifID), + IfID: iface.ID(ifID), }, }, }) diff --git a/private/topology/interface.go b/private/topology/interface.go index 957c04d46a..e5bb6f6984 100644 --- a/private/topology/interface.go +++ b/private/topology/interface.go @@ -39,7 +39,7 @@ type Topology interface { // Core returns whether the local AS is core. Core() bool // InterfaceIDs returns all interface IDS from the local AS. - IfIDs() []iface.IfIDType + IfIDs() []iface.ID // PortRange returns the first and last ports of the port range (both included), // in which endhost listen for SCION/UDP application using the UDP/IP underlay. PortRange() (uint16, uint16) @@ -59,7 +59,7 @@ type Topology interface { UnderlayMulticast(svc addr.SVC) ([]*net.UDPAddr, error) // UnderlayNextHop returns the internal underlay address of the router // containing the interface ID. - UnderlayNextHop(ifID iface.IfIDType) (*net.UDPAddr, bool) + UnderlayNextHop(ifID iface.ID) (*net.UDPAddr, bool) // MakeHostInfos returns the underlay addresses of all services for the specified service type. MakeHostInfos(st ServiceType) ([]*net.UDPAddr, error) @@ -144,8 +144,8 @@ func (t *topologyS) MTU() uint16 { return uint16(t.Topology.MTU) } -func (t *topologyS) IfIDs() []iface.IfIDType { - intfs := make([]iface.IfIDType, 0, len(t.Topology.IFInfoMap)) +func (t *topologyS) IfIDs() []iface.ID { + intfs := make([]iface.ID, 0, len(t.Topology.IFInfoMap)) for ifID := range t.Topology.IFInfoMap { intfs = append(intfs, ifID) } @@ -156,7 +156,7 @@ func (t *topologyS) PortRange() (uint16, uint16) { return t.Topology.DispatchedPortStart, t.Topology.DispatchedPortEnd } -func (t *topologyS) UnderlayNextHop(ifID iface.IfIDType) (*net.UDPAddr, bool) { +func (t *topologyS) UnderlayNextHop(ifID iface.ID) (*net.UDPAddr, bool) { ifInfo, ok := t.Topology.IFInfoMap[ifID] if !ok { return nil, false diff --git a/private/topology/json/json.go b/private/topology/json/json.go index 9aec94730e..d0c68138dd 100644 --- a/private/topology/json/json.go +++ b/private/topology/json/json.go @@ -93,8 +93,8 @@ type ServerInfo struct { // BRInfo contains Border Router specific information. type BRInfo struct { - InternalAddr string `json:"internal_addr"` - Interfaces map[iface.IfIDType]*BRInterface `json:"interfaces"` + InternalAddr string `json:"internal_addr"` + Interfaces map[iface.ID]*BRInterface `json:"interfaces"` } // GatewayInfo contains SCION gateway information. @@ -108,12 +108,12 @@ type GatewayInfo struct { // BRInterface contains the information for an data-plane BR socket that is external (i.e., facing // the neighboring AS). type BRInterface struct { - Underlay Underlay `json:"underlay,omitempty"` - IA string `json:"isd_as"` - LinkTo string `json:"link_to"` - MTU int `json:"mtu"` - BFD *BFD `json:"bfd,omitempty"` - RemoteIfID iface.IfIDType `json:"remote_interface_id,omitempty"` + Underlay Underlay `json:"underlay,omitempty"` + IA string `json:"isd_as"` + LinkTo string `json:"link_to"` + MTU int `json:"mtu"` + BFD *BFD `json:"bfd,omitempty"` + RemoteIfID iface.ID `json:"remote_interface_id,omitempty"` } // Underlay is the underlay information for a BR interface. diff --git a/private/topology/json/json_test.go b/private/topology/json/json_test.go index b5c2e4e677..43b77a41f8 100644 --- a/private/topology/json/json_test.go +++ b/private/topology/json/json_test.go @@ -46,7 +46,7 @@ func TestLoadRawFromFile(t *testing.T) { BorderRouters: map[string]*jsontopo.BRInfo{ "borderrouter6-f00:0:362-1": { InternalAddr: "10.1.0.1:0", - Interfaces: map[iface.IfIDType]*jsontopo.BRInterface{ + Interfaces: map[iface.ID]*jsontopo.BRInterface{ 91: { Underlay: jsontopo.Underlay{ Local: "192.0.2.1:4997", @@ -65,7 +65,7 @@ func TestLoadRawFromFile(t *testing.T) { }, "borderrouter6-f00:0:362-9": { InternalAddr: "[2001:db8:a0b:12f0::2]:0", - Interfaces: map[iface.IfIDType]*jsontopo.BRInterface{ + Interfaces: map[iface.ID]*jsontopo.BRInterface{ 32: { Underlay: jsontopo.Underlay{ Local: "[2001:db8:a0b:12f0::1]:4997", diff --git a/private/topology/mock_topology/mock.go b/private/topology/mock_topology/mock.go index dfdebc66da..c218327cf3 100644 --- a/private/topology/mock_topology/mock.go +++ b/private/topology/mock_topology/mock.go @@ -125,10 +125,10 @@ func (mr *MockTopologyMockRecorder) IFInfoMap() *gomock.Call { } // IfIDs mocks base method. -func (m *MockTopology) IfIDs() []iface.IfIDType { +func (m *MockTopology) IfIDs() []iface.ID { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "IfIDs") - ret0, _ := ret[0].([]iface.IfIDType) + ret0, _ := ret[0].([]iface.ID) return ret0 } @@ -256,7 +256,7 @@ func (mr *MockTopologyMockRecorder) UnderlayMulticast(arg0 interface{}) *gomock. } // UnderlayNextHop mocks base method. -func (m *MockTopology) UnderlayNextHop(arg0 iface.IfIDType) (*net.UDPAddr, bool) { +func (m *MockTopology) UnderlayNextHop(arg0 iface.ID) (*net.UDPAddr, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UnderlayNextHop", arg0) ret0, _ := ret[0].(*net.UDPAddr) diff --git a/private/topology/reload.go b/private/topology/reload.go index 6da1b56da3..5f794b44a1 100644 --- a/private/topology/reload.go +++ b/private/topology/reload.go @@ -133,7 +133,7 @@ func (l *Loader) UnderlayNextHop(ifID uint16) *net.UDPAddr { l.mtx.Lock() defer l.mtx.Unlock() - addr, _ := l.topo.UnderlayNextHop(iface.IfIDType(ifID)) + addr, _ := l.topo.UnderlayNextHop(iface.ID(ifID)) return addr } @@ -182,7 +182,7 @@ func (l *Loader) Gateways() ([]GatewayInfo, error) { return l.topo.Gateways() } -func (l *Loader) InterfaceInfoMap() map[iface.IfIDType]IFInfo { +func (l *Loader) InterfaceInfoMap() map[iface.ID]IFInfo { l.mtx.Lock() defer l.mtx.Unlock() diff --git a/private/topology/topology.go b/private/topology/topology.go index f85b79c1e8..1d4a528dba 100644 --- a/private/topology/topology.go +++ b/private/topology/topology.go @@ -95,25 +95,25 @@ type ( // InternalAddr is the local data-plane address. InternalAddr netip.AddrPort // IfIDs is a sorted list of the interface IDs. - IfIDs []iface.IfIDType + IfIDs []iface.ID // IFs is a map of interface IDs. - IFs map[iface.IfIDType]*IFInfo + IFs map[iface.ID]*IFInfo } // IfInfoMap maps interface ids to the interface information. - IfInfoMap map[iface.IfIDType]IFInfo + IfInfoMap map[iface.ID]IFInfo // IFInfo describes a border router link to another AS, including the internal data-plane // address applications should send traffic to and information about the link itself and the // remote side of it. IFInfo struct { // ID is the interface ID. It is unique per AS. - ID iface.IfIDType + ID iface.ID BRName string InternalAddr netip.AddrPort Local netip.AddrPort Remote netip.AddrPort - RemoteIfID iface.IfIDType + RemoteIfID iface.ID IA addr.IA LinkType LinkType MTU int @@ -267,7 +267,7 @@ func (t *RWTopology) populateBR(raw *jsontopo.Topology) error { brInfo := BRInfo{ Name: name, InternalAddr: intAddr, - IFs: make(map[iface.IfIDType]*IFInfo), + IFs: make(map[iface.ID]*IFInfo), } for ifID, rawIntf := range rawBr.Interfaces { var err error @@ -474,11 +474,11 @@ func (i *BRInfo) copy() *BRInfo { } } -func copyIFsMap(m map[iface.IfIDType]*IFInfo) map[iface.IfIDType]*IFInfo { +func copyIFsMap(m map[iface.ID]*IFInfo) map[iface.ID]*IFInfo { if m == nil { return nil } - newM := make(map[iface.IfIDType]*IFInfo) + newM := make(map[iface.ID]*IFInfo) for k, v := range m { newM[k] = v.copy() } diff --git a/private/topology/topology_test.go b/private/topology/topology_test.go index 0f934267d6..65cfcbb632 100644 --- a/private/topology/topology_test.go +++ b/private/topology/topology_test.go @@ -58,10 +58,10 @@ func TestBRs(t *testing.T) { brs := map[string]BRInfo{ "br1-ff00:0:311-1": { - IfIDs: []iface.IfIDType{1, 3, 8}, + IfIDs: []iface.ID{1, 3, 8}, }, "br1-ff00:0:311-2": { - IfIDs: []iface.IfIDType{11}, + IfIDs: []iface.ID{11}, }, } @@ -312,10 +312,10 @@ func TestBRsCoreAS(t *testing.T) { c := MustLoadTopo(t, "testdata/core.json") brCases := []struct { name string - interfaces []iface.IfIDType + interfaces []iface.ID }{ - {name: "borderrouter6-ff00:0:362-1", interfaces: []iface.IfIDType{91}}, - {name: "borderrouter6-ff00:0:362-9", interfaces: []iface.IfIDType{32}}, + {name: "borderrouter6-ff00:0:362-1", interfaces: []iface.ID{91}}, + {name: "borderrouter6-ff00:0:362-9", interfaces: []iface.ID{32}}, } for _, test := range brCases { t.Run(test.name, func(t *testing.T) { diff --git a/router/connector.go b/router/connector.go index 52a318c9ed..36c610caa2 100644 --- a/router/connector.go +++ b/router/connector.go @@ -80,7 +80,7 @@ func (c *Connector) AddInternalInterface(ia addr.IA, local netip.AddrPort) error } // AddExternalInterface adds a link between the local and remote address. -func (c *Connector) AddExternalInterface(localIfID iface.IfIDType, link control.LinkInfo, +func (c *Connector) AddExternalInterface(localIfID iface.ID, link control.LinkInfo, owned bool) error { c.mtx.Lock() diff --git a/router/control/conf.go b/router/control/conf.go index 456de4b8ab..fc8c0520f9 100644 --- a/router/control/conf.go +++ b/router/control/conf.go @@ -32,7 +32,7 @@ import ( type Dataplane interface { CreateIACtx(ia addr.IA) error AddInternalInterface(ia addr.IA, local netip.AddrPort) error - AddExternalInterface(localIfID iface.IfIDType, info LinkInfo, owned bool) error + AddExternalInterface(localIfID iface.ID, info LinkInfo, owned bool) error AddSvc(ia addr.IA, svc addr.SVC, a netip.AddrPort) error DelSvc(ia addr.IA, svc addr.SVC, a netip.AddrPort) error SetKey(ia addr.IA, index int, key []byte) error @@ -57,7 +57,7 @@ type LinkInfo struct { type LinkEnd struct { IA addr.IA Addr netip.AddrPort - IfID iface.IfIDType + IfID iface.ID } type ObservableDataplane interface { @@ -169,7 +169,7 @@ func confExternalInterfaces(dp Dataplane, cfg *Config) error { // nothing to do return nil } - ifIDs := []iface.IfIDType{} + ifIDs := []iface.ID{} for k := range infoMap { ifIDs = append(ifIDs, k) } diff --git a/router/control/internal/metrics/metrics.go b/router/control/internal/metrics/metrics.go index 79c50d883b..ad4392749f 100644 --- a/router/control/internal/metrics/metrics.go +++ b/router/control/internal/metrics/metrics.go @@ -65,7 +65,7 @@ func (l IntfLabels) Values() []string { return []string{l.Intf, l.NeighIA} } -func IntfToLabel(ifID iface.IfIDType) string { +func IntfToLabel(ifID iface.ID) string { if ifID == 0 { return "loc" } diff --git a/scion/cmd/scion/common.go b/scion/cmd/scion/common.go index 7db29d1331..48db32d300 100644 --- a/scion/cmd/scion/common.go +++ b/scion/cmd/scion/common.go @@ -43,8 +43,8 @@ type Path struct { // Hop represents an hop on the path. type Hop struct { - ID iface.IfIDType `json:"interface" yaml:"interface"` - IA addr.IA `json:"isd_as" yaml:"isd_as"` + ID iface.ID `json:"interface" yaml:"interface"` + IA addr.IA `json:"isd_as" yaml:"isd_as"` } // getHops constructs a list of snet path interfaces from an snet path diff --git a/scion/showpaths/showpaths.go b/scion/showpaths/showpaths.go index ccb6fef357..b0c301d378 100644 --- a/scion/showpaths/showpaths.go +++ b/scion/showpaths/showpaths.go @@ -58,8 +58,8 @@ type Path struct { // Hop represents an hop on the path. type Hop struct { - IfID iface.IfIDType `json:"interface"` - IA addr.IA `json:"isd_as"` + IfID iface.ID `json:"interface"` + IA addr.IA `json:"isd_as"` } // Human writes human readable output to the writer.