-
Notifications
You must be signed in to change notification settings - Fork 4
IPsec blog #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
IPsec blog #25
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| --- | ||
| layout: :theme/post | ||
| title: "Monitoring IPSec encryption and decryption using Network Observability" | ||
| description: IPSec provides enriched information to indicate if IPsec encryption or decryption using libreswan was successful or not | ||
| tags: Monitoring,Networking,IPSEC | ||
| authors: [msherif1234] | ||
| --- | ||
|
|
||
| # Monitoring IPsec Encryption and Decryption with eBPF | ||
|
|
||
| **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. | ||
|
|
||
| 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. | ||
|
|
||
| In this blog post, we'll show how to leverage eBPF to observe IPsec encryption and decryption processes in the Linux kernel. | ||
|
|
||
| --- | ||
|
|
||
| ## Understanding IPsec Traffic | ||
|
|
||
| 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: | ||
|
|
||
|  | ||
|
|
||
| --- | ||
|
|
||
| ## 1. Tracing IPsec Encryption | ||
|
|
||
| **IPsec encryption** transforms plaintext data into ciphertext to protect it from unauthorized access. | ||
|
|
||
| To monitor this process with eBPF: | ||
|
|
||
| - 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. | ||
| - Set a **`kretprobe`** on the same function to capture its return value and extract flow metadata, allowing us to determine whether encryption was successful. | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Tracing IPsec Decryption | ||
|
|
||
| **IPsec decryption** converts ciphertext back into plaintext. | ||
|
|
||
| To monitor decryption: | ||
|
|
||
| - 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. | ||
| - Use a **`kretprobe`** on `xfrm_input` to capture the return code and associated flow information, helping determine success or failure. | ||
|
|
||
| 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 | ||
|
|
||
|
|
||
|  | ||
|
|
||
| --- | ||
|
|
||
| ## Network Observability Enrichment | ||
|
|
||
| With eBPF instrumentation, NetObserv enriches flow records with two fields related to IPsec operations: | ||
|
|
||
| - **`ipsec_encrypted_ret`**: Contains the kernel return code from the encryption/decryption function. | ||
| - **`ipsec_encrypted`**: A boolean indicator (`1` = success, `0` = failure) representing whether encryption or decryption was completed successfully. | ||
|
|
||
| --- | ||
|
|
||
| ## IPsec Insights | ||
|
|
||
| The NetObserv user interface offers detailed visibility into IPsec operations through enriched flow records: | ||
|
|
||
|  | ||
|
|
||
| Additionally, the traffic overview section provides insights into the percentage of IPsec traffic, along with per-node statistics for IPsec flow rates. | ||
|
|
||
|  | ||
|
|
||
| --- | ||
|
|
||
| ## Enabling IPsec Monitoring | ||
|
|
||
| To activate IPsec tracing, update the `FlowCollector` configuration as follows: | ||
|
|
||
| ```yaml | ||
| apiVersion: flows.netobserv.io/v1beta2 | ||
| kind: FlowCollector | ||
| metadata: | ||
| name: cluster | ||
| spec: | ||
| agent: | ||
| type: EBPF | ||
| ebpf: | ||
| features: | ||
| - IPSec | ||
| ``` | ||
|
|
||
|
|
||
| ## Availability | ||
|
|
||
| The IPsec feature is available in NetObserv release 1.9. | ||
|
|
||
|
|
||
| ## Conclusion | ||
| 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. | ||
|
|
||
|
|
||
| ## Feedback | ||
|
|
||
| We hope you liked this article ! | ||
| NetObserv is an open source project [available on github](https://github.com/netobserv). | ||
| 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). | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just noticed the chart shows a global rate and not per-node, as written. I would say the text is correct but the metric is wrong, so I'll file a bug for that, no need to change your text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ftr - https://issues.redhat.com/browse/NETOBSERV-2322