Skip to content

Commit ef45081

Browse files
authored
IPsec blog (#25)
* WIP: IPsec blog Signed-off-by: Mohamed S. Mahmoud <mmahmoud2201@gmail.com> * Add ipsec latest console image and overview Signed-off-by: Mohamed S. Mahmoud <mmahmoud2201@gmail.com> --------- Signed-off-by: Mohamed S. Mahmoud <mmahmoud2201@gmail.com>
1 parent 803e748 commit ef45081

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
layout: :theme/post
3+
title: "Monitoring IPSec encryption and decryption using Network Observability"
4+
description: IPSec provides enriched information to indicate if IPsec encryption or decryption using libreswan was successful or not
5+
tags: Monitoring,Networking,IPSEC
6+
authors: [msherif1234]
7+
---
8+
9+
# Monitoring IPsec Encryption and Decryption with eBPF
10+
11+
**IPsec (Internet Protocol Security)** is a widely used protocol suite that secures communication at the IP layer through authentication and encryption. While powerful, IPsec can be opaque—making it difficult to inspect or debug encrypted traffic, especially at the kernel level.
12+
13+
With **eBPF (Extended Berkeley Packet Filter)** and its dynamic tracing capabilities via **kprobes** and **kretprobes**, we can instrument IPsec-related kernel functions without modifying kernel source code or rebooting the system.
14+
15+
In this blog post, we'll show how to leverage eBPF to observe IPsec encryption and decryption processes in the Linux kernel.
16+
17+
---
18+
19+
## Understanding IPsec Traffic
20+
21+
OpenShift uses [**Libreswan**](https://libreswan.org/) to handle IPsec encryption and decryption. The diagram below illustrates how an IPsec packet appears before and after encryption:
22+
23+
![IPsec Packet Flow](ipsec-packet.png)
24+
25+
---
26+
27+
## 1. Tracing IPsec Encryption
28+
29+
**IPsec encryption** transforms plaintext data into ciphertext to protect it from unauthorized access.
30+
31+
To monitor this process with eBPF:
32+
33+
- Set a **`kprobe`** on the [xfrm_output](https://elixir.bootlin.com/linux/v6.15.3/source/net/xfrm/xfrm_output.c#L743) function to trace when encryption is initiated.
34+
- Set a **`kretprobe`** on the same function to capture its return value and extract flow metadata, allowing us to determine whether encryption was successful.
35+
36+
---
37+
38+
## 2. Tracing IPsec Decryption
39+
40+
**IPsec decryption** converts ciphertext back into plaintext.
41+
42+
To monitor decryption:
43+
44+
- Set a **`kprobe`** on the [xfrm_input](https://elixir.bootlin.com/linux/v6.15.3/source/net/xfrm/xfrm_input.c#L463) function to trace when decryption is triggered.
45+
- Use a **`kretprobe`** on `xfrm_input` to capture the return code and associated flow information, helping determine success or failure.
46+
47+
The following diagram shows how IPsec packets is processed at ebpf layers and how the netobserv flow been created and updated to reflect ipsec packet processing status
48+
49+
50+
![IPsec eBPF packet processing](ipsec.png)
51+
52+
---
53+
54+
## Network Observability Enrichment
55+
56+
With eBPF instrumentation, NetObserv enriches flow records with two fields related to IPsec operations:
57+
58+
- **`ipsec_encrypted_ret`**: Contains the kernel return code from the encryption/decryption function.
59+
- **`ipsec_encrypted`**: A boolean indicator (`1` = success, `0` = failure) representing whether encryption or decryption was completed successfully.
60+
61+
---
62+
63+
## IPsec Insights
64+
65+
The NetObserv user interface offers detailed visibility into IPsec operations through enriched flow records:
66+
67+
![IPsec Flows in UI](ipsec-flows.png)
68+
69+
Additionally, the traffic overview section provides insights into the percentage of IPsec traffic, along with per-node statistics for IPsec flow rates.
70+
71+
![IPsec Flows Overview](ipsec-dashboard.png)
72+
73+
---
74+
75+
## Enabling IPsec Monitoring
76+
77+
To activate IPsec tracing, update the `FlowCollector` configuration as follows:
78+
79+
```yaml
80+
apiVersion: flows.netobserv.io/v1beta2
81+
kind: FlowCollector
82+
metadata:
83+
name: cluster
84+
spec:
85+
agent:
86+
type: EBPF
87+
ebpf:
88+
features:
89+
- IPSec
90+
```
91+
92+
93+
## Availability
94+
95+
The IPsec feature is available in NetObserv release 1.9.
96+
97+
98+
## Conclusion
99+
Network Observability with eBPF provides a powerful way to monitor IPsec encryption and decryption operations in the Linux kernel. By using kprobe and kretprobe, we can dynamically insert probes into IPsec-related kernel functions without modifying kernel source code or requiring system reboots.
100+
101+
102+
## Feedback
103+
104+
We hope you liked this article !
105+
NetObserv is an open source project [available on github](https://github.com/netobserv).
106+
Feel free to share your [ideas](https://github.com/orgs/netobserv/discussions/categories/ideas), [use cases](https://github.com/orgs/netobserv/discussions/categories/show-and-tell) or [ask the community for help](https://github.com/orgs/netobserv/discussions/categories/q-a).
70.4 KB
Loading
141 KB
Loading
189 KB
Loading
69.8 KB
Loading

0 commit comments

Comments
 (0)