Skip to content

Conversation

victorjulien
Copy link
Member

By default a VXLAN packet is handled by splitting off the encapsulated packet into it's own Packet, that remains coupled with the original Packet to allow verdicts to be set in IPS mode. For the original "root" packet, payload inspection is disabled, but detection like IP, ports and other non-payload properties can still be inspected.

There cases where all packets will be VXLAN encapsulated, and the headers before the encapsulation matter little. One example is AWS network mirror, where packets are delivered over VXLAN. This is inefficient, as for each real packet there are 2 packets going through the pipeline.

This patch introduces an option to strip the envelope headers, and let the encapsulated packet "take over" the Packet.

The decoder.vxlan.mode=strip option will strip the headers.

SV_BRANCH=OISF/suricata-verify#1972

By default a VXLAN packet is handled by splitting off the encapsulated
packet into it's own Packet, that remains coupled with the original
Packet to allow verdicts to be set in IPS mode. For the original "root"
packet, payload inspection is disabled, but detection like IP, ports and
other non-payload properties can still be inspected.

There cases where all packets will be VXLAN encapsulated, and the
headers before the encapsulation matter little. One example is AWS
network mirror, where packets are delivered over VXLAN. This is
inefficient, as for each real packet there are 2 packets going through
the pipeline.

This patch introduces an option to strip the envelope headers, and
let the encapsulated packet "take over" the Packet.

The `decoder.vxlan.mode=strip` option will strip the headers.
@victorjulien victorjulien added needs ticket Needs (link to) redmine ticket needs doc update labels Jul 10, 2024
#define VXLAN_DEFAULT_PORT 4789
#define VXLAN_DEFAULT_PORT_S "4789"

enum TunnelPacketMode {
Copy link
Member Author

Choose a reason for hiding this comment

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

would move this into decode.h, but maybe only after adding support for other protocols like geneve, erspan, etc

default:
SCLogDebug("VXLAN found unsupported Ethertype - expected IPv4, IPv6, VLAN, or ARP");
ENGINE_SET_INVALID_EVENT(p, VXLAN_UNKNOWN_PAYLOAD_TYPE);
/* TODO check further that we strip only once per real packet */
Copy link
Member Author

Choose a reason for hiding this comment

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

concern here is that we may strip things that we don't want to strip, leading to a bypass

PacketClearL2(p);
PacketClearL3(p);
PacketClearL4(p);
// TODO clear things more: tuple, events?
Copy link
Member Author

Choose a reason for hiding this comment

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

need to clear more of the packet: addr, port, ipproto, decode events. Need to review flags too.

Copy link

codecov bot commented Jul 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.58%. Comparing base (090079c) to head (6375503).
Report is 1157 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11472      +/-   ##
==========================================
+ Coverage   82.52%   82.58%   +0.06%     
==========================================
  Files         938      938              
  Lines      248297   248317      +20     
==========================================
+ Hits       204917   205083     +166     
+ Misses      43380    43234     -146     
Flag Coverage Δ
fuzzcorpus 60.69% <72.54%> (+0.25%) ⬆️
livemode 18.69% <3.92%> (-0.01%) ⬇️
pcap 43.75% <47.05%> (-0.03%) ⬇️
suricata-verify 61.55% <74.50%> (+0.01%) ⬆️
unittests 59.42% <37.25%> (+<0.01%) ⬆️

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

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

@suricata-qa
Copy link

Information:

ERROR: QA failed on SURI_TLPW2_autofp_suri_time.

field baseline test %
SURI_TLPW2_autofp_stats_chk
.uptime 137 146 106.57%

Pipeline 21468

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 21474

@catenacyber
Copy link
Contributor

The decoder.vxlan.mode=strip option will strip the headers.

Should it be the case for other protocols than vxlan ?
Like decoder.strip = all, or decode.strip = vxlan, gre

@catenacyber
Copy link
Contributor

@victorjulien should we close this old PR until you plan to work back on this ?

@catenacyber catenacyber added the needs rebase Needs rebase to main label May 6, 2025
@catenacyber
Copy link
Contributor

999c74d is another alternative : let ebpf XDP do the vxlan stripping so Suricata does not bother with it ;-)

@catenacyber
Copy link
Contributor

catenacyber commented May 15, 2025

Yet another solution may be routing to a virtual interface and letting the linux kernel to the work like ip link add vxlan0 type vxlan id 123 dev rootdev local 1.2.3.4 dstport 4789 and ip a add 1.2.3.4/32 dev rootdev and have suricata listen on vxlan0 instead of rootdev + ip link set vxlan0 promisc on and ip link set vxlan0 up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs doc update needs rebase Needs rebase to main needs ticket Needs (link to) redmine ticket
Development

Successfully merging this pull request may close these issues.

3 participants