Skip to content

Commit 5eb09c9

Browse files
author
lec-bit
committed
rm OE_23_03 MARCO and optmize build
Signed-off-by: lec-bit <glfhzmy@126.com>
1 parent 9d6febf commit 5eb09c9

File tree

11 files changed

+18
-74
lines changed

11 files changed

+18
-74
lines changed

bpf/include/common.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,7 @@ static inline bool is_ipv4_mapped_addr(__u32 ip6[4])
113113
(dst)[3] = (src)[3]; \
114114
} while (0)
115115

116-
#if OE_23_03
117-
#define bpf__strncmp bpf_strncmp
118-
#define GET_SKOPS_REMOTE_PORT(sk_ops) (__u16)((sk_ops)->remote_port)
119-
#else
120116
#define GET_SKOPS_REMOTE_PORT(sk_ops) (__u16)((sk_ops)->remote_port >> 16)
121-
#endif
122-
123117
#define GET_SKOPS_LOCAL_PORT(sk_ops) (__u16)((sk_ops)->local_port)
124118

125119
#define MAX_BUF_LEN 100

bpf/kmesh/ads/include/ctx/sock_ops.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ typedef struct bpf_sock_ops ctx_buff_t;
2222
name.ipv4 = (ctx)->remote_ip4; \
2323
name.port = (ctx)->remote_port
2424

25-
#if OE_23_03
26-
#define SET_CTX_ADDRESS(ctx, address) \
27-
(ctx)->remote_ip4 = (address)->ipv4; \
28-
(ctx)->remote_port = (address)->port
29-
30-
#define MARK_REJECTED(ctx) \
31-
BPF_LOG(DEBUG, KMESH, "mark reject\n"); \
32-
(ctx)->remote_ip4 = 0; \
33-
(ctx)->remote_port = 0
34-
#else
3525
#define SET_CTX_ADDRESS(ctx, address) \
3626
(ctx)->replylong[2] = (address)->ipv4; \
3727
(ctx)->replylong[3] = (address)->port
@@ -40,6 +30,5 @@ typedef struct bpf_sock_ops ctx_buff_t;
4030
BPF_LOG(DEBUG, KMESH, "mark reject\n"); \
4131
(ctx)->replylong[2] = 0; \
4232
(ctx)->replylong[3] = 0
43-
#endif
4433

4534
#endif //__BPF_CTX_SOCK_OPS_H

build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ if [ -z "$1" -o "$1" == "-b" -o "$1" == "--build" ]; then
4848
exit
4949
fi
5050

51+
if [ "$1" == "-d" -o "$1" == "--docker" ]; then
52+
prepare
53+
make kmesh-bpf
54+
make all-binary
55+
exit
56+
fi
57+
5158
if [ "$1" == "-i" -o "$1" == "--install" ]; then
5259
make install
5360
install

config/kmesh_marcos_def.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,6 @@
2424
*/
2525
#define MDA_GID_UID_FILTER 1
2626

