-
Notifications
You must be signed in to change notification settings - Fork 173
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Hi all,
I might have found a problem.
The method resolveInbound
calls the function resolveLocalDst
. resolveLocalDst
may return a nil and an error. These errors may not be catched by resolveInbound
. This means resolveInbound
will instead return a nil value for *net.UDPAddr
and a nil value for the error.
This might be problematic, since the client code below might receive a nil for *net.UDPAddr` without realizing that an error occurred.
func (p *scionPacketProcessor) resolveInbound() (*net.UDPAddr, processResult, error) {
a, err := p.d.resolveLocalDst(p.scionLayer)
switch {
case errors.Is(err, noSVCBackend):
r, err := p.packSCMP(
&slayers.SCMP{
TypeCode: slayers.CreateSCMPTypeCode(slayers.SCMPTypeDestinationUnreachable,
slayers.SCMPCodeNoRoute),
},
&slayers.SCMPDestinationUnreachable{}, err)
return nil, r, err
default:
return a, processResult{}, nil
}
}
func (d *DataPlane) resolveLocalDst(s slayers.SCION) (*net.UDPAddr, error) {
dst, err := s.DstAddr()
if err != nil {
// TODO parameter problem.
return nil, err
}
switch v := dst.(type) {
case addr.HostSVC:
// For map lookup use the Base address, i.e. strip the multi cast
// information, because we only register base addresses in the map.
a, ok := d.svc.Any(v.Base())
if !ok {
return nil, noSVCBackend
}
return a, nil
case *net.IPAddr:
return addEndhostPort(v), nil
default:
panic("unexpected address type returned from DstAddr")
}
}
client code calling resolveInbound
// Inbound: pkts destined to the local IA.
if p.scionLayer.DstIA.Equal(p.d.localIA) && int(p.path.PathMeta.CurrHF)+1 == p.path.NumHops {
a, r, err := p.resolveInbound()
if err != nil {
return r, err
}
return processResult{OutConn: p.d.internal, OutAddr: a, OutPkt: p.rawPkt}, nil
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working