Repository: kmesh-net/kmesh

Issue:
Pretty print config dump
<!-- Please only use this template for submitting enhancement requests -->
**What would you like to be added**:
Pretty print the kmesh config dump, currently the config dump like:
```json
{
    "WorkloadPolicies": null,
    "Backends": [
        {
            "Ip": [
                121,
                41,
                28,
                169,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0
            ],
            "ServiceCount": 1,
            "Services": [
                3646867460,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0
            ],
            "WaypointAddr": [
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0
            ],
      ...
```
which is not an easy task to check the config.

**Why is this needed**:


Discussion:
@LiZhenCheng9527: https://github.com/kmesh-net/kmesh/issues/1117

Similar requests have been made previously.
We can talk about it in our regular meeting@LiZhenCheng9527: /assign @Kuromesi 

Solution patch:
diff --git a/Makefile b/Makefile
index 43b6d15a..f7bd28b7 100644
--- a/Makefile
+++ b/Makefile
@@ -82,8 +82,7 @@ ifeq ($(TAG),)
   $(error "TAG cannot be empty")
 endif
 
-TMP_FILES := bpf/kmesh/bpf2go/bpf2go.go \
-	config/kmesh_marcos_def.h \
+TMP_FILES := config/kmesh_marcos_def.h \
 	mk/api-v2-c.pc \
 	mk/bpf.pc \
 	bpf/include/bpf_helper_defs_ext.h \
diff --git a/bpf/include/bpf_common.h b/bpf/include/bpf_common.h
index bd556e99..2a739fe1 100644
--- a/bpf/include/bpf_common.h
+++ b/bpf/include/bpf_common.h
@@ -223,4 +223,86 @@ static inline void *get_ptr_val_from_map(void *map, __u8 map_type, const void *p
         val_tmp;                                                                                                       \
     })
 
+static inline void record_kmesh_managed_ip(__u32 family, __u32 ip4, __u32 *ip6)
+{
+    int err;
+    __u32 value = 0;
+    struct manager_key key = {0};
+    if (family == AF_INET)
+        key.addr.ip4 = ip4;
+    if (family == AF_INET6 && ip6)
+        IP6_COPY(key.addr.ip6, ip6);
+
+    err = bpf_map_update_elem(&map_of_manager, &key, &value, BPF_ANY);
+    if (err)
+        BPF_LOG(ERR, KMESH, "record ip failed, err is %d\n", err);
+}
+
+static inline void remove_kmesh_managed_ip(__u32 family, __u32 ip4, __u32 *ip6)
+{
+    struct manager_key key = {0};
+    if (family == AF_INET)
+        key.addr.ip4 = ip4;
+    if (family == AF_INET6 && ip6)
+        IP6_COPY(key.addr.ip6, ip6);
+
+    int err = bpf_map_delete_elem(&map_of_manager, &key);
+    if (err && err != -ENOENT)
+        BPF_LOG(ERR, KMESH, "remove ip failed, err is %d\n", err);
+}
+
+static inline bool conn_from_sim(struct bpf_sock_ops *skops, __u32 ip, __u16 port)
+{
+    __u16 remote_port = GET_SKOPS_REMOTE_PORT(skops);
+    if (bpf_ntohs(remote_port) != port)
+        return false;
+
+    if (skops->family == AF_INET)
+        return (bpf_ntohl(skops->remote_ip4) == ip);
+
+    return (
+        skops->remote_ip6[0] == 0 && skops->remote_ip6[1] == 0 && skops->remote_ip6[2] == 0
+        && bpf_ntohl(skops->remote_ip6[3]) == ip);
+}
+
+static inline bool skops_conn_from_cni_sim_add(struct bpf_sock_ops *skops)
+{
+    // cni sim connect CONTROL_CMD_IP:929(0x3a1)
+    // 0x3a1 is the specific port handled by the cni to enable Kmesh
+    return conn_from_sim(skops, CONTROL_CMD_IP, ENABLE_KMESH_PORT);
+}
+
+static inline bool skops_conn_from_cni_sim_delete(struct bpf_sock_ops *skops)
+{
+    // cni sim connect CONTROL_CMD_IP:930(0x3a2)
+    // 0x3a2 is the specific port handled by the cni to disable Kmesh
+    return conn_from_sim(skops, CONTROL_CMD_IP, DISABLE_KMESH_PORT);
+}
+
+static inline void skops_handle_kmesh_managed_process(struct bpf_sock_ops *skops)
+{
+    if (skops_conn_from_cni_sim_add(skops))
+        record_kmesh_managed_ip(skops->family, skops->local_ip4, skops->local_ip6);
+    if (skops_conn_from_cni_sim_delete(skops))
+        remove_kmesh_managed_ip(skops->family, skops->local_ip4, skops->local_ip6);
+}
+
+static inline bool is_managed_by_kmesh(struct bpf_sock_ops *skops)
+{
+    struct manager_key key = {0};
+    if (skops->family == AF_INET)
+        key.addr.ip4 = skops->local_ip4;
+    if (skops->family == AF_INET6) {
+        if (is_ipv4_mapped_addr(skops->local_ip6))
+            key.addr.ip4 = skops->local_ip6[3];
+        else
+            IP6_COPY(key.addr.ip6, skops->local_ip6);
+    }
+
+    int *value = bpf_map_lookup_elem(&map_of_manager, &key);
+    if (!value)
+        return false;
+    return (*value == 0);
+}
+
 #endif
