mirror of
https://github.com/h3xduck/TripleCross.git
synced 2025-12-27 03:43:09 +08:00
Completed detachment of probes, enabling to attach and detach at will. Work needs to be done with xdp tho
This commit is contained in:
@@ -22,6 +22,4 @@ typedef struct module_config_t{
|
||||
|
||||
extern module_config_t module_config;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <bpf/libbpf.h>
|
||||
#include "xdp_filter.skel.h"
|
||||
|
||||
//Connections
|
||||
int attach_handle_sched_process_exec(struct xdp_filter_bpf *skel){
|
||||
skel->links.handle_sched_process_exec = bpf_program__attach(skel->progs.handle_sched_process_exec);
|
||||
return libbpf_get_error(skel->links.handle_sched_process_exec);
|
||||
@@ -15,4 +16,17 @@ int attach_sched_all(struct xdp_filter_bpf *skel){
|
||||
}
|
||||
|
||||
|
||||
//Disconnections
|
||||
int detach_link_generic(struct bpf_link *link){
|
||||
int ret = bpf_link__destroy(link);
|
||||
if(ret!=0){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int detach_sched_all(struct xdp_filter_bpf *skel){
|
||||
return detach_link_generic(skel->links.handle_sched_process_exec);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -46,9 +46,10 @@ int attach_xdp_all(struct xdp_filter_bpf *skel, __u32 ifindex, __u32 flags){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int detach_xdp_all(__u32 fd, __u32 ifindex, __u32 flags){
|
||||
int detach_xdp_all(__u32 ifindex, __u32 fd, __u32 flags){
|
||||
int err = bpf_set_link_xdp_fd(ifindex, fd, flags);
|
||||
if(err<0){
|
||||
perror("j");
|
||||
fprintf(stderr, "Failed to detach XDP program\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user