Skip to content

Commit

Permalink
comment r6
Browse files Browse the repository at this point in the history
  • Loading branch information
sgmonroy committed Oct 1, 2019
1 parent 9dc9315 commit b9d5ac1
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 31 deletions.
18 changes: 7 additions & 11 deletions go/border/internal/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,22 @@ const Namespace = "br"

// Result values.
const (
Success = prom.Success
ErrProcess = prom.ErrProcess
ErrParse = prom.ErrParse
ErrCrypto = prom.ErrCrypto
Success = prom.Success
ErrProcess = prom.ErrProcess
ErrParse = prom.ErrParse
ErrCrypto = prom.ErrCrypto
ErrValidate = prom.ErrValidate
ErrInvalidReq = prom.ErrInvalidReq
// ErrRead is an error reading a packet from snet.
ErrRead = "err_read"
// ErrWrite is an error writing a packet to snet.
ErrWrite = "err_write"
// ErrValidate is an error validating the packet.
ErrValidate = "err_validate"
// ErrValidate is an error routing the packet.
// ErrRoute is an error routing the packet.
ErrRoute = "err_route"
// ErrProcessLocal is an error on local processing the packet, ie. SVC resolution.
ErrProcessLocal = "err_process_local"
// ErrParsePayload is an error parsing the packet payload.
ErrParsePayload = "err_parse_payload"
// ErrResolveSVC is an error resolving a SVC address.
ErrResolveSVC = "err_resolve_svc"
// ErrInvalidRequest is an error for unsupported control message.
ErrInvalidRequest = "err_invalid_request"
)

// Metrics initialization.
Expand Down
4 changes: 2 additions & 2 deletions go/border/rctrl/ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func processCtrlFromRaw(b common.RawBytes) error {
case *path_mgmt.Pld:
err = processPathMgmtSelf(pld)
default:
cl.Result = metrics.ErrInvalidRequest
cl.Result = metrics.ErrInvalidReq
metrics.Control.ProcessErrors(cl).Inc()
err = common.NewBasicError("Unsupported control payload", nil, "type", common.TypeOf(pld))
}
Expand All @@ -137,7 +137,7 @@ func processPathMgmtSelf(p *path_mgmt.Pld) error {
case *path_mgmt.IFStateInfos:
ifstate.Process(pld)
default:
cl.Result = metrics.ErrInvalidRequest
cl.Result = metrics.ErrInvalidReq
metrics.Control.ProcessErrors(cl).Inc()
err = common.NewBasicError("Unsupported PathMgmt payload", nil, "type", common.TypeOf(pld))
}
Expand Down
2 changes: 1 addition & 1 deletion go/border/rctrl/revinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func revInfoFwd(revInfoQ chan rpkt.RawSRevCallbackArgs) {
func fwdRevInfo(sRevInfo *path_mgmt.SignedRevInfo, dstHost addr.HostSVC) {
cl := metrics.SentRevInfoLabels{
Result: metrics.ErrProcess,
SVC: dstHost.String(),
SVC: dstHost.BaseString(),
}
ctx := rctx.Get()
cpld, err := ctrl.NewPathMgmtPld(sRevInfo, nil, nil)
Expand Down
13 changes: 3 additions & 10 deletions go/border/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,9 @@ func (r *Router) processPacket(rp *rpkt.RtrPkt) {
metrics.Process.Pkts(l).Inc()
return
}
// Check if the packet needs to be processed locally, and if so register
// hooks for doing so.
if err := rp.NeedsLocalProcessing(); err != nil {
rp.Error("Error checking for local processing", "err", err)
l.Result = metrics.ErrProcessLocal
metrics.Process.Pkts(l).Inc()
return
}
// Parse the packet payload, if a previous step has registered a relevant
// hook for doing so.
// Check if the packet needs to be processed locally, and if so register hooks for doing so.
rp.NeedsLocalProcessing()
// Parse the packet payload, if a previous step has registered a relevant hook for doing so.
if _, err := rp.Payload(true); err != nil {
// Any errors at this point are application-level, and hence not
// calling handlePktError, as no SCMP errors will be sent.
Expand Down
6 changes: 1 addition & 5 deletions go/border/rpkt/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ func (rp *RtrPkt) validateLocalIF(ifid *common.IFIDType) error {
}
// If the BR does not have a revocation for the current epoch, it considers
// the interface as active until it receives a new revocation.
intf, ok := rp.Ctx.Conf.BR.IFs[*ifid]
if !ok {
rp.Error("Invalid interface", "ifid", *ifid)
return nil
}
intf := rp.Ctx.Conf.BR.IFs[*ifid]
newState := ifstate.NewInfo(*ifid, intf.ISD_AS, true, nil, nil)
ifstate.UpdateIfNew(*ifid, state, newState)
return nil
Expand Down
3 changes: 1 addition & 2 deletions go/border/rpkt/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

// NeedsLocalProcessing determines if the router needs to do more than just
// forward a packet (e.g. resolve an SVC destination address).
func (rp *RtrPkt) NeedsLocalProcessing() error {
func (rp *RtrPkt) NeedsLocalProcessing() {
// Check if SVC packet to local AS
if rp.dstIA.Equal(rp.Ctx.Conf.IA) && rp.CmnHdr.DstType == addr.HostTypeSVC {
// SVC address needs to be resolved for delivery.
Expand All @@ -39,7 +39,6 @@ func (rp *RtrPkt) NeedsLocalProcessing() error {
// Non-SVC packet to local AS, just forward.
rp.hooks.Route = append(rp.hooks.Route, rp.forward)
}
return nil
}

// Process uses any registered hooks to process the packet. Note that there is
Expand Down

0 comments on commit b9d5ac1

Please sign in to comment.