Skip to content
Snippets Groups Projects
Commit e8a33796 authored by NGUYEN Do Duc Anh's avatar NGUYEN Do Duc Anh
Browse files

undo deploy from bpg since scapy not always catch

parent f1ee75e3
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,7 @@ struct FirewallRequest
// entry.inter_val, pkt_dst, entry.cmd_val
// BPF_QUEUE(queue, struct FirewallRequest, 10240);
BPF_QUEUE(queue, struct FirewallRequest, 10240);
int op_ebpf(struct xdp_md *ctx)
{
......@@ -137,19 +137,19 @@ int op_ebpf(struct xdp_md *ctx)
// bpf_trace_printk("Count %d", (__u32)option_count);
// bpf_trace_printk("ID %u, Inter %u, CMD %u", (__u32)id_val, (__u32)inter_val, (__u32)cmd_val);
// if (cmd_val == DROP)
// {
// if (id_val == MY_NODE_ID)
// {
// struct FirewallRequest req = {};
// req.ip_dst = addition_info; // Store as __u32 (network byte order)
// req.entry_inter_val = inter_val;
// req.entry_cmd_val = DROP;
//
// queue.push(&req, 0);
// }
// }
if (cmd_val == REGISTER)
if (cmd_val == DROP)
{
if (id_val == MY_NODE_ID)
{
struct FirewallRequest req = {};
req.ip_dst = addition_info; // Store as __u32 (network byte order)
req.entry_inter_val = inter_val;
req.entry_cmd_val = DROP;
queue.push(&req, 0);
}
}
else if (cmd_val == REGISTER)
{
__u16 id_val_2nd = bpf_ntohs((__u16)(addition_info >> 16));
if (id_val_2nd == 0)
......
......@@ -116,21 +116,21 @@ def start_process_from_queue():
print("Attach the ebpf program at", inter_name)
try:
# request_queue = b[b'queue']
#
request_queue = b[b'queue']
while True:
b.trace_print()
# try:
# req = request_queue.pop()
# entry_inter_val, ip_dst, entry_cmd_val = struct.unpack("III", req)
# ip_dst_le = struct.unpack("<I", struct.pack(">I", ip_dst))[0] # Convert to little-endian
# ip_str = socket.inet_ntoa(struct.pack("!I", ip_dst_le))
#
# # print(f"Entry: {entry_inter_val}, IP: {ip_str}, Cmd: {entry_cmd_val}")
# FirewallOpportunistic.firewall_queue.put((entry_inter_val, ip_str, entry_cmd_val))
# # time.sleep(1)
# except KeyError:
# continue
# b.trace_print()
try:
req = request_queue.pop()
entry_inter_val, ip_dst, entry_cmd_val = struct.unpack("III", req)
ip_dst_le = struct.unpack("<I", struct.pack(">I", ip_dst))[0] # Convert to little-endian
ip_str = socket.inet_ntoa(struct.pack("!I", ip_dst_le))
# print(f"Entry: {entry_inter_val}, IP: {ip_str}, Cmd: {entry_cmd_val}")
FirewallOpportunistic.firewall_queue.put((entry_inter_val, ip_str, entry_cmd_val))
# time.sleep(1)
except KeyError:
continue
except Exception as e:
print(f"ERROR {e}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment