Skip to content

NETOBSERV-2198: IPsec support #538

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 3 commits into from
Apr 2, 2025
Merged

Conversation

msherif1234
Copy link
Contributor

@msherif1234 msherif1234 commented Jan 30, 2025

Description

probing XFRM input and output processing to know if packets came encrypted or left encrypted

image

image

[root@ip-10-0-1-35 /]# ip xfrm state
src 10.0.1.158 dst 10.0.1.35
	proto esp spi 0x17e83b29 reqid 16393 mode transport
	replay-window 0 flag esn
	aead rfc4106(gcm(aes)) 0x2dff2e25143878e71710cc484f87a0e04a5d9882b9e23643f28692e33935eef6879f7ef5 128
	anti-replay esn context:
	 seq-hi 0x0, seq 0x0, oseq-hi 0x0, oseq 0x0
	 replay_window 128, bitmap-length 4
	 00000000 00000000 00000000 00000000 
	sel src 10.0.1.158/32 dst 10.0.1.35/32 proto udp sport 6081 

Dependencies

n/a

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Will this change affect NetObserv / Network Observability operator? If not, you can ignore the rest of this checklist.
  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
    • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
    • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
    • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
    • Standard QE validation, with pre-merge tests unless stated otherwise.
    • Regression tests only (e.g. refactoring with no user-facing change).
    • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

@msherif1234 msherif1234 marked this pull request as draft January 30, 2025 11:30
@msherif1234 msherif1234 changed the title WIP: Ipsec support WIP: IPsec support Jan 30, 2025
@msherif1234 msherif1234 force-pushed the ipsec_support branch 2 times, most recently from b85b6d1 to 539f368 Compare January 30, 2025 16:09
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 2.96296% with 131 lines in your changes missing coverage. Please review.

Project coverage is 26.59%. Comparing base (6c04bb6) to head (584a90b).

Files with missing lines Patch % Lines
pkg/tracer/tracer.go 0.00% 118 Missing ⚠️
pkg/ebpf/bpf_x86_bpfel.go 0.00% 6 Missing ⚠️
pkg/model/flow_content.go 0.00% 4 Missing and 2 partials ⚠️
pkg/agent/agent.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #538      +/-   ##
==========================================
- Coverage   27.34%   26.59%   -0.75%     
==========================================
  Files          47       47              
  Lines        4988     5121     +133     
