diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-05-02 20:22:31 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-05-02 20:22:31 +0000 |
commit | e2d7ab91d79f5b9807ff24e1b813b982167f9e6f (patch) | |
tree | 748b939f1cf3826538b33b8545297a481a4fe08c | |
parent | ad1fc5d97c58a46e67192ea7bcfadb69a11f6242 (diff) | |
parent | 155d4dd0c429b66441c76268ff3152b1037b2b4c (diff) | |
download | netd-e2d7ab91d79f5b9807ff24e1b813b982167f9e6f.tar.gz |
Merge "Do not count dropped packet on egress side" into pi-dev
-rw-r--r-- | bpfloader/bpf_kern.h | 12 | ||||
-rw-r--r-- | bpfloader/bpf_kern.o | bin | 6232 -> 6264 bytes |
2 files changed, 10 insertions, 2 deletions
diff --git a/bpfloader/bpf_kern.h b/bpfloader/bpf_kern.h index 8fb6046f..975f4655 100644 --- a/bpfloader/bpf_kern.h +++ b/bpfloader/bpf_kern.h @@ -150,6 +150,14 @@ static inline int bpf_owner_match(struct __sk_buff* skb, uint32_t uid) { } static __always_inline inline int bpf_traffic_account(struct __sk_buff* skb, int direction) { + uint32_t sock_uid = get_socket_uid(skb); + int match = bpf_owner_match(skb, sock_uid); + if ((direction == BPF_EGRESS) && (match == BPF_DROP)) { + // If an outbound packet is going to be dropped, we do not count that + // traffic. + return match; + } + uint64_t cookie = get_socket_cookie(skb); struct uid_tag* utag = find_map_entry(COOKIE_TAG_MAP, &cookie); uint32_t uid, tag; @@ -157,7 +165,7 @@ static __always_inline inline int bpf_traffic_account(struct __sk_buff* skb, int uid = utag->uid; tag = utag->tag; } else { - uid = get_socket_uid(skb); + uid = sock_uid; tag = 0; } @@ -174,5 +182,5 @@ static __always_inline inline int bpf_traffic_account(struct __sk_buff* skb, int key.tag = 0; bpf_update_stats(skb, UID_STATS_MAP, direction, &key); - return bpf_owner_match(skb, uid); + return match; } diff --git a/bpfloader/bpf_kern.o b/bpfloader/bpf_kern.o Binary files differindex 32d8e876..7b60514e 100644 --- a/bpfloader/bpf_kern.o +++ b/bpfloader/bpf_kern.o |