Skip to content

http_client_http2: bracket IPv6 authority hosts#11922

Merged
edsiper merged 2 commits into
masterfrom
http2-ipv6-authority-11895
Jun 5, 2026
Merged

http_client_http2: bracket IPv6 authority hosts#11922
edsiper merged 2 commits into
masterfrom
http2-ipv6-authority-11895

Conversation

@edsiper
Copy link
Copy Markdown
Member

@edsiper edsiper commented Jun 5, 2026

fixes #11895

Fix HTTP/2 :authority generation for IPv6 literal hosts by formatting
unbracketed IPv6 addresses as [host]:port.

Root Cause

The HTTP/2 client built request->authority by appending :<port> directly to
request->host. For IPv6 literals this produced invalid authority values such
as ::1:4317, which strict HTTP/2 servers reject. The older HTTP/1 Host header
path already handled IPv6 bracketing, but the newer HTTP/2 request path did not.

Changes

  • Add IPv6 literal detection in src/flb_http_client_http2.c.
  • Format HTTP/2 authority as [ipv6]:port for unbracketed IPv6 literals.
  • Add an out_opentelemetry integration scenario using IPv6 loopback and HTTP/2.
  • Add a focused raw HTTP/2 test receiver that asserts the emitted :authority.

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

  • Improvements

    • Better IPv6 address handling and authority header formatting for HTTP/2 requests
    • Improved Windows socket compatibility for the HTTP/2 client
  • Tests

    • Added IPv6 HTTP/2 integration tests for OpenTelemetry logging (validates :authority and path)
    • Added test dependency: h2 (pinned to 4.1.0)

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d72db934-8266-454d-a00e-b11cbdcec6e2

📥 Commits

Reviewing files that changed from the base of the PR and between 4fe85f0 and a7e5c40.

📒 Files selected for processing (4)
  • src/flb_http_client_http2.c
  • tests/integration/requirements.txt
  • tests/integration/scenarios/out_opentelemetry/config/out_otel_http2_ipv6_logs.yaml
  • tests/integration/scenarios/out_opentelemetry/tests/test_out_opentelemetry_001.py
✅ Files skipped from review due to trivial changes (1)
  • tests/integration/requirements.txt
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/integration/scenarios/out_opentelemetry/config/out_otel_http2_ipv6_logs.yaml
  • src/flb_http_client_http2.c

📝 Walkthrough

Walkthrough

Adds IPv6-literal detection and authority formatting for HTTP/2 requests, replaces inline authority construction in the request commit path with the new helper, and adds an integration test (with h2) that verifies bracketed IPv6 :authority on the IPv6 loopback.

Changes

IPv6 HTTP/2 Authority Header Formatting

Layer / File(s) Summary
IPv6 authority format helpers in HTTP/2 client
src/flb_http_client_http2.c
Adds Windows socket headers and implements http2_is_ipv6_literal() to detect IPv6 literals (supports %zone) and http2_request_set_authority() to allocate/format request->authority as host:port or [host]:port with error handling.
Apply authority helpers in request commit
src/flb_http_client_http2.c
Replaces manual request->authority construction in flb_http2_request_commit() with http2_request_set_authority(request), removes the temporary sds_result variable, and adds early failure handling for allocation/format errors.
IPv6 HTTP/2 OTLP integration test
tests/integration/requirements.txt, tests/integration/scenarios/out_opentelemetry/config/out_otel_http2_ipv6_logs.yaml, tests/integration/scenarios/out_opentelemetry/tests/test_out_opentelemetry_001.py
Adds h2==4.1.0, a YAML test scenario targeting ::1:<port>, an IPv6-capable HTTP/2 OTLP receiver/service wrapper, and a test that asserts /v1/logs path and :authority equals [::1]:<port>.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • cosmo0920

Poem

🐰 IPv6 brackets, now in place!
Six colons wrapped with grace,
Authority headers, RFC-compliant and bright,
HTTP/2 flows now set it right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.55% 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 'http_client_http2: bracket IPv6 authority hosts' accurately describes the main change—fixing HTTP/2 authority header generation for IPv6 addresses by adding bracketing.
Linked Issues check ✅ Passed The PR successfully addresses all requirements from issue #11895: IPv6 literal detection, RFC-compliant bracketed authority formatting, and comprehensive test coverage via IPv6 HTTP/2 integration tests.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #11895: HTTP/2 client IPv6 authority formatting, supporting infrastructure (test requirements, test configuration), and validation tests.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch http2-ipv6-authority-11895

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/flb_http_client_http2.c

src/flb_http_client_http2.c:29:10: fatal error: 'fluent-bit/flb_info.h' file not found
29 | #include <fluent-bit/flb_info.h>
| ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/a7e5c4044c6a1706fa03447cff2474c276e83c52-b6489214243af2c2/tmp/clang_command_.tmp.918197.txt
++Contents of '/tmp/coderabbit-infer/a7e5c4044c6a1706fa03447cff2474c276e83c52-b6489214243af2c2/tmp/clang_command_.tmp.918197.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-

... [truncated 746 characters] ...

r-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/b6489214243af2c2/file.o" "-x" "c"
"src/flb_http_client_http2.c" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"


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.

Copy link
Copy Markdown

@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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/flb_http_client_http2.c`:
- Around line 109-123: The IPv6 scoped address handling currently strips the
zone when constructing host_for_authority by copying only the part before '%'
into address_buffer; instead, validate the IPv6 address using the substring
before '%' (using inet_pton on address_buffer) but preserve the original scoped
host (the full host string containing '%' and the scope id) when assigning
*host_for_authority so the emitted :authority keeps the scope suffix. Apply the
same change in the other symmetric block that performs the same
inet_pton/host_for_authority assignment (the second occurrence using
zone_id/host_length/address_buffer/inet_pton/host_for_authority).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a01409cb-bb33-4287-991e-938a58ac62bf

📥 Commits

Reviewing files that changed from the base of the PR and between 4cb3476 and 9e4217d.

📒 Files selected for processing (4)
  • src/flb_http_client_http2.c
  • tests/integration/requirements.txt
  • tests/integration/scenarios/out_opentelemetry/config/out_otel_http2_ipv6_logs.yaml
  • tests/integration/scenarios/out_opentelemetry/tests/test_out_opentelemetry_001.py

Comment thread src/flb_http_client_http2.c Outdated
edsiper added 2 commits June 5, 2026 12:08
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
@edsiper edsiper force-pushed the http2-ipv6-authority-11895 branch from 4fe85f0 to a7e5c40 Compare June 5, 2026 18:09
@edsiper edsiper merged commit 5880717 into master Jun 5, 2026
94 of 99 checks passed
@edsiper edsiper deleted the http2-ipv6-authority-11895 branch June 5, 2026 21:45
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.

opentelemetry output plugin with 'http2: on' and IPv6 address generates wrong ':authority' header

1 participant