Skip to content

Remove dependency on vmlinux.h - #40482

Open
dramforever wants to merge 6 commits into
systemd:mainfrom
dramforever:no-vmlinux-h
Open

dramforever wants to merge 6 commits into
systemd:mainfrom
dramforever:no-vmlinux-h

Conversation

@dramforever

@dramforever dramforever commented Jan 27, 2026 •

Copy link
Copy Markdown
Contributor

Don't depend on vmlinux.h for types in *.bpf.c. Instead, follow what was done in restrict-fs.bpf.c, and include what we can from ABI stable user headers, and define the rest ourselves, with __attribute__((preserve_access_index)) on structures.

Depending on vmlinux.h complicates the build process. There doesn't seem to be a clean way to get a vmlinux.h:

  • Generating the vmlinux.h from the running kernel with /sys/kernel/btf/vmlinux doesn't work for environments that deliberately hide /sys for build reproducibility.
  • There seems to be no way to build a vmlinux.h without building an entire kernel at the same time, which complicates the build dependencies of systemd. This is especially painful for building systemd from source, including cross compilation use cases.
  • https://github.com/libbpf/vmlinux.h provides vmlinux.h but has a "Development-only" warning. Even if you ignore that warning, it doesn't enable enough configs to provide struct bpf_sysctl.

So IMO not depending on vmlinux.h is the better choice. Using our own types is no worse than loading these BPF programs on the kernel version different from the one that generated vmlinux.h, and, if anything, makes it more explicit what implementation details of the kernel we actually depend on.

Summary of what was done:

  • The BPF programs userns-restrict.bpf.c and sysctl-monitor.bpf.c no longer depends on vmlinux.h for types.
  • The build options vmlinux-h and vmlinux-h-path and associated handling are removed since they're unused.
  • The configuration HAVE_VMLINUX_H is removed. References are removed or changed to the more general BPF_FRAMEWORK.
  • The +/-BTF feature is removed since it's now meaningless. test/units/TEST-29-PORTABLE.user.sh referred to it, so it was changed to check BPF_FRAMEWORK.

Instead of relying on vmlinux.h, bring in types from UAPI headers and
define the remaining types ourselves, similar to what we do in
restrict-fs.bpf.c.
Instead of relying on vmlinux.h, bring in types from UAPI headers.
Since vmlinux.h is no longer required, this feature is now meaningless.
Remove it.

There was a test checking for BTF. Change it to check BPF_FRAMEWORK
instead.
Since vmlinux.h is no longer required, HAVE_VMLINUX_H is now
meaningless. Check BPF_FRAMEWORK instead.
Since vmlinux.h is no longer required, all related build system code can
be removed.

Make ENABLE_SYSCTL_BPF depend on BPF_FRAMEWORK instead of
HAVE_VMLINUX_H.
Nothing includes vmlinux.h now. Remove it from .clang-format.
@bluca

bluca commented Jan 27, 2026 •

Copy link
Copy Markdown
Member

Very strongly disagree with this. All main distributions now provide an appropriate vmlinux.h in a package that can be trivially used. It's very simple to generate and package when building the kernel.
Vendoring more stuff is dangerous, more work-intensive and doesn't solve any real problem that is not already solved elsewhere. There's no real guarantee that what is vendored here will work on any kernel past, future or present. The only safe solution is to use the sources from the target kernel, which is what we are already doing thanks to the packaged vmlinux.h.

@bluca bluca added needs-discussion 🤔 and removed please-review PR is ready for (re-)review by a maintainer labels Jan 27, 2026
@daandemeyer

Copy link
Copy Markdown
Collaborator

I agree with @bluca. If there is no good way to get vmlinux.h in your environment, that's something to solve in your environment, not in every project that uses vmlinux.h for its BPF programs.

@alyssais

Copy link
Copy Markdown
Contributor

Vendoring more stuff is dangerous, more work-intensive and doesn't solve any real problem that is not already solved elsewhere. There's no real guarantee that what is vendored here will work on any kernel past, future or present. The only safe solution is to use the sources from the target kernel, which is what we are already doing thanks to the packaged vmlinux.h.

As a distribution, we support different kernels. There's equally no guarantee that a vmlinux.h we generate from one kernel will "work on any [other] kernel past, future or present". Are you saying we need to build one systemd per kernel?

@bluca

bluca commented Jan 27, 2026

Copy link
Copy Markdown
Member

