---
title: "Match the hook to the job"
---

> Documentation Index
> Fetch the complete documentation index at: https://example.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Match the hook to the job

Every step higher in the Linux network stack trades raw packets-per-second for richer metadata and symmetry. Pick the lowest hook that still sees the context you need.

Use XDP for ingress filtering and DDoS defense, TC for bidirectional pod capture and policy, and socket hooks for identity-aware service routing.

## Networking hook comparison

|  | XDP | TC (cls_bpf) | Socket / cgroup |
| --- | --- | --- | --- |
| Direction | Ingress only | Ingress + egress | App send/recv |
| sk_buff ready | No (raw DMA) | Yes | Full socket |
| Pod identity | IP only | veth / mark | Exact cgroup |
| Best use | Drop / redirect | CNI & capture | Mesh / NAT bypass |

Source: https://example.com/ebpf-field-guide/networking-and-packet-path/networking-hooks/recap/index.mdx
