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

Remove obsolete limit on path segments in SegReply #3765

Merged
merged 1 commit into from
May 14, 2020
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
35 changes: 3 additions & 32 deletions go/cs/segreq/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,50 +42,21 @@ func (c *CoreChecker) IsCore(ctx context.Context, ia addr.IA) (bool, error) {

func segsToRecs(ctx context.Context, segs segfetcher.Segments) []*seg.Meta {
logger := log.FromCtx(ctx)
lup, lcore, ldown := limit(len(segs.Up), len(segs.Core), len(segs.Down), 9)
recs := make([]*seg.Meta, 0, len(segs.Up)+len(segs.Core)+len(segs.Down))
for i := range segs.Up {
if i == lup {
break
}
s := segs.Up[i]
for _, s := range segs.Up {
logger.Trace(fmt.Sprintf("[segReqHandler:collectSegs] up %v -> %v",
s.FirstIA(), s.LastIA()), "seg", s.GetLoggingID())
recs = append(recs, seg.NewMeta(s, proto.PathSegType_up))
}
for i := range segs.Core {
if i == lcore {
break
}
s := segs.Core[i]
for _, s := range segs.Core {
logger.Trace(fmt.Sprintf("[segReqHandler:collectSegs] core %v -> %v",
s.FirstIA(), s.LastIA()), "seg", s.GetLoggingID())
recs = append(recs, seg.NewMeta(s, proto.PathSegType_core))
}
for i := range segs.Down {
if i == ldown {
break
}
s := segs.Down[i]
for _, s := range segs.Down {
logger.Trace(fmt.Sprintf("[segReqHandler:collectSegs] down %v -> %v",
s.FirstIA(), s.LastIA()), "seg", s.GetLoggingID())
recs = append(recs, seg.NewMeta(s, proto.PathSegType_down))
}
return recs
}

// XXX(roosd): Dirty hack to avoid exceeding jumbo frames until quic is implemented.
// Revert tainted code after quic is implemented.
func limit(upSegs, coreSegs, downSegs, all int) (int, int, int) {
for upSegs+coreSegs+downSegs > all {
switch {
case upSegs >= coreSegs && upSegs >= downSegs:
upSegs--
case coreSegs >= upSegs && coreSegs >= downSegs:
coreSegs--
default:
downSegs--
}
}
return upSegs, coreSegs, downSegs
}