Skip to content

Commit

Permalink
Apply reviewer suggested simplifications. Also fix latent bug in test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiceatscion committed Jul 18, 2024
1 parent d63e202 commit 1fe66f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
22 changes: 10 additions & 12 deletions router/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ func (d *DataPlane) resolveLocalDst(
if dstIP.Is4In6() {
return unsupportedV4MappedV6Address
}
return d.addEndhostPort(resolvedDst, lastLayer, dst.IP())
return d.addEndhostPort(resolvedDst, lastLayer, dstIP)
default:
panic("unexpected address type returned from DstAddr")
}
Expand Down Expand Up @@ -2446,18 +2446,13 @@ func (p *slowPathPacketProcessor) prepareSCMP(
scionL.Path = revPath
scionL.DstIA = p.scionLayer.SrcIA
scionL.SrcIA = p.d.localIA
srcA, err := p.scionLayer.SrcAddr()
if err != nil {
return nil, serrors.Wrap(cannotRoute, err, "details", "extracting src addr")
}
if err := scionL.SetDstAddr(srcA); err != nil {
return nil, serrors.Wrap(cannotRoute, err, "details", "setting dest addr")
}
scionL.DstAddrType = p.scionLayer.SrcAddrType
scionL.RawDstAddr = p.scionLayer.RawSrcAddr
scionL.NextHdr = slayers.L4SCMP

if err := scionL.SetSrcAddr(addr.HostIP(p.d.internalIP)); err != nil {
return nil, serrors.Wrap(cannotRoute, err, "details", "setting src addr")
}
scionL.NextHdr = slayers.L4SCMP

typeCode := slayers.CreateSCMPTypeCode(typ, code)
scmpH := slayers.SCMP{TypeCode: typeCode}
scmpH.SetNetworkLayerForChecksum(&scionL)
Expand Down Expand Up @@ -2516,8 +2511,11 @@ func (p *slowPathPacketProcessor) prepareSCMP(
scionL.NextHdr = slayers.End2EndClass

now := time.Now()
// srcA == scionL.DstAddr
key, err := p.drkeyProvider.GetASHostKey(now, scionL.DstIA, srcA)
dstA, err := scionL.DstAddr()
if err != nil {
return nil, serrors.Wrap(cannotRoute, err, "details", "parsing destination address")
}
key, err := p.drkeyProvider.GetASHostKey(now, scionL.DstIA, dstA)
if err != nil {
return nil, serrors.Wrap(cannotRoute, err, "details", "retrieving DRKey")
}
Expand Down
2 changes: 1 addition & 1 deletion router/dataplane_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ func prepBaseMsgHop0Out(t *testing.T, payload []byte, flowId uint32) *slayers.SC
{ConsIngress: 31, ConsEgress: 30},
},
}
dpath.HopFields[2].Mac = computeMAC(t, testKey, dpath.InfoFields[0], dpath.HopFields[2])
dpath.HopFields[0].Mac = computeMAC(t, testKey, dpath.InfoFields[0], dpath.HopFields[0])
spkt.Path = dpath
return spkt
}

0 comments on commit 1fe66f0

Please sign in to comment.