\ No newline at end of file
diff --git a/bpf/kmesh/ads/sockops.c b/bpf/kmesh/ads/sockops.c
index e7800842..20c12e5f 100644
--- a/bpf/kmesh/ads/sockops.c
+++ b/bpf/kmesh/ads/sockops.c
@@ -19,7 +19,13 @@ int sockops_prog(struct bpf_sock_ops *skops)
         return BPF_OK;
 
     switch (skops->op) {
+    case BPF_SOCK_OPS_TCP_CONNECT_CB:
+        skops_handle_kmesh_managed_process(skops);
+        break;
     case BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB:
+        if (!is_managed_by_kmesh(skops))
+            break;
+
         if (bpf_sock_ops_cb_flags_set(skops, BPF_SOCK_OPS_STATE_CB_FLAG) != 0) {
             BPF_LOG(ERR, SOCKOPS, "set sockops cb failed!\n");
         } else {
diff --git a/bpf/kmesh/bpf2go/bpf2go.go b/bpf/kmesh/bpf2go/bpf2go.go
index 1ef4aa61..f79735de 100644
--- a/bpf/kmesh/bpf2go/bpf2go.go
+++ b/bpf/kmesh/bpf2go/bpf2go.go
@@ -18,18 +18,18 @@
 package bpf2go
 
 // go run github.com/cilium/ebpf/cmd/bpf2go --help
-//go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir kernelnative/normal --go-package normal -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshCgroupSock ../ads/cgroup_sock.c -- -I../ads/include -I../../include -I../../../api/v2-c -DCGROUP_SOCK_MANAGE -DKERNEL_VERSION_HIGHER_5_13_0=1
+//go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir kernelnative/$ENHANCED_KERNEL --go-package $ENHANCED_KERNEL -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshCgroupSock ../ads/cgroup_sock.c -- -I../ads/include -I../../include -I../../../api/v2-c -DCGROUP_SOCK_MANAGE -DKERNEL_VERSION_HIGHER_5_13_0=1
 //go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir dualengine --go-package dualengine -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshCgroupSockWorkload ../workload/cgroup_sock.c -- -I../workload/include -I../../include -I../probes -DKERNEL_VERSION_HIGHER_5_13_0=1
-//go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir kernelnative/enhanced --go-package enhanced -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshSockops ../ads/sockops.c -- -I../ads/include -I../../include -I../../../api/v2-c -DKERNEL_VERSION_HIGHER_5_13_0=1
+//go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir kernelnative/$ENHANCED_KERNEL --go-package $ENHANCED_KERNEL -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshSockops ../ads/sockops.c -- -I../ads/include -I../../include -I../../../api/v2-c -DKERNEL_VERSION_HIGHER_5_13_0=1
 //go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir dualengine --go-package dualengine -cc clang --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshSockopsWorkload ../workload/sockops.c -- -I../workload/include -I../../include -I../probes -DKERNEL_VERSION_HIGHER_5_13_0=1
 //go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir dualengine --go-package dualengine -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshXDPAuth ../workload/xdp.c -- -I../workload/include -I../../include -I../../../api/v2-c -DKERNEL_VERSION_HIGHER_5_13_0=1
 //go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir dualengine --go-package dualengine -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshSendmsg ../workload/sendmsg.c -- -I../workload/include -I../../include -DKERNEL_VERSION_HIGHER_5_13_0=1
 //go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir general --go-package general -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshTcMarkEncrypt ../general/tc_mark_encrypt.c -- -I../general/include -I../../include -DKERNEL_VERSION_HIGHER_5_13_0=1
 //go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir general --go-package general -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshTcMarkDecrypt ../general/tc_mark_decrypt.c -- -I../general/include -I../../include -DKERNEL_VERSION_HIGHER_5_13_0=1
 
-//go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir kernelnative/normal --go-package normal -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshCgroupSockCompat ../ads/cgroup_sock.c -- -I../ads/include -I../../include -I../../../api/v2-c -DCGROUP_SOCK_MANAGE -DKERNEL_VERSION_HIGHER_5_13_0=0
+//go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir kernelnative/$ENHANCED_KERNEL --go-package $ENHANCED_KERNEL -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshCgroupSockCompat ../ads/cgroup_sock.c -- -I../ads/include -I../../include -I../../../api/v2-c -DCGROUP_SOCK_MANAGE -DKERNEL_VERSION_HIGHER_5_13_0=0
 //go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir dualengine --go-package dualengine -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshCgroupSockWorkloadCompat ../workload/cgroup_sock.c -- -I../workload/include -I../../include -I../probes -DKERNEL_VERSION_HIGHER_5_13_0=0
-//go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir kernelnative/enhanced --go-package enhanced -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshSockopsCompat ../ads/sockops.c -- -I../ads/include -I../../include -I../../../api/v2-c -DKERNEL_VERSION_HIGHER_5_13_0=0
+//go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir kernelnative/$ENHANCED_KERNEL --go-package $ENHANCED_KERNEL -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshSockopsCompat ../ads/sockops.c -- -I../ads/include -I../../include -I../../../api/v2-c -DKERNEL_VERSION_HIGHER_5_13_0=0
 //go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir dualengine --go-package dualengine  -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshSockopsWorkloadCompat ../workload/sockops.c -- -I../workload/include -I../../include -I../probes -DKERNEL_VERSION_HIGHER_5_13_0=0
 //go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir dualengine --go-package dualengine -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshXDPAuthCompat ../workload/xdp.c -- -I../workload/include -I../../include -I../../../api/v2-c -DKERNEL_VERSION_HIGHER_5_13_0=0
 //go:generate go run github.com/cilium/ebpf/cmd/bpf2go --output-dir dualengine --go-package dualengine -cc clang  --cflags $EXTRA_CFLAGS --cflags $EXTRA_CDEFINE KmeshSendmsgCompat ../workload/sendmsg.c -- -I../workload/include -I../../include -DKERNEL_VERSION_HIGHER_5_13_0=0
diff --git a/bpf/kmesh/bpf2go/kernelnative/normal/kmeshsockops_bpfeb.go b/bpf/kmesh/bpf2go/kernelnative/normal/kmeshsockops_bpfeb.go
new file mode 100644
index 00000000..1e0cb005
--- /dev/null
+++ b/bpf/kmesh/bpf2go/kernelnative/normal/kmeshsockops_bpfeb.go
@@ -0,0 +1,189 @@
+// Code generated by bpf2go; DO NOT EDIT.
+//go:build mips || mips64 || ppc64 || s390x
+
+package normal
+
+import (
+	"bytes"
+	_ "embed"
+	"fmt"
+	"io"
+
+	"github.com/cilium/ebpf"
+)
+
+type KmeshSockopsBuf struct{ Data [40]int8 }
+
+type KmeshSockopsClusterSockData struct{ ClusterId uint32 }
+
+type KmeshSockopsKmeshConfig struct {
+	BpfLogLevel      uint32
+	NodeIp           [4]uint32
+	PodGateway       [4]uint32
+	AuthzOffload     uint32
+	EnableMonitoring uint32
+}
+
+type KmeshSockopsManagerKey struct {
+	NetnsCookie uint64
+	_           [8]byte
+}
+
+type KmeshSockopsSockStorageData struct {
+	ConnectNs      uint64
+	Direction      uint8
+	ConnectSuccess uint8
+	_              [6]byte
+}
+
+// LoadKmeshSockops returns the embedded CollectionSpec for KmeshSockops.
+func LoadKmeshSockops() (*ebpf.CollectionSpec, error) {
+	reader := bytes.NewReader(_KmeshSockopsBytes)
+	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
+	if err != nil {
+		return nil, fmt.Errorf("can't load KmeshSockops: %w", err)
+	}
+
+	return spec, err
+}
+
+// LoadKmeshSockopsObjects loads KmeshSockops and converts it into a struct.
+//
+// The following types are suitable as obj argument:
+//
+//	*KmeshSockopsObjects
+//	*KmeshSockopsPrograms
+//	*KmeshSockopsMaps
+//
+// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
+func LoadKmeshSockopsObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
+	spec, err := LoadKmeshSockops()
+	if err != nil {
+		return err
+	}
+
+	return spec.LoadAndAssign(obj, opts)
+}
+
+// KmeshSockopsSpecs contains maps and programs before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsSpecs struct {
+	KmeshSockopsProgramSpecs
+	KmeshSockopsMapSpecs
+	KmeshSockopsVariableSpecs
+}
+
+// KmeshSockopsProgramSpecs contains programs before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsProgramSpecs struct {
+	SockopsProg *ebpf.ProgramSpec `ebpf:"sockops_prog"`
+}
+
+// KmeshSockopsMapSpecs contains maps before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsMapSpecs struct {
+	KmClusterSock  *ebpf.MapSpec `ebpf:"km_cluster_sock"`
+	KmClusterstats *ebpf.MapSpec `ebpf:"km_clusterstats"`
+	KmConfigmap    *ebpf.MapSpec `ebpf:"km_configmap"`
+	KmLogEvent     *ebpf.MapSpec `ebpf:"km_log_event"`
+	KmManage       *ebpf.MapSpec `ebpf:"km_manage"`
+	KmSockstorage  *ebpf.MapSpec `ebpf:"km_sockstorage"`
+	KmTmpbuf       *ebpf.MapSpec `ebpf:"km_tmpbuf"`
+	KmeshMap1600   *ebpf.MapSpec `ebpf:"kmesh_map1600"`
+	KmeshMap192    *ebpf.MapSpec `ebpf:"kmesh_map192"`
+	KmeshMap296    *ebpf.MapSpec `ebpf:"kmesh_map296"`
+	KmeshMap64     *ebpf.MapSpec `ebpf:"kmesh_map64"`
+}
+
+// KmeshSockopsVariableSpecs contains global variables before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsVariableSpecs struct {
+	BpfLogLevel *ebpf.VariableSpec `ebpf:"bpf_log_level"`
+}
+
+// KmeshSockopsObjects contains all objects after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsObjects struct {
+	KmeshSockopsPrograms
+	KmeshSockopsMaps
+	KmeshSockopsVariables
+}
+
+func (o *KmeshSockopsObjects) Close() error {
+	return _KmeshSockopsClose(
+		&o.KmeshSockopsPrograms,
+		&o.KmeshSockopsMaps,
+	)
+}
+
+// KmeshSockopsMaps contains all maps after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsMaps struct {
+	KmClusterSock  *ebpf.Map `ebpf:"km_cluster_sock"`
+	KmClusterstats *ebpf.Map `ebpf:"km_clusterstats"`
+	KmConfigmap    *ebpf.Map `ebpf:"km_configmap"`
+	KmLogEvent     *ebpf.Map `ebpf:"km_log_event"`
+	KmManage       *ebpf.Map `ebpf:"km_manage"`
+	KmSockstorage  *ebpf.Map `ebpf:"km_sockstorage"`
+	KmTmpbuf       *ebpf.Map `ebpf:"km_tmpbuf"`
+	KmeshMap1600   *ebpf.Map `ebpf:"kmesh_map1600"`
+	KmeshMap192    *ebpf.Map `ebpf:"kmesh_map192"`
+	KmeshMap296    *ebpf.Map `ebpf:"kmesh_map296"`
+	KmeshMap64     *ebpf.Map `ebpf:"kmesh_map64"`
+}
+
+func (m *KmeshSockopsMaps) Close() error {
+	return _KmeshSockopsClose(
+		m.KmClusterSock,
+		m.KmClusterstats,
+		m.KmConfigmap,
+		m.KmLogEvent,
+		m.KmManage,
+		m.KmSockstorage,
+		m.KmTmpbuf,
+		m.KmeshMap1600,
+		m.KmeshMap192,
+		m.KmeshMap296,
+		m.KmeshMap64,
+	)
+}
+
+// KmeshSockopsVariables contains all global variables after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsVariables struct {
+	BpfLogLevel *ebpf.Variable `ebpf:"bpf_log_level"`
+}
+
+// KmeshSockopsPrograms contains all programs after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsPrograms struct {
+	SockopsProg *ebpf.Program `ebpf:"sockops_prog"`
+}
+
+func (p *KmeshSockopsPrograms) Close() error {
+	return _KmeshSockopsClose(
+		p.SockopsProg,
+	)
+}
+
+func _KmeshSockopsClose(closers ...io.Closer) error {
+	for _, closer := range closers {
+		if err := closer.Close(); err != nil {
+			return err
+		}
+	}
+	return nil
+}
+
+// Do not access this directly.
+//
+//go:embed kmeshsockops_bpfeb.o
+var _KmeshSockopsBytes []byte
diff --git a/bpf/kmesh/bpf2go/kernelnative/normal/kmeshsockops_bpfel.go b/bpf/kmesh/bpf2go/kernelnative/normal/kmeshsockops_bpfel.go
new file mode 100644
index 00000000..60824489
--- /dev/null
+++ b/bpf/kmesh/bpf2go/kernelnative/normal/kmeshsockops_bpfel.go
@@ -0,0 +1,189 @@
+// Code generated by bpf2go; DO NOT EDIT.
+//go:build 386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || ppc64le || riscv64
+
+package normal
+
+import (
+	"bytes"
+	_ "embed"
+	"fmt"
+	"io"
+
+	"github.com/cilium/ebpf"
+)
+
+type KmeshSockopsBuf struct{ Data [40]int8 }
+
+type KmeshSockopsClusterSockData struct{ ClusterId uint32 }
+
+type KmeshSockopsKmeshConfig struct {
+	BpfLogLevel      uint32
+	NodeIp           [4]uint32
+	PodGateway       [4]uint32
+	AuthzOffload     uint32
+	EnableMonitoring uint32
+}
+
+type KmeshSockopsManagerKey struct {
+	NetnsCookie uint64
+	_           [8]byte
+}
+
+type KmeshSockopsSockStorageData struct {
+	ConnectNs      uint64
+	Direction      uint8
+	ConnectSuccess uint8
+	_              [6]byte
+}
+
+// LoadKmeshSockops returns the embedded CollectionSpec for KmeshSockops.
+func LoadKmeshSockops() (*ebpf.CollectionSpec, error) {
+	reader := bytes.NewReader(_KmeshSockopsBytes)
+	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
+	if err != nil {
+		return nil, fmt.Errorf("can't load KmeshSockops: %w", err)
+	}
+
+	return spec, err
+}
+
+// LoadKmeshSockopsObjects loads KmeshSockops and converts it into a struct.
+//
+// The following types are suitable as obj argument:
+//
+//	*KmeshSockopsObjects
+//	*KmeshSockopsPrograms
+//	*KmeshSockopsMaps
+//
+// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
+func LoadKmeshSockopsObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
+	spec, err := LoadKmeshSockops()
+	if err != nil {
+		return err
+	}
+
+	return spec.LoadAndAssign(obj, opts)
+}
+
+// KmeshSockopsSpecs contains maps and programs before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsSpecs struct {
+	KmeshSockopsProgramSpecs
+	KmeshSockopsMapSpecs
+	KmeshSockopsVariableSpecs
+}
+
+// KmeshSockopsProgramSpecs contains programs before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsProgramSpecs struct {
+	SockopsProg *ebpf.ProgramSpec `ebpf:"sockops_prog"`
+}
+
+// KmeshSockopsMapSpecs contains maps before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsMapSpecs struct {
+	KmClusterSock  *ebpf.MapSpec `ebpf:"km_cluster_sock"`
+	KmClusterstats *ebpf.MapSpec `ebpf:"km_clusterstats"`
+	KmConfigmap    *ebpf.MapSpec `ebpf:"km_configmap"`
+	KmLogEvent     *ebpf.MapSpec `ebpf:"km_log_event"`
+	KmManage       *ebpf.MapSpec `ebpf:"km_manage"`
+	KmSockstorage  *ebpf.MapSpec `ebpf:"km_sockstorage"`
+	KmTmpbuf       *ebpf.MapSpec `ebpf:"km_tmpbuf"`
+	KmeshMap1600   *ebpf.MapSpec `ebpf:"kmesh_map1600"`
+	KmeshMap192    *ebpf.MapSpec `ebpf:"kmesh_map192"`
+	KmeshMap296    *ebpf.MapSpec `ebpf:"kmesh_map296"`
+	KmeshMap64     *ebpf.MapSpec `ebpf:"kmesh_map64"`
+}
+
+// KmeshSockopsVariableSpecs contains global variables before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsVariableSpecs struct {
+	BpfLogLevel *ebpf.VariableSpec `ebpf:"bpf_log_level"`
+}
+
+// KmeshSockopsObjects contains all objects after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsObjects struct {
+	KmeshSockopsPrograms
+	KmeshSockopsMaps
+	KmeshSockopsVariables
+}
+
+func (o *KmeshSockopsObjects) Close() error {
+	return _KmeshSockopsClose(
+		&o.KmeshSockopsPrograms,
+		&o.KmeshSockopsMaps,
+	)
+}
+
+// KmeshSockopsMaps contains all maps after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsMaps struct {
+	KmClusterSock  *ebpf.Map `ebpf:"km_cluster_sock"`
+	KmClusterstats *ebpf.Map `ebpf:"km_clusterstats"`
+	KmConfigmap    *ebpf.Map `ebpf:"km_configmap"`
+	KmLogEvent     *ebpf.Map `ebpf:"km_log_event"`
+	KmManage       *ebpf.Map `ebpf:"km_manage"`
+	KmSockstorage  *ebpf.Map `ebpf:"km_sockstorage"`
+	KmTmpbuf       *ebpf.Map `ebpf:"km_tmpbuf"`
+	KmeshMap1600   *ebpf.Map `ebpf:"kmesh_map1600"`
+	KmeshMap192    *ebpf.Map `ebpf:"kmesh_map192"`
+	KmeshMap296    *ebpf.Map `ebpf:"kmesh_map296"`
+	KmeshMap64     *ebpf.Map `ebpf:"kmesh_map64"`
+}
+
+func (m *KmeshSockopsMaps) Close() error {
+	return _KmeshSockopsClose(
+		m.KmClusterSock,
+		m.KmClusterstats,
+		m.KmConfigmap,
+		m.KmLogEvent,
+		m.KmManage,
+		m.KmSockstorage,
+		m.KmTmpbuf,
+		m.KmeshMap1600,
+		m.KmeshMap192,
+		m.KmeshMap296,
+		m.KmeshMap64,
+	)
+}
+
+// KmeshSockopsVariables contains all global variables after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsVariables struct {
+	BpfLogLevel *ebpf.Variable `ebpf:"bpf_log_level"`
+}
+
+// KmeshSockopsPrograms contains all programs after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsPrograms struct {
+	SockopsProg *ebpf.Program `ebpf:"sockops_prog"`
+}
+
+func (p *KmeshSockopsPrograms) Close() error {
+	return _KmeshSockopsClose(
+		p.SockopsProg,
+	)
+}
+
+func _KmeshSockopsClose(closers ...io.Closer) error {
+	for _, closer := range closers {
+		if err := closer.Close(); err != nil {
+			return err
+		}
+	}
+	return nil
+}
+
+// Do not access this directly.
+//
+//go:embed kmeshsockops_bpfel.o
+var _KmeshSockopsBytes []byte
diff --git a/bpf/kmesh/bpf2go/kernelnative/normal/kmeshsockopscompat_bpfeb.go b/bpf/kmesh/bpf2go/kernelnative/normal/kmeshsockopscompat_bpfeb.go
new file mode 100644
index 00000000..0d2536ad
--- /dev/null
+++ b/bpf/kmesh/bpf2go/kernelnative/normal/kmeshsockopscompat_bpfeb.go
@@ -0,0 +1,189 @@
+// Code generated by bpf2go; DO NOT EDIT.
+//go:build mips || mips64 || ppc64 || s390x
+
+package normal
+
+import (
+	"bytes"
+	_ "embed"
+	"fmt"
+	"io"
+
+	"github.com/cilium/ebpf"
+)
+
+type KmeshSockopsCompatBuf struct{ Data [40]int8 }
+
+type KmeshSockopsCompatClusterSockData struct{ ClusterId uint32 }
+
+type KmeshSockopsCompatKmeshConfig struct {
+	BpfLogLevel      uint32
+	NodeIp           [4]uint32
+	PodGateway       [4]uint32
+	AuthzOffload     uint32
+	EnableMonitoring uint32
+}
+
+type KmeshSockopsCompatManagerKey struct {
+	NetnsCookie uint64
+	_           [8]byte
+}
+
+type KmeshSockopsCompatSockStorageData struct {
+	ConnectNs      uint64
+	Direction      uint8
+	ConnectSuccess uint8
+	_              [6]byte
+}
+
+// LoadKmeshSockopsCompat returns the embedded CollectionSpec for KmeshSockopsCompat.
+func LoadKmeshSockopsCompat() (*ebpf.CollectionSpec, error) {
+	reader := bytes.NewReader(_KmeshSockopsCompatBytes)
+	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
+	if err != nil {
+		return nil, fmt.Errorf("can't load KmeshSockopsCompat: %w", err)
+	}
+
+	return spec, err
+}
+
+// LoadKmeshSockopsCompatObjects loads KmeshSockopsCompat and converts it into a struct.
+//
+// The following types are suitable as obj argument:
+//
+//	*KmeshSockopsCompatObjects
+//	*KmeshSockopsCompatPrograms
+//	*KmeshSockopsCompatMaps
+//
+// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
+func LoadKmeshSockopsCompatObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
+	spec, err := LoadKmeshSockopsCompat()
+	if err != nil {
+		return err
+	}
+
+	return spec.LoadAndAssign(obj, opts)
+}
+
+// KmeshSockopsCompatSpecs contains maps and programs before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsCompatSpecs struct {
+	KmeshSockopsCompatProgramSpecs
+	KmeshSockopsCompatMapSpecs
+	KmeshSockopsCompatVariableSpecs
+}
+
+// KmeshSockopsCompatProgramSpecs contains programs before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsCompatProgramSpecs struct {
+	SockopsProg *ebpf.ProgramSpec `ebpf:"sockops_prog"`
+}
+
+// KmeshSockopsCompatMapSpecs contains maps before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsCompatMapSpecs struct {
+	KmClusterSock  *ebpf.MapSpec `ebpf:"km_cluster_sock"`
+	KmClusterstats *ebpf.MapSpec `ebpf:"km_clusterstats"`
+	KmConfigmap    *ebpf.MapSpec `ebpf:"km_configmap"`
+	KmLogEvent     *ebpf.MapSpec `ebpf:"km_log_event"`
+	KmManage       *ebpf.MapSpec `ebpf:"km_manage"`
+	KmSockstorage  *ebpf.MapSpec `ebpf:"km_sockstorage"`
+	KmTmpbuf       *ebpf.MapSpec `ebpf:"km_tmpbuf"`
+	KmeshMap1600   *ebpf.MapSpec `ebpf:"kmesh_map1600"`
+	KmeshMap192    *ebpf.MapSpec `ebpf:"kmesh_map192"`
+	KmeshMap296    *ebpf.MapSpec `ebpf:"kmesh_map296"`
+	KmeshMap64     *ebpf.MapSpec `ebpf:"kmesh_map64"`
+}
+
+// KmeshSockopsCompatVariableSpecs contains global variables before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsCompatVariableSpecs struct {
+	BpfLogLevel *ebpf.VariableSpec `ebpf:"bpf_log_level"`
+}
+
+// KmeshSockopsCompatObjects contains all objects after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsCompatObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsCompatObjects struct {
+	KmeshSockopsCompatPrograms
+	KmeshSockopsCompatMaps
+	KmeshSockopsCompatVariables
+}
+
+func (o *KmeshSockopsCompatObjects) Close() error {
+	return _KmeshSockopsCompatClose(
+		&o.KmeshSockopsCompatPrograms,
+		&o.KmeshSockopsCompatMaps,
+	)
+}
+
+// KmeshSockopsCompatMaps contains all maps after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsCompatObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsCompatMaps struct {
+	KmClusterSock  *ebpf.Map `ebpf:"km_cluster_sock"`
+	KmClusterstats *ebpf.Map `ebpf:"km_clusterstats"`
+	KmConfigmap    *ebpf.Map `ebpf:"km_configmap"`
+	KmLogEvent     *ebpf.Map `ebpf:"km_log_event"`
+	KmManage       *ebpf.Map `ebpf:"km_manage"`
+	KmSockstorage  *ebpf.Map `ebpf:"km_sockstorage"`
+	KmTmpbuf       *ebpf.Map `ebpf:"km_tmpbuf"`
+	KmeshMap1600   *ebpf.Map `ebpf:"kmesh_map1600"`
+	KmeshMap192    *ebpf.Map `ebpf:"kmesh_map192"`
+	KmeshMap296    *ebpf.Map `ebpf:"kmesh_map296"`
+	KmeshMap64     *ebpf.Map `ebpf:"kmesh_map64"`
+}
+
+func (m *KmeshSockopsCompatMaps) Close() error {
+	return _KmeshSockopsCompatClose(
+		m.KmClusterSock,
+		m.KmClusterstats,
+		m.KmConfigmap,
+		m.KmLogEvent,
+		m.KmManage,
+		m.KmSockstorage,
+		m.KmTmpbuf,
+		m.KmeshMap1600,
+		m.KmeshMap192,
+		m.KmeshMap296,
+		m.KmeshMap64,
+	)
+}
+
+// KmeshSockopsCompatVariables contains all global variables after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsCompatObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsCompatVariables struct {
+	BpfLogLevel *ebpf.Variable `ebpf:"bpf_log_level"`
+}
+
+// KmeshSockopsCompatPrograms contains all programs after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsCompatObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsCompatPrograms struct {
+	SockopsProg *ebpf.Program `ebpf:"sockops_prog"`
+}
+
+func (p *KmeshSockopsCompatPrograms) Close() error {
+	return _KmeshSockopsCompatClose(
+		p.SockopsProg,
+	)
+}
+
+func _KmeshSockopsCompatClose(closers ...io.Closer) error {
+	for _, closer := range closers {
+		if err := closer.Close(); err != nil {
+			return err
+		}
+	}
+	return nil
+}
+
+// Do not access this directly.
+//
+//go:embed kmeshsockopscompat_bpfeb.o
+var _KmeshSockopsCompatBytes []byte
diff --git a/bpf/kmesh/bpf2go/kernelnative/normal/kmeshsockopscompat_bpfel.go b/bpf/kmesh/bpf2go/kernelnative/normal/kmeshsockopscompat_bpfel.go
new file mode 100644
index 00000000..4b1e9a2d
--- /dev/null
+++ b/bpf/kmesh/bpf2go/kernelnative/normal/kmeshsockopscompat_bpfel.go
@@ -0,0 +1,189 @@
+// Code generated by bpf2go; DO NOT EDIT.
+//go:build 386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || ppc64le || riscv64
+
+package normal
+
+import (
+	"bytes"
+	_ "embed"
+	"fmt"
+	"io"
+
+	"github.com/cilium/ebpf"
+)
+
+type KmeshSockopsCompatBuf struct{ Data [40]int8 }
+
+type KmeshSockopsCompatClusterSockData struct{ ClusterId uint32 }
+
+type KmeshSockopsCompatKmeshConfig struct {
+	BpfLogLevel      uint32
+	NodeIp           [4]uint32
+	PodGateway       [4]uint32
+	AuthzOffload     uint32
+	EnableMonitoring uint32
+}
+
+type KmeshSockopsCompatManagerKey struct {
+	NetnsCookie uint64
+	_           [8]byte
+}
+
+type KmeshSockopsCompatSockStorageData struct {
+	ConnectNs      uint64
+	Direction      uint8
+	ConnectSuccess uint8
+	_              [6]byte
+}
+
+// LoadKmeshSockopsCompat returns the embedded CollectionSpec for KmeshSockopsCompat.
+func LoadKmeshSockopsCompat() (*ebpf.CollectionSpec, error) {
+	reader := bytes.NewReader(_KmeshSockopsCompatBytes)
+	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
+	if err != nil {
+		return nil, fmt.Errorf("can't load KmeshSockopsCompat: %w", err)
+	}
+
+	return spec, err
+}
+
+// LoadKmeshSockopsCompatObjects loads KmeshSockopsCompat and converts it into a struct.
+//
+// The following types are suitable as obj argument:
+//
+//	*KmeshSockopsCompatObjects
+//	*KmeshSockopsCompatPrograms
+//	*KmeshSockopsCompatMaps
+//
+// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
+func LoadKmeshSockopsCompatObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
+	spec, err := LoadKmeshSockopsCompat()
+	if err != nil {
+		return err
+	}
+
+	return spec.LoadAndAssign(obj, opts)
+}
+
+// KmeshSockopsCompatSpecs contains maps and programs before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsCompatSpecs struct {
+	KmeshSockopsCompatProgramSpecs
+	KmeshSockopsCompatMapSpecs
+	KmeshSockopsCompatVariableSpecs
+}
+
+// KmeshSockopsCompatProgramSpecs contains programs before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsCompatProgramSpecs struct {
+	SockopsProg *ebpf.ProgramSpec `ebpf:"sockops_prog"`
+}
+
+// KmeshSockopsCompatMapSpecs contains maps before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsCompatMapSpecs struct {
+	KmClusterSock  *ebpf.MapSpec `ebpf:"km_cluster_sock"`
+	KmClusterstats *ebpf.MapSpec `ebpf:"km_clusterstats"`
+	KmConfigmap    *ebpf.MapSpec `ebpf:"km_configmap"`
+	KmLogEvent     *ebpf.MapSpec `ebpf:"km_log_event"`
+	KmManage       *ebpf.MapSpec `ebpf:"km_manage"`
+	KmSockstorage  *ebpf.MapSpec `ebpf:"km_sockstorage"`
+	KmTmpbuf       *ebpf.MapSpec `ebpf:"km_tmpbuf"`
+	KmeshMap1600   *ebpf.MapSpec `ebpf:"kmesh_map1600"`
+	KmeshMap192    *ebpf.MapSpec `ebpf:"kmesh_map192"`
+	KmeshMap296    *ebpf.MapSpec `ebpf:"kmesh_map296"`
+	KmeshMap64     *ebpf.MapSpec `ebpf:"kmesh_map64"`
+}
+
+// KmeshSockopsCompatVariableSpecs contains global variables before they are loaded into the kernel.
+//
+// It can be passed ebpf.CollectionSpec.Assign.
+type KmeshSockopsCompatVariableSpecs struct {
+	BpfLogLevel *ebpf.VariableSpec `ebpf:"bpf_log_level"`
+}
+
+// KmeshSockopsCompatObjects contains all objects after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsCompatObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsCompatObjects struct {
+	KmeshSockopsCompatPrograms
+	KmeshSockopsCompatMaps
+	KmeshSockopsCompatVariables
+}
+
+func (o *KmeshSockopsCompatObjects) Close() error {
+	return _KmeshSockopsCompatClose(
+		&o.KmeshSockopsCompatPrograms,
+		&o.KmeshSockopsCompatMaps,
+	)
+}
+
+// KmeshSockopsCompatMaps contains all maps after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsCompatObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsCompatMaps struct {
+	KmClusterSock  *ebpf.Map `ebpf:"km_cluster_sock"`
+	KmClusterstats *ebpf.Map `ebpf:"km_clusterstats"`
+	KmConfigmap    *ebpf.Map `ebpf:"km_configmap"`
+	KmLogEvent     *ebpf.Map `ebpf:"km_log_event"`
+	KmManage       *ebpf.Map `ebpf:"km_manage"`
+	KmSockstorage  *ebpf.Map `ebpf:"km_sockstorage"`
+	KmTmpbuf       *ebpf.Map `ebpf:"km_tmpbuf"`
+	KmeshMap1600   *ebpf.Map `ebpf:"kmesh_map1600"`
+	KmeshMap192    *ebpf.Map `ebpf:"kmesh_map192"`
+	KmeshMap296    *ebpf.Map `ebpf:"kmesh_map296"`
+	KmeshMap64     *ebpf.Map `ebpf:"kmesh_map64"`
+}
+
+func (m *KmeshSockopsCompatMaps) Close() error {
+	return _KmeshSockopsCompatClose(
+		m.KmClusterSock,
+		m.KmClusterstats,
+		m.KmConfigmap,
+		m.KmLogEvent,
+		m.KmManage,
+		m.KmSockstorage,
+		m.KmTmpbuf,
+		m.KmeshMap1600,
+		m.KmeshMap192,
+		m.KmeshMap296,
+		m.KmeshMap64,
+	)
+}
+
+// KmeshSockopsCompatVariables contains all global variables after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsCompatObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsCompatVariables struct {
+	BpfLogLevel *ebpf.Variable `ebpf:"bpf_log_level"`
+}
+
+// KmeshSockopsCompatPrograms contains all programs after they have been loaded into the kernel.
+//
+// It can be passed to LoadKmeshSockopsCompatObjects or ebpf.CollectionSpec.LoadAndAssign.
+type KmeshSockopsCompatPrograms struct {
+	SockopsProg *ebpf.Program `ebpf:"sockops_prog"`
+}
+
+func (p *KmeshSockopsCompatPrograms) Close() error {
+	return _KmeshSockopsCompatClose(
+		p.SockopsProg,
+	)
+}
+
+func _KmeshSockopsCompatClose(closers ...io.Closer) error {
+	for _, closer := range closers {
+		if err := closer.Close(); err != nil {
+			return err
+		}
+	}
+	return nil
+}
+
+// Do not access this directly.
+//
+//go:embed kmeshsockopscompat_bpfel.o
+var _KmeshSockopsCompatBytes []byte
diff --git a/bpf/kmesh/workload/sockops.c b/bpf/kmesh/workload/sockops.c
index 738d6664..03872d49 100644
--- a/bpf/kmesh/workload/sockops.c
+++ b/bpf/kmesh/workload/sockops.c
@@ -29,24 +29,6 @@ struct {
     __uint(map_flags, 0);
 } map_of_kmesh_socket SEC(".maps");
 