==========================================
- Hits         1364     1362       -2     
- Misses       3521     3653     +132     
- Partials      103      106       +3     
Flag Coverage Δ
unittests 26.59% <2.96%> (-0.75%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/agent/config.go 8.33% <ø> (ø)
pkg/decode/decode_protobuf.go 32.10% <100.00%> (+0.78%) ⬆️
pkg/agent/agent.go 30.69% <0.00%> (-0.08%) ⬇️
pkg/ebpf/bpf_x86_bpfel.go 0.00% <0.00%> (ø)
pkg/model/flow_content.go 60.19% <0.00%> (-3.73%) ⬇️
pkg/tracer/tracer.go 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@msherif1234 msherif1234 force-pushed the ipsec_support branch 5 times, most recently from d1c4b50 to e0ce8ed Compare January 31, 2025 16:22
@msherif1234
Copy link
Contributor Author

/ok-to-test

@openshift-ci openshift-ci bot added the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Jan 31, 2025
Copy link

New images:
quay.io/netobserv/ebpf-bytecode:5162ef0
quay.io/netobserv/netobserv-ebpf-agent:5162ef0

These will expire after two weeks.

To deploy this build, run from the operator repo, assuming the operator is running:

USER=netobserv VERSION=5162ef0 make set-agent-image

@github-actions github-actions bot removed the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Jan 31, 2025
@msherif1234
Copy link
Contributor Author

/ok-to-test

@openshift-ci openshift-ci bot added the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Jan 31, 2025
Copy link

New images:
quay.io/netobserv/ebpf-bytecode:bdedd3c
quay.io/netobserv/netobserv-ebpf-agent:bdedd3c

These will expire after two weeks.

To deploy this build, run from the operator repo, assuming the operator is running:

USER=netobserv VERSION=bdedd3c make set-agent-image

@github-actions github-actions bot removed the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Jan 31, 2025
@msherif1234
Copy link
Contributor Author

/ok-to-test

@openshift-ci openshift-ci bot added the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Jan 31, 2025
Copy link

New images:
quay.io/netobserv/ebpf-bytecode:d4ab178
quay.io/netobserv/netobserv-ebpf-agent:d4ab178

These will expire after two weeks.

To deploy this build, run from the operator repo, assuming the operator is running:

USER=netobserv VERSION=d4ab178 make set-agent-image

@github-actions github-actions bot removed the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Jan 31, 2025
@msherif1234 msherif1234 changed the title NETOBSERV-2052: IPsec support NETOBSERV-1668: IPsec support Mar 31, 2025
@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Mar 31, 2025

@msherif1234: This pull request references NETOBSERV-1668 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target either version "4.19." or "openshift-4.19.", but it targets "netobserv-1.9" instead.

In response to this:

Description

probing XFRM input and output processing to know if packets came encrypted or left encrypted

image

image

[root@ip-10-0-1-35 /]# ip xfrm state
src 10.0.1.158 dst 10.0.1.35
  proto esp spi 0x17e83b29 reqid 16393 mode transport
  replay-window 0 flag esn
  aead rfc4106(gcm(aes)) 0x2dff2e25143878e71710cc484f87a0e04a5d9882b9e23643f28692e33935eef6879f7ef5 128
  anti-replay esn context:
   seq-hi 0x0, seq 0x0, oseq-hi 0x0, oseq 0x0
   replay_window 128, bitmap-length 4
   00000000 00000000 00000000 00000000 
  sel src 10.0.1.158/32 dst 10.0.1.35/32 proto udp sport 6081 

Dependencies

n/a

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Will this change affect NetObserv / Network Observability operator? If not, you can ignore the rest of this checklist.
  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
  • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
  • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
  • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

bpf/ipsec.h Outdated
extra_metrics->end_mono_time_ts = bpf_ktime_get_ns();
extra_metrics->eth_protocol = eth_protocol;
extra_metrics->flow_encrypted_ret = flow_encrypted_ret;
extra_metrics->flow_encrypted = flow_encrypted_ret == 0 ? true : false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a flow contains both encrypted and unencrypted packets, here we keep only the last packet state.
I'd argue it's more important to show any unencrypted state, no?
So something like:

if (extra_metrics->flow_encrypted && flow_encrypted_ret != 0) {
extra_metrics->flow_encrypted = false;
}

wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the encrypted flag name my be missleading here as it work both ways
for xfrm_input where we decrypt and check decryption state, while in xfrm_out this the encryption path , maybe I should rename them here as well to ipsec_ret and ipsec_success similar to the json ?

Comment on lines 121 to 124
if other.FlowEncrypted {
p.AdditionalMetrics.FlowEncrypted = other.FlowEncrypted
}
if p.AdditionalMetrics.FlowEncryptedRet != other.FlowEncryptedRet {
p.AdditionalMetrics.FlowEncryptedRet = other.FlowEncryptedRet
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same remark as in the bpf code: I think we should prioritize showing errors over successes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't the above show both ?

@github-actions github-actions bot removed the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Apr 1, 2025
bpf/ipsec.h Outdated
if (extra_metrics != NULL) {
extra_metrics->end_mono_time_ts = bpf_ktime_get_ns();
extra_metrics->eth_protocol = eth_protocol;
extra_metrics->flow_encrypted_ret = flow_encrypted_ret;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't update flow_encrypted_ret to replace it with a success, if it had an error I think

Suggested change
extra_metrics->flow_encrypted_ret = flow_encrypted_ret;
if (flow_encrypted_ret != 0) {
extra_metrics->flow_encrypted_ret = flow_encrypted_ret;
}

@msherif1234 msherif1234 requested a review from jotak April 1, 2025 13:25
@jotak jotak changed the title NETOBSERV-1668: IPsec support NETOBSERV-2198: IPsec support Apr 1, 2025
@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Apr 1, 2025

@msherif1234: This pull request references NETOBSERV-2198 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.19.0" version, but no target version was set.

In response to this:

Description

probing XFRM input and output processing to know if packets came encrypted or left encrypted

image

image

[root@ip-10-0-1-35 /]# ip xfrm state
src 10.0.1.158 dst 10.0.1.35
  proto esp spi 0x17e83b29 reqid 16393 mode transport
  replay-window 0 flag esn
  aead rfc4106(gcm(aes)) 0x2dff2e25143878e71710cc484f87a0e04a5d9882b9e23643f28692e33935eef6879f7ef5 128
  anti-replay esn context:
   seq-hi 0x0, seq 0x0, oseq-hi 0x0, oseq 0x0
   replay_window 128, bitmap-length 4
   00000000 00000000 00000000 00000000 
  sel src 10.0.1.158/32 dst 10.0.1.35/32 proto udp sport 6081 

Dependencies

n/a

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Will this change affect NetObserv / Network Observability operator? If not, you can ignore the rest of this checklist.
  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
  • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
  • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
  • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link

openshift-ci bot commented Apr 1, 2025

@msherif1234: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/qe-e2e-tests 142bea6 link false /test qe-e2e-tests

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link
Member

@jotak jotak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Apr 2, 2025
@msherif1234
Copy link
Contributor Author

/approve

Copy link

openshift-ci bot commented Apr 2, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: msherif1234

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Apr 2, 2025
@msherif1234 msherif1234 merged commit 4b40d24 into netobserv:main Apr 2, 2025
6 of 11 checks passed
@msherif1234 msherif1234 deleted the ipsec_support branch April 2, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants