-
Notifications
You must be signed in to change notification settings - Fork 94
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
chore(prog): Add attach/detach legacy api for xdp #438
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.
That's great. I placed some requests. As soon as they are addressed I will do the final tests. Tks.
prog.go
Outdated
optsC := &C.struct_bpf_xdp_attach_opts{ | ||
sz: C.ulong(unsafe.Sizeof(C.struct_bpf_xdp_attach_opts{})), | ||
old_prog_fd: 0, | ||
} |
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 convert these instantiations to use the structure handlers
pattern found in libbpfgo.h
, since cgo has problems with structure packaging and field offsets? By instance:
- cgo_bpf_xdp_attach_opts_new
- cgo_bpf_xdp_attach_opts_free
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.
done
prog.go
Outdated
optsC := &C.struct_bpf_xdp_attach_opts{ | ||
sz: C.ulong(unsafe.Sizeof(C.struct_bpf_xdp_attach_opts{})), | ||
old_prog_fd: C.int(p.FileDescriptor()), | ||
} |
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.
ditto
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.
done
prog-common.go
Outdated
// XDPFlags | ||
type XDPFlags uint32 | ||
|
||
const ( | ||
XDPFlagsUpdateIfNoExist XDPFlags = C.XDP_FLAGS_UPDATE_IF_NOEXIST | ||
XDPFlagsSkbMode XDPFlags = C.XDP_FLAGS_SKB_MODE | ||
XDPFlagsDrvMode XDPFlags = C.XDP_FLAGS_DRV_MODE | ||
XDPFlagsHwMode XDPFlags = C.XDP_FLAGS_HW_MODE | ||
XDPFlagsReplace XDPFlags = C.XDP_FLAGS_REPLACE | ||
XDPFlagsModes XDPFlags = C.XDP_FLAGS_MODES | ||
XDPFlagsMask XDPFlags = C.XDP_FLAGS_MASK | ||
) | ||
|
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.
Please move this block to the end of the file following the comment pattern.
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.
done
Hi, geyslan, thank you for your reply, i will do it later! |
The AttachXDP api use bpf link to attach xdp prog, AttachXDPLegacy/DetachXDPLegacy apis corresponds to bpf_xdp_attach/bpf_xdp_detach, which can be used on old kernel, so add it. Signed-off-by: Tao Chen <[email protected]>
43a3f7d
to
b8df610
Compare
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.
LGTM. @chentao-kernel thanks a lot.
The AttachXDP api use bpf link to attach xdp prog, AttachXDPLegacy/DetachXDPLegacy apis corresponds to bpf_xdp_attach/bpf_xdp_detach, which can be used on old kernel, so add it.