-static inline bool is_managed_by_kmesh(struct bpf_sock_ops *skops)
-{
-    struct manager_key key = {0};
-    if (skops->family == AF_INET)
-        key.addr.ip4 = skops->local_ip4;
-    if (skops->family == AF_INET6) {
-        if (is_ipv4_mapped_addr(skops->local_ip6))
-            key.addr.ip4 = skops->local_ip6[3];
-        else
-            IP6_COPY(key.addr.ip6, skops->local_ip6);
-    }
-
-    int *value = bpf_map_lookup_elem(&map_of_manager, &key);
-    if (!value)
-        return false;
-    return (*value == 0);
-}
-
 static inline bool skip_specific_probe(struct bpf_sock_ops *skops)
 {
     struct kmesh_config *data = {0};
@@ -182,70 +164,6 @@ static inline void enable_encoding_metadata(struct bpf_sock_ops *skops)
         BPF_LOG(ERR, SOCKOPS, "enable encoding metadata failed!, err is %d", err);
 }
 
-static inline void record_kmesh_managed_ip(__u32 family, __u32 ip4, __u32 *ip6)
-{
-    int err;
-    __u32 value = 0;
-    struct manager_key key = {0};
-    if (family == AF_INET)
-        key.addr.ip4 = ip4;
-    if (family == AF_INET6 && ip6)
-        IP6_COPY(key.addr.ip6, ip6);
-
-    err = bpf_map_update_elem(&map_of_manager, &key, &value, BPF_ANY);
-    if (err)
-        BPF_LOG(ERR, KMESH, "record ip failed!, err is %d\n", err);
-}
-
-static inline void remove_kmesh_managed_ip(__u32 family, __u32 ip4, __u32 *ip6)
-{
-    struct manager_key key = {0};
-    if (family == AF_INET)
-        key.addr.ip4 = ip4;
-    if (family == AF_INET6 && ip6)
-        IP6_COPY(key.addr.ip6, ip6);
-
-    int err = bpf_map_delete_elem(&map_of_manager, &key);
-    if (err && err != -ENOENT)
-        BPF_LOG(ERR, KMESH, "remove ip failed!, err is %d\n", err);
-}
-
-static inline bool conn_from_sim(struct bpf_sock_ops *skops, __u32 ip, __u16 port)
-{
-    __u16 remote_port = GET_SKOPS_REMOTE_PORT(skops);
-    if (bpf_ntohs(remote_port) != port)
-        return false;
-
-    if (skops->family == AF_INET)
-        return (bpf_ntohl(skops->remote_ip4) == ip);
-
-    return (
-        skops->remote_ip6[0] == 0 && skops->remote_ip6[1] == 0 && skops->remote_ip6[2] == 0
-        && bpf_ntohl(skops->remote_ip6[3]) == ip);
-}
-
-static inline bool skops_conn_from_cni_sim_add(struct bpf_sock_ops *skops)
-{
-    // cni sim connect CONTROL_CMD_IP:929(0x3a1)
-    // 0x3a1 is the specific port handled by the cni to enable Kmesh
-    return conn_from_sim(skops, CONTROL_CMD_IP, ENABLE_KMESH_PORT);
-}
-
-static inline bool skops_conn_from_cni_sim_delete(struct bpf_sock_ops *skops)
-{
-    // cni sim connect CONTROL_CMD_IP:930(0x3a2)
-    // 0x3a2 is the specific port handled by the cni to disable Kmesh
-    return conn_from_sim(skops, CONTROL_CMD_IP, DISABLE_KMESH_PORT);
-}
-
-static inline void skops_handle_kmesh_managed_process(struct bpf_sock_ops *skops)
-{
-    if (skops_conn_from_cni_sim_add(skops))
-        record_kmesh_managed_ip(skops->family, skops->local_ip4, skops->local_ip6);
-    if (skops_conn_from_cni_sim_delete(skops))
-        remove_kmesh_managed_ip(skops->family, skops->local_ip4, skops->local_ip6);
-}
-
 SEC("sockops")
 int sockops_prog(struct bpf_sock_ops *skops)
 {
diff --git a/kmesh_compile.sh b/kmesh_compile.sh
index 5dcf8b7a..5e2ec379 100755
--- a/kmesh_compile.sh
+++ b/kmesh_compile.sh
@@ -4,6 +4,8 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
 
 . $ROOT_DIR/hack/utils.sh
 
+bash kmesh_macros_env_kernel.sh
+make kmesh-ko
 container_id=$(run_docker_container)
 build_kmesh $container_id
 clean_container $container_id
diff --git a/kmesh_compile_env_pre.sh b/kmesh_compile_env_pre.sh
index b6dd0366..523c97b9 100644
--- a/kmesh_compile_env_pre.sh
+++ b/kmesh_compile_env_pre.sh
@@ -109,15 +109,6 @@ function kmesh_set_env(){
     export EXTRA_CFLAGS="-O0 -g"
 }
 
-# adjust the range of BPF code compilation based on the kernel is enhanced
-function bpf_compile_range_adjust() {
-    if [ "$ENHANCED_KERNEL" == "enhanced" ]; then
-            sed -i '/ads\/sockops\.c/s/\(.*\)generate/\/\/go:generate/' bpf/kmesh/bpf2go/bpf2go.go
-    else
-            sed -i '/ads\/sockops\.c/s/\(.*\)generate/\/\/not go:generate/' bpf/kmesh/bpf2go/bpf2go.go
-    fi
-}
-
 function set_enhanced_kernel_env() {
     # we use /usr/include/linux/bpf.h to determine the runtime environment’s
     # support for kmesh. Considering the case of online image compilation, a
@@ -135,7 +126,7 @@ function set_enhanced_kernel_env() {
     if grep -q "FN(parse_header_msg)" $KERNEL_HEADER_LINUX_BPF; then
             export ENHANCED_KERNEL="enhanced"
     else
-            export ENHANCED_KERNEL="unenhanced"
+            export ENHANCED_KERNEL="normal"
     fi
 }
 
@@ -149,5 +140,4 @@ function prepare() {
     kmesh_set_env
     bash kmesh_macros_env.sh
     bash kmesh_bpf_env.sh
-    bpf_compile_range_adjust
 }
diff --git a/kmesh_macros_env_kernel.sh b/kmesh_macros_env_kernel.sh
new file mode 100755
index 00000000..2a489182
--- /dev/null
+++ b/kmesh_macros_env_kernel.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+  
+VERSION=$(uname -r | cut -d '.' -f 1)
+KERNEL_VERSION=$(uname -r | cut -d '-' -f 1)
+KERNEL_HEADER_LINUX_BPF=/usr/include/linux/bpf.h
+
+function set_config() {
+    sed -i -r -e "s/($1)([ \t]*)([0-9]+)/\1\2$2/" config/kmesh_marcos_def.h
+}
+
+# MDA_LOOPBACK_ADDR
+if grep -q "FN(get_netns_cookie)" $KERNEL_HEADER_LINUX_BPF; then
+	set_config MDA_LOOPBACK_ADDR 1
+else
+	set_config MDA_LOOPBACK_ADDR 0
+fi
+
+# MDA_NAT_ACCEL
+if grep -q "FN(sk_original_addr)" $KERNEL_HEADER_LINUX_BPF; then
+	set_config MDA_NAT_ACCEL 1
+else
+	set_config MDA_NAT_ACCEL 0
+fi
+
+# MDA_GID_UID_FILTER
+if grep -q "FN(get_sockops_uid_gid)" $KERNEL_HEADER_LINUX_BPF; then
+	set_config MDA_GID_UID_FILTER 1
+else
+	set_config MDA_GID_UID_FILTER 0
+fi
+
+# ITER_TYPE_IS_UBUF
+if [ "$VERSION" -ge 6 ]; then
+	set_config ITER_TYPE_IS_UBUF 1
+else
+	set_config ITER_TYPE_IS_UBUF 0
+fi
+
+# ENHANCED_KERNEL
+if grep -q "FN(parse_header_msg)" $KERNEL_HEADER_LINUX_BPF; then
+	set_config ENHANCED_KERNEL 1
+else
+	set_config ENHANCED_KERNEL 0
+fi
+
+# KERNEL_KFUNC
+if [ "$VERSION" -ge 6 ]; then
+	set_config ENHANCED_KERNEL 1
+	set_config KERNEL_KFUNC 1
+else
+	set_config KERNEL_KFUNC 0
+fi
\ No newline at end of file
diff --git a/pkg/bpf/ads/loader.go b/pkg/bpf/ads/loader.go
index d3aadb07..d5a3d779 100644
--- a/pkg/bpf/ads/loader.go
+++ b/pkg/bpf/ads/loader.go
@@ -27,26 +27,70 @@ import (
 	"fmt"
 
 	"github.com/cilium/ebpf"
+	"github.com/cilium/ebpf/link"
 
+	bpf2go "kmesh.net/kmesh/bpf/kmesh/bpf2go/kernelnative/normal"
 	"kmesh.net/kmesh/daemon/options"
 	"kmesh.net/kmesh/pkg/bpf/general"
 	"kmesh.net/kmesh/pkg/bpf/utils"
 	"kmesh.net/kmesh/pkg/consistenthash/maglev"
 	"kmesh.net/kmesh/pkg/logger"
+	helper "kmesh.net/kmesh/pkg/utils"
 )
 
 var log = logger.NewLoggerScope("bpf_ads")
 
 type BpfAds struct {
 	SockConn BpfSockConn
+	SockOps  BpfSockOps
 	Tc       *general.BpfTCGeneral
 }
 
+type BpfSockConn struct {
+	Info general.BpfInfo
+	Link link.Link
+	bpf2go.KmeshCgroupSockObjects
+}
+
+type BpfSockOps struct {
+	Info general.BpfInfo
+	Link link.Link
+	bpf2go.KmeshSockopsObjects
+}
+
+func loadKmeshCgroupSock() (*ebpf.CollectionSpec, error) {
+	var spec *ebpf.CollectionSpec
+	var err error
+	if helper.KernelVersionLowerThan5_13() {
+		spec, err = bpf2go.LoadKmeshCgroupSockCompat()
+	} else {
+		spec, err = bpf2go.LoadKmeshCgroupSock()
+	}
+	return spec, err
+}
+
+func loadKmeshSockOps() (*ebpf.CollectionSpec, error) {
+	var spec *ebpf.CollectionSpec
+	var err error
+	if helper.KernelVersionLowerThan5_13() {
+		spec, err = bpf2go.LoadKmeshSockops()
+	} else {
+		spec, err = bpf2go.LoadKmeshSockopsCompat()
+	}
+	return spec, err
+}
+
 func NewBpfAds(cfg *options.BpfConfig) (*BpfAds, error) {
 	sc := &BpfAds{}
+
+	if err := sc.SockOps.NewBpf(cfg); err != nil {
+		return nil, err
+	}
+
 	if err := sc.SockConn.NewBpf(cfg); err != nil {
 		return nil, err
 	}
+
 	if cfg.EnableIPsec {
 		var err error
 		sc.Tc, err = general.NewBpf(cfg)
@@ -105,6 +149,10 @@ func (sc *BpfAds) Load() error {
 		return err
 	}
 
+	if err := sc.SockOps.Load(); err != nil {
+		return err
+	}
+
 	if err := sc.Tc.LoadTC(); err != nil {
 		return err
 	}
@@ -142,6 +190,10 @@ func (sc *BpfAds) ApiEnvCfg() error {
 }
 
 func (sc *BpfAds) Attach() error {
+	if err := sc.SockOps.Attach(); err != nil {
+		return err
+	}
+
 	if err := sc.SockConn.Attach(); err != nil {
 		return err
 	}
@@ -150,9 +202,14 @@ func (sc *BpfAds) Attach() error {
 }
 
 func (sc *BpfAds) Detach() error {
+	if err := sc.SockOps.Detach(); err != nil {
+		return err
+	}
+
 	if err := sc.SockConn.Detach(); err != nil {
 		return err
 	}
+
 	if err := sc.Tc.Close(); err != nil {
 		return err
 	}
diff --git a/pkg/bpf/ads/loader_enhanced.go b/pkg/bpf/ads/loader_enhanced.go
index 999ea6f7..cf0d6ac2 100644
--- a/pkg/bpf/ads/loader_enhanced.go
+++ b/pkg/bpf/ads/loader_enhanced.go
@@ -27,11 +27,14 @@ import (
 	"fmt"
 
 	"github.com/cilium/ebpf"
+	"github.com/cilium/ebpf/link"
 
+	bpf2go "kmesh.net/kmesh/bpf/kmesh/bpf2go/kernelnative/enhanced"
 	"kmesh.net/kmesh/daemon/options"
 	"kmesh.net/kmesh/pkg/bpf/general"
 	"kmesh.net/kmesh/pkg/bpf/utils"
 	"kmesh.net/kmesh/pkg/logger"
+	helper "kmesh.net/kmesh/pkg/utils"
 )
 
 var log = logger.NewLoggerScope("bpf_ads")
@@ -42,6 +45,40 @@ type BpfAds struct {
 	Tc       *general.BpfTCGeneral
 }
 
+type BpfSockConn struct {
+	Info general.BpfInfo
+	Link link.Link
+	bpf2go.KmeshCgroupSockObjects
+}
+
+type BpfSockOps struct {
+	Info general.BpfInfo
+	Link link.Link
+	bpf2go.KmeshSockopsObjects
+}
+
+func loadKmeshCgroupSock() (*ebpf.CollectionSpec, error) {
+	var spec *ebpf.CollectionSpec
+	var err error
+	if helper.KernelVersionLowerThan5_13() {
+		spec, err = bpf2go.LoadKmeshCgroupSockCompat()
+	} else {
+		spec, err = bpf2go.LoadKmeshCgroupSock()
+	}
+	return spec, err
+}
+
+func loadKmeshSockOps() (*ebpf.CollectionSpec, error) {
+	var spec *ebpf.CollectionSpec
+	var err error
+	if helper.KernelVersionLowerThan5_13() {
+		spec, err = bpf2go.LoadKmeshSockops()
+	} else {
+		spec, err = bpf2go.LoadKmeshSockopsCompat()
+	}
+	return spec, err
+}
+
 func NewBpfAds(cfg *options.BpfConfig) (*BpfAds, error) {
 	sc := &BpfAds{}
 
diff --git a/pkg/bpf/ads/sock_connection.go b/pkg/bpf/ads/sock_connection.go
index f574a936..2f72f6ba 100644
--- a/pkg/bpf/ads/sock_connection.go
+++ b/pkg/bpf/ads/sock_connection.go
@@ -32,11 +32,8 @@ import (
 	"kmesh.net/kmesh/pkg/bpf/restart"
 	"kmesh.net/kmesh/pkg/constants"
 
-	bpf2go "kmesh.net/kmesh/bpf/kmesh/bpf2go/kernelnative/normal"
 	"kmesh.net/kmesh/daemon/options"
-	"kmesh.net/kmesh/pkg/bpf/general"
 	"kmesh.net/kmesh/pkg/bpf/utils"
-	helper "kmesh.net/kmesh/pkg/utils"
 )
 
 var KMESH_TAIL_CALL_LISTENER = uint32(C.KMESH_TAIL_CALL_LISTENER)
@@ -46,12 +43,6 @@ var KMESH_TAIL_CALL_ROUTER = uint32(C.KMESH_TAIL_CALL_ROUTER)
 var KMESH_TAIL_CALL_CLUSTER = uint32(C.KMESH_TAIL_CALL_CLUSTER)
 var KMESH_TAIL_CALL_ROUTER_CONFIG = uint32(C.KMESH_TAIL_CALL_ROUTER_CONFIG)
 
-type BpfSockConn struct {
-	Info general.BpfInfo
-	Link link.Link
-	bpf2go.KmeshCgroupSockObjects
-}
-
 func (sc *BpfSockConn) NewBpf(cfg *options.BpfConfig) error {
 	sc.Info.MapPath = cfg.BpfFsPath + "/bpf_kmesh/map/"
 	sc.Info.BpfFsPath = cfg.BpfFsPath + "/bpf_kmesh/sockconn/"
@@ -80,11 +71,7 @@ func (sc *BpfSockConn) loadKmeshSockConnObjects() (*ebpf.CollectionSpec, error)
 	)
 	opts.Maps.PinPath = sc.Info.MapPath
 
-	if helper.KernelVersionLowerThan5_13() {
-		spec, err = bpf2go.LoadKmeshCgroupSockCompat()
-	} else {
-		spec, err = bpf2go.LoadKmeshCgroupSock()
-	}
+	spec, err = loadKmeshCgroupSock()
 	if err != nil || spec == nil {
 		return nil, err
 	}
diff --git a/pkg/bpf/ads/sock_ops.go b/pkg/bpf/ads/sock_ops.go
index cebee39d..579638f5 100644
--- a/pkg/bpf/ads/sock_ops.go
+++ b/pkg/bpf/ads/sock_ops.go
@@ -1,6 +1,3 @@
-//go:build enhanced
-// +build enhanced
-
 /*
  * Copyright The Kmesh Authors.
  *
@@ -28,21 +25,12 @@ import (
 	"github.com/cilium/ebpf"
 	"github.com/cilium/ebpf/link"
 
-	bpf2go "kmesh.net/kmesh/bpf/kmesh/bpf2go/kernelnative/enhanced"
 	"kmesh.net/kmesh/daemon/options"
-	"kmesh.net/kmesh/pkg/bpf/general"
 	"kmesh.net/kmesh/pkg/bpf/restart"
 	"kmesh.net/kmesh/pkg/bpf/utils"
 	"kmesh.net/kmesh/pkg/constants"
-	helper "kmesh.net/kmesh/pkg/utils"
 )
 
-type BpfSockOps struct {
-	Info general.BpfInfo
-	Link link.Link
-	bpf2go.KmeshSockopsObjects
-}
-
 func (sc *BpfSockOps) NewBpf(cfg *options.BpfConfig) error {
 	sc.Info.MapPath = cfg.BpfFsPath + "/bpf_kmesh/map/"
 	sc.Info.BpfFsPath = cfg.BpfFsPath + "/bpf_kmesh/sockops/"
@@ -71,11 +59,7 @@ func (sc *BpfSockOps) loadKmeshSockopsObjects() (*ebpf.CollectionSpec, error) {
 	)
 
 	opts.Maps.PinPath = sc.Info.MapPath
-	if helper.KernelVersionLowerThan5_13() {
-		spec, err = bpf2go.LoadKmeshSockopsCompat()
-	} else {
-		spec, err = bpf2go.LoadKmeshSockops()
-	}
+	spec, err = loadKmeshSockOps()
 	if err != nil || spec == nil {
 		return nil, err
 	}
diff --git a/pkg/controller/workload/workload_processor.go b/pkg/controller/workload/workload_processor.go
index 7bce75d2..390db813 100644
--- a/pkg/controller/workload/workload_processor.go
+++ b/pkg/controller/workload/workload_processor.go
@@ -108,6 +108,10 @@ func (p *Processor) GetBpfCache() *bpf.Cache {
 	return p.bpf
 }
 
+func (p *Processor) GetHashName() *utils.HashName {
+	return p.hashName
+}
+
 func (p *Processor) processWorkloadResponse(rsp *service_discovery_v3.DeltaDiscoveryResponse, rbac *auth.Rbac) {
 	var err error
 
diff --git a/pkg/nets/nets.go b/pkg/nets/nets.go
index 9be63571..fc015109 100644
--- a/pkg/nets/nets.go
+++ b/pkg/nets/nets.go
@@ -56,6 +56,14 @@ func ConvertPortToBigEndian(little uint32) uint32 {
 	return uint32(big16)
 }
 
+// ConvertPortToLittleEndian convert port to host order
+func ConvertPortToLittleEndian(big uint32) uint32 {
+	tmp := make([]byte, 2)
+	binary.LittleEndian.PutUint16(tmp, uint16(big))
+	little16 := binary.BigEndian.Uint16(tmp)
+	return uint32(little16)
+}
+
 func CopyIpByteFromSlice(dst *[16]byte, src []byte) {
 	len := len(src)
 	if len != 4 && len != 16 {
@@ -64,6 +72,26 @@ func CopyIpByteFromSlice(dst *[16]byte, src []byte) {
 	copy(dst[:], src)
 }
 
+// IpString converts ip bytes to string, for IpV4, it checks
+// whether the last 12 bytes are all zeros.
+// TODO: this may conflict with IpV6 addresses with the same pattern,
+// we should find a better way to indicate the ipv4 address.
+func IpString(ip [16]byte) string {
+	if isZeros(ip[5:]) {
+		return net.IP(ip[:4]).String()
+	}
+	return net.IP(ip[:]).String()
+}
+
+func isZeros(p []byte) bool {
+	for i := 0; i < len(p); i++ {
+		if p[i] != 0 {
+			return false
+		}
+	}
+	return true
+}
+
 func checkIPVersion() (ipv4, ipv6 bool) {
 	addrs, err := net.InterfaceAddrs()
 	if err != nil {
diff --git a/pkg/status/api.go b/pkg/status/api.go
index 0a53df2f..f11571b8 100644
--- a/pkg/status/api.go
+++ b/pkg/status/api.go
@@ -17,10 +17,16 @@
 package status
 
 import (
+	"encoding/json"
+	"fmt"
 	"net"
+	"strings"
 
 	"kmesh.net/kmesh/api/v2/workloadapi"
 	"kmesh.net/kmesh/api/v2/workloadapi/security"
+	"kmesh.net/kmesh/pkg/controller/workload/bpfcache"
+	"kmesh.net/kmesh/pkg/nets"
+	"kmesh.net/kmesh/pkg/utils"
 )
 
 type Workload struct {
@@ -183,3 +189,161 @@ func ConvertAuthorizationPolicy(p *security.Authorization) *AuthorizationPolicy
 
 	return out
 }
+
+type prettyArray[T any] []T
+
+func (a prettyArray[T]) MarshalJSON() ([]byte, error) {
+	prettified := make([]string, len(a))
+	for i, elem := range a {
+		prettified[i] = fmt.Sprintf("%v", elem)
+	}
+
+	return json.Marshal(strings.Join(prettified, ", "))
+}
+
+type BpfServiceValue struct {
+	// EndpointCount is the number of endpoints for each priority.
+	EndpointCount prettyArray[uint32] `json:"endpointCount"`
+	LbPolicy      string              `json:"lbPolicy"`
+	ServicePort   prettyArray[uint32] `json:"servicePort,omitempty"`
+	TargetPort    prettyArray[uint32] `json:"targetPort,omitempty"`
+	WaypointAddr  string              `json:"waypointAddr,omitempty"`
+	WaypointPort  uint32              `json:"waypointPort,omitempty"`
+}
+
+type BpfBackendValue struct {
+	Ip           string   `json:"ip"`
+	ServiceCount uint32   `json:"serviceCount"`
+	Services     []string `json:"services"`
+	WaypointAddr string   `json:"waypointAddr,omitempty"`
+	WaypointPort uint32   `json:"waypointPort,omitempty"`
+}
+
+type BpfFrontendValue struct {
+	UpstreamId string `json:"upstreamId,omitempty"`
+}
+
+type BpfWorkloadPolicyValue struct {
+	PolicyIds []string `json:"policyIds,omitempty"`
+}
+
+type BpfEndpointValue struct {
+	BackendUid string `json:"backendUid,omitempty"`
+}
+
+type WorkloadBpfDump struct {
+	hashName *utils.HashName
+
+	WorkloadPolicies []BpfWorkloadPolicyValue `json:"workloadPolicies"`
+	Backends         []BpfBackendValue        `json:"backends"`
+	Endpoints        []BpfEndpointValue       `json:"endpoints"`
+	Frontends        []BpfFrontendValue       `json:"frontends"`
+	Services         []BpfServiceValue        `json:"services"`
+}
+
+func NewWorkloadBpfDump(hashName *utils.HashName) WorkloadBpfDump {
+	return WorkloadBpfDump{hashName: hashName}
+}
+
+func (wd WorkloadBpfDump) WithWorkloadPolicies(workloadPolicies []bpfcache.WorkloadPolicyValue) WorkloadBpfDump {
+	converted := make([]BpfWorkloadPolicyValue, 0, len(workloadPolicies))
+	for _, policy := range workloadPolicies {
+		policyIds := []string{}
+		for _, id := range policy.PolicyIds {
+			policyIds = append(policyIds, wd.hashName.NumToStr(id))
+		}
+		converted = append(converted, BpfWorkloadPolicyValue{
+			PolicyIds: policyIds,
+		})
+	}
+	wd.WorkloadPolicies = converted
+	return wd
+}
+
+func (wd WorkloadBpfDump) WithBackends(backends []bpfcache.BackendValue) WorkloadBpfDump {
+	converted := make([]BpfBackendValue, 0, len(backends))
+	for _, backend := range backends {
+		waypointAddr := ""
+		if backend.WaypointAddr != [16]byte{} {
+			waypointAddr = nets.IpString(backend.WaypointAddr)
+		}
+		bac := BpfBackendValue{
+			Ip:           nets.IpString(backend.Ip),
+			ServiceCount: backend.ServiceCount,
+			WaypointAddr: waypointAddr,
+			WaypointPort: nets.ConvertPortToLittleEndian(backend.WaypointPort),
+		}
+		services := make([]string, 0, len(backend.Services))
+		for _, s := range backend.Services {
+			svc := wd.hashName.NumToStr(s)
+			if svc == "" {
+				continue
+			}
+			services = append(services, svc)
+		}
+		bac.Services = services
+		converted = append(converted, bac)
+	}
+	wd.Backends = converted
+	return wd
+}
+
+func (wd WorkloadBpfDump) WithEndpoints(endpoints []bpfcache.EndpointValue) WorkloadBpfDump {
+	converted := make([]BpfEndpointValue, 0, len(endpoints))
+	for _, endpoint := range endpoints {
+		converted = append(converted, BpfEndpointValue{
+			BackendUid: wd.hashName.NumToStr(endpoint.BackendUid),
+		})
+	}
+	wd.Endpoints = converted
+	return wd
+}
+
+func (wd WorkloadBpfDump) WithFrontends(frontends []bpfcache.FrontendValue) WorkloadBpfDump {
+	converted := make([]BpfFrontendValue, 0, len(frontends))
+	for _, frontend := range frontends {
+		converted = append(converted, BpfFrontendValue{
+			UpstreamId: wd.hashName.NumToStr(frontend.UpstreamId),
+		})
+	}
+	wd.Frontends = converted
+	return wd
+}
+
+func (wd WorkloadBpfDump) WithServices(services []bpfcache.ServiceValue) WorkloadBpfDump {
+	converted := make([]BpfServiceValue, 0, len(services))
+	for _, s := range services {
+		waypointAddr := ""
+		if s.WaypointAddr != [16]byte{} {
+			waypointAddr = nets.IpString(s.WaypointAddr)
+		}
+		svc := BpfServiceValue{
+			EndpointCount: []uint32{},
+			LbPolicy:      workloadapi.LoadBalancing_Mode_name[int32(s.LbPolicy)],
+			WaypointAddr:  waypointAddr,
+			WaypointPort:  nets.ConvertPortToLittleEndian(s.WaypointPort),
+		}
+
+		for _, c := range s.EndpointCount {
+			svc.EndpointCount = append(svc.EndpointCount, c)
+		}
+
+		for _, p := range s.ServicePort {
+			if p == 0 {
+				continue
+			}
+			svc.ServicePort = append(svc.ServicePort, nets.ConvertPortToLittleEndian(p))
+		}
+
+		for _, p := range s.TargetPort {
+			if p == 0 {
+				continue
+			}
+			svc.TargetPort = append(svc.TargetPort, nets.ConvertPortToLittleEndian(p))
+		}
+
+		converted = append(converted, svc)
+	}
+	wd.Services = converted
+	return wd
+}
diff --git a/pkg/status/status_server.go b/pkg/status/status_server.go
index e12e9332..bb56895e 100644
--- a/pkg/status/status_server.go
+++ b/pkg/status/status_server.go
@@ -38,7 +38,6 @@ import (
 	"kmesh.net/kmesh/pkg/constants"
 	"kmesh.net/kmesh/pkg/controller"
 	"kmesh.net/kmesh/pkg/controller/ads"
-	"kmesh.net/kmesh/pkg/controller/workload/bpfcache"
 	"kmesh.net/kmesh/pkg/logger"
 	"kmesh.net/kmesh/pkg/version"
 )
@@ -149,27 +148,19 @@ func (s *Server) checkAdsMode(w http.ResponseWriter) bool {
 	return true
 }
 
-type WorkloadBpfDump struct {
-	WorkloadPolicies []bpfcache.WorkloadPolicyValue
-	Backends         []bpfcache.BackendValue
-	Endpoints        []bpfcache.EndpointValue
-	Frontends        []bpfcache.FrontendValue
-	Services         []bpfcache.ServiceValue
-}
-
 func (s *Server) bpfWorkloadMaps(w http.ResponseWriter, r *http.Request) {
 	if !s.checkWorkloadMode(w) {
 		return
 	}
 	client := s.xdsClient
 	bpfMaps := client.WorkloadController.Processor.GetBpfCache()
-	workloadBpfDump := WorkloadBpfDump{
-		WorkloadPolicies: bpfMaps.WorkloadPolicyLookupAll(),
-		Backends:         bpfMaps.BackendLookupAll(),
-		Endpoints:        bpfMaps.EndpointLookupAll(),
-		Frontends:        bpfMaps.FrontendLookupAll(),
-		Services:         bpfMaps.ServiceLookupAll(),
-	}
+	workloadBpfDump := NewWorkloadBpfDump(s.xdsClient.WorkloadController.Processor.GetHashName()).
+		WithBackends(bpfMaps.BackendLookupAll()).
+		WithEndpoints(bpfMaps.EndpointLookupAll()).
+		WithFrontends(bpfMaps.FrontendLookupAll()).
+		WithServices(bpfMaps.ServiceLookupAll()).
+		WithWorkloadPolicies(bpfMaps.WorkloadPolicyLookupAll())
+
 	printWorkloadBpfDump(w, workloadBpfDump)
 }
 
@@ -458,9 +449,9 @@ func (s *Server) configDumpAds(w http.ResponseWriter, r *http.Request) {
 }
 
 type WorkloadDump struct {
-	Workloads []*Workload
-	Services  []*Service
-	Policies  []*AuthorizationPolicy
+	Workloads []*Workload            `json:"workloads"`
+	Services  []*Service             `json:"services"`
+	Policies  []*AuthorizationPolicy `json:"policies"`
 }
 
 func (s *Server) configDumpWorkload(w http.ResponseWriter, r *http.Request) {



Test patch:
diff --git a/pkg/nets/nets_test.go b/pkg/nets/nets_test.go
index 65529372..9a754f31 100644
--- a/pkg/nets/nets_test.go
+++ b/pkg/nets/nets_test.go
@@ -118,3 +118,39 @@ func TestCompareIpByte(t *testing.T) {
 		})
 	}
 }
+
+func TestConvertPortToLittleEndian(t *testing.T) {
+	tests := []struct {
+		input    uint32
+		expected uint32
+	}{
+		{8080, 8080},
+		{0x5678, 0x5678},
+	}
+
+	for _, test := range tests {
+		input := ConvertPortToBigEndian(test.input)
+		actual := ConvertPortToLittleEndian(input)
+		if actual != test.expected {
+			t.Errorf("ConvertPortToLittleEndian(%#x) = %#x; expected %#x", test.input, actual, test.expected)
+		}
+	}
+}
+
+func TestIpString(t *testing.T) {
+	tests := []struct {
+		ip       [16]byte
+		expected string
+	}{
+		{[16]byte{192, 168, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "192.168.0.1"},
+		{[16]byte{192, 168, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, "c0a8:1::1"},
+		{[16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "0.0.0.0"},
+	}
+
+	for _, test := range tests {
+		actual := IpString(test.ip)
+		if actual != test.expected {
+			t.Errorf("IpString(%v) = %v; expected %v", test.ip, actual, test.expected)
+		}
+	}
+}
diff --git a/pkg/status/testdata/workload_configdump.json b/pkg/status/testdata/workload_configdump.json
index ad0288c3..ef7c6a25 100644
--- a/pkg/status/testdata/workload_configdump.json
+++ b/pkg/status/testdata/workload_configdump.json
@@ -1,5 +1,5 @@
 {
-    "Workloads": [
+    "workloads": [
         {
             "uid": "cluster0//Pod/ns/name",
             "addresses": [
@@ -27,7 +27,7 @@
             ]
         }
     ],
-    "Services": [
+    "services": [
         {
             "name": "svc",
             "namespace": "ns",
@@ -51,7 +51,7 @@
             }
         }
     ],
-    "Policies": [
+    "policies": [
         {
             "name": "policy",
             "namespace": "ns",