-
Notifications
You must be signed in to change notification settings - Fork 175
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
zmx
committed
Jun 14, 2024
1 parent
68b824c
commit 54aecc5
Showing
7 changed files
with
164 additions
and
19 deletions.
There are no files selected for viewing
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
1 change: 0 additions & 1 deletion
1
eBPF_Supermarket/Network_Subsystem/net_watcher/data/connects.log
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 |
---|---|---|
@@ -1 +0,0 @@ | ||
connection{pid="214827",sock="0xffff944e0c3dda00",src="192.168.239.132:35422",dst="20.189.173.1:443",is_server="0",backlog="-",maxbacklog="-",cwnd="-",ssthresh="-",sndbuf="-",wmem_queued="-",rx_bytes="-",tx_bytes="-",srtt="-",duration="-",total_retrans="-",fast_retrans="-",timeout_retrans="-"} | ||
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
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
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
47 changes: 47 additions & 0 deletions
47
eBPF_Supermarket/Network_Subsystem/net_watcher/redis.bpf.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,47 @@ | ||
// Copyright 2023 The LMP Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://github.com/linuxkerneltravel/lmp/blob/develop/LICENSE | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// author: [email protected] | ||
// mysql | ||
|
||
#include "common.bpf.h" | ||
#include "redis_helper.bpf.h" | ||
|
||
static __always_inline int __handle_redis_start(struct pt_regs *ctx) { | ||
struct client *cli = (struct client *)PT_REGS_PARM1(ctx); | ||
int argc; | ||
char name; | ||
int argv_len; | ||
bpf_probe_read(&argc, sizeof(argc), &cli->argc); | ||
robj **arg0; | ||
robj *arg1; | ||
//unsigned type; | ||
unsigned encoding; | ||
unsigned lru; | ||
int refcount; | ||
bpf_probe_read(&arg0, sizeof(arg0), &cli->argv); | ||
|
||
// 读取 argv[0],即第一个命令参数 | ||
bpf_probe_read(&arg1, sizeof(arg1), &arg0[1]); | ||
|
||
// 读取 argv[0]->ptr 中的字符串 | ||
bpf_probe_read(&name, sizeof(name),&arg1->ptr); | ||
bpf_probe_read(&argv_len, sizeof(argv_len), &cli->argv_len_sum); | ||
; | ||
bpf_printk("%d %s %d",argc,name,argv_len); | ||
|
||
pid_t pid = bpf_get_current_pid_tgid() >> 32; | ||
return 0; | ||
} | ||
|
55 changes: 55 additions & 0 deletions
55
eBPF_Supermarket/Network_Subsystem/net_watcher/redis_helper.bpf.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,55 @@ | ||
// Copyright 2023 The LMP Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://github.com/linuxkerneltravel/lmp/blob/develop/LICENSE | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// author: [email protected] | ||
// | ||
// netwatcher libbpf 内核<->用户 传递信息相关结构体 | ||
|
||
#ifndef __REDIS_HELPER_BPF_H | ||
#define __REDIS_HELPER_BPF_H | ||
|
||
#include "netwatcher.h" | ||
#include "vmlinux.h" | ||
#include <asm-generic/errno.h> | ||
#include <bpf/bpf_core_read.h> | ||
#include <bpf/bpf_endian.h> | ||
#include <bpf/bpf_helpers.h> | ||
#include <bpf/bpf_tracing.h> | ||
#include <string.h> | ||
|
||
#define LRU_BITS 24 | ||
typedef struct redisObject { | ||
unsigned type:4; | ||
unsigned encoding:4; | ||
unsigned lru:LRU_BITS; | ||
int refcount; | ||
void *ptr; | ||
} robj; | ||
|
||
struct client { | ||
u64 id; /* Client incremental unique ID. */ | ||
u64 conn; | ||
int resp; /* RESP protocol version. Can be 2 or 3. */ | ||
u64 db; /* Pointer to currently SELECTed DB. */ | ||
robj *name; /* As set by CLIENT SETNAME. */ | ||
char* querybuf; /* Buffer we use to accumulate client queries. */ | ||
unsigned long qb_pos; /* The position we have read in querybuf. */ | ||
char* pending_querybuf; | ||
unsigned long querybuf_peak; /* Recent (100ms or more) peak of querybuf size. */ | ||
int argc; /* Num of arguments of current command. */ | ||
robj **argv; /* Arguments of current command. */ | ||
unsigned long argv_len_sum; /* Size of argv array (may be more than argc) */ | ||
}; | ||
|
||
#endif |