Skip to content

Commit

Permalink
cleanup: purge go/lib/{hpkt,spkt,scmp} (#3898)
Browse files Browse the repository at this point in the history
Also cleanup a lot of other legacy code and remove the option to switch between header formats.

Co-authored-by: Lukas Vogel <vogel@anapaya.net>
  • Loading branch information
oncilla and lukedirtwalker authored Oct 14, 2020
1 parent e63406b commit 46b36b5
Show file tree
Hide file tree
Showing 98 changed files with 231 additions and 4,121 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ require (
google.golang.org/genproto v0.0.0-20191002211648-c459b9ce5143 // indirect
google.golang.org/grpc v1.29.1
google.golang.org/protobuf v1.23.0
gopkg.in/restruct.v1 v1.0.0-20151213023948-80ede2e57cc2
gopkg.in/yaml.v2 v2.3.0
zombiezen.com/go/capnproto2 v0.0.0-20190813022230-ddfb9bb855fa
)
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,6 @@ gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/restruct.v1 v1.0.0-20151213023948-80ede2e57cc2 h1:pqzOumCQ6icMR4sIIYRe2w7xCERvcPOFx22W9jSRsWg=
gopkg.in/restruct.v1 v1.0.0-20151213023948-80ede2e57cc2/go.mod h1:WJaLhyHHEQFOgwIxu/SJxvUHJA18glYsMETBTMIySTY=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
Expand Down
1 change: 0 additions & 1 deletion go/cs/cs.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ func run(file string) error {
&onehop.OHPPacketDispatcherService{
PacketDispatcherService: &snet.DefaultPacketDispatcherService{
Dispatcher: reliable.NewDispatcher(""),
Version2: true,
},
},
)
Expand Down
4 changes: 0 additions & 4 deletions go/cs/onehop/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,14 @@ type ohpPacketConn struct {
}

func (c *ohpPacketConn) WriteTo(pkt *snet.Packet, ov *net.UDPAddr) error {
extensions := pkt.Extensions
return c.PacketConn.WriteTo(
&snet.Packet{
Bytes: pkt.Bytes,
PacketInfo: snet.PacketInfo{
Destination: pkt.Destination,
Source: pkt.Source,
Path: pkt.Path,
Extensions: extensions,
L4Header: pkt.L4Header,
Payload: pkt.Payload,
PayloadV2: pkt.PayloadV2,
},
},
ov,
Expand Down
2 changes: 1 addition & 1 deletion go/cs/onehop/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *Sender) CreatePkt(msg *Msg) (*snet.Packet, error) {
Host: addr.HostFromIP(s.Addr.IP),
},
Path: (*spath.Path)(path),
PayloadV2: snet.UDPPayload{
Payload: snet.UDPPayload{
SrcPort: uint16(s.Addr.Port),
Payload: msg.Pld,
},
Expand Down
4 changes: 2 additions & 2 deletions go/cs/onehop/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ func checkTestPkt(t *testing.T, s *Sender, msg *Msg, pkt *snet.Packet) {
Host: addr.HostFromIPStr("127.0.0.1"),
}, pkt.Source)
assert.True(t, pkt.Path.IsOHP())
assert.Equal(t, uint16(4242), pkt.PayloadV2.(snet.UDPPayload).SrcPort)
assert.Equal(t, msg.Pld, pkt.PayloadV2.(snet.UDPPayload).Payload)
assert.Equal(t, uint16(4242), pkt.Payload.(snet.UDPPayload).SrcPort)
assert.Equal(t, msg.Pld, pkt.Payload.(snet.UDPPayload).Payload)
}

// testConn is a packet conn that returns an empty underlay address.
Expand Down
5 changes: 0 additions & 5 deletions go/dispatcher/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,8 @@ go_test(
embed = [":go_default_library"],
deps = [
"//go/lib/addr:go_default_library",
"//go/lib/common:go_default_library",
"//go/lib/hpkt:go_default_library",
"//go/lib/l4:go_default_library",
"//go/lib/scmp:go_default_library",
"//go/lib/snet:go_default_library",
"//go/lib/sock/reliable:go_default_library",
"//go/lib/spkt:go_default_library",
"//go/lib/xtest:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
"@com_github_stretchr_testify//require:go_default_library",
Expand Down
8 changes: 0 additions & 8 deletions go/dispatcher/dispatcher/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go_library(
name = "go_default_library",
srcs = [
"dispatcher.go",
"scmp.go",
"table.go",
"underlay.go",
],
Expand All @@ -16,14 +15,10 @@ go_library(
"//go/dispatcher/internal/respool:go_default_library",
"//go/lib/addr:go_default_library",
"//go/lib/common:go_default_library",
"//go/lib/hpkt:go_default_library",
"//go/lib/l4:go_default_library",
"//go/lib/log:go_default_library",
"//go/lib/ringbuf:go_default_library",
"//go/lib/scmp:go_default_library",
"//go/lib/serrors:go_default_library",
"//go/lib/slayers:go_default_library",
"//go/lib/spkt:go_default_library",
"//go/lib/underlay/conn:go_default_library",
"@com_github_google_gopacket//:go_default_library",
],
Expand All @@ -38,12 +33,9 @@ go_test(
"//go/lib/addr:go_default_library",
"//go/lib/common:go_default_library",
"//go/lib/l4:go_default_library",
"//go/lib/l4/mock_l4:go_default_library",
"//go/lib/scmp:go_default_library",
"//go/lib/slayers:go_default_library",
"//go/lib/slayers/path:go_default_library",
"//go/lib/slayers/path/scion:go_default_library",
"//go/lib/spkt:go_default_library",
"//go/lib/xtest:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
"@com_github_google_gopacket//:go_default_library",
Expand Down
29 changes: 0 additions & 29 deletions go/dispatcher/dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import (
"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/log"
"github.com/scionproto/scion/go/lib/ringbuf"
"github.com/scionproto/scion/go/lib/scmp"
"github.com/scionproto/scion/go/lib/serrors"
"github.com/scionproto/scion/go/lib/slayers"
"github.com/scionproto/scion/go/lib/spkt"
"github.com/scionproto/scion/go/lib/underlay/conn"
)

Expand All @@ -33,8 +31,6 @@ type Server struct {
routingTable *IATable
ipv4Conn net.PacketConn
ipv6Conn net.PacketConn
// HeaderV2 indicates whether the new header format is used.
HeaderV2 bool
}

// NewServer creates new instance of Server. Internally, it opens the dispatcher ports
Expand Down Expand Up @@ -75,7 +71,6 @@ func (as *Server) Serve() error {
netToRingDataplane := &NetToRingDataplane{
UnderlayConn: as.ipv4Conn,
RoutingTable: as.routingTable,
HeaderV2: as.HeaderV2,
}
errChan <- netToRingDataplane.Run()
}()
Expand All @@ -84,7 +79,6 @@ func (as *Server) Serve() error {
netToRingDataplane := &NetToRingDataplane{
UnderlayConn: as.ipv6Conn,
RoutingTable: as.routingTable,
HeaderV2: as.HeaderV2,
}
errChan <- netToRingDataplane.Run()
}()
Expand Down Expand Up @@ -135,8 +129,6 @@ func (ac *Conn) WriteTo(p []byte, addr net.Addr) (int, error) {

// Write is optimized for the use by ConnHandler (avoids reparsing the packet).
func (ac *Conn) Write(pkt *respool.Packet) (int, error) {
// FIXME(roosd): Drop this with header v1.
registerIfSCMPRequest(ac.regReference, &pkt.Info)
// XXX(roosd): Ignore error since there is nothing we can do about it.
// Currently, the ID space is shared between all applications that register
// with the dispatcher. Likelihood that they overlap is very small.
Expand Down Expand Up @@ -226,27 +218,6 @@ func openConn(network, address string, p SocketMetaHandler) (net.PacketConn, err
return &underlayConnWrapper{Conn: c, Handler: p}, nil
}

// registerIfSCMPRequest registers the ID of the SCMP Request, if it is an
// SCMP::General::EchoRequest, SCMP::General::TraceRouteRequest or SCMP::General::RecordPathRequest
// packet. It also increments SCMP-related metrics.
func registerIfSCMPRequest(ref registration.RegReference, packet *spkt.ScnPkt) error {
if scmpHdr, ok := packet.L4.(*scmp.Hdr); ok {
metrics.M.SCMPWritePkts(
metrics.SCMP{
Class: scmpHdr.Class.String(),
Type: scmpHdr.Type.Name(scmpHdr.Class),
},
).Inc()
if !isSCMPGeneralRequest(scmpHdr) {
return nil
}
if id := getSCMPGeneralID(packet); id != 0 {
return ref.RegisterID(id)
}
}
return nil
}

// registerIfSCMPInfo registers the ID of the SCMP request if it is an echo or
// traceroute message.
func registerIfSCMPInfo(ref registration.RegReference, pkt *respool.Packet) error {
Expand Down
139 changes: 0 additions & 139 deletions go/dispatcher/dispatcher/scmp.go

This file was deleted.

Loading

0 comments on commit 46b36b5

Please sign in to comment.