Skip to content

Commit

Permalink
Merge pull request #75 from OpenCloudOS/dev
Browse files Browse the repository at this point in the history
nettrace: disable preserve_access_index in vmlinux.h
  • Loading branch information
menglongdong authored Oct 18, 2023
2 parents 74069e1 + fab512e commit c1e7b7b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
4 changes: 2 additions & 2 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COMMON_SHARED := $(ROOT)/shared/pkt_utils.c $(COMPONENT)/net_utils.c \
CFLAGS += -I./ -I$(ROOT)/shared/bpf/
BPF_CFLAGS = $(CFLAGS) -Wno-unused-function \
-Wno-compare-distinct-pointer-types -Wuninitialized \
-D__TARGET_ARCH_$(SRCARCH)
-D__TARGET_ARCH_$(SRCARCH) -DBPF_NO_PRESERVE_ACCESS_INDEX
HOST_CFLAGS = \
-lbpf -lelf -lz -O2 -static $(CFLAGS) \
-Wno-deprecated-declarations -DVERSION=$(VERSION) \
Expand Down Expand Up @@ -58,7 +58,7 @@ endif
kheaders_cmd := ln -s vmlinux_header.h kheaders.h
CFLAGS += -DCOMPAT_MODE
BPF_CFLAGS += $(KERNEL_CFLAGS) -DBPF_NO_GLOBAL_DATA \
-DBPF_NO_PRESERVE_ACCESS_INDEX -g
-g
else
kheaders_cmd := ln -s ../shared/bpf/vmlinux.h kheaders.h
BPF_CFLAGS += -target bpf -g
Expand Down
8 changes: 0 additions & 8 deletions shared/bpf/vmlinux_arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -121851,10 +121851,6 @@ enum flow_offload_tuple_dir {
FLOW_OFFLOAD_DIR_MAX = 2,
};

#ifndef BPF_NO_PRESERVE_ACCESS_INDEX
#pragma clang attribute pop
#endif

struct nft_pktinfo {
struct sk_buff *skb;
bool tprot_set;
Expand Down Expand Up @@ -122112,10 +122108,6 @@ struct nft_jumpstack {
struct nft_rule * const *rules;
};

#ifndef BPF_NO_PRESERVE_ACCESS_INDEX
#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record)
#endif

enum nf_tables_msg_types {
NFT_MSG_NEWTABLE = 0,
NFT_MSG_GETTABLE = 1,
Expand Down
8 changes: 0 additions & 8 deletions shared/bpf/vmlinux_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -137614,10 +137614,6 @@ enum flow_offload_tuple_dir {
FLOW_OFFLOAD_DIR_MAX = 2,
};

#ifndef BPF_NO_PRESERVE_ACCESS_INDEX
#pragma clang attribute pop
#endif

struct nft_pktinfo {
struct sk_buff___2 *skb;
bool tprot_set;
Expand Down Expand Up @@ -137877,10 +137873,6 @@ struct nft_jumpstack {
struct nft_rule * const *rules;
};

#ifndef BPF_NO_PRESERVE_ACCESS_INDEX
#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record)
#endif

enum nf_tables_msg_types {
NFT_MSG_NEWTABLE = 0,
NFT_MSG_GETTABLE = 1,
Expand Down
12 changes: 6 additions & 6 deletions src/progs/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ static try_inline int filter_by_netns(context_t *ctx)
if (!netns && !ctx->args->detail)
return 0;

dev = _(skb->dev);
dev = _C(skb, dev);
if (!dev) {
struct sock *sk = _(skb->sk);
struct sock *sk = _C(skb, sk);
if (!sk)
goto no_ns;
ns = _(sk->__sk_common.skc_net.net);
ns = _C(sk, __sk_common.skc_net.net);
} else {
ns = _(dev->nd_net.net);
ns = _C(dev, nd_net.net);
}

if (!ns)
goto no_ns;

inode = _(ns->ns.inum);
inode = _C(ns, ns.inum);
if (ctx->args->detail)
((detail_event_t *)ctx->e)->netns = inode;

Expand Down Expand Up @@ -448,7 +448,7 @@ DEFINE_KPROBE_INIT(nft_do_chain, nft_do_chain, .arg_count = 2)
if (!bpf_core_field_exists(pkt->xt))
state = _C((struct nft_pktinfo___new *)pkt, state);
else
state = _C(&(pkt->xt), state);
state = _C(pkt, xt.state);
} else {
/* don't use CO-RE, as nft may be a module */
state = _(pkt->xt.state);
Expand Down

0 comments on commit c1e7b7b

Please sign in to comment.