summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-04-12 23:45:02 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-04-12 23:45:02 +0000
commitaddacdff9591ff58aedbfd63bab33a2da0782517 (patch)
treec356dbaf710fd1c78c5a34c879b72793deb19c40
parent13121743d17dd7aa55a88780559350af88839d70 (diff)
parente4b5a883015cd7dd8da5d9603498cde4c6db018d (diff)
downloadnetd-addacdff9591ff58aedbfd63bab33a2da0782517.tar.gz
Snap for 7277594 from e4b5a883015cd7dd8da5d9603498cde4c6db018d to mainline-documentsui-releaseandroid-mainline-11.0.0_r38android11-mainline-documentsui-release
Change-Id: I926ee4f883bb9a13be73372c51c299730a6e21ea
-rw-r--r--bpf_progs/bpf_net_helpers.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/bpf_progs/bpf_net_helpers.h b/bpf_progs/bpf_net_helpers.h
index 179aca4c..d978f3a2 100644
--- a/bpf_progs/bpf_net_helpers.h
+++ b/bpf_progs/bpf_net_helpers.h
@@ -26,6 +26,9 @@
static uint64_t (*bpf_get_socket_cookie)(struct __sk_buff* skb) = (void*)BPF_FUNC_get_socket_cookie;
static uint32_t (*bpf_get_socket_uid)(struct __sk_buff* skb) = (void*)BPF_FUNC_get_socket_uid;
+
+static int (*bpf_skb_pull_data)(struct __sk_buff* skb, __u32 len) = (void*)BPF_FUNC_skb_pull_data;
+
static int (*bpf_skb_load_bytes)(struct __sk_buff* skb, int off, void* to,
int len) = (void*)BPF_FUNC_skb_load_bytes;
@@ -44,6 +47,8 @@ static int (*bpf_l3_csum_replace)(struct __sk_buff* skb, __u32 offset, __u64 fro
static int (*bpf_l4_csum_replace)(struct __sk_buff* skb, __u32 offset, __u64 from, __u64 to,
__u64 flags) = (void*)BPF_FUNC_l4_csum_replace;
static int (*bpf_redirect)(__u32 ifindex, __u64 flags) = (void*)BPF_FUNC_redirect;
+static int (*bpf_redirect_map)(const struct bpf_map_def* map, __u32 key,
+ __u64 flags) = (void*)BPF_FUNC_redirect_map;
static int (*bpf_skb_change_head)(struct __sk_buff* skb, __u32 head_room,
__u64 flags) = (void*)BPF_FUNC_skb_change_head;
@@ -61,4 +66,10 @@ static inline __always_inline __unused bool is_received_skb(struct __sk_buff* sk
skb->pkt_type == PACKET_MULTICAST;
}
+// try to make the first 'len' header bytes readable via direct packet access
+static inline __always_inline void try_make_readable(struct __sk_buff* skb, int len) {
+ if (len > skb->len) len = skb->len;
+ if (skb->data_end - skb->data < len) bpf_skb_pull_data(skb, len);
+}
+
#endif // NETDBPF_BPF_NET_HELPERS_H