Skip to content

Commit

Permalink
net_manager
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhangchannel committed Jun 3, 2024
1 parent 995eed9 commit 8b3deee
Show file tree
Hide file tree
Showing 8 changed files with 1,643 additions and 1 deletion.
1 change: 0 additions & 1 deletion eBPF_Supermarket/Network_Subsystem/net_manager/lib/libbpf
Submodule libbpf deleted from 2778cb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)

XDP_TARGETS := xdp_prog_kern
USER_TARGETS := xdp_loader

COMMON_DIR = ../common

# Extend with another COMMON_OBJS
COMMON_OBJS += $(COMMON_DIR)/common_user_bpf_xdp.o


EXTRA_DEPS := $(COMMON_DIR)/parsing_helpers.h

include $(COMMON_DIR)/common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* This common_kern_user.h is used by kernel side BPF-progs and
* userspace programs, for sharing common struct's and DEFINEs.
*/
#ifndef __COMMON_KERN_USER_H
#define __COMMON_KERN_USER_H

#include <linux/bpf.h>

typedef __u32 xdp_act;
#define ETH_ALEN 6

#define ALERT_ERR_STR "[XACL] ERROR:"


#define MAX_RULES 256


#ifndef PATH_MAX
#define PATH_MAX 4096
#endif

//#define DEBUG_PRINT
//#define DEBUG_PRINT_EVERY

struct datarec {
__u64 rx_packets;
__u64 rx_bytes;
};

struct conn_ipv4 {
__u32 saddr;
__u32 daddr;
__u16 sport;
__u16 dport;
__u16 ip_proto;
};

struct rules_ipv4 {
__u32 saddr;
__u32 daddr;
__u8 saddr_mask;
__u8 daddr_mask;
__u16 sport;
__u16 dport;
__u16 ip_proto;
__u16 action;
__u16 prev_rule;
__u16 next_rule;
};


// 转发表项
struct rt_item {
__u32 saddr;
__u8 eth_source[ETH_ALEN]; // 封装帧的源MAC地址。
__u8 eth_dest[ETH_ALEN]; // 封装帧的目标MAC地址。
};

// mac 过滤
struct mac_addr {
__u8 addr[ETH_ALEN];
};


// 会话保持
struct conn_ipv4_key {
__u32 saddr;
__u32 daddr;
__u16 sport;
__u16 dport;
__u16 proto;
};

struct conn_ipv4_val {
__u32 tcp_state;
__u32 rid;
};

enum {
TCP_S_NONE = 0U,
TCP_S_ESTABLISHED,
TCP_S_SYN_SENT,
TCP_S_SYN_RECV,
TCP_S_FIN_WAIT1,
TCP_S_FIN_WAIT2,
TCP_S_CLOSE_WAIT,
TCP_S_CLOSE,
};



#ifndef XDP_ACTION_MAX
#define XDP_ACTION_MAX (XDP_REDIRECT + 1)
#endif

#endif /* __COMMON_KERN_USER_H */
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
192.168.207.138/0 192.168.207.177/0 0 0 0 DENY
192.168.207.129/0 192.168.207.177/0 0 0 0 ALLOW
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
00:0c:29:dd:17:2c DENY
00:0c:29:fd:69:58 DENY
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0.0.0.0 00:0c:29:7b:a6:d9 00:0c:29:fd:69:58
1.2.3.4 00:0c:29:7b:a6:d9 00:0c:29:dd:17:2c
Loading

0 comments on commit 8b3deee

Please sign in to comment.