Skip to content

Commit

Permalink
Also fix issue 4558 (no zero destination host addresses).
Browse files Browse the repository at this point in the history
  • Loading branch information
jiceatscion committed Jul 18, 2024
1 parent 1fe66f0 commit b4f85c8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
8 changes: 5 additions & 3 deletions router/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ var (
unsupportedPathType = errors.New("unsupported path type")
unsupportedPathTypeNextHeader = errors.New("unsupported combination")
unsupportedV4MappedV6Address = errors.New("unsupported v4mapped IP v6 address")
unsupportedUnspecifiedAddress = errors.New("unsupported unspecified address")
noBFDSessionFound = errors.New("no BFD session was found")
noBFDSessionConfigured = errors.New("no BFD sessions have been configured")
errPeeringEmptySeg0 = errors.New("zero-length segment[0] in peering path")
Expand Down Expand Up @@ -1656,7 +1657,7 @@ func (p *scionPacketProcessor) resolveInbound() disposition {
code: slayers.SCMPCodeNoRoute,
}
return pSlowPath
case invalidDstAddr, unsupportedV4MappedV6Address:
case invalidDstAddr, unsupportedV4MappedV6Address, unsupportedUnspecifiedAddress:
log.Debug("SCMP response", "cause", err)
p.pkt.slowPathRequest = slowPathRequest{
scmpType: slayers.SCMPTypeParameterProblem,
Expand Down Expand Up @@ -1855,8 +1856,6 @@ func (p *scionPacketProcessor) validateSrcHost() disposition {
if p.scionLayer.SrcIA != p.d.localIA {
return pForward
}
// TODO(jiceatscion): That is the second time we parse the src address
// we might want to cache it.
src, err := p.scionLayer.SrcAddr()
if err == nil && src.IP().Is4In6() {
err = unsupportedV4MappedV6Address
Expand Down Expand Up @@ -2104,6 +2103,9 @@ func (d *DataPlane) resolveLocalDst(
if dstIP.Is4In6() {
return unsupportedV4MappedV6Address
}
if dstIP.IsUnspecified() { // IsInvalid() not possible, we initialized it from wire bits.
return unsupportedUnspecifiedAddress
}
return d.addEndhostPort(resolvedDst, lastLayer, dstIP)
default:
panic("unexpected address type returned from DstAddr")
Expand Down
23 changes: 23 additions & 0 deletions router/dataplane_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,29 @@ func TestSlowPathProcessing(t *testing.T) {
},
expectedLayerType: slayers.LayerTypeSCMPParameterProblem,
},
"invalid dest unspecified": {
prepareDP: func(ctrl *gomock.Controller) *DataPlane {
return NewDP(fakeExternalInterfaces,
nil, mock_router.NewMockBatchConn(ctrl),
fakeInternalNextHops,
fakeServices,
addr.MustParseIA("1-ff00:0:110"), nil, testKey)
},
mockMsg: func() []byte {
spkt := prepBaseMsg(t, payload, 0)
spkt.DstAddrType = slayers.T4Ip
spkt.RawDstAddr = []byte{0, 0, 0, 0}
ret := toMsg(t, spkt)
return ret
},
srcInterface: 1,
expectedSlowPathRequest: slowPathRequest{
typ: slowPathSCMP,
scmpType: slayers.SCMPTypeParameterProblem,
code: slayers.SCMPCodeInvalidDestinationAddress,
},
expectedLayerType: slayers.LayerTypeSCMPParameterProblem,
},
"invalid src v4mapped": {
prepareDP: func(ctrl *gomock.Controller) *DataPlane {
return NewDP(fakeExternalInterfaces,
Expand Down
1 change: 1 addition & 0 deletions router/dataplane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ func TestDataPlaneRun(t *testing.T) {
for i := 0; i < totalCount; i++ {
spkt, dpath := prepBaseMsg(time.Now())
spkt.DstIA = local
spkt.RawDstAddr = []byte{192, 168, 1, 1}
dpath.HopFields = []path.HopField{
{ConsIngress: 41, ConsEgress: 40},
{ConsIngress: 31, ConsEgress: 30},
Expand Down

0 comments on commit b4f85c8

Please sign in to comment.