27-
/*
28-
* openEuler-23.03 is an innovative version of openEuler, in the early time, we
29-
* developed kmesh based on openEuler-23.03, and the implementation of kmesh
30-
* was related to the openEuler-23.03 kernel. Now, the general implementation
31-
* of kmesh differs from the previous openEuler-23.03 version, so we need to
32-
* use this macro to distinguish these differences.
33-
* The main differences between the general implementation of kmesh and the
34-
* openEuler-23.03 version are as follows:
35-
* 1. Use replylong parameter instead of directly modifying the remote IP and Port;
36-
* 2. Use bpf__strncmp instead of bpf_strncmp for string comparison;
37-
* 3. Fix Port shift bug on openEuler-23.03.In the kernel network protocol
38-
* stack, the port is stored in u16, but in the bpf network module, the port
39-
* is stored in u32. Therefore, after the endian conversion, the 16-bit port
40-
* needs to be obtained from the 32-bit data structure.
41-
* You need to find the position of the valid 16 bits. Generally, after the
42-
* port is extended from 16 bits to 32 bits, the port is in the upper 16
43-
* bits after the endian conversion. Therefore, you need to offset the port
44-
* before using the u16 RX port. In some specific kernels, the port stored
45-
* in sockops is in the lower 16 bits and does not need to be offset.
46-
*/
47-
#define OE_23_03 0
48-
4927
/*
5028
* in kernel 6.x version, add the new iter type ITER_UBUF, and we need add code
5129
* for the corresponding scenarios.

hack/gen_bpf_specs.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ func main() {
167167
importPath := filepath.ToSlash(filepath.Join(modulePrefix, "bpf", "kmesh", "bpf2go", real))
168168
pi := pkgInfo{Alias: alias, ImportPath: importPath, OutputDir: real, Entries: list}
169169
pkgsDefault = append(pkgsDefault, pi)
170-
pkgsEnhanced = append(pkgsEnhanced, pi)
170+
if !strings.HasPrefix(real, "dualengine") {
171+
pkgsEnhanced = append(pkgsEnhanced, pi)
172+
}
171173
}
172174
}
173175
}

hack/utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function get_arch() {
3030
function build_kmesh() {
3131
local container_id=$1
3232
docker exec $container_id git config --global --add safe.directory /kmesh
33-
docker exec -e VERSION=$VERSION $container_id sh /kmesh/build.sh
33+
docker exec -e VERSION=$VERSION $container_id sh /kmesh/build.sh -d
3434
docker exec -e VERSION=$VERSION $container_id sh /kmesh/build.sh -i
3535
docker exec $container_id sh -c "$(declare -f copy_to_host); copy_to_host"
3636
}

kernel/ko_src/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ CURRENT_PATH := $(shell pwd)
22
DIRS := $(shell find $(CURRENT_PATH) -maxdepth 1 -type d)
33
BASE_DIRS := $(basename $(patsubst $(CURRENT_PATH)/%, %, $(DIRS)))
44
BASE_DIRS := $(filter-out $(CURRENT_PATH), $(BASE_DIRS))
5+
CONFIG_FILE := ../../config/kmesh_marcos_def.h
6+
ENHANCED_KERNEL := $(shell grep -q "#define ENHANCED_KERNEL 1" $(CONFIG_FILE) && echo yes || echo no)
57

6-
ifeq ($(ENHANCED_KERNEL), enhanced)
8+
ifeq ($(ENHANCED_KERNEL), yes)
79
all:
810
@for dir in ${BASE_DIRS}; do \
911
make -C $(CURRENT_PATH)/$$dir; \

kernel/ko_src/kmesh/defer_connect.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,31 +79,11 @@ static int defer_connect(struct sock *sk, struct msghdr *msg, size_t size)
7979
tmpMem.size = kbuf_size;
8080
tmpMem.ptr = kbuf;
8181

82-
#if OE_23_03
83-
tcp_call_bpf_3arg(
84-
sk,
85-
BPF_SOCK_OPS_TCP_DEFER_CONNECT_CB,
86-
((u64)(&tmpMem) & U32_MAX),
87-
(((u64)(&tmpMem) >> 32) & U32_MAX),
88-
kbuf_size);
89-
daddr = sk->sk_daddr;
90-
dport = sk->sk_dport;
91-
92-
// daddr == 0 && dport == 0 are special flags meaning the circuit breaker is open
93-
// Should reject connection here
94-
if (daddr == 0 && dport == 0) {
95-
tcp_set_state(sk, TCP_CLOSE);
96-
sk->sk_route_caps = 0;
97-
inet_sk(sk)->inet_dport = 0;
98-
err = -1;
99-
goto out;
100-
}
101-
#else
10282
uaddr.sin_family = AF_INET;
10383
uaddr.sin_addr.s_addr = daddr;
10484
uaddr.sin_port = dport;
10585
err = BPF_CGROUP_RUN_PROG_INET4_CONNECT_KMESH(sk, (struct sockaddr *)&uaddr, &tmpMem);
106-
#endif
86+
10787
connect:
10888
err = sk->sk_prot->connect(sk, (struct sockaddr *)&uaddr, sizeof(struct sockaddr_in));
10989
if (unlikely(err)) {

oncn-mda/include/mesh_accelerate.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,7 @@ enum bpf_loglevel {
2121
};
2222

2323
#define BPF_LOGLEVEL BPF_LOG_ERROR
24-
25-
#if OE_23_03
26-
#define GET_SKOPS_REMOTE_PORT(sk_ops) (__u16)((sk_ops)->remote_port)
27-
#else
2824
#define GET_SKOPS_REMOTE_PORT(sk_ops) (__u16)((sk_ops)->remote_port >> 16)
29-
#endif
30-
3125
#define GET_SKOPS_LOCAL_PORT(sk_ops) (__u16)((sk_ops)->local_port)
3226

3327
#ifndef bpf_printk

pkg/bpf/restart/new_version_mapspec_loader_enhanced.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)