Skip to content

Commit

Permalink
pass
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiSubira committed May 8, 2024
1 parent 9df5657 commit 870ffc2
Show file tree
Hide file tree
Showing 18 changed files with 255 additions and 249 deletions.
4 changes: 2 additions & 2 deletions acceptance/app_vs_endhost_br_dispatch/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def setup_prepare(self):

br_as_2_file = self.artifacts / "gen" / "ASff00_0_2" \
/ ("%s.toml" % br_as_2_id)
scion.update_toml({"router.endhost_start_port": 0,
"router.endhost_end_port": 0},
scion.update_toml({"router.dispatched_port_start": 0,
"router.dispatched_port_end": 0},
[br_as_2_file])

def setup_start(self):
Expand Down
6 changes: 3 additions & 3 deletions daemon/internal/servers/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,16 @@ func (s *DaemonServer) notifyInterfaceDown(ctx context.Context,
return &sdpb.NotifyInterfaceDownResponse{}, nil
}

// AS serves the AS request.
// PortRange returns the port range for the dispatched ports.
func (s *DaemonServer) PortRange(
_ context.Context,
_ *emptypb.Empty,
) (*sdpb.PortRangeResponse, error) {

startPort, endPort := s.Topology.PortRange()
return &sdpb.PortRangeResponse{
EndhostStartPort: uint32(startPort),
EndhostEndPort: uint32(endPort),
DispatchedPortStart: uint32(startPort),
DispatchedPortEnd: uint32(endPort),
}, nil
}

Expand Down
4 changes: 2 additions & 2 deletions dispatcher/cmd/dispatcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func realMain(ctx context.Context) error {
g, errCtx := errgroup.WithContext(ctx)
g.Go(func() error {
defer log.HandlePanic()
return RunDispatcher(
return runDispatcher(
globalCfg.Dispatcher.IsDispatcher,
globalCfg.Dispatcher.ServiceAddresses,
netip.AddrPortFrom(
Expand Down Expand Up @@ -133,7 +133,7 @@ func realMain(ctx context.Context) error {
}
}

func RunDispatcher(
func runDispatcher(
isDispatcher bool,
svcAddrs map[addr.Addr]netip.AddrPort,
underlayAddr netip.AddrPort,
Expand Down
36 changes: 18 additions & 18 deletions dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ func NewServer(
)
parser.IgnoreUnsupported = true
server.parser = parser
// if the dispatcher feature is enabled, we enable IP_PKTINFO; see
// description of setIPPktInfo for more information.
server.conn = conn
if isDispatcher {
server.conn, server.cmParser = setIPPktInfo(conn)
Expand Down Expand Up @@ -145,17 +143,18 @@ func (s *Server) Serve() error {
}
}

// processMsgNextHop processes the message arriving to the shim dispatcher and returns
// a byte array corresponding to the packet that has to be forwarded.
// The input byte array *buf* is the raw incoming packet; the *underlay* address MUST NOT
// be nil and corresponds to the IP address in the encapsulation UDP/IP header; *prevHop*
// address is the address from the previous SCION hop in the local network.
// The intended nextHop address, either the end application or the next BR (for SCMP
// informational response), is returned.
// It returns a non-nil error for non-recoverable errors, only.
// If the incoming packet couldn't be processed due to a recoverable error or due to
// incorrect address validation the returned buffer and address will be nil.
// The caller must check both values consistently.
// processMsgNextHop processes the message arriving at the shim dispatcher and returns
// a byte array corresponding to the packet that needs to be forwarded.
// The input byte array `buf` is the raw incoming packet;
// `underlay` corresponds to the IP address on the outer UDP/IP header;
// `prevHop` is the address from the previous SCION hop in the local network.
// The intended nextHop address, i.e., either the end application
// or the next BR (for SCMP informational response), is returned.
// It returns a non-nil error for non-recoverable errors only.
// If the incoming packet couldn't be processed due to a recoverable error or
// incorrect address validation, the returned buffer will be nil and the address
// will be empty.
// The caller must consistently check both values.
func (s *Server) processMsgNextHop(
buf []byte,
underlay netip.Addr,
Expand All @@ -168,15 +167,15 @@ func (s *Server) processMsgNextHop(
return nil, netip.AddrPort{}, nil
}
if len(s.decoded) < 2 {
log.Error("Unexpected decode packet", "layers decoded", len(s.decoded))
log.Error("Unexpected packet", "layers decoded", len(s.decoded))
return nil, netip.AddrPort{}, nil
}
err = s.outBuffer.Clear()
if err != nil {
return nil, netip.AddrPort{}, err
}

// If the dispatcher feature flag is disabled we only process SCMPInfo packets
// If the dispatcher feature flag is disabled we only process SCMPInfo packets.
if !s.isDispatcher {
if s.decoded[len(s.decoded)-1] != slayers.LayerTypeSCMP {
log.Debug("Dispatcher feature is disabled, shim discards non-SCMPInfo packets",
Expand Down Expand Up @@ -451,9 +450,10 @@ func (m ipv6ControlMessage) Destination() net.IP {
return m.Dst
}

// parseUnderlayAddr returns the underlay destination address on the UDP/IP wrapper.
// It returns nil, if the control message information is not present or cannot be parsed.
// This is useful for checking that this address corresponds to the address of the encapsulated
// parseUnderlayAddr returns the underlay destination address on the outer UDP/IP wrapper.
// It returns an empty address, if the control message information is not present
// or it cannot be parsed.
// This is useful for checking that this address corresponds to the address of the inner
// UDP/SCION header. This refers to the safeguard for traffic reflection as discussed in:
// https://github.com/scionproto/scion/pull/4280#issuecomment-1775177351
func (s *Server) parseUnderlayAddr(oobuffer []byte) netip.Addr {
Expand Down
2 changes: 1 addition & 1 deletion pkg/daemon/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (c grpcConn) PortRange(ctx context.Context) (uint16, uint16, error) {
if err != nil {
return 0, 0, err
}
return uint16(response.EndhostStartPort), uint16(response.EndhostEndPort), nil
return uint16(response.DispatchedPortStart), uint16(response.DispatchedPortEnd), nil
}

func (c grpcConn) Interfaces(ctx context.Context) (map[uint16]*net.UDPAddr, error) {
Expand Down
Loading

0 comments on commit 870ffc2

Please sign in to comment.