Vendoring more stuff is dangerous, more work-intensive and doesn't solve any real problem that is not already solved elsewhere. There's no real guarantee that what is vendored here will work on any kernel past, future or present. The only safe solution is to use the sources from the target kernel, which is what we are already doing thanks to the packaged vmlinux.h.

As a distribution, we support different kernels. There's equally no guarantee that a vmlinux.h we generate from one kernel will "work on any [other] kernel past, future or present". Are you saying we need to build one systemd per kernel?

It's up to you to make sure you use one that guarantees the highest compatibility range. What that means is unclear to me, probably you want to pick the kernel build with the largest number of enabled features among the ones you have, and hope there's no incompatibility. But you definitely have higher chances to make that work, than hardcoding the one generated on someone's laptop, and hoping it never breaks and works everywhere, backward and forward in time.

@dramforever

dramforever commented Jan 27, 2026 •

Copy link
Copy Markdown
Contributor Author

But you definitely have higher chances to make that work, than hardcoding the one generated on someone's laptop, and hoping it never breaks and works everywhere, backward and forward in time.

Perhaps there was a misunderstanding? I didn't generate a vmlinux.h. Instead, I wrote down the kernel types and struct fields that userns-restrict.bpf.c needs. These are not more hardcoded than userns-restrict.bpf.c itself.

libbpf's CO-RE support handles actually accessing kernel structure fields such that the BPF object code is resilient to changes in the kernel-internal structs, as long as the accessed fields are not affected.

This isn't even a new thing in-tree. Of the 6 .bpf.c programs, 4 don't depend on vmlinux.h, and restrict-fs.bpf.c is already using explicitly defined types with struct subsets having __attribute__((preserve_access_index)).

Of course whether explicitly defining used types and fields is preferable remains up to discussion, but I thought I should make it clear that this isn't vendoring a generated vmlinux.h.

@poettering

Copy link
Copy Markdown
Member

As a distribution, we support different kernels. There's equally no guarantee that a vmlinux.h we generate from one kernel will "work on any [other] kernel past, future or present". Are you saying we need to build one systemd per kernel?

you don't, ebpf knows how to deal with slight differences in the structures. hence: you need a somewhat recent vmlinuz.h, but not one that strictly matches your kernel, unless the structures we bind to are massively changed, i.e. more than just offset changes.

@bluca

bluca commented Jan 27, 2026

Copy link
Copy Markdown
Member

I thought I should make it clear that this isn't vendoring a generated vmlinux.h.

It's pretty much equivalent though. There is no guarantee whatsoever that what you generated/copied/manually written here is going to be compatible with a riscv32 kernel 3 years from now with a different kconfig, and viceversa. There is no guarantee of compatibility made by these bpf headers, we don't know what it will be a year from now, what it was a year ago, what it's going to be once the next 1, 2, 3 modules get added.

The safest approach is the one we took - get distributions to generate a vmlinux.h when the target kernels are built, so that there is a reasonable hope of compatibility since there is as-near-as-it-can-be 1:1 matching between what is built and what is ran, with the undertanding that it will always be best-effort. So far it worked out pretty well.

It took a great deal of effort to get all of this infrastructure sorted out and in place, and I very strongly disagree with throwing all of that away and go back to hope things might just work out somehow with hardcoding definitions, just because one distribution hasn't done the work to package the vmlinux.h yet.
Just add it? It's really simple change in your kernel package build, it shouldn't take more than a few minutes, and then you are sorted for life too. It's one single command to generate it after the kernel image build, and then you pick the header up and package it.

@alyssais

Copy link
Copy Markdown
Contributor

We absolutely can add it. We're not bringing this because packaging the header is difficult, but because to us it looks less safe than the approach suggested here. (@dramforever can probably explain the logic behind that better than I can.)

@dramforever

Copy link
Copy Markdown
Contributor Author

@alyssais I don't think it is less safe, since BTF type checking should catch exactly the same set of problems.

My main point is build complexity. Perhaps I should elaborate one use case.

Let's say I want to cross compile a source distro, and I want to use systemd on it with unprivileged nspawn enabled, because there's no reason it shouldn't work.

Here, I can't use the build machine's vmlinux.h, since struct pt_regs or struct user_pt_regs would be different. So unless I come up with a vmlinux.h subset somehow, I'd have to compile the kernel first.

