Skip to content

Handling for inet_lookup compilation error - #196

Merged
mpenny-github merged 3 commits into
masterfrom
inet_lookup_established_error
Aug 3, 2026
Merged

mpenny-github merged 3 commits into
masterfrom
inet_lookup_established_error

Conversation

@mpenny-github

@mpenny-github mpenny-github commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Root cause

The helpers inet_lookup_established(), __inet6_lookup_established(),
inet_lookup_listener(), and inet6_lookup_listener() dropped their
struct inet_hashinfo *hashinfo parameter — the global tcp_hashinfo is now
reached internally via the network namespace, so callers no longer pass
&tcp_hashinfo. Because distributions may backport this change independently of
the mainline version, a LINUX_VERSION_CODE check alone is not reliable.
torvalds/linux@cb16f4b6c73d

Changes

  • ipt_GLBREDIRECT.c: introduce a GLB_TCP_HASHINFO_ARG macro that expands
    to &tcp_hashinfo, on kernels that still expect the argument, or to nothing on
    kernels that dropped it. The four call sites now use the macro instead of a
    hard-coded &tcp_hashinfo,. The macro is selected by a build-time probe (see
    below), with a LINUX_VERSION_CODE fallback only when the headers can't be
    read. This mirrors the existing autodetection already used for the
    __cookie_v[46]_check() arity change.
  • Makefile: probe include/net/inet_hashtables.h for the
    inet_lookup_established declaration and emit
    -DGLB_INET_LOOKUP_HAS_HASHINFO_ARG or -DGLB_INET_LOOKUP_NO_HASHINFO_ARG
    depending on whether the inet_hashinfo parameter is present. Also adds a
    print-lookup-arg helper target that echoes the resolved flag.
  • script/test: add a lookup_arg_detection_check() step that drives the
    Makefile probe against fixture headers for both the old and new API forms,
    asserting the correct macro is selected. This covers both detection branches
    regardless of the host kernel and needs only make + awk (no full kernel
    build).

Why autodetection instead of a version check

The mainline-vs-backport ambiguity means a fixed version boundary can be wrong
on distro kernels. The header probe is deterministic and authoritative; the
LINUX_VERSION_CODE fallback is only a last resort for when the kernel headers
can't be read at build time.

Testing

  • compile_check builds the module + userspace target against the running
    kernel.
  • lookup_arg_detection_check validates the probe classifies both header forms
    correctly (old form with the inet_hashinfo parameter → "has arg"; new form
    without it → "no arg").
  • Verified the module compiles cleanly against a kernel that has removed the
    argument.

Copilot AI review requested due to automatic review settings July 31, 2026 16:09
@mpenny-github mpenny-github changed the title Handling for inet_lookup_established error Handling for inet_lookup compilation error Jul 31, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds compatibility handling for Linux socket-lookup helper signature changes.

Changes:

  • Detects lookup-helper arity from kernel headers.
  • Adapts four socket lookup call sites.
  • Tests both detected API variants.
Show a summary per file
File Description
src/glb-redirect/Makefile Adds header probing and diagnostic target.
src/glb-redirect/ipt_GLBREDIRECT.c Adds compatibility macro and updates calls.
src/glb-redirect/script/test Tests both probe outcomes.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread src/glb-redirect/ipt_GLBREDIRECT.c Outdated
Comment thread src/glb-redirect/Makefile Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mpenny-github
mpenny-github requested a review from Copilot July 31, 2026 16:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@mpenny-github
mpenny-github merged commit 0c9c384 into master Aug 3, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants