Skip to content

Ipv6 literal fixes#11561

Open
pv2b wants to merge 3 commits intofluent:masterfrom
pv2b:ipv6-fixes
Open

Ipv6 literal fixes#11561
pv2b wants to merge 3 commits intofluent:masterfrom
pv2b:ipv6-fixes

Conversation

@pv2b
Copy link
Contributor

@pv2b pv2b commented Mar 15, 2026

This PR fixes #11560 and fixes #11558 and fixes #11559


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A] Documentation required for this feature

Backporting

  • Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • Bug Fixes
    • IPv6 addresses now display with correct bracket notation in connection details.
    • IPv4-mapped IPv6 addresses are presented as IPv4 for clearer network info.
    • TCP and UDP connection displays unified for a more consistent user experience.
    • Connection label length increased to accommodate IPv6 bracketed addresses and port notation.

@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b1b67475-e3dc-4492-9a37-8e8457f1c6db

📥 Commits

Reviewing files that changed from the base of the PR and between a0ca954 and 6ca6772.

📒 Files selected for processing (1)
  • plugins/in_syslog/syslog_server.c

📝 Walkthrough

Walkthrough

Updated connection label length and host formatting; compose_user_friendly_remote_host now brackets IPv6 literals and unifies TCP/UDP formatting; net_address_ip_str recognizes IPv4-mapped IPv6 addresses and emits native IPv4 text; minor syslog plugin log message wording adjusted.

Changes

Cohort / File(s) Summary
Connection label & host composition
include/fluent-bit/flb_connection.h, src/flb_connection.c
Increased FLB_CONNECTION_MAX_LABEL_LENGTH from 7 to 9. Refactored compose_user_friendly_remote_host to unify TCP/UDP formatting, detect IPv6 literals (presence of :) and wrap them in [...]. Added #include <string.h>.
Address stringification / IPv4-mapped handling
src/flb_network.c
net_address_ip_str now detects AF_INET6 addresses that are IPv4-mapped (IN6_IS_ADDR_V4MAPPED), remaps to AF_INET using the last 4 bytes, and calls inet_ntop so mapped addresses render as plain IPv4 strings.
Syslog plugin log messages
plugins/in_syslog/syslog_server.c
Adjusted binding log text from binding %s:%s to binding %s port %s and corresponding error message wording (no control-flow changes).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • #11560 — Addresses the issue where source_address_key emitted IPv4-mapped IPv6 (::ffff:...) by converting mapped addresses to native IPv4 text.
  • #11558 — Adds brackets around IPv6 literals in host:port strings, matching the requested fix for missing [] around IPv6 addresses.

Suggested reviewers

  • edsiper
  • cosmo0920

Poem

🐰 I hop through bytes and network streams,
Brackets snug 'round IPv6 dreams,
Mapped shadows fade to plain IPv4 light,
Hosts now dress tidy, ports sit right,
A joyful nibble — code takes flight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Ipv6 literal fixes' directly summarizes the main changes—addressing IPv6 literal handling issues in syslog input for proper bracketing and IPv4-mapped address detection.
Linked Issues check ✅ Passed All coding requirements from issues #11560 and #11558 are met: IPv4-mapped IPv6 address detection (src/flb_network.c), IPv6 literal bracketing in URLs (src/flb_connection.c), label length adjustment, and log message formatting.
Out of Scope Changes check ✅ Passed All changes directly support the linked issues: macro value update for label length, IPv6 bracket handling, IPv4-mapped address logic, and log message consistency—no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pv2b
Copy link
Contributor Author

pv2b commented Mar 15, 2026

Example config file:

[SERVICE]
    flush        1
    daemon       Off
    log_level    info
    parsers_file ../conf/parsers.conf

[INPUT]
    name         syslog
    tag          syslog
    listen       ::
    mode         udp
    parser       syslog-rfc5424
    source_address_key source

[OUTPUT]
    name         stdout
    match        *

@pv2b
Copy link
Contributor Author

pv2b commented Mar 15, 2026

Debug log output:

Fluent Bit v5.0.0
* Copyright (C) 2015-2025 The Fluent Bit Authors
* Fluent Bit is a CNCF graduated project under the Fluent organization
* https://fluentbit.io

______ _                  _    ______ _ _           _____  _____           _            
|  ___| |                | |   | ___ (_) |         |  ___||  _  |         | |           
| |_  | |_   _  ___ _ __ | |_  | |_/ /_| |_  __   _|___ \ | |/' |______ __| | _____   __
|  _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / /   \ \|  /| |______/ _` |/ _ \ \ / /
| |   | | |_| |  __/ | | | |_  | |_/ / | |_   \ V //\__/ /\ |_/ /     | (_| |  __/\ V / 
\_|   |_|\__,_|\___|_| |_|\__| \____/|_|\__|   \_/ \____(_)\___/       \__,_|\___| \_/


[2026/03/15 12:22:39.447] [ info] [fluent bit] version=5.0.0, commit=1ee3148cc4, pid=57010
[2026/03/15 12:22:39.448] [ info] [storage] ver=1.5.4, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2026/03/15 12:22:39.448] [ info] [simd    ] disabled
[2026/03/15 12:22:39.448] [ info] [cmetrics] version=2.0.2
[2026/03/15 12:22:39.448] [ info] [ctraces ] version=0.7.0
[2026/03/15 12:22:39.448] [ info] [input:syslog:syslog.0] initializing
[2026/03/15 12:22:39.448] [ info] [input:syslog:syslog.0] storage_strategy='memory' (memory only)
[2026/03/15 12:22:39.448] [ info] [in_syslog] UDP server binding :::5140
[2026/03/15 12:22:39.448] [ info] [sp] stream processor started
[2026/03/15 12:22:39.448] [ info] [engine] Shutdown Grace Period=5, Shutdown Input Grace Period=2
[2026/03/15 12:22:39.448] [ info] [output:stdout:stdout.0] worker #0 started
[0] syslog: [[1773577377.055672000, {}], {"pri"=>"13", "time"=>"2026-03-15T12:22:57.055672+00:00", "host"=>"ace7e86ecd9f", "ident"=>"fluent-bit", "pid"=>"-", "msgid"=>"-", "extradata"=>"[timeQuality tzKnown="1" isSynced="1" syncAccuracy="459500"]", "message"=>"test ipv6", "source"=>"udp://[::1]:55505"}]
[0] syslog: [[1773577379.058750000, {}], {"pri"=>"13", "time"=>"2026-03-15T12:22:59.058750+00:00", "host"=>"ace7e86ecd9f", "ident"=>"fluent-bit", "pid"=>"-", "msgid"=>"-", "extradata"=>"[timeQuality tzKnown="1" isSynced="1" syncAccuracy="460500"]", "message"=>"test ipv4", "source"=>"udp://127.0.0.1:50427"}]

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ddc3721b37

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@include/fluent-bit/flb_connection.h`:
- Around line 37-46: The macro FLB_CONNECTION_MAX_LABEL_LENGTH is miscalculated
for IPv6 brackets (should be 9 not 8); update the define
FLB_CONNECTION_MAX_LABEL_LENGTH to 9 and correct the accompanying comment, and
then verify usages in compose_user_friendly_remote_host and the buffer
connection->user_friendly_remote_host to ensure their allocated size accounts
for the updated label overhead plus hostname/port and NUL terminator (increase
buffer allocation if needed) so snprintf bounds remain correct and the formatted
string cannot be truncated into a malformed value.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 243328ff-3724-4484-8152-788c8cba2acc

📥 Commits

Reviewing files that changed from the base of the PR and between acad02a and ddc3721.

📒 Files selected for processing (3)
  • include/fluent-bit/flb_connection.h
  • src/flb_connection.c
  • src/flb_network.c

pv2b added 2 commits March 15, 2026 12:30
Fixes: fluent#11558
Signed-off-by: Per von Zweigbergk <pvz@pvz.pp.se>
Fixes: fluent#11560
Signed-off-by: Per von Zweigbergk <pvz@pvz.pp.se>
@pv2b
Copy link
Contributor Author

pv2b commented Mar 15, 2026

@coderabbitai review
Fixed an off-by-one error

@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

@pv2b Sure, I'll review the changes including the off-by-one fix to FLB_CONNECTION_MAX_LABEL_LENGTH. The debug output looks promising — IPv6 addresses correctly wrapped in brackets (udp://[::1]:55505) and IPv4 literals properly extracted from mapped addresses (udp://127.0.0.1:50427).


🧠 Learnings used
Learnt from: hlein
Repo: fluent/fluent-bit PR: 11199
File: conf/parsers_mikrotik.yaml:61-66
Timestamp: 2025-11-24T23:19:02.599Z
Learning: In Fluent Bit parser configurations, the IPv4 pattern `(?:[0-9]{1,3}\.){3}[0-9]{1,3}` is standardized across parsers (e.g., iptables in parsers_extra.conf, mikrotik parsers) for consistency and maintainability, even though it's permissive and could theoretically match invalid addresses like 999.999.999.999. This is acceptable because the parsers are validated against real-world logs where the input format is controlled by the logging source.

Learnt from: hlein
Repo: fluent/fluent-bit PR: 11168
File: conf/parsers_mult.yaml:8-14
Timestamp: 2025-11-16T22:16:26.032Z
Learning: In Fluent Bit parser configurations (both .conf and .yaml formats), the regex engine automatically strips leading and trailing `/` characters from regex patterns, so patterns like `/Processing by .../` and `Processing by ...` are functionally equivalent and both work correctly.
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@pv2b
Copy link
Contributor Author

pv2b commented Mar 15, 2026

Valgrind output:

==60688== Memcheck, a memory error detector
==60688== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==60688== Using Valgrind-3.24.0 and LibVEX; rerun with -h for copyright info
==60688== Command: ../build/bin/fluent-bit -c syslog-to-stdout.conf
==60688== Parent PID: 60657
==60688== 
==60688== 
==60688== HEAP SUMMARY:
==60688==     in use at exit: 0 bytes in 0 blocks
==60688==   total heap usage: 5,424 allocs, 5,424 frees, 3,065,667 bytes allocated
==60688== 
==60688== All heap blocks were freed -- no leaks are possible
==60688== 
==60688== For lists of detected and suppressed errors, rerun with: -s
==60688== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant