Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

border: check errors before updating metadata #1988

Merged
merged 3 commits into from
Oct 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions go/border/rpkt/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,34 +344,28 @@ func (rp *RtrPkt) IncPath() (bool, error) {
return false, common.NewBasicError("New HopF offset > header length", nil,
"max", hdrLen, "actual", hOff)
}
// Update common header, and packet's InfoF/HopF fields.
segChgd := iOff != rp.CmnHdr.InfoFOffBytes()
rp.CmnHdr.UpdatePathOffsets(rp.Raw, uint8(iOff/common.LineLen), uint8(hOff/common.LineLen))
rp.infoF = infoF
rp.hopF = hopF
rp.IncrementedPath = true
if segChgd {
// Extract new ConsDir flag.
rp.consDirFlag = nil
if _, err = rp.ConsDirFlag(); err != nil {
return segChgd, err
}
}
// Extract the next interface ID.
rp.ifNext = nil
if _, err = rp.IFNext(); err != nil {
return segChgd, err
}
// Check that there's no VERIFY_ONLY fields in the middle of a segment.
if vOnly > 0 && !segChgd {
return segChgd, common.NewBasicError("VERIFY_ONLY in middle of segment",
scmp.NewError(scmp.C_Path, scmp.T_P_BadHopField, rp.mkInfoPathOffsets(), nil))
}
// Check that the segment didn't change from a down-segment to an up-segment.
if origConsDir && !*rp.consDirFlag {
if origConsDir && !infoF.ConsDir {
return segChgd, common.NewBasicError("Switched from down-segment to up-segment",
scmp.NewError(scmp.C_Path, scmp.T_P_BadSegment, rp.mkInfoPathOffsets(), nil))
}
// Update common header, and packet's InfoF/HopF fields.
rp.CmnHdr.UpdatePathOffsets(rp.Raw, uint8(iOff/common.LineLen), uint8(hOff/common.LineLen))
rp.infoF = infoF
rp.hopF = hopF
rp.IncrementedPath = true
rp.consDirFlag = &infoF.ConsDir
// Extract the next interface ID.
rp.ifNext = nil
if _, err = rp.IFNext(); err != nil {
return segChgd, err
}
return segChgd, nil
}

Expand Down