-
Notifications
You must be signed in to change notification settings - Fork 16
Conversation
go.mod
Outdated
@@ -8,6 +8,7 @@ require ( | |||
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 | |||
github.com/google/gofuzz v1.1.0 | |||
github.com/google/uuid v1.3.0 | |||
github.com/intel/afxdp-plugins-for-kubernetes/pkg/goclient v0.0.0-20230728160820-93d43de9a412 |
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.
can you check if it works with just v0.0.0, like the import below?
go.mod
Outdated
@@ -22,3 +23,5 @@ require ( | |||
) | |||
|
|||
replace github.com/intel/afxdp-plugins-for-kubernetes/pkg/subfunctions => ./pkg/subfunctions | |||
|
|||
replace github.com/intel/afxdp-plugins-for-kubernetes/pkg/goclient => ./pkg/goclient |
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.
NIT: remove blank line between "replace" lines and always try have a blank line at the very bottom of the file, i.e. just under last "replace" line
pkg/cclient/README.md
Outdated
@@ -0,0 +1,67 @@ | |||
#Compiling the C Library |
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.
Just a general comment on your readme - your headings aren't working, I think you need a space after the # symbols
https://github.com/intel/afxdp-plugins-for-kubernetes/blob/07ae9f57207f0fb19d517734bd9055b051e6b2ef/pkg/cclient/README.md
pkg/cclient/README.md
Outdated
@@ -0,0 +1,67 @@ | |||
#Compiling the C Library | |||
|
|||
>NOTE: You may have to run ```go get github.com/intel/afxdp-plugins-for-kubernetes/pkg/goclient@93d43de``` |
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.
You can remove this, was just a note for you as I had only just merged your goclient
pkg/cclient/README.md
Outdated
```go build -o lib_udsclient.so -buildmode=c-shared cclient.go``` | ||
- this creates .h and .so files from the cclient.go file. | ||
|
||
```cp lib_udsclient.so /lib``` |
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.
You've gone above and beyond here on build documentation, no need for anything beyond how to generate the .so
.a
and .h
files. A C developer will know how to take it from there.
All the "test app" stuff I just sent to yourself for your own info and testing.
This build section of the readme will be very short...
pkg/cclient/cclient.go
Outdated
return C.CString(response), -1 | ||
} | ||
|
||
cleaners[0] = function |
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.
These can be removed in favor of a single global variable.
We should also be able to assign that variable directly when we're calling the goclient, see the code snippet in the comment at line 34.
pkg/cclient/cclient.go
Outdated
return 0, errVal | ||
} | ||
|
||
cleaners[1] = function |
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.
These can be removed in favor of a single global variable.
pkg/cclient/cclient.go
Outdated
ServerVersion is an exported version for c of goclient's XskMapFd() | ||
*/ | ||
//export XskMapFd | ||
func XskMapFd(device *C.char) (fd, errVal C.int) { |
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.
Again, watch the function name and we need a single return value, the fd which is a C.int
Check your error and handle it just like the version function.
Return a -1 int if there are any problems.
pkg/cclient/cclient.go
Outdated
ServerVersion is an exported version for c of goclient's RequestBusyPoll() | ||
*/ | ||
//export RequestBusyPoll | ||
func RequestBusyPoll(busyTimeout, busyBudget, fd int) C.int { |
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.
This function is fine, good name, single return, handling the error from the Go client (maybe just update the error handling with error message like the rest).
I think the variables you're passing in busyTimeout, busyBudget, fd
all need to be of type C.int ?
It might complain about type mismatch, not sure. You might then need to convert/cast them to Go ints to pass to your Go client. I think it'll look something like:
CleanupFunc, err := goclient.RequestBusyPoll(int(busyTimeout), int(busyBudget), int(fd))
pkg/cclient/cclient.go
Outdated
Pass in one of the available function names to clean up the connection after use. | ||
*/ | ||
//export CleanUpConnection | ||
func CleanUpConnection(function *C.char) { |
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.
Cleanup function is way too complicated. I think you need to simply:
- check the global variable, I'm referring to it as CleanupFunc, is not nil
- call it
All of the go client functions return a cleanup function, but it's the exact same function they're all returning, so I think it's fine just to have a single variable to that function, rather than an array of functions.
They all just return this:
https://github.com/intel/afxdp-plugins-for-kubernetes/blob/main/internal/uds/uds.go#L297
Again "CloseUdsConnection" might be a little more readable in C
d951400
to
03efbad
Compare
Quick thing: The changes to the UDS Server seem to have been overwritten by my first force-push, I think it's because the branch I was working on didn't branch off of main before I changed the UDS server |
03efbad
to
7a86b34
Compare
Signed-off-by: phansGithub <[email protected]>
7a86b34
to
32ac1d3
Compare
pkg/cclient/README.md
Outdated
@@ -0,0 +1,36 @@ | |||
# Compiling the C Library | |||
|
|||
## Creating the .h and the .so files: |
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.
## Creating the .h and the .so files: | |
## Creating the shared library and header files: |
pkg/cclient/README.md
Outdated
## Creating the .h and the .so files: | ||
|
||
|
||
```go build -o lib_udsclient.so -buildmode=c-shared cclient.go``` |
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.
```go build -o lib_udsclient.so -buildmode=c-shared cclient.go``` | |
```cmd | |
go build -o lib_udsclient.so -buildmode=c-shared cclient.go |
Again I'm surprised the linter didn't flag this
pkg/cclient/README.md
Outdated
- this creates .h and .so files from the cclient.go file. | ||
|
||
|
||
## Creating the .h and the .a files: |
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.
## Creating the .h and the .a files: | |
## Creating the static library and header files: |
pkg/cclient/README.md
Outdated
|
||
## Creating the .h and the .a files: | ||
|
||
```go build -o lib_udsclient.a -buildmode=c-archive ./cclient.go``` |
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.
```go build -o lib_udsclient.a -buildmode=c-archive ./cclient.go``` | |
```cmd | |
go build -o lib_udsclient.a -buildmode=c-archive ./cclient.go |
pkg/cclient/README.md
Outdated
This returns the version of our handshake on the server/host. | ||
|
||
```int RequestXskMapFd(char* device)``` | ||
This requests an Xsk map Fd for a specifed device. |
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.
This requests an Xsk map Fd for a specifed device. | |
This requests an xskmap Fd for a specified device. |
pkg/cclient/README.md
Outdated
|
||
```void CleanUpConnection()``` | ||
After all the other functions are called, this needs to be called after all the work you need to do is done, | ||
so that the connection to the Uds can be cleaned up. |
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.
so that the connection to the Uds can be cleaned up. | |
so that the connection to the UDS can be cleaned up. |
pkg/cclient/cclient.go
Outdated
var cleaner uds.CleanupFunc | ||
|
||
/* | ||
GetClientVersion is an exported version for c of goclient's GetClientVersion() |
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.
GetClientVersion is an exported version for c of goclient's GetClientVersion() | |
GetClientVersion is an exported version for c of the goclient GetClientVersion() |
same throughout the file... I don't think goclient's
is grammatically correct
pkg/cclient/cclient.go
Outdated
*/ | ||
//export RequestXskMapFd | ||
func RequestXskMapFd(device *C.char) (fd C.int) { | ||
fdVal, function, err := goclient.RequestXSKmapFD(C.GoString(device)) |
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.
should you check device isn't Nil before passing it along to RequestXSKmapFD
pkg/cclient/cclient.go
Outdated
*/ | ||
//export RequestBusyPoll | ||
func RequestBusyPoll(busyTimeout, busyBudget, fd C.int) C.int { | ||
function, err := goclient.RequestBusyPoll(int(busyTimeout), int(busyBudget), int(fd)) |
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.
should probably do some param error checking before calling RequestBusyPoll
Signed-off-by: phansGithub <[email protected]>
ae286cc
to
89ebed7
Compare
This is to wrap the go client library for c using cgo, however there are two commits caused by syncing the fork, so maybe I can try squashing the commits together because one of the commits is just a merge.