Skip to content

Commit

Permalink
router: implement reviewers suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiceatscion committed Nov 9, 2023
1 parent b655c50 commit 934f992
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 36 deletions.
6 changes: 0 additions & 6 deletions .buildkite/pipeline_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ gen_bazel_test_steps() {
cache=""
args=""

# Tell the test that it is being used for CI testing. That may trigger additional checks.
# only one test understands this at this point and most tests reject unknown flags.
if [[ "$test" =~ router_benchmark ]]; then
args="--test_arg=--ci"
fi

if [[ "$test" =~ "go" ]]; then
args="$args --test_arg=-test.v"
fi
Expand Down
3 changes: 2 additions & 1 deletion acceptance/router_benchmark/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# Copyright 2020 Anapaya Systems
# Copyright 2023 SCION Association
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,6 +53,7 @@ class Test(base.TestTopogen):
ci = cli.Flag(
"ci",
help="Do extra checks for CI",
envname="CI"
)

def setup_prepare(self):
Expand Down
12 changes: 0 additions & 12 deletions pkg/snet/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,6 @@ func (s *DefaultPacketDispatcherService) Register(
registration *net.UDPAddr,
svc addr.SVC) (PacketConn, uint16, error) {

// If now flowID is specified, use the backward compatible value of 1.
return s.RegisterWithFlowID(ctx, ia, registration, svc, 1)
}

func (s *DefaultPacketDispatcherService) RegisterWithFlowID(
ctx context.Context,
ia addr.IA,
registration *net.UDPAddr,
svc addr.SVC,
flowID uint32) (PacketConn, uint16, error) {

rconn, port, err := s.Dispatcher.Register(ctx, ia, registration, svc)
if err != nil {
return nil, 0, err
Expand All @@ -77,7 +66,6 @@ func (s *DefaultPacketDispatcherService) RegisterWithFlowID(
Conn: rconn,
SCMPHandler: s.SCMPHandler,
Metrics: s.SCIONPacketConnMetrics,
FlowID: flowID,
}, port, nil
}

Expand Down
6 changes: 0 additions & 6 deletions pkg/snet/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,6 @@ func (p *Packet) Decode() error {

// Serialize serializes the PacketInfo into the raw buffer of the packet.
func (p *Packet) Serialize() error {
// Use the bw compatible default value.
return p.SerializeWithFlowID(1)
}

// Serialize serializes the PacketInfo into the raw buffer of the packet.
func (p *Packet) SerializeWithFlowID(flowID uint32) error {
p.Prepare()
if p.Payload == nil {
return serrors.New("no payload set")
Expand Down
5 changes: 1 addition & 4 deletions pkg/snet/packet_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ type SCIONPacketConn struct {
SCMPHandler SCMPHandler
// Metrics are the metrics exported by the conn.
Metrics SCIONPacketConnMetrics
// FlowID: arbitrary value to distribute connections over router CPUs.
// Initialize to 1 if backward compatible (no-distribution) behavior is desired.
FlowID uint32
}

func (c *SCIONPacketConn) SetDeadline(d time.Time) error {
Expand All @@ -128,7 +125,7 @@ func (c *SCIONPacketConn) Close() error {
}

func (c *SCIONPacketConn) WriteTo(pkt *Packet, ov *net.UDPAddr) error {
if err := pkt.SerializeWithFlowID(c.FlowID); err != nil {
if err := pkt.Serialize(); err != nil {
return serrors.WrapStr("serialize SCION packet", err)
}
// Send message
Expand Down
9 changes: 4 additions & 5 deletions tools/end2end/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"errors"
"flag"
"fmt"
"math/rand"
"net"
"net/netip"
"os"
Expand Down Expand Up @@ -314,8 +313,8 @@ func (c *client) run() int {
}

var err error
c.conn, c.port, err = connFactory.RegisterWithFlowID(context.Background(), integration.Local.IA,
integration.Local.Host, addr.SvcNone, rand.Uint32())
c.conn, c.port, err = connFactory.Register(context.Background(), integration.Local.IA,
integration.Local.Host, addr.SvcNone)
if err != nil {
integration.LogFatal("Unable to listen", "err", err)
}
Expand Down Expand Up @@ -486,7 +485,7 @@ func (c *client) drainPong(n int) bool {
return false // Don't stop; keep consuming pongs
}

func (c *client) ping(ctx context.Context, n int, path snet.Path, log_ok bool) error {
func (c *client) ping(ctx context.Context, n int, path snet.Path, logIfOk bool) error {
rawPing, err := json.Marshal(Ping{
Server: remote.IA,
Message: ping,
Expand Down Expand Up @@ -531,7 +530,7 @@ func (c *client) ping(ctx context.Context, n int, path snet.Path, log_ok bool) e
},
},
}
if log_ok {
if logIfOk {
log.Info("sending ping", "attempt", n, "path", path)
}
if err := c.conn.WriteTo(pkt, remote.NextHop); err != nil {
Expand Down
6 changes: 4 additions & 2 deletions tools/integration/integrationlib/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,13 @@ type AttemptFunc func(n int) bool
// Returns 0 on success, 1 on failure.
func AttemptRepeatedly(name string, attempt AttemptFunc) int {
for attempts := 0; attempts < Attempts; attempts++ {
if attempts != 0 {
log.Info("Retrying...")
time.Sleep(integration.RetryTimeout)
}
if attempt(attempts) {
return 0
}
log.Info("Retrying...")
time.Sleep(integration.RetryTimeout)
}
log.Error(fmt.Sprintf("%s failed. No more attempts...", name))
return 1
Expand Down

0 comments on commit 934f992

Please sign in to comment.