From 12d4328933e3cebd60b6115d17af15de01ba8470 Mon Sep 17 00:00:00 2001 From: Matheus Castanho Date: Fri, 29 May 2026 16:51:20 -0300 Subject: [PATCH 1/2] Add new test for NoInline in ToC --- c_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/c_test.go b/c_test.go index 023e822..bb968df 100644 --- a/c_test.go +++ b/c_test.go @@ -2,6 +2,7 @@ package cbpfc import ( "bytes" + "strings" "testing" "github.com/cilium/ebpf" @@ -30,6 +31,22 @@ func TestFunctionName(t *testing.T) { checkName(t, "a2", true) } +func TestToCNoInline(t *testing.T) { + elf, err := ToC([]bpf.Instruction{ + bpf.RetConstant{Val: 1}, + }, COpts{ + FunctionName: "filter", + NoInline: true, + }) + if err != nil { + t.Fatal(err) + } + + if strings.Contains(elf, "__always_inline__") { + t.Fatal("generated C source should not contain __always_inline__ when NoInline is true") + } +} + func TestNoInline(t *testing.T) { elf, err := buildC([]bpf.Instruction{ bpf.RetConstant{Val: 1}, From 565914bbce5edcb2127c30b3d3e867df6e28c7d3 Mon Sep 17 00:00:00 2001 From: Matheus Castanho Date: Fri, 29 May 2026 16:55:33 -0300 Subject: [PATCH 2/2] Fix ToC to respect NoInline argument Previously the ToC function silently ignored the NoInline option passed as argument to it. Even though the template correctly considered it, the value specified by the caller was not being passed down to the template execution function. --- c.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/c.go b/c.go index 80534e6..68f7533 100644 --- a/c.go +++ b/c.go @@ -106,8 +106,9 @@ func ToC(filter []bpf.Instruction, opts COpts) (string, error) { } fun := cFunction{ - Name: opts.FunctionName, - Blocks: make([]cBlock, len(blocks)), + Name: opts.FunctionName, + NoInline: opts.NoInline, + Blocks: make([]cBlock, len(blocks)), } // Compile blocks to C