And many different machines need their own kernels (16 KiB page arm64, kernel forks for random platforms, some mips64 machine-specific configs...), so I have a few options on wiring this up:

  • Build systemd using a vmlinux.h built with a generic kernel, or a "canonical" machine's kernel. This basically builds the vmlinux.h the same as you would on a "normal" distro, but I have to build the kernel twice, just because I want some BPF programs that are supposed to be mostly kernel version agnostic.
  • Build systemd using a vmlinux.h built with a trimmed down kernel, perhaps a mod2noconfig one. This saves time compared to the previous approach. But still builds an extra special kernel.
  • Build systemd using vmlinux.h generated by the machine-specific kernel. This saves yet more build time but requires configuring the build process of systemd with machine-specific information, and puts the kernel build on what's likely to be the critical path to systemd.

All of these approaches are relatively easy with Nixpkgs, but it is my opinion that none of these are necessary. Not having to depend on the kernel is the reason many projects maintain a vmlinux.h subset, and I am still not convinced it's a bad thing - it is in fact a definition of the interface between the eBPF program and the kernel.

@bluca

bluca commented Jan 27, 2026

Copy link
Copy Markdown
Member

Here, I can't use the build machine's vmlinux.h, since struct pt_regs or struct user_pt_regs would be different. So unless I come up with a vmlinux.h subset somehow, I'd have to compile the kernel first.

Yes, but that's why distributions now generate and ship it as part of their kernel builds in a package that you can install and reference. You don't need to come up with anything, just use what the kernel package build provides. In fact one of the reason to package this is to avoid everyone having to figure out what they are supposed to do every time, from scratch, and take wild guesses.

You have generated/written/copied a subset of headers here that you have tested on nixos x86-64 with a current kernel, I assume. You have no way to know that this is going to work out of the box 2 years from now on a debian loongarch kernel. You have no way to know that it works with a fedora armv7 kernel from 2 years argo. This is not a whack-a-mole game that we can play and win, it is not sustainable, it risks breaking every time someone changes arch/kconfig/distro, and every time a new bpf program is added.

Using a header generated by the distro from a kernel close enough to the one that is going to be deployed is not a perfect solution, but it's by far the safest and most-compatible one that we have. If your distro has multiple kernels at the same time, that's not really a difficult problem - just pick one and go with it, and the result is not really any worse than hardcoding everything. Maybe one day the BPF internal interfaces will have the same stability guarantees as UAPI interfaces, but for now that's not the case, and we have to deal with what we have, unfortunately.

@dramforever

dramforever commented Jan 27, 2026 •

Copy link
Copy Markdown
Contributor Author

The safest approach is the one we took - get distributions to generate a vmlinux.h when the target kernels are built, so that there is a reasonable hope of compatibility since there is as-near-as-it-can-be 1:1 matching between what is built and what is ran, with the undertanding that it will always be best-effort. So far it worked out pretty well.

Using vmlinux.h is not the safest approach regarding compatibility.

For compatibility with multiple kernel versions, we need to use CO-RE queries to check for variations and pick the correct types to use. When that happens we need to explicitly define multiple type variations and can't rely on a generated vmlinux.h to have all of them. So if anything, defining the interfaces explicitly is (part of) what allows future compatibility.

See https://docs.ebpf.io/ebpf-library/libbpf/ebpf/ "CO-RE queries", noting in particular the example for bpf_core_type_matches, and e.g. https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html for an overview

@Ericson2314 Ericson2314 mentioned this pull request Jan 29, 2026
4 of 13 tasks
@dramforever

Copy link
Copy Markdown
Contributor Author

I've found a recent-ish real example of eBPF handling of kernel internal ABI changes. I hope this will, if not convince you, at least provide a reference to what I have been talking about. This is in https://github.com/loresuso/psc and AFAICT is not yet completely resolved:

What happened was that in Linux 6.3 the type kernel_cap_t changed from:

// Linux < 6.3
typedef struct kernel_cap_struct {
	__u32 cap[_KERNEL_CAPABILITY_U32S];
} kernel_cap_t;

To:

// Linux >= 6.3
typedef struct { u64 val; } kernel_cap_t;

Therefore, if you want your eBPF program to be built with a new kernel's vmlinux.h and be ABI-compatible to both, you can use the approach in loresuso/psc@2ec2889, where effectively what it does is:

struct kernel_cap_struct___old {
	__u32 cap[2];
} __attribute__((preserve_access_index));

