cloudflare / cloudflare/xdpcap

Allow hook.Patch() to operate on ProgramSpec

Open
#6 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
786
Forks
78
PR merge metrics
No merged PRs in 30d

Description

From #5 :

Patching Program doesn't work because it's already loaded, using a ProgramSpec doesn't quite work either I think:
We can't remove the map from the CollectionSpec, so it will be created, duplicating the map created by hook.go. NewCollection() will overwrite the instructions we overwrote with RewriteMap to use the map it created, because RewriteMap preserves the instruction.Reference.

@lmb 's comments:

> We can't remove the map from the CollectionSpec, so it will be created, duplicating the map created by hook.go

I'm not super fussed by this, tbh. As long as the collection is closed it'll be closed afterwards. Something similar already happens for nested maps, etc.

> overwrite the instructions we overwrote with RewriteMap to use the map it created

That's an interesting case. Should the collection loader in that case refrain from patching the map twice? We could look at ins.Constant = 0.

Contributor guide

Open the contributing guide

Research direction

Start by tracing hook.Patch() and hook.go alongside ProgramSpec, CollectionSpec, NewCollection(), and RewriteMap(). Determine how map creation and instruction references interact during loading; done means hook.Patch() can operate on ProgramSpec without its rewritten instructions being overwritten or maps being patched inconsistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.