Skip to content

Commit

Permalink
fix e2e admission sending messages
Browse files Browse the repository at this point in the history
  • Loading branch information
juagargi committed Sep 4, 2020
1 parent 537b04a commit 9c3d1f6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
5 changes: 5 additions & 0 deletions go/cs/reservation/e2e/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ func NewResponse(ts time.Time, id *reservation.E2EID, idx reservation.IndexNumbe
}, nil
}

// IsHopByHop returns false, as all the responses travel directly to the source endhost.
func (r *Response) IsHopByHop() bool {
return false
}

// ResponseSetupSuccess is the response to a success setup. It's sent on the reverse direction.
type ResponseSetupSuccess struct {
Response
Expand Down
5 changes: 5 additions & 0 deletions go/cs/reservation/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ func (m *RequestMetadata) Path() *spath.Path {
return &m.path
}

// IsHopByHop returns true. If a subtype needs not to be hop by hop, it can override the function.
func (m *RequestMetadata) IsHopByHop() bool {
return true
}

// NumberOfHops returns the number of hops in this reservation.
func (m *RequestMetadata) NumberOfHops() int {
return (len(m.path.Raw) - spath.InfoFieldLength) / spath.HopFieldLength
Expand Down
1 change: 1 addition & 0 deletions go/cs/reservation/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ type Capacities interface {
// MessageWithPath is used to send messages from the COLIBRI service via the BR.
type MessageWithPath interface {
Path() *spath.Path
IsHopByHop() bool
// Payload() []byte
}
36 changes: 13 additions & 23 deletions go/cs/reservationstore/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,29 +286,15 @@ func (s *Store) AdmitE2EReservation(ctx context.Context, request e2e.SetupReques
if err := s.validateAuthenticators(&req.RequestMetadata); err != nil {
return nil, serrors.WrapStr("error validating e2e request", err, "id", req.ID)
}
response, err := s.prepareFailureE2EResp(&req.Request)
if err != nil {
return nil, serrors.WrapStr("cannot construct response", err, "id", req.ID)
}
var failedResponse base.MessageWithPath
pathToUse := req.Path().Copy()
if req.IsThisASTheDst() {
// TODO(juagargi) find the path to the src endhost
// pathToUse =
basicResponse, err := e2e.NewResponse(time.Now(), &req.ID, req.Index, pathToUse,
false, uint8(req.IndexOfCurrentHop()))
if err != nil {
return nil, serrors.WrapStr("cannot construct e2e response", err)
}
failedResponse = &e2e.ResponseSetupFailure{
Response: *basicResponse,
ErrorCode: 1,
MaxBWs: req.AllocationTrail,
}
} else {
if err := pathToUse.Reverse(); err != nil {
return nil, serrors.WrapStr("cannot reverse path for response", err)
}
failedResponse = &e2e.SetupReqFailure{
SetupReq: *req,
ErrorCode: 1, // TODO(juagargi) use error codes
}
failedResponse = &e2e.ResponseSetupFailure{
Response: *response,
ErrorCode: 1,
MaxBWs: req.AllocationTrail,
}
// sanity check: all successful requests are SetupReqSuccess. Failed ones are SetupReqFailure.
if request.IsSuccess() {
Expand Down Expand Up @@ -401,8 +387,12 @@ func (s *Store) AdmitE2EReservation(ctx context.Context, request e2e.SetupReques
asAResponse := failedResponse.(*e2e.ResponseSetupFailure)
asAResponse.MaxBWs = append(asAResponse.MaxBWs, maxWillingToAlloc)
} else {
asARequest := failedResponse.(*e2e.SetupReqFailure)
asARequest := &e2e.SetupReqFailure{
SetupReq: *req,
ErrorCode: 1,
}
asARequest.AllocationTrail = append(asARequest.AllocationTrail, maxWillingToAlloc)
failedResponse = asARequest
}
return failedResponse, serrors.WrapStr("e2e not admitted", err, "id", req.ID,
"index", req.Index)
Expand Down

0 comments on commit 9c3d1f6

Please sign in to comment.