From c9cfa94c516d67b0597b77f2392529f1ee5a12b2 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Hugly Date: Mon, 22 Jul 2024 18:37:44 +0200 Subject: [PATCH] More scrubbing of malspelled names. The addition of a linter rules for ifid and trc has revealed a truckload more. Some *cannot* be fixed as they are automatically derived from published APIs and Protobufs. --- control/beaconing/writer_test.go | 2 +- control/cmd/control/main.go | 2 +- control/mgmtapi/api.go | 18 +-- control/trust/grpc/proto.go | 2 +- control/trust/grpc/proto_test.go | 2 +- daemon/internal/servers/grpc.go | 4 +- daemon/mgmtapi/api.go | 14 ++- .../hiddenpath/beaconwriter_test.go | 2 +- pkg/private/xtest/graph/graph.go | 110 +++++++++--------- pkg/snet/squic/net_test.go | 11 +- private/mgmtapi/cppki/api/api.go | 9 +- private/path/combinator/graph.go | 14 +-- private/revcache/util_test.go | 4 +- private/storage/trust/fspersister/db_test.go | 38 +++--- private/topology/interface.go | 4 +- private/topology/json/json.go | 2 +- private/topology/reload.go | 4 +- private/topology/reload_test.go | 2 +- private/topology/topology.go | 20 ++-- private/topology/topology_test.go | 10 +- private/trust/grpc/fetcher.go | 2 +- private/trust/grpc/fetcher_test.go | 12 +- private/trust/signer.go | 4 +- private/trust/verifier.go | 4 +- router/connector.go | 12 +- router/control/conf.go | 10 +- router/dataplane.go | 8 +- router/mgmtapi/api.go | 4 +- router/mgmtapi/api_test.go | 10 +- scion/cmd/scion/traceroute.go | 4 +- scion/showpaths/showpaths.go | 10 +- 31 files changed, 188 insertions(+), 166 deletions(-) diff --git a/control/beaconing/writer_test.go b/control/beaconing/writer_test.go index 3a73fe9748..508b00849c 100644 --- a/control/beaconing/writer_test.go +++ b/control/beaconing/writer_test.go @@ -390,7 +390,7 @@ func interfaceInfos(topo topology.Topology) map[uint16]ifstate.InterfaceInfo { IA: info.IA, LinkType: info.LinkType, InternalAddr: netip.MustParseAddrPort(info.InternalAddr.String()), - RemoteID: uint16(info.RemoteIFID), + RemoteID: uint16(info.RemoteIfID), MTU: uint16(info.MTU), } } diff --git a/control/cmd/control/main.go b/control/cmd/control/main.go index e4142f4f9d..c591180d79 100644 --- a/control/cmd/control/main.go +++ b/control/cmd/control/main.go @@ -852,7 +852,7 @@ func adaptInterfaceMap(in map[common.IfIDType]topology.IFInfo) map[uint16]ifstat IA: info.IA, LinkType: info.LinkType, InternalAddr: info.InternalAddr, - RemoteID: uint16(info.RemoteIFID), + RemoteID: uint16(info.RemoteIfID), MTU: uint16(info.MTU), } } diff --git a/control/mgmtapi/api.go b/control/mgmtapi/api.go index a18993ffe8..666df8bfe3 100644 --- a/control/mgmtapi/api.go +++ b/control/mgmtapi/api.go @@ -586,22 +586,26 @@ func (s *Server) GetCa(w http.ResponseWriter, r *http.Request) { } // GetTrcs gets the trcs specified by it's params. -func (s *Server) GetTrcs(w http.ResponseWriter, r *http.Request, params GetTrcsParams) { - cppkiParams := cppkiapi.GetTrcsParams{ +func (s *Server) GetTrcs( + w http.ResponseWriter, + r *http.Request, + params GetTrcsParams, // nolint - name from published API +) { + cppkiParams := cppkiapi.GetTrcsParams{ // nolint - name from published API Isd: params.Isd, All: params.All, } - s.CPPKIServer.GetTrcs(w, r, cppkiParams) + s.CPPKIServer.GetTrcs(w, r, cppkiParams) // nolint - name from published API } // GetTrc gets the trc specified by it's isd base and serial. func (s *Server) GetTrc(w http.ResponseWriter, r *http.Request, isd int, base int, serial int) { - s.CPPKIServer.GetTrc(w, r, isd, base, serial) + s.CPPKIServer.GetTrc(w, r, isd, base, serial) // nolint - name from published API } // GetTrcBlob gets the trc encoded pem blob. func (s *Server) GetTrcBlob(w http.ResponseWriter, r *http.Request, isd int, base int, serial int) { - s.CPPKIServer.GetTrcBlob(w, r, isd, base, serial) + s.CPPKIServer.GetTrcBlob(w, r, isd, base, serial) // nolint - name from published API } // GetConfig is an indirection to the http handler. @@ -663,12 +667,12 @@ func (s *Server) GetSigner(w http.ResponseWriter, r *http.Request) { }, }, Expiration: p.Expiration, - TrcId: TRCID{ + TrcId: TRCID{ // nolint - name from published API BaseNumber: int(p.TRCID.Base), Isd: int(p.TRCID.ISD), SerialNumber: int(p.TRCID.Serial), }, - TrcInGracePeriod: p.InGrace, + TrcInGracePeriod: p.InGrace, // nolint - name from published API } enc := json.NewEncoder(w) enc.SetIndent("", " ") diff --git a/control/trust/grpc/proto.go b/control/trust/grpc/proto.go index af20257fe2..5c1644e9a5 100644 --- a/control/trust/grpc/proto.go +++ b/control/trust/grpc/proto.go @@ -86,6 +86,6 @@ func chainsToResponse(chains [][]*x509.Certificate) *cppb.ChainsResponse { func trcToResponse(trc cppki.SignedTRC) *cppb.TRCResponse { return &cppb.TRCResponse{ - Trc: trc.Raw, + Trc: trc.Raw, // nolint - name from protobuf } } diff --git a/control/trust/grpc/proto_test.go b/control/trust/grpc/proto_test.go index 2370ed3e68..d5e01bcde5 100644 --- a/control/trust/grpc/proto_test.go +++ b/control/trust/grpc/proto_test.go @@ -150,5 +150,5 @@ func TestChainsToRep(t *testing.T) { func TestTRCToRep(t *testing.T) { trc := cppki.SignedTRC{Raw: []byte("you can trust me, for sure!")} rep := trustgrpc.TRCToResponse(trc) - assert.Equal(t, trc.Raw, rep.Trc) + assert.Equal(t, trc.Raw, rep.Trc) // nolint - name from published protobuf } diff --git a/daemon/internal/servers/grpc.go b/daemon/internal/servers/grpc.go index 6f050dff79..16b64b9d15 100644 --- a/daemon/internal/servers/grpc.go +++ b/daemon/internal/servers/grpc.go @@ -47,7 +47,7 @@ import ( ) type Topology interface { - InterfaceIDs() []uint16 + IfIDs() []uint16 UnderlayNextHop(uint16) *net.UDPAddr ControlServiceAddresses() []*net.UDPAddr PortRange() (uint16, uint16) @@ -277,7 +277,7 @@ func (s *DaemonServer) interfaces(ctx context.Context, Interfaces: make(map[uint64]*sdpb.Interface), } topo := s.Topology - for _, ifID := range topo.InterfaceIDs() { + for _, ifID := range topo.IfIDs() { nextHop := topo.UnderlayNextHop(ifID) if nextHop == nil { continue diff --git a/daemon/mgmtapi/api.go b/daemon/mgmtapi/api.go index 60e7ff7753..15815a2ced 100644 --- a/daemon/mgmtapi/api.go +++ b/daemon/mgmtapi/api.go @@ -102,20 +102,24 @@ func (s *Server) GetCertificateBlob(w http.ResponseWriter, r *http.Request, chai } // GetTrcs gets the trcs specified by it's params. -func (s *Server) GetTrcs(w http.ResponseWriter, r *http.Request, params GetTrcsParams) { - cppkiParams := cppkiapi.GetTrcsParams{ +func (s *Server) GetTrcs( + w http.ResponseWriter, + r *http.Request, + params GetTrcsParams, // nolint - name from published API +) { + cppkiParams := cppkiapi.GetTrcsParams{ // nolint - name from published API Isd: params.Isd, All: params.All, } - s.CPPKIServer.GetTrcs(w, r, cppkiParams) + s.CPPKIServer.GetTrcs(w, r, cppkiParams) // nolint - name from published API } // GetTrc gets the trc specified by it's isd base and serial. func (s *Server) GetTrc(w http.ResponseWriter, r *http.Request, isd int, base int, serial int) { - s.CPPKIServer.GetTrc(w, r, isd, base, serial) + s.CPPKIServer.GetTrc(w, r, isd, base, serial) // nolint - name from published API } // GetTrcBlob gets the trc encoded pem blob. func (s *Server) GetTrcBlob(w http.ResponseWriter, r *http.Request, isd int, base int, serial int) { - s.CPPKIServer.GetTrcBlob(w, r, isd, base, serial) + s.CPPKIServer.GetTrcBlob(w, r, isd, base, serial) // nolint - name from published API } diff --git a/pkg/experimental/hiddenpath/beaconwriter_test.go b/pkg/experimental/hiddenpath/beaconwriter_test.go index 6b04b7ef3b..d68c0b19c0 100644 --- a/pkg/experimental/hiddenpath/beaconwriter_test.go +++ b/pkg/experimental/hiddenpath/beaconwriter_test.go @@ -369,7 +369,7 @@ func interfaceInfos(topo topology.Topology) map[uint16]ifstate.InterfaceInfo { IA: info.IA, LinkType: info.LinkType, InternalAddr: netip.MustParseAddrPort(info.InternalAddr.String()), - RemoteID: uint16(info.RemoteIFID), + RemoteID: uint16(info.RemoteIfID), MTU: uint16(info.MTU), } } diff --git a/pkg/private/xtest/graph/graph.go b/pkg/private/xtest/graph/graph.go index a114ba9c61..ee3020f4fd 100644 --- a/pkg/private/xtest/graph/graph.go +++ b/pkg/private/xtest/graph/graph.go @@ -48,20 +48,20 @@ import ( "github.com/scionproto/scion/pkg/slayers/path" ) -// Graph implements a graph of ASes and IFIDs for testing purposes. IFIDs +// Graph implements a graph of ASes and IfIDs for testing purposes. IfIDs // must be globally unique. // // Nodes are represented by ASes. // -// Edges are represented by pairs of IFIDs. +// Edges are represented by pairs of IfIDs. type Graph struct { - // maps IFIDs to the other IFID of the edge + // maps IfIDs to the other IfID of the edge links map[uint16]uint16 - // specifies whether an IFID is on a peering link + // specifies whether an IfID is on a peering link isPeer map[uint16]bool - // maps IFIDs to the AS they belong to + // maps IfIDs to the AS they belong to parents map[uint16]addr.IA - // maps ASes to a structure containing a slice of their IFIDs + // maps ASes to a structure containing a slice of their IfIDs ases map[addr.IA]*AS signers map[addr.IA]*Signer @@ -101,7 +101,7 @@ func (g *Graph) Add(ia string) { defer g.lock.Unlock() isdas := MustParseIA(ia) g.ases[isdas] = &AS{ - IFIDs: make(map[uint16]struct{}), + IfIDs: make(map[uint16]struct{}), } g.signers[isdas] = NewSigner( WithIA(isdas), @@ -121,10 +121,10 @@ func (g *Graph) GetSigner(ia string) *Signer { } // AddLink adds a new edge between the ASes described by xIA and yIA, with -// xIFID in xIA and yIFID in yIA. If xIA or yIA are not valid string +// xIfID in xIA and yIfID in yIA. If xIA or yIA are not valid string // representations of an ISD-AS, AddLink panics. -func (g *Graph) AddLink(xIA string, xIFID uint16, - yIA string, yIFID uint16, peer bool) { +func (g *Graph) AddLink(xIA string, xIfID uint16, + yIA string, yIfID uint16, peer bool) { g.lock.Lock() defer g.lock.Unlock() @@ -136,20 +136,20 @@ func (g *Graph) AddLink(xIA string, xIFID uint16, if _, ok := g.ases[y]; !ok { panic(fmt.Sprintf("AS %s not in graph", yIA)) } - if _, ok := g.links[xIFID]; ok { - panic(fmt.Sprintf("IFID %d is not unique", xIFID)) + if _, ok := g.links[xIfID]; ok { + panic(fmt.Sprintf("IfID %d is not unique", xIfID)) } - if _, ok := g.links[yIFID]; ok { - panic(fmt.Sprintf("IFID %d is not unique", yIFID)) + if _, ok := g.links[yIfID]; ok { + panic(fmt.Sprintf("IfID %d is not unique", yIfID)) } - g.links[xIFID] = yIFID - g.links[yIFID] = xIFID - g.isPeer[xIFID] = peer - g.isPeer[yIFID] = peer - g.parents[xIFID] = x - g.parents[yIFID] = y - g.ases[x].IFIDs[xIFID] = struct{}{} - g.ases[y].IFIDs[yIFID] = struct{}{} + g.links[xIfID] = yIfID + g.links[yIfID] = xIfID + g.isPeer[xIfID] = peer + g.isPeer[yIfID] = peer + g.parents[xIfID] = x + g.parents[yIfID] = y + g.ases[x].IfIDs[xIfID] = struct{}{} + g.ases[y].IfIDs[yIfID] = struct{}{} } // RemoveLink deletes the edge containing ifID from the graph. @@ -157,17 +157,17 @@ func (g *Graph) RemoveLink(ifID uint16) { g.lock.Lock() defer g.lock.Unlock() ia := g.parents[ifID] - neighborIFID := g.links[ifID] - neighborIA := g.parents[neighborIFID] + neighborIfID := g.links[ifID] + neighborIA := g.parents[neighborIfID] delete(g.links, ifID) - delete(g.links, neighborIFID) + delete(g.links, neighborIfID) delete(g.isPeer, ifID) - delete(g.isPeer, neighborIFID) + delete(g.isPeer, neighborIfID) delete(g.parents, ifID) - delete(g.parents, neighborIFID) + delete(g.parents, neighborIfID) g.ases[ia].Delete(ifID) - g.ases[neighborIA].Delete(neighborIFID) + g.ases[neighborIA].Delete(neighborIfID) } // GetParent returns the parent AS of ifID. @@ -215,15 +215,15 @@ func (g *Graph) GetPaths(xIA string, yIA string) [][]uint16 { } // Explore neighboring ASes, if not visited yet. - for ifID := range g.ases[curSolution.CurrentIA].IFIDs { - nextIFID := g.links[ifID] - nextIA := g.parents[nextIFID] + for ifID := range g.ases[curSolution.CurrentIA].IfIDs { + nextIfID := g.links[ifID] + nextIA := g.parents[nextIfID] if curSolution.Visited(nextIA) { continue } // Copy to avoid mutating the trails of other explorations. nextTrail := curSolution.Copy() - nextTrail.Add(ifID, nextIFID, nextIA) + nextTrail.Add(ifID, nextIfID, nextIA) nextTrail.CurrentIA = nextIA queue = append(queue, nextTrail) } @@ -232,8 +232,8 @@ func (g *Graph) GetPaths(xIA string, yIA string) [][]uint16 { } // Beacon constructs path segments across a series of egress ifIDs. The parent -// AS of the first IFID is the origin of the beacon, and the beacon propagates -// down to the parent AS of the remote counterpart of the last IFID. The +// AS of the first IfID is the origin of the beacon, and the beacon propagates +// down to the parent AS of the remote counterpart of the last IfID. The // constructed segment includes peering links. The hop fields in the returned // segment do not contain valid MACs. func (g *Graph) Beacon(ifIDs []uint16) *seg.PathSegment { @@ -245,8 +245,8 @@ func (g *Graph) BeaconWithStaticInfo(ifIDs []uint16) *seg.PathSegment { } // beacon constructs path segments across a series of egress ifIDs. The parent -// AS of the first IFID is the origin of the beacon, and the beacon propagates -// down to the parent AS of the remote counterpart of the last IFID. The +// AS of the first IfID is the origin of the beacon, and the beacon propagates +// down to the parent AS of the remote counterpart of the last IfID. The // constructed segment includes peering links. The hop fields in the returned // segment do not contain valid MACs. func (g *Graph) beacon(ifIDs []uint16, addStaticInfo bool) *seg.PathSegment { @@ -303,13 +303,13 @@ func (g *Graph) beacon(ifIDs []uint16, addStaticInfo bool) *seg.PathSegment { // use int to avoid implementing sort.Interface var ifIDs []int - for peeringLocalIF := range as.IFIDs { + for peeringLocalIF := range as.IfIDs { ifIDs = append(ifIDs, int(peeringLocalIF)) } sort.Ints(ifIDs) - for _, intIFID := range ifIDs { - peeringLocalIF := uint16(intIFID) + for _, intIfID := range ifIDs { + peeringLocalIF := uint16(intIfID) if g.isPeer[peeringLocalIF] { peeringRemoteIF := g.links[peeringLocalIF] asEntry.PeerEntries = append(asEntry.PeerEntries, seg.PeerEntry{ @@ -338,7 +338,7 @@ func (g *Graph) beacon(ifIDs []uint16, addStaticInfo bool) *seg.PathSegment { } // DeleteInterface removes ifID from the graph without deleting its remote -// counterpart. This is useful for testing IFID misconfigurations. +// counterpart. This is useful for testing IfID misconfigurations. func (g *Graph) DeleteInterface(ifID uint16) { delete(g.links, ifID) } @@ -478,8 +478,8 @@ func (s Signer) Sign(ctx context.Context, msg []byte, id := &cppb.VerificationKeyID{ IsdAs: uint64(s.IA), - TrcBase: uint64(s.TRCID.Base), - TrcSerial: uint64(s.TRCID.Serial), + TrcBase: uint64(s.TRCID.Base), // nolint - name from published protobuf + TrcSerial: uint64(s.TRCID.Serial), // nolint - name from published protobuf SubjectKeyId: skid, } rawID, err := proto.Marshal(id) @@ -497,17 +497,17 @@ func (s Signer) Sign(ctx context.Context, msg []byte, return signed.Sign(hdr, msg, s.PrivateKey, associatedData...) } -// AS contains a list of all the IFIDs in an AS. +// AS contains a list of all the IfIDs in an AS. type AS struct { - IFIDs map[uint16]struct{} + IfIDs map[uint16]struct{} } // Delete removes ifID from as. func (as *AS) Delete(ifID uint16) { - if _, ok := as.IFIDs[ifID]; !ok { + if _, ok := as.IfIDs[ifID]; !ok { panic("ifID not found") } - delete(as.IFIDs, ifID) + delete(as.IfIDs, ifID) } // solution tracks the state of a candidate solution for the graph @@ -517,7 +517,7 @@ type solution struct { CurrentIA addr.IA // whether the AS has already been visited by this path, to avoid loops visited map[addr.IA]struct{} - // the trail of IFIDs + // the trail of IfIDs trail []uint16 } @@ -547,10 +547,10 @@ func (s *solution) Visited(ia addr.IA) bool { return ok } -// Add appends localIFID and nextIFID to the trail, and advances to nextIA. -func (s *solution) Add(localIFID, nextIFID uint16, nextIA addr.IA) { +// Add appends localIfID and nextIfID to the trail, and advances to nextIA. +func (s *solution) Add(localIfID, nextIfID uint16, nextIA addr.IA) { s.visited[nextIA] = struct{}{} - s.trail = append(s.trail, localIFID, nextIFID) + s.trail = append(s.trail, localIfID, nextIfID) } func (s *solution) Len() int { @@ -605,7 +605,7 @@ func generateStaticInfo(g *Graph, ia addr.IA, inIF, outIF uint16) *staticinfo.Ex if outIF != 0 { latency.Intra = make(map[common.IfIDType]time.Duration) latency.Inter = make(map[common.IfIDType]time.Duration) - for ifID := range as.IFIDs { + for ifID := range as.IfIDs { if ifID != outIF { // Note: the test graph does not distinguish between parent/child or // core interfaces. @@ -623,7 +623,7 @@ func generateStaticInfo(g *Graph, ia addr.IA, inIF, outIF uint16) *staticinfo.Ex if outIF != 0 { bandwidth.Intra = make(map[common.IfIDType]uint64) bandwidth.Inter = make(map[common.IfIDType]uint64) - for ifID := range as.IFIDs { + for ifID := range as.IfIDs { if ifID != outIF { bandwidth.Intra[common.IfIDType(ifID)] = g.Bandwidth(ifID, outIF) } @@ -634,12 +634,12 @@ func generateStaticInfo(g *Graph, ia addr.IA, inIF, outIF uint16) *staticinfo.Ex } geo := make(staticinfo.GeoInfo) - for ifID := range as.IFIDs { + for ifID := range as.IfIDs { geo[common.IfIDType(ifID)] = g.GeoCoordinates(ifID) } linkType := make(staticinfo.LinkTypeInfo) - for ifID := range as.IFIDs { + for ifID := range as.IfIDs { linkType[common.IfIDType(ifID)] = g.LinkType(ifID, g.links[ifID]) } @@ -649,7 +649,7 @@ func generateStaticInfo(g *Graph, ia addr.IA, inIF, outIF uint16) *staticinfo.Ex if inIF != 0 { internalHops[common.IfIDType(inIF)] = g.InternalHops(inIF, outIF) } - for ifID := range as.IFIDs { + for ifID := range as.IfIDs { if ifID != outIF && ifID != inIF { internalHops[common.IfIDType(ifID)] = g.InternalHops(ifID, outIF) } diff --git a/pkg/snet/squic/net_test.go b/pkg/snet/squic/net_test.go index 700a6f6189..687c53cded 100644 --- a/pkg/snet/squic/net_test.go +++ b/pkg/snet/squic/net_test.go @@ -46,9 +46,12 @@ func TestAcceptLoopParallelism(t *testing.T) { defer mctrl.Finish() handler := mock_cp.NewMockTrustMaterialServiceServer(mctrl) - handler.EXPECT().TRC(gomock.Any(), gomock.Any()).Return( + handler.EXPECT().TRC( // nolint - name from published protobuf + gomock.Any(), + gomock.Any(), + ).Return( &cppb.TRCResponse{ - Trc: make([]byte, 500), + Trc: make([]byte, 500), // nolint - name from published protobuf }, nil, ).AnyTimes() @@ -113,7 +116,7 @@ func TestGRPCQUIC(t *testing.T) { handler := mock_cp.NewMockTrustMaterialServiceServer(mctrl) handler.EXPECT().TRC(gomock.Any(), gomock.Any()).Return( &cppb.TRCResponse{ - Trc: []byte("hello"), + Trc: []byte("hello"), // nolint - name from published protobuf }, nil, ) @@ -139,7 +142,7 @@ func TestGRPCQUIC(t *testing.T) { client := cppb.NewTrustMaterialServiceClient(conn) rep, err := client.TRC(context.Background(), &cppb.TRCRequest{}) require.NoError(t, err) - assert.Equal(t, "hello", string(rep.Trc)) + assert.Equal(t, "hello", string(rep.Trc)) // nolint - name from published protobuf } func TestEstablishConnection(t *testing.T) { diff --git a/private/mgmtapi/cppki/api/api.go b/private/mgmtapi/cppki/api/api.go index cb5ecb38be..3e0c13a8e8 100644 --- a/private/mgmtapi/cppki/api/api.go +++ b/private/mgmtapi/cppki/api/api.go @@ -227,7 +227,12 @@ func (s *Server) GetCertificateBlob(w http.ResponseWriter, r *http.Request, chai _, _ = w.Write(buf.Bytes()) } -func (s *Server) GetTrcs(w http.ResponseWriter, r *http.Request, params GetTrcsParams) { +func (s *Server) GetTrcs( + w http.ResponseWriter, + r *http.Request, + params GetTrcsParams, // nolint - name from published API +) { + db := s.TrustDB q := truststorage.TRCsQuery{Latest: !(params.All != nil && *params.All)} if params.Isd != nil { @@ -279,7 +284,7 @@ func (s *Server) GetTrcs(w http.ResponseWriter, r *http.Request, params GetTrcsP } -// GetTrc gets the trc specified by it's isd bas and serial. +// GetTrc gets the trc specified by it's isd base and serial. func (s *Server) GetTrc(w http.ResponseWriter, r *http.Request, isd int, base int, serial int) { db := s.TrustDB trc, err := db.SignedTRC(r.Context(), cppki.TRCID{ diff --git a/private/path/combinator/graph.go b/private/path/combinator/graph.go index 51736715b7..447c2a97bc 100644 --- a/private/path/combinator/graph.go +++ b/private/path/combinator/graph.go @@ -50,7 +50,7 @@ type vertexInfo map[vertex]edgeMap // dmg is a Directed Multigraph. // // Vertices are either ASes (identified by their ISD-AS number) or peering -// links (identified by the the ISD-AS numbers of the peers, and the IFIDs on +// links (identified by the the ISD-AS numbers of the peers, and the IfIDs on // the peering link). type dmg struct { Adjacencies map[vertex]vertexInfo @@ -259,25 +259,25 @@ func (s *inputSegment) IsDownSeg() bool { type vertex struct { IA addr.IA UpIA addr.IA - UpIFID common.IfIDType + UpIfID common.IfIDType DownIA addr.IA - DownIFID common.IfIDType + DownIfID common.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 common.IfIDType, + downIA addr.IA, downIfID common.IfIDType) vertex { - return vertex{UpIA: upIA, UpIFID: upIFID, DownIA: downIA, DownIFID: downIFID} + return vertex{UpIA: upIA, UpIfID: upIfID, DownIA: downIA, DownIfID: downIfID} } // Reverse returns a new vertex that contains the peering information in // reverse. AS vertices remain unchanged. func (v vertex) Reverse() vertex { - return vertex{IA: v.IA, UpIA: v.DownIA, UpIFID: v.DownIFID, DownIA: v.UpIA, DownIFID: v.UpIFID} + return vertex{IA: v.IA, UpIA: v.DownIA, UpIfID: v.DownIfID, DownIA: v.UpIA, DownIfID: v.UpIfID} } // edgeMap is used to keep the set of edges going from one vertex to another. diff --git a/private/revcache/util_test.go b/private/revcache/util_test.go index b2ee074191..94e92f1651 100644 --- a/private/revcache/util_test.go +++ b/private/revcache/util_test.go @@ -35,7 +35,7 @@ import ( ) var ( - ia211 = addr.MustParseIA("2-ff00:0:211") + ia211 = addr.MustParseIA("2-ff00:0:211") timeout = time.Second ) @@ -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: common.IfIDType(graph.If_210_X_211_A)}: sRev, }, nil, ) noR, err := revcache.NoRevokedHopIntf(ctx, revCache, seg210_222_1) diff --git a/private/storage/trust/fspersister/db_test.go b/private/storage/trust/fspersister/db_test.go index 94f54363ee..fe313b01df 100644 --- a/private/storage/trust/fspersister/db_test.go +++ b/private/storage/trust/fspersister/db_test.go @@ -32,7 +32,7 @@ import ( ) const ( - testTrcsDir = "testdata/overthenetwork/" + testTRCsDir = "testdata/overthenetwork/" ) type DB struct { @@ -96,55 +96,55 @@ func TestInsertTRCWithFSPersistence(t *testing.T) { testDB.Prepare(t, ctx) t.Run("insert TRC not present in neither DB nor FS", func(t *testing.T) { - SignedTRC, persistedTrcPath := getTRC(t, "ISD1-B1-S1.trc", testDB.Dir) + SignedTRC, persistedTRCPath := getTRC(t, "ISD1-B1-S1.trc", testDB.Dir) in, err := testDB.InsertTRC(ctx, SignedTRC) require.NoError(t, err) require.True(t, in) - persistedTRC := xtest.LoadTRC(t, persistedTrcPath) + persistedTRC := xtest.LoadTRC(t, persistedTRCPath) require.Equal(t, SignedTRC, persistedTRC) }) t.Run("insert TRC already present in DB and FS", func(t *testing.T) { - SignedTRC, persistedTrcPath := getTRC(t, "ISD1-B1-S1.trc", testDB.Dir) - mtimeBeforeInsert := getModTime(t, persistedTrcPath) + SignedTRC, persistedTRCPath := getTRC(t, "ISD1-B1-S1.trc", testDB.Dir) + mtimeBeforeInsert := getModTime(t, persistedTRCPath) - persistedTRC := xtest.LoadTRC(t, persistedTrcPath) + persistedTRC := xtest.LoadTRC(t, persistedTRCPath) require.Equal(t, SignedTRC, persistedTRC) in, err := testDB.InsertTRC(ctx, SignedTRC) require.NoError(t, err) require.False(t, in) - mtimeAfterInsert := getModTime(t, persistedTrcPath) + mtimeAfterInsert := getModTime(t, persistedTRCPath) require.Equal(t, mtimeBeforeInsert, mtimeAfterInsert) - persistedTRC = xtest.LoadTRC(t, persistedTrcPath) + persistedTRC = xtest.LoadTRC(t, persistedTRCPath) require.Equal(t, SignedTRC, persistedTRC) }) t.Run("insert TRC not present in DB but present on FS", func(t *testing.T) { - SignedTRC, persistedTrcPath := getTRC(t, "ISD2-B1-S1.trc", testDB.Dir) - require.NoError(t, os.WriteFile(persistedTrcPath, SignedTRC.Raw, 0644)) - mtimeBeforeInsert := getModTime(t, persistedTrcPath) + SignedTRC, persistedTRCPath := getTRC(t, "ISD2-B1-S1.trc", testDB.Dir) + require.NoError(t, os.WriteFile(persistedTRCPath, SignedTRC.Raw, 0644)) + mtimeBeforeInsert := getModTime(t, persistedTRCPath) in, err := testDB.InsertTRC(ctx, SignedTRC) require.NoError(t, err) require.True(t, in) - mtimeAfterInsert := getModTime(t, persistedTrcPath) + mtimeAfterInsert := getModTime(t, persistedTRCPath) require.Equal(t, mtimeBeforeInsert, mtimeAfterInsert) }) t.Run("insert TRC that is already present in DB but not on FS", func(t *testing.T) { - SignedTRC, persistedTrcPath := getTRC(t, "ISD1-B1-S1.trc", testDB.Dir) - err := os.Remove(persistedTrcPath) + SignedTRC, persistedTRCPath := getTRC(t, "ISD1-B1-S1.trc", testDB.Dir) + err := os.Remove(persistedTRCPath) require.NoError(t, err) in, err := testDB.InsertTRC(ctx, SignedTRC) require.NoError(t, err) require.False(t, in) - persistedTRC := xtest.LoadTRC(t, persistedTrcPath) + persistedTRC := xtest.LoadTRC(t, persistedTRCPath) require.Equal(t, SignedTRC, persistedTRC) }) @@ -164,8 +164,8 @@ func getModTime(t *testing.T, file string) int64 { } func getTRC(t *testing.T, trcName, persistDir string) (cppki.SignedTRC, string) { - testTrcPath := filepath.Join(testTrcsDir, trcName) - trc := xtest.LoadTRC(t, testTrcPath) - persistedTrcPath := filepath.Join(persistDir, trcName) - return trc, persistedTrcPath + testTRCPath := filepath.Join(testTRCsDir, trcName) + trc := xtest.LoadTRC(t, testTRCPath) + persistedTRCPath := filepath.Join(persistDir, trcName) + return trc, persistedTRCPath } diff --git a/private/topology/interface.go b/private/topology/interface.go index 7a02609eb3..eb8d9879a2 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. - InterfaceIDs() []common.IfIDType + IfIDs() []common.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) @@ -144,7 +144,7 @@ func (t *topologyS) MTU() uint16 { return uint16(t.Topology.MTU) } -func (t *topologyS) InterfaceIDs() []common.IfIDType { +func (t *topologyS) IfIDs() []common.IfIDType { intfs := make([]common.IfIDType, 0, len(t.Topology.IFInfoMap)) for ifID := range t.Topology.IFInfoMap { intfs = append(intfs, ifID) diff --git a/private/topology/json/json.go b/private/topology/json/json.go index a15b1f90cd..5c4ebc273b 100644 --- a/private/topology/json/json.go +++ b/private/topology/json/json.go @@ -113,7 +113,7 @@ type BRInterface struct { LinkTo string `json:"link_to"` MTU int `json:"mtu"` BFD *BFD `json:"bfd,omitempty"` - RemoteIFID common.IfIDType `json:"remote_interface_id,omitempty"` + RemoteIfID common.IfIDType `json:"remote_interface_id,omitempty"` } // Underlay is the underlay information for a BR interface. diff --git a/private/topology/reload.go b/private/topology/reload.go index b8ea4e6ccf..37a2cf4251 100644 --- a/private/topology/reload.go +++ b/private/topology/reload.go @@ -137,12 +137,12 @@ func (l *Loader) UnderlayNextHop(ifID uint16) *net.UDPAddr { return addr } -func (l *Loader) InterfaceIDs() []uint16 { +func (l *Loader) IfIDs() []uint16 { l.mtx.Lock() defer l.mtx.Unlock() var ids []uint16 - for _, id := range l.topo.InterfaceIDs() { + for _, id := range l.topo.IfIDs() { ids = append(ids, uint16(id)) } return ids diff --git a/private/topology/reload_test.go b/private/topology/reload_test.go index e801ea2e05..831fdcf36e 100644 --- a/private/topology/reload_test.go +++ b/private/topology/reload_test.go @@ -42,7 +42,7 @@ func TestLoader(t *testing.T) { assert.Equal(t, addr.MustParseIA("1-ff00:0:311"), l.IA()) assert.Equal(t, uint16(1472), l.MTU()) assert.Equal(t, false, l.Core()) - assert.ElementsMatch(t, []uint16{1, 3, 8, 11}, l.InterfaceIDs()) + assert.ElementsMatch(t, []uint16{1, 3, 8, 11}, l.IfIDs()) assert.ElementsMatch(t, xtest.MustParseUDPAddrs(t, "127.0.0.67:30073", diff --git a/private/topology/topology.go b/private/topology/topology.go index 20bb10c688..f7646112bd 100644 --- a/private/topology/topology.go +++ b/private/topology/topology.go @@ -53,7 +53,7 @@ type ( // // The second section concerns the Border routers. // The BR map points from border router names to BRInfo structs, which in turn - // are lists of IFID type slices, thus defines the IFIDs that belong to a + // are lists of IfID type slices, thus defines the IfIDs that belong to a // particular border router. The IFInfoMap points from interface IDs to IFInfo structs. // // The third section in RWTopology concerns the SCION-specific services in the topology. @@ -94,8 +94,8 @@ type ( Name string // InternalAddr is the local data-plane address. InternalAddr netip.AddrPort - // IFIDs is a sorted list of the interface IDs. - IFIDs []common.IfIDType + // IfIDs is a sorted list of the interface IDs. + IfIDs []common.IfIDType // IFs is a map of interface IDs. IFs map[common.IfIDType]*IFInfo } @@ -113,7 +113,7 @@ type ( InternalAddr netip.AddrPort Local netip.AddrPort Remote netip.AddrPort - RemoteIFID common.IfIDType + RemoteIfID common.IfIDType IA addr.IA LinkType LinkType MTU int @@ -273,9 +273,9 @@ func (t *RWTopology) populateBR(raw *jsontopo.Topology) error { var err error // Check that ifID is unique if _, ok := t.IFInfoMap[ifID]; ok { - return serrors.New("IFID already exists", "ID", ifID) + return serrors.New("IfID already exists", "ID", ifID) } - brInfo.IFIDs = append(brInfo.IFIDs, ifID) + brInfo.IfIDs = append(brInfo.IfIDs, ifID) ifinfo := IFInfo{ ID: ifID, BRName: name, @@ -287,7 +287,7 @@ func (t *RWTopology) populateBR(raw *jsontopo.Topology) error { } ifinfo.LinkType = LinkTypeFromString(rawIntf.LinkTo) if ifinfo.LinkType == Peer { - ifinfo.RemoteIFID = rawIntf.RemoteIFID + ifinfo.RemoteIfID = rawIntf.RemoteIfID } if err = ifinfo.CheckLinks(t.IsCore, name); err != nil { @@ -320,8 +320,8 @@ func (t *RWTopology) populateBR(raw *jsontopo.Topology) error { brInfo.IFs[ifID] = &ifinfo t.IFInfoMap[ifID] = ifinfo } - sort.Slice(brInfo.IFIDs, func(i, j int) bool { - return brInfo.IFIDs[i] < brInfo.IFIDs[j] + sort.Slice(brInfo.IfIDs, func(i, j int) bool { + return brInfo.IfIDs[i] < brInfo.IfIDs[j] }) t.BR[name] = brInfo } @@ -467,7 +467,7 @@ func (i *BRInfo) copy() *BRInfo { return &BRInfo{ Name: i.Name, InternalAddr: i.InternalAddr, - IFIDs: append(i.IFIDs[:0:0], i.IFIDs...), + IfIDs: append(i.IfIDs[:0:0], i.IfIDs...), IFs: copyIFsMap(i.IFs), } } diff --git a/private/topology/topology_test.go b/private/topology/topology_test.go index a0d634eff4..5830dc9b39 100644 --- a/private/topology/topology_test.go +++ b/private/topology/topology_test.go @@ -58,17 +58,17 @@ func TestBRs(t *testing.T) { brs := map[string]BRInfo{ "br1-ff00:0:311-1": { - IFIDs: []common.IfIDType{1, 3, 8}, + IfIDs: []common.IfIDType{1, 3, 8}, }, "br1-ff00:0:311-2": { - IFIDs: []common.IfIDType{11}, + IfIDs: []common.IfIDType{11}, }, } for name, info := range brs { t.Run("checking BR details for "+name, func(t *testing.T) { - for _, i := range info.IFIDs { - assert.Contains(t, c.BR[name].IFIDs, i) + for _, i := range info.IfIDs { + assert.Contains(t, c.BR[name].IfIDs, i) } }) } @@ -321,7 +321,7 @@ func TestBRsCoreAS(t *testing.T) { t.Run(test.name, func(t *testing.T) { assert.Contains(t, c.BR, test.name) for _, intf := range test.interfaces { - assert.Contains(t, c.BR[test.name].IFIDs, intf) + assert.Contains(t, c.BR[test.name].IfIDs, intf) } }) } diff --git a/private/trust/grpc/fetcher.go b/private/trust/grpc/fetcher.go index d164accd0d..f5c04cc149 100644 --- a/private/trust/grpc/fetcher.go +++ b/private/trust/grpc/fetcher.go @@ -128,7 +128,7 @@ func (f Fetcher) TRC(ctx context.Context, id cppki.TRCID, return cppki.SignedTRC{}, serrors.WrapStr("receiving TRC", err) } - trc, err := cppki.DecodeSignedTRC(rep.Trc) + trc, err := cppki.DecodeSignedTRC(rep.Trc) // nolint - name from protobuf if err != nil { f.updateMetric(span, labels.WithResult(trustmetrics.ErrParse), err) return cppki.SignedTRC{}, serrors.WrapStr("parse TRC reply", err) diff --git a/private/trust/grpc/fetcher_test.go b/private/trust/grpc/fetcher_test.go index 0cd77ea50f..51df4fd0f2 100644 --- a/private/trust/grpc/fetcher_test.go +++ b/private/trust/grpc/fetcher_test.go @@ -210,7 +210,10 @@ func TestFetcherTRC(t *testing.T) { Server: func(mctrl *gomock.Controller) *mock_cp.MockTrustMaterialServiceServer { srv := mock_cp.NewMockTrustMaterialServiceServer(mctrl) srv.EXPECT().TRC(gomock.Any(), gomock.Any()).Return( - &cppb.TRCResponse{Trc: []byte("garbage")}, nil, + &cppb.TRCResponse{ + Trc: []byte("garbage"), // nolint - name from published protobuf + }, + nil, ) return srv }, @@ -224,7 +227,7 @@ func TestFetcherTRC(t *testing.T) { srv := mock_cp.NewMockTrustMaterialServiceServer(mctrl) srv.EXPECT().TRC(gomock.Any(), gomock.Any()).Return( - &cppb.TRCResponse{Trc: rawBase}, nil, + &cppb.TRCResponse{Trc: rawBase}, nil, // nolint - name from published protobuf ) return srv }, @@ -235,7 +238,10 @@ func TestFetcherTRC(t *testing.T) { Server: func(mctrl *gomock.Controller) *mock_cp.MockTrustMaterialServiceServer { srv := mock_cp.NewMockTrustMaterialServiceServer(mctrl) srv.EXPECT().TRC(gomock.Any(), gomock.Any()).Return( - &cppb.TRCResponse{Trc: updated.Raw}, nil, + &cppb.TRCResponse{ + Trc: updated.Raw, // nolint - name from published protobuf + }, + nil, ) return srv }, diff --git a/private/trust/signer.go b/private/trust/signer.go index 5f4e1789cb..71c5ba4631 100644 --- a/private/trust/signer.go +++ b/private/trust/signer.go @@ -67,8 +67,8 @@ func (s Signer) Sign( id := &cppb.VerificationKeyID{ IsdAs: uint64(s.IA), - TrcBase: uint64(s.TRCID.Base), - TrcSerial: uint64(s.TRCID.Serial), + TrcBase: uint64(s.TRCID.Base), // nolint - name from published protobuf + TrcSerial: uint64(s.TRCID.Serial), // nolint - name from published protobuf SubjectKeyId: s.SubjectKeyID, } rawID, err := proto.Marshal(id) diff --git a/private/trust/verifier.go b/private/trust/verifier.go index 8b9ba81700..5ea498676a 100644 --- a/private/trust/verifier.go +++ b/private/trust/verifier.go @@ -94,8 +94,8 @@ func (v Verifier) Verify(ctx context.Context, signedMsg *cryptopb.SignedMessage, return nil, serrors.New("nil engine that provides cert chains") } id := cppki.TRCID{ISD: ia.ISD(), - Base: scrypto.Version(keyID.TrcBase), - Serial: scrypto.Version(keyID.TrcSerial), + Base: scrypto.Version(keyID.TrcBase), // nolint - name from published protobuf + Serial: scrypto.Version(keyID.TrcSerial), // nolint - name from published protobuf } if err := v.notifyTRC(ctx, id); err != nil { metrics.Verifier.Verify(l.WithResult(metrics.ErrInternal)).Inc() diff --git a/router/connector.go b/router/connector.go index 0cafc81bf4..6c9fccef71 100644 --- a/router/connector.go +++ b/router/connector.go @@ -110,16 +110,16 @@ func (c *Connector) AddExternalInterface(localIfID common.IfIDType, link control c.externalInterfaces = make(map[uint16]control.ExternalInterface) } c.externalInterfaces[intf] = control.ExternalInterface{ - InterfaceID: intf, - Link: link, - State: control.InterfaceDown, + IfID: intf, + Link: link, + State: control.InterfaceDown, } } else { if len(c.siblingInterfaces) == 0 { c.siblingInterfaces = make(map[uint16]control.SiblingInterface) } c.siblingInterfaces[intf] = control.SiblingInterface{ - InterfaceID: intf, + IfID: intf, InternalInterface: link.Remote.Addr, Relationship: link.LinkTo, MTU: link.MTU, @@ -192,7 +192,7 @@ func (c *Connector) ListExternalInterfaces() ([]control.ExternalInterface, error externalInterfaceList := make([]control.ExternalInterface, 0, len(c.externalInterfaces)) for _, externalInterface := range c.externalInterfaces { - externalInterface.State = c.DataPlane.getInterfaceState(externalInterface.InterfaceID) + externalInterface.State = c.DataPlane.getInterfaceState(externalInterface.IfID) externalInterfaceList = append(externalInterfaceList, externalInterface) } return externalInterfaceList, nil @@ -204,7 +204,7 @@ func (c *Connector) ListSiblingInterfaces() ([]control.SiblingInterface, error) siblingInterfaceList := make([]control.SiblingInterface, 0, len(c.siblingInterfaces)) for _, siblingInterface := range c.siblingInterfaces { - siblingInterface.State = c.DataPlane.getInterfaceState(siblingInterface.InterfaceID) + siblingInterface.State = c.DataPlane.getInterfaceState(siblingInterface.IfID) siblingInterfaceList = append(siblingInterfaceList, siblingInterface) } return siblingInterfaceList, nil diff --git a/router/control/conf.go b/router/control/conf.go index b911e5e92d..f9676c12ea 100644 --- a/router/control/conf.go +++ b/router/control/conf.go @@ -57,7 +57,7 @@ type LinkInfo struct { type LinkEnd struct { IA addr.IA Addr netip.AddrPort - IFID common.IfIDType + IfID common.IfIDType } type ObservableDataplane interface { @@ -75,7 +75,7 @@ type InternalInterface struct { // ExternalInterface represents an external interface of a router. type ExternalInterface struct { // InterfaceID is the identifier of the external interface. - InterfaceID uint16 + IfID uint16 // Link is the information associated with this link. Link LinkInfo // State indicates the interface state. @@ -85,7 +85,7 @@ type ExternalInterface struct { // SiblingInterface represents a sibling interface of a router. type SiblingInterface struct { // InterfaceID is the identifier of the external interface. - InterfaceID uint16 + IfID uint16 // InternalInterfaces is the local address (internal interface) // of the sibling router that owns this interface. InternalInterface netip.AddrPort @@ -181,12 +181,12 @@ func confExternalInterfaces(dp Dataplane, cfg *Config) error { Local: LinkEnd{ IA: cfg.IA, Addr: iface.Local, - IFID: iface.ID, + IfID: iface.ID, }, Remote: LinkEnd{ IA: iface.IA, Addr: iface.Remote, - IFID: iface.RemoteIFID, + IfID: iface.RemoteIfID, }, Instance: iface.BRName, BFD: BFD(iface.BFD), diff --git a/router/dataplane.go b/router/dataplane.go index f26aaea7d9..e318c3729f 100644 --- a/router/dataplane.go +++ b/router/dataplane.go @@ -464,9 +464,9 @@ func (d *DataPlane) addExternalInterfaceBFD(ifID uint16, conn BatchConn, // getInterfaceState checks if there is a bfd session for the input interfaceID and // returns InterfaceUp if the relevant bfdsession state is up, or if there is no BFD // session. Otherwise, it returns InterfaceDown. -func (d *DataPlane) getInterfaceState(interfaceID uint16) control.InterfaceState { +func (d *DataPlane) getInterfaceState(ifID uint16) control.InterfaceState { bfdSessions := d.bfdSessions - if bfdSession, ok := bfdSessions[interfaceID]; ok && !bfdSession.IsUp() { + if bfdSession, ok := bfdSessions[ifID]; ok && !bfdSession.IsUp() { return control.InterfaceDown } return control.InterfaceUp @@ -1835,7 +1835,7 @@ func (p *scionPacketProcessor) egressRouterAlertFlag() *bool { return &p.hopField.EgressRouterAlert } -func (p *slowPathPacketProcessor) handleSCMPTraceRouteRequest(interfaceID uint16) error { +func (p *slowPathPacketProcessor) handleSCMPTraceRouteRequest(ifID uint16) error { if p.lastLayer.NextLayerType() != slayers.LayerTypeSCMP { log.Debug("Packet with router alert, but not SCMP") @@ -1861,7 +1861,7 @@ func (p *slowPathPacketProcessor) handleSCMPTraceRouteRequest(interfaceID uint16 Identifier: scmpP.Identifier, Sequence: scmpP.Sequence, IA: p.d.localIA, - Interface: uint64(interfaceID), + Interface: uint64(ifID), } return p.packSCMP(slayers.SCMPTypeTracerouteReply, 0, &scmpP, false) } diff --git a/router/mgmtapi/api.go b/router/mgmtapi/api.go index 639b8832e2..eb127c88b7 100644 --- a/router/mgmtapi/api.go +++ b/router/mgmtapi/api.go @@ -102,7 +102,7 @@ func (s *Server) GetInterfaces(w http.ResponseWriter, r *http.Request) { Enabled: !*(intf.Link.BFD.Disable), RequiredMinimumReceive: intf.Link.BFD.RequiredMinRxInterval.String(), }, - InterfaceId: int(intf.InterfaceID), + InterfaceId: int(intf.IfID), // nolint - name from published API. InternalInterface: findInternalInterface(intf.Link.Local.IA), Neighbor: InterfaceNeighbor{ Address: intf.Link.Remote.Addr.String(), @@ -118,7 +118,7 @@ func (s *Server) GetInterfaces(w http.ResponseWriter, r *http.Request) { for _, intf := range siblingInterfaces { siblingInterface := SiblingInterface{ - InterfaceId: int(intf.InterfaceID), + InterfaceId: int(intf.IfID), // nolint - name from published API. InternalInterface: intf.InternalInterface.String(), Neighbor: SiblingNeighbor{ IsdAs: intf.NeighborIA.String(), diff --git a/router/mgmtapi/api_test.go b/router/mgmtapi/api_test.go index c6e01412e3..8683a86544 100644 --- a/router/mgmtapi/api_test.go +++ b/router/mgmtapi/api_test.go @@ -154,7 +154,7 @@ func TestAPI(t *testing.T) { func createExternalIntfs(t *testing.T) []control.ExternalInterface { return []control.ExternalInterface{ { - InterfaceID: 1, + IfID: 1, Link: control.LinkInfo{ Local: control.LinkEnd{ IA: addr.MustParseIA("1-ff00:0:110"), @@ -177,7 +177,7 @@ func createExternalIntfs(t *testing.T) []control.ExternalInterface { State: control.InterfaceUp, }, { - InterfaceID: 2, + IfID: 2, Link: control.LinkInfo{ Local: control.LinkEnd{ IA: addr.MustParseIA("1-ff00:0:110"), @@ -200,7 +200,7 @@ func createExternalIntfs(t *testing.T) []control.ExternalInterface { State: control.InterfaceUp, }, { - InterfaceID: 5, + IfID: 5, Link: control.LinkInfo{ Local: control.LinkEnd{ IA: addr.MustParseIA("1-ff00:0:111"), @@ -223,7 +223,7 @@ func createExternalIntfs(t *testing.T) []control.ExternalInterface { State: control.InterfaceUp, }, { - InterfaceID: 6, + IfID: 6, Link: control.LinkInfo{ Local: control.LinkEnd{ IA: addr.MustParseIA("1-ff00:0:112"), @@ -264,7 +264,7 @@ func createInternalIntfs(t *testing.T) []control.InternalInterface { func createSiblingIntfs(t *testing.T) []control.SiblingInterface { return []control.SiblingInterface{ { - InterfaceID: 5, + IfID: 5, InternalInterface: netip.MustParseAddrPort("172.20.0.20:30042"), Relationship: topology.Parent, MTU: 1280, diff --git a/scion/cmd/scion/traceroute.go b/scion/cmd/scion/traceroute.go index addbc9b231..4438ccf1cf 100644 --- a/scion/cmd/scion/traceroute.go +++ b/scion/cmd/scion/traceroute.go @@ -266,14 +266,14 @@ func fmtRemote(remote snet.SCIONAddress, intf uint64) string { func getHopInfo(u traceroute.Update, hop Hop) HopInfo { if u.Remote == (snet.SCIONAddress{}) { - return HopInfo{IA: hop.IA, InterfaceID: uint16(hop.ID)} + return HopInfo{IA: hop.IA, InterfaceID: uint16(hop.ID)} // nolint - name from published API } RTTs := make([]durationMillis, 0, len(u.RTTs)) for _, rtt := range u.RTTs { RTTs = append(RTTs, durationMillis(rtt)) } return HopInfo{ - InterfaceID: uint16(u.Interface), + InterfaceID: uint16(u.Interface), // nolint - name from published protobuf IP: u.Remote.Host.IP().String(), IA: u.Remote.IA, RoundTripTimes: RTTs, diff --git a/scion/showpaths/showpaths.go b/scion/showpaths/showpaths.go index 621c4bc9af..54b236219f 100644 --- a/scion/showpaths/showpaths.go +++ b/scion/showpaths/showpaths.go @@ -242,8 +242,8 @@ func humanInternalHops(p *snet.PathMetadata) string { if numHops == 0 { continue } - interfaceIdx := 2*i + 1 - ia := p.Interfaces[interfaceIdx].IA + interfaceIndex := 2*i + 1 + ia := p.Interfaces[interfaceIndex].IA internalHops = append(internalHops, fmt.Sprintf("%s: %d", ia, numHops)) } if len(internalHops) == 0 { @@ -260,11 +260,11 @@ func humanNotes(p *snet.PathMetadata) string { if note == "" { continue } - interfaceIdx := 0 + interfaceIndex := 0 if i > 0 { - interfaceIdx = 2*i - 1 + interfaceIndex = 2*i - 1 } - ia := p.Interfaces[interfaceIdx].IA + ia := p.Interfaces[interfaceIndex].IA notes = append(notes, fmt.Sprintf("%s: \"%s\"", ia, sanitizeString(note))) } if len(notes) == 0 {