-
Notifications
You must be signed in to change notification settings - Fork 685
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
prog: Allow empty data for prog.Test and prog.Run #685
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test for this? AFAIR SK_LOOKUP programs will refuse to run if given DataIn, so you can use that to make sure this works.
Ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long wait, there has been some PTO in between. Thanks for your patience! Left some minor comments.
internal/cmd/gentypes/main.go
Outdated
@@ -179,6 +179,13 @@ import ( | |||
{"FuncInfo", "bpf_func_info", nil}, | |||
{"LineInfo", "bpf_line_info", nil}, | |||
{"XdpMd", "xdp_md", nil}, | |||
{ | |||
"BpfSkLookup", "bpf_sk_lookup", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lmb Shouldn't this be BPFSKLookup
? Same for XdpMd
and BtfInfo
above. :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's easier to automate generating names like BtfInfo
vs capitalising some things.
prog_test.go
Outdated
Family: 2, /* AF_INET */ | ||
} | ||
opts := RunOptions{ | ||
Data: []byte{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be removed, the call to sys.NewSlicePointer(opts.Data)
in testRun() will return a Pointer{}
whether Data is nil or length 0.
prog_test.go
Outdated
defer prog.Close() | ||
|
||
skLookup := sys.BpfSkLookup{ | ||
Family: 2, /* AF_INET */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to add an entry to internal/unix/types_*.go
.
Will be used for unit testing BPF_PROG_TYPE_SK_LOOKUP progs. IPs are stored as arrays of bytes to make use from Go easier.
Certain prog types (SK_LOOKUP, RAW_TRACEPOINT and RAW_TRACEPOINT_WRITABLE) require that data_in is NULL. The previous check prevented 0 length data_in. Fix by removing check.
Sorry for the long delay, I wasn't aware that you had made changes and then I was busy with life when you pinged me. Thanks for following up :) |
Certain prog types (SK_LOOKUP, RAW_TRACEPOINT and
RAW_TRACEPOINT_WRITABLE) require that data_in is NULL. The previous
check prevented 0 length data_in.
Fix by removing check.
Followup from #647.