Skip to content

output/ipv6: Add configuration option to shorten IPv6 IP addresses#14458

Closed
jlucovsky wants to merge 2 commits intoOISF:mainfrom
jlucovsky:7399.v2/7
Closed

output/ipv6: Add configuration option to shorten IPv6 IP addresses#14458
jlucovsky wants to merge 2 commits intoOISF:mainfrom
jlucovsky:7399.v2/7

Conversation

@jlucovsky
Copy link
Contributor

Continuation of #14449

Add a configuration option for outputting shortened IPv6 addresses per RFC-5952

The configuration option:
logging.ipv6-addr-shorten has a default value of no.

When set to yes, IPv6 addresses will be shortened everywhere they are output. E.g., the IPv6 address fe80:0000:0000:0000:020c:29ff:faf2:ab42 will be output as fe80::20c:29ff:faf2:ab42

Link to ticket: https://redmine.openinfosecfoundation.org/issues/7399

Describe changes:

  • Add a configuration variable for choosing shortened IPv6 IP addresses
  • Add Rust logic to create a shortened IPv6 address
  • Document changes and usage.

Updates:

  • Address Clippy issues
  • Renamed Rust function to conform to API-naming standard
  • Eliminated extra copy in Rust function
  • s-v test updates.
  • Removed commented-out line from Rust module; added copyright
  • Misc doc updates.
  • Rearranged copyright notice
  • Updated s-v test cases with min-version
  • Formatted with rustfmt
  • Added test cases
  • Changed return for detection of success/failure.
  • Fixed issue handling return value.

Provide values to any of the below to override the defaults.

  • To use a Suricata-Verify or Suricata-Update pull request,
    link to the pull request in the respective _BRANCH variable.
  • Leave unused overrides blank or remove.

SV_REPO=
SV_BRANCH=OISF/suricata-verify#2789
SU_REPO=
SU_BRANCH=

Issue: 7399

Use shortened IPv6 addresses in all output when configured.

IPv6 addresses are shortened per RFC5952

By default, IPv6 addresses are never shortened; set
logging.ipv6-addr-shorten=yes to shorten.

Added Rust utility function to create shortened IPv6 address.
Document the configuration variable logging.ipv6-addr-shorten

Issue: 7399
@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 98.26087% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.17%. Comparing base (354e998) to head (cda88b7).
⚠️ Report is 117 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14458      +/-   ##
==========================================
- Coverage   84.20%   84.17%   -0.03%     
==========================================
  Files        1013     1014       +1     
  Lines      262383   262498     +115     
==========================================
+ Hits       220936   220959      +23     
- Misses      41447    41539      +92     
Flag Coverage Δ
fuzzcorpus 63.18% <9.37%> (-0.01%) ⬇️
livemode 18.73% <6.25%> (-0.03%) ⬇️
pcap 44.62% <9.37%> (+0.01%) ⬆️
suricata-verify 64.90% <90.62%> (-0.08%) ⬇️
unittests 59.26% <93.91%> (+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.

let bytes = std::slice::from_raw_parts(addr, 16);

// Convert &[u8] → Ipv6Addr
let ipv6 = match <&[u8; 16]>::try_from(bytes) {
Copy link
Member

Choose a reason for hiding this comment

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

how might this fail? If we have 16 bytes we have a valid ipv6 address, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

As reported in #14433 (comment)

I think you should use a from method that is MSRV-compatible

Copy link
Member

Choose a reason for hiding this comment

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

Can we unwrap this somehow then? Now the error check is just dead code AFAICS

Comment on lines +611 to +612
# Shorten IPv6 addresses per RFC 5952 before logging. The default is no
#ipv6-addr-shorten: no
Copy link
Member

Choose a reason for hiding this comment

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

This section logging typically has no effect on outputs. I wonder if this should be specified per eve logger?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went down that rabbit hole (per eve logger) but decided on this approach to catch the output of any IPv6 address anywhere.

Perhaps logging isn't the correct section but I feel this is a global Suricata config setting, not per-output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jasonish Suggestions on how to specify the global config value?

Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately not. Perhaps at the top level? This is an issue with Eve output currently; there is no way to specify global things. A goal for 9 is to remove globals as well. I feel it more naturally belongs on the eve instance? Maybe the idea of a global section is not a bad idea?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll start a global section with the IPv6 option being the first member.

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline = 28672

E.g., previously, ``ether_type`` values were logged in host order; an ethertype value of ``0xfbb7``
(network order) was logged as `47099`` (``0xb7fb``). This ethertype value will be logged as ``64439``.

- The output format for IPv6 addresses can be configured. By default, they are presented in their
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this belongs here unless we change the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove mention of this from the upgrade unless you suggest changing the default value to "always shorten"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@victorjulien Should the default be yes (shorten)?

Copy link
Contributor

@catenacyber catenacyber left a comment

Choose a reason for hiding this comment

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

Some changes were requested inline if I understand correctly

@jlucovsky
Copy link
Contributor Author

Continued in #14636

@jlucovsky jlucovsky closed this Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants