Lines Matching refs:skb
100 static __always_inline inline void update_##the_stats_map(struct __sk_buff* skb, \
111 uint64_t bytes = skb->len; \
113 bool is_ipv6 = (skb->protocol == htons(ETH_P_IPV6)); \
136 static inline bool skip_owner_match(struct __sk_buff* skb) { in DEFINE_UPDATE_STATS()
139 if (skb->protocol == htons(ETH_P_IP)) { in DEFINE_UPDATE_STATS()
143 ret = bpf_skb_load_bytes(skb, offset, &proto, 1); in DEFINE_UPDATE_STATS()
148 ret = bpf_skb_load_bytes(skb, IPPROTO_IHL_OFF, &ihl, 1); in DEFINE_UPDATE_STATS()
150 ret = bpf_skb_load_bytes(skb, ihl * 4 + TCP_FLAG_OFF, &flag, 1); in DEFINE_UPDATE_STATS()
156 } else if (skb->protocol == htons(ETH_P_IPV6)) { in DEFINE_UPDATE_STATS()
159 ret = bpf_skb_load_bytes(skb, offset, &proto, 1); in DEFINE_UPDATE_STATS()
165 ret = bpf_skb_load_bytes(skb, sizeof(struct ipv6hdr) + TCP_FLAG_OFF, &flag, 1); in DEFINE_UPDATE_STATS()
185 static inline int bpf_owner_match(struct __sk_buff* skb, uint32_t uid, int direction) { in bpf_owner_match() argument
186 if (skip_owner_match(skb)) return BPF_PASS; in bpf_owner_match()
212 if (allowed_iif && skb->ifindex != 1 && skb->ifindex != allowed_iif) { in bpf_owner_match()
219 static __always_inline inline void update_stats_with_config(struct __sk_buff* skb, int direction, in update_stats_with_config() argument
222 update_stats_map_A(skb, direction, key); in update_stats_with_config()
224 update_stats_map_B(skb, direction, key); in update_stats_with_config()
228 static __always_inline inline int bpf_traffic_account(struct __sk_buff* skb, int direction) { in bpf_traffic_account() argument
229 uint32_t sock_uid = bpf_get_socket_uid(skb); in bpf_traffic_account()
236 int match = bpf_owner_match(skb, sock_uid, direction); in bpf_traffic_account()
243 uint64_t cookie = bpf_get_socket_cookie(skb); in bpf_traffic_account()
265 StatsKey key = {.uid = uid, .tag = tag, .counterSet = 0, .ifaceIndex = skb->ifindex}; in bpf_traffic_account()
277 update_stats_with_config(skb, direction, &key, *selectedMap); in bpf_traffic_account()
281 update_stats_with_config(skb, direction, &key, *selectedMap); in bpf_traffic_account()
282 update_app_uid_stats_map(skb, direction, &uid); in bpf_traffic_account()
287 (struct __sk_buff* skb) {
288 return bpf_traffic_account(skb, BPF_INGRESS);
292 (struct __sk_buff* skb) {
293 return bpf_traffic_account(skb, BPF_EGRESS);
297 (struct __sk_buff* skb) {
301 uint32_t sock_uid = bpf_get_socket_uid(skb);
304 uint32_t key = skb->ifindex;
305 update_iface_stats_map(skb, BPF_EGRESS, &key);
310 (struct __sk_buff* skb) {
316 uint32_t key = skb->ifindex;
317 update_iface_stats_map(skb, BPF_INGRESS, &key);
322 (struct __sk_buff* skb) {
323 uint32_t sock_uid = bpf_get_socket_uid(skb);
330 if ((sock_uid == 65534) && !bpf_get_socket_cookie(skb) && is_received_skb(skb))
339 (struct __sk_buff* skb) {
340 uint32_t sock_uid = bpf_get_socket_uid(skb);