forked from linuxkerneltravel/lmp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
995eed9
commit 8b3deee
Showing
8 changed files
with
1,643 additions
and
1 deletion.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
eBPF_Supermarket/Network_Subsystem/net_manager/net_manager/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
96 changes: 96 additions & 0 deletions
96
eBPF_Supermarket/Network_Subsystem/net_manager/net_manager/common_kern_user.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ |
2 changes: 2 additions & 0 deletions
2
eBPF_Supermarket/Network_Subsystem/net_manager/net_manager/conf.d/black_ipv4.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
2 changes: 2 additions & 0 deletions
2
eBPF_Supermarket/Network_Subsystem/net_manager/net_manager/conf.d/mac_load.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
2 changes: 2 additions & 0 deletions
2
eBPF_Supermarket/Network_Subsystem/net_manager/net_manager/conf.d/router_load.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.