if (bpf_core_field_exists(cred->cap_effective.val)) {
	/* (Indirectly) use kernel_cap_t from vmlinux.h */
} else {
	/* Use struct kernel_cap_struct___old */
}

If, however, you want the eBPF program to be buildable with an old kernel's vmlinux.h as well (thus addressing loresuso/psc#1), you'd need your own kernel_cap_t___new to check against:

typedef struct {
	u64 val;
} __attribute__((preserve_access_index)) kernel_cap_t___new;

And the kernel_cap_t in vmlinux.h cannot be relied on at all.

This is why I said that "Using vmlinux.h is not the safest approach regarding compatibility." When, say, Linux 7.n breaks one of the structs we use in the kprobe, I believe the most likely case is similar to the psc thing, where the types will change significantly, and both source and binary compat will be broken, and no amount of "Using a header generated by the distro from a kernel close enough to the one that is going to be deployed" will fix it. By then will have to define the two variants in our code and check them with libbpf CO-RE queries.

(Even if it doesn't change that much, say just a u32 vs u64 change, the program will probably just silently use the wrong size thanks to C implicit conversions. I don't think I can accept that this is "by far the safest and most-compatible one that we have". Even if we consider not catching this mismatch a bug in the compiler/libbpf and it's fixed, that will just make loading the program fail, still breaking binary compat.)

So, even though I can acknowledge that vmlinux.h provides convenience for eBPF program authors in the happy case (while complicating the work of packagers), I still think it is mistaken to think it provides compatibility, source or binary.

@yuwata

yuwata commented Feb 4, 2026

Copy link
Copy Markdown
Member

kernel internal ABI changes

Terrible. I do not think it is not 'internal', as it is exposed through vmlinux.h ...
The kernel should not change like that, and should provide a way to keep compatibility.

@dramforever

dramforever commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Terrible. I do not think it is not 'internal', as it is exposed through vmlinux.h ...

Sadly not the world we live in, and unfortunately I don't think there's anything we can do about this. Most? "advanced" eBPF programs (HID, LSM, kprobe...) are basically slightly safer kernel modules and "enjoy" the same source and binary compat breakages. We make do with what we can with CO-RE relocations and queries.

Also even if the types don't change, the kprobe in userns-restrict.bpf.c completely relies on implementation details of the kernel, so it's gonna be a problem no matter what.

BPF-LSM at least is more of an interface. Still kernel internal though...

The only way to "truly" fix these is to somehow have the kernel support this inherently. The fact that these eBPF CO-RE stuff even exists speaks to the difficulty of that, though...

@poettering

Copy link
Copy Markdown
Member

I am not sure I follow? ebpf works the way it works: the kernel's internals are not generally stable, and the ebpf code inserts itself into that world, so it has to accept that. Our ebpf programs hence are not completely and universally and forever stable, because they can't be, because they use kernel constructs which are not considered stable forever. But then again, the interfaces that we use, have been very stable in in the past years, at least to the level that CO-RE can handle them fine. So it's empiric stability, not political stability, if you so will.

But this all has nothing to do with vmlinux.h, because that just is a convenient way for us to make use of kernel structures. If you do eBPF it's kinda what you have to do, unless you copy the relevant structs into your own code, but this wins you nothing, they do not become stable kernel's ABI.

Hence, I am not impressed by @dramforever's points at all: they might be worth something if the discussion was about "should we use ebpf at all?" or about "should the kernel have an internal stable ABI?". But this is not the discussion we are having here, we have one about vmlinux.h and that's orthogonal to both questions.

Hence, sorry, I really don#t get what the issue is supposed to be.

@poettering

Copy link
Copy Markdown
Member

I mean, you are just copying the relevant structs from vmlinux.h into our codebase. how does that change anything about anything? you just renamed the file where the structs that come with weak abi guarantees are placed. that makes no effective difference. hence, sorry, but this PR seems entirely unnecessary?

also, systemd is not the only subsystem using ebpf. Are you patching vmlinux.h out of everything? who is helped by that???

@dramforever

Copy link
Copy Markdown
Contributor Author

My original point was the point made in the pull request description: Depending on a vmlinux.h and hence a kernel build complicates the build process of systemd, a core component on many distros.

If among:

  1. Writing ~60 lines of Linux UAPI includes and kernel internal struct subset definitions
  2. Writing ~60 lines of meson.build to grab a vmlinux.h, which the packager is expected to provide

The systemd team thinks the convenience of 2 outweighs the build process complication, then I can accept that and consider this a wontfix.


However, the discussion was muddled when vmlinux.h was described as, by itself, the compatibility mechanism, in e.g. #40482 (comment)

The safest approach is the one we took - get distributions to generate a vmlinux.h when the target kernels are built, so that there is a reasonable hope of compatibility since there is as-near-as-it-can-be 1:1 matching between what is built and what is ran, with the undertanding that it will always be best-effort. So far it worked out pretty well.

Most of the typing has been spent on arguing this...

I mean, you are just copying the relevant structs from vmlinux.h into our codebase. how does that change anything about anything?

Exactly. I agree that this doesn't change anything regarding compatibility.

@keszybz

keszybz commented Feb 13, 2026 •

Copy link
Copy Markdown
Member

if you want your eBPF program to be built with a new kernel's vmlinux.h and be ABI-compatible to both, you can use the approach in loresuso/psc@2ec2889

In this patch series, some types are copied ("vendored") into our source. This drops the dependency on vmlinux.h, but we still refer to the same fields in the same structures as before. You link to the patch which introduces a if (bpf_core_field_exists(…)) check. So IIUC, if one of the structures that we use in our code changes incompatibly, we'd still need to introduce a similar check in our codebase. So the vendoring of the struct definitions doesn't help us to be forward-compatible. If we encounter such a case in the future, we can always vendor the struct definition at that point, no?

(EDIT: I wrote this in parallel with the discussion happening above. My question is answered.)

@bluca

bluca commented Feb 13, 2026

Copy link
Copy Markdown
Member

Depending on a vmlinux.h and hence a kernel build complicates the build process of systemd, a core component on many distros.

That may be the case on NIX, but it is certainly not the case anywhere else. We just got the file packaged in the relevant distros, and then it's just a build dependency like any other, and like the other kernel UAPI headers or so. There's no complication whatsoever, just a new build-depends.

@bluca

bluca commented Feb 13, 2026

Copy link
Copy Markdown
Member

Also the Fedora packaging guidelines are going to require using the prebuilt vmlinux.h, rather than hardcoding and vendoring, so more and more software will require a shipped vmlinux.h: https://fosdem.org/2026/schedule/event/VSXPA8-packaging-ebpf-in-linux-distros/

@pwaller

pwaller commented Feb 13, 2026 •

Copy link
Copy Markdown
Contributor

how does that change anything about anything?

Imagine if every rpm that depends on libsystemd had to be rebuilt every time the kernel was updated. That's essentially what happens in an input-addressed build system. Nixpkgs (and other similarly shaped systems) need a way out to avoid having the kernel appear as a transitive dependency through systemd for many other packages.

@bluca

bluca commented Feb 13, 2026

Copy link
Copy Markdown
Member

Sorry, but hardcoding and vendoring generated code from someone's laptop is really not something worth doing to solve an internal nix build issue (that doesn't happen on any other distro, fyi). If you want to vendor this kernel header, you can just do it in your nix package. You don't even need a patch, you just point the meson option to where you vendor it in the source tree.

@dramforever

Copy link
Copy Markdown
Contributor Author

I don't mind if systemd maintainers don't care about making Nixpkgs's life easier with this. If it's just for Nixpkgs I wouldn't have bothered posting this PR here.

However, systemd isn't just used in "normal" binary distros. For any source distro, as what is currently implemented, we can't build a fully featured systemd, a core, userland program, without having to also build a kernel.

If the systemd maintainers think that's desirable, then I don't mind keeping whatever stuff we need to get this working within Nixpkgs/NixOS.

@pwaller

pwaller commented Feb 13, 2026

Copy link
Copy Markdown
Contributor

hardcoding and vendoring generated code from someone's laptop is really not something worth doing to solve an internal nix build issue

Understood, and I am not pushing for any particular solution. Just wanted to highlight that the issue at hand. I'm not sure it's true that nixpkgs is the only distro with this issue for what it's worth. It would be nice if there was a proper solution; as @pottering suggests maybe such a thing would have to be in kernel space. Finding the common ground, long term solution that can be deployed today would be nice, but if it requires planting trees then that is worth acknowledging as well.

@Ericson2314

Ericson2314 commented Feb 14, 2026 •

Copy link
Copy Markdown

Something that all you systemd maintainers have missed is that what @dramforever is trying to do is not some weird thing us Nix people have made up, but in fact established CO-RE best practice.

Here's my evidence:

  1. In this very repo we have some inlined vmlinux.h already! See

    struct super_block {
    unsigned long s_magic;
    } __attribute__((preserve_access_index));
    struct inode {
    struct super_block *i_sb;
    } __attribute__((preserve_access_index));
    struct file {
    struct inode *f_inode;
    } __attribute__((preserve_access_index));
    super_block, inode, and file are all structs defined in vmlinux.h already. This file doesn't vendor them as is, but just includes the fields the program actually uses. __attribute__((preserve_access_index)) will do the rest, magically ensuring everything works at runtime.

    This is exactly how CO-RE is meant to be employed. If you all want vmlinux.h to always be used, and never vendored even in part, then to be consistent you need to not only reject this PR, but also modify that file to instead include vmlinux.h and delete those definitions. I think that would be a bad move, but I would at least appreciate the consistent enforcement of the policy, regardless of what the policy is.

  2. https://github.com/torvalds/linux/blob/master/Documentation/bpf/prog_lsm.rst#structure The documentation mentions both ways of doing things

  3. torvalds/linux@a887466 this commit replaced the generated vmlinux.h with a shrunked vendored ones --- even the kernel developers themselves found this workflow of depending on kernel build too annoying! Now, to be transparent in torvalds/linux@b7a2d77 they added back the generation way as another option, with GEN_VMLINUX_H, but it is still not the default.

Also to address two things @poettering said

I mean, you are just copying the relevant structs from vmlinux.h into our codebase. how does that change anything about anything? you just renamed the file where the structs that come with weak abi guarantees are placed. that makes no effective difference. hence, sorry, but this PR seems entirely unnecessary?

The key point is that we're not coppying the entire struct whole hog --- that would indeed be mindless vendoring. We're instead just putting in the data definitions that the programs actually used --- small portions of the relevant structs. This is much better --- it is documenting exactly to what the assumptions on the kernel interfaces are. Or, in the original since of "interface" as the intersection of what's wanted/provided, it is exactly the interlace between the BFP program and the kernel, explicitly written down.

(If anyone is familiar with https://ocaml.org/docs/functors, that is a useful comparison to the above.)

So it's empiric stability, not political stability, if you so will.

You can think of the above as codifying the "empirically stable" bits, rather than keeping it an unspoken assumption as to which aspects of vmlinux.h are stable to depend upon.

also, systemd is not the only subsystem using ebpf. Are you patching vmlinux.h out of everything? who is helped by that???

Yes ideally every program would do this, but systemd is especially early in our bootstrap / dependency graph, because of the core libraries it provides.

We have some hacks to build the libraries and the executables separately, and we might end up using them if this PR is not accepted. But it would be much nicer if you all would use e.g. Meson subprojects to natively support building different parts of systemd separately --- really, that would be fantastic. Then things like systemd-nsresourced would not have a boatload of reverse dependencies, and it alone depending on the kernel build would be far less frustrating.

@LekKit

LekKit commented Feb 16, 2026

Copy link
Copy Markdown

Sorry, but hardcoding and vendoring generated code from someone's laptop is really not something worth doing to solve an internal nix build issue (that doesn't happen on any other distro, fyi). If you want to vendor this kernel header, you can just do it in your nix package. You don't even need a patch, you just point the meson option to where you vendor it in the source tree.

Sorry, but you are incorrect. This is neither hardcoding nor vendoring, at least not to the extent more than what's already conveyed in-tree.
Loaded BPF code always relocates used struct offsets to match the running kernel. The only way it could break is if the struct field is actually removed in the kernel. If the BPF modules ever break, it's because of eventual API incompatibility with the running kernel rather than any headers or struct field definitions.

This PR doesn't change that fact in any way, other than it clearly defines the names of used structure fields before they are used, and removes the (arguably, messy) dependency on a vmlinux.h produced by kernel build. And it's not the first time it's done in-tree in systemd.

@Ericson2314

Copy link
Copy Markdown

Can someone read the latest comments? I think I wrote a pretty air-tight, backed-with-evidenced argument, if I may so myself, but it's been crickets ever since (though I do appreciate @LekKit's agreement :)).

This branch has not been deployed

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

Development

Successfully merging this pull request may close these issues.

10 participants