Skip to content

Commit

Permalink
Merge pull request #81 from named-data/parse-fast
Browse files Browse the repository at this point in the history
fw: do not validate packets after parse
  • Loading branch information
pulsejet authored Dec 25, 2024
2 parents 0a3ea4d + 7081f47 commit e5c2033
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: build
on:
push:
branches: ["main"]
pull_request:

permissions:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: test
on:
push:
branches: ["main"]
pull_request:

jobs:
Expand Down
11 changes: 9 additions & 2 deletions fw/face/ndnlp-link-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (l *NDNLPLinkService) handleIncomingFrame(frame []byte) {
IncomingFaceID: utils.IdPtr(l.faceID),
}

L2, _, err := spec.ReadPacket(enc.NewBufferReader(wire))
L2, err := ReadPacketUnverified(enc.NewBufferReader(wire))
if err != nil {
core.LogError(l, err)
return
Expand Down Expand Up @@ -370,7 +370,7 @@ func (l *NDNLPLinkService) handleIncomingFrame(frame []byte) {
}

// Parse inner packet in place
L3, _, err := spec.ReadPacket(enc.NewBufferReader(wire))
L3, err := ReadPacketUnverified(enc.NewBufferReader(wire))
if err != nil {
return
}
Expand Down Expand Up @@ -442,3 +442,10 @@ func (op *NDNLPLinkServiceOptions) Flags() (ret uint64) {
}
return
}

// Reads a packet without validating the internal fields
func ReadPacketUnverified(reader enc.ParseReader) (*spec.Packet, error) {
context := spec.PacketParsingContext{}
context.Init()
return context.Parse(reader, false)
}

0 comments on commit e5c2033

Please # to comment.