Skip to content

Commit eacdeef

Browse files
authored
router: return SCMP on invalid dst address (scionproto#4506)
Return SCMP on invalid destination address. Fixes scionproto#4126.
1 parent 83a83c4 commit eacdeef

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

router/dataplane.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ var (
122122
invalidSrcIA = errors.New("invalid source ISD-AS")
123123
invalidDstIA = errors.New("invalid destination ISD-AS")
124124
invalidSrcAddrForTransit = errors.New("invalid source address for transit pkt")
125+
invalidDstAddr = errors.New("invalid destination address")
125126
cannotRoute = errors.New("cannot route, dropping pkt")
126127
emptyValue = errors.New("empty value")
127128
malformedPath = errors.New("malformed path content")
@@ -1588,6 +1589,14 @@ func (p *scionPacketProcessor) resolveInbound() (*net.UDPAddr, processResult, er
15881589
cause: err,
15891590
}
15901591
return nil, processResult{SlowPathRequest: slowPathRequest}, slowPathRequired
1592+
case errors.Is(err, invalidDstAddr):
1593+
log.Debug("SCMP: invalid destination address")
1594+
slowPathRequest := slowPathRequest{
1595+
scmpType: slayers.SCMPTypeParameterProblem,
1596+
code: slayers.SCMPCodeInvalidDestinationAddress,
1597+
cause: err,
1598+
}
1599+
return nil, processResult{SlowPathRequest: slowPathRequest}, slowPathRequired
15911600
default:
15921601
return a, processResult{}, nil
15931602
}
@@ -1988,8 +1997,7 @@ func (d *DataPlane) resolveLocalDst(
19881997

19891998
dst, err := s.DstAddr()
19901999
if err != nil {
1991-
// TODO parameter problem.
1992-
return nil, err
2000+
return nil, invalidDstAddr
19932001
}
19942002
switch dst.Type() {
19952003
case addr.HostTypeSVC:

router/dataplane_internal_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,30 @@ func TestSlowPathProcessing(t *testing.T) {
512512
},
513513
expectedLayerType: slayers.LayerTypeSCMPParameterProblem,
514514
},
515+
"invalid dest addr": {
516+
prepareDP: func(ctrl *gomock.Controller) *DataPlane {
517+
return NewDP(fakeExternalInterfaces,
518+
nil, mock_router.NewMockBatchConn(ctrl),
519+
fakeInternalNextHops,
520+
map[addr.SVC][]*net.UDPAddr{},
521+
xtest.MustParseIA("1-ff00:0:110"), nil, testKey)
522+
},
523+
mockMsg: func() []byte {
524+
spkt := prepBaseMsg(t, payload, 0)
525+
spkt.RawDstAddr = []byte("invalid")
526+
spkt.DstAddrType = 1 // invalid address type
527+
ret := toMsg(t, spkt)
528+
return ret
529+
},
530+
srcInterface: 1,
531+
expectedSlowPathRequest: slowPathRequest{
532+
typ: slowPathSCMP,
533+
scmpType: slayers.SCMPTypeParameterProblem,
534+
code: slayers.SCMPCodeInvalidDestinationAddress,
535+
cause: invalidDstAddr,
536+
},
537+
expectedLayerType: slayers.LayerTypeSCMPParameterProblem,
538+
},
515539
}
516540
for name, tc := range testCases {
517541
name, tc := name, tc

0 commit comments

Comments
 (0)