Skip to contentSkip to conversation

Add uapi header import script

PATCH In review Kory Maincent 3 participants 11 messages Sep 9, 2025 – Sep 16, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Add uapi header import script

Add a script to automate importing Linux UAPI headers from kernel source. The script handles dependency resolution and creates a commit with proper attribution, similar to the ethtool project approach.

Run the script and import the current state of Linux UAPI header from net-next.

---
Kory Maincent (2):
scripts: Add uapi header import script
Update kernel headers

 include/uapi/linux/devlink.h |  2 ++
 include/uapi/linux/if_link.h |  1 +
 include/uapi/linux/stddef.h  |  1 -
 scripts/iproute2-import-uapi | 67 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 70 insertions(+), 1 deletion(-)

---
base-commit: 68ba2bc6e2d060526496bc79591b09fcbc851a7f
change-id: 20250909-feature_uapi_import-8bdbade4fb93

Best regards,

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#1 lore raw

PATCH 1/2 scripts: Add uapi header import script

Add a script to automate importing Linux UAPI headers from kernel source. The script handles dependency resolution and creates a commit with proper attribution, similar to the ethtool project approach.

Usage:

    $ LINUX_GIT="$LINUX_PATH" iproute2-import-uapi [commit]
---
 scripts/iproute2-import-uapi | 67 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
scripts/iproute2-import-uapi new file +67 -0
new file mode 100755
index 00000000..505ab25a
@@ -0,0 +1,67 @@
+#!/bin/bash -e
+#
+# iproute2-import-uapi [commit]
+#
+# Imports sanitized copies of kernel uapi headers from <commit> (can be
+# a commit id, a tag or a branch name). If the argument is omitted,
+# commit currently checked out in the kernel repository is used.
+
+sn="${0##*/}"
+export ARCH="x86_64"
+mkopt="-j$(nproc)" || mkopt=''
+
+if [ ! -d "$LINUX_GIT" ]; then
+    echo "${sn}: please set LINUX_GIT to the location of kernel git" >&2
+    exit 1
+fi
+
+pushd "$LINUX_GIT"
+if [ -n "$1" ]; then
+    git checkout "$1"
+fi
+desc=$(git describe --exact-match 2>/dev/null \
+       || git show -s --abbrev=12 --pretty='%h: ("%s")')
+kobj=$(mktemp -d)
+make $mkopt O="$kobj" allmodconfig
+make $mkopt O="$kobj" prepare
+make $mkopt O="$kobj" INSTALL_HDR_PATH="${kobj}/hdr" headers_install
+popd
+
+pushd include/uapi
+find . -type f -name '*.h' -exec cp -v "${kobj}/hdr/include/{}" {} \;
+
+go_on=true
+while $go_on; do
+    go_on=false
+    while read f; do
+        if [ "${f#asm/}" != "$f" ]; then
+            # skip architecture dependent asm/ headers
+            continue
+        fi
+        if [ -f "$f" ]; then
+            # already present
+            continue
+        fi
+	if [ ! -f "${kobj}/hdr/include/${f}" ]; then
+            # not a kernel header
+            continue
+        fi
+        echo "+ add $f"
+        go_on=true
+        mkdir -p "${f%/*}"
+        cp "${kobj}/hdr/include/${f}" "${f}"
+    done < <(
+        find . -type f -name '*.[ch]' -exec sed -nre '\_^[[:blank:]]*#include[[:blank:]]<.+>_ { s_^[[:blank:]]*#include[[:blank:]]<([^>]*)>.*$_\1_ ; p }' {} \; \
+            | LC_ALL=C sort -u
+    )
+done
+popd
+rm -rf "$kobj"
+
+git add include/uapi
+git commit -s -F - <<EOT
+Update kernel headers
+
+Update kernel headers to commit:
+	${desc}
+EOT
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH iproute2-next 1/2] scripts: Add uapi header import script

Quoted 4 lines · Kory Maincent

Add a script to automate importing Linux UAPI headers from kernel source. The script handles dependency resolution and creates a commit with proper attribution, similar to the ethtool project approach.

Quoted 8 lines

Usage:

    $ LINUX_GIT="$LINUX_PATH" iproute2-import-uapi [commit]
---
 scripts/iproute2-import-uapi | 67 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

Stephen and I have scripts for this, but this one is fairly easy to use, so applied.

#3 lore raw

Re: [PATCH iproute2-next 1/2] scripts: Add uapi header import script

In reply to Kory Maincent
Quoted 8 lines · On Tue, 09 Sep 2025 15:21:42 +0200 Kory Maincent <[email protected]>…

Add a script to automate importing Linux UAPI headers from kernel source. The script handles dependency resolution and creates a commit with proper attribution, similar to the ethtool project approach.

Usage:

    $ LINUX_GIT="$LINUX_PATH" iproute2-import-uapi [commit]

I will continue to use my script which works off of headers processed by "make headers_install"

#4 lore raw

Re: [PATCH iproute2-next 1/2] scripts: Add uapi header import script

In reply to Kory Maincent
Quoted 8 lines · On Tue, 09 Sep 2025 15:21:42 +0200 Kory Maincent <[email protected]>…

Add a script to automate importing Linux UAPI headers from kernel source. The script handles dependency resolution and creates a commit with proper attribution, similar to the ethtool project approach.

Usage:

    $ LINUX_GIT="$LINUX_PATH" iproute2-import-uapi [commit]

This script doesn't handle the fact that kernel headers for iproute exist in multiple locations because rdma and vduse.

#5 lore raw

Re: [PATCH iproute2-next 1/2] scripts: Add uapi header import script

Quoted 7 lines · Stephen Hemminger
Quoted 4 lines · On Tue, 09 Sep 2025 15:21:42 +0200 Kory Maincent <[email protected]>…

Add a script to automate importing Linux UAPI headers from kernel source. The script handles dependency resolution and creates a commit with proper attribution, similar to the ethtool project approach.

Quoted 7 lines
Quoted 4 lines

Usage:

    $ LINUX_GIT="$LINUX_PATH" iproute2-import-uapi [commit]

This script doesn't handle the fact that kernel headers for iproute exist in multiple locations because rdma and vduse.

rdma and vdpa are not synced from net-next.

#6 lore raw

Re: [PATCH iproute2-next 1/2] scripts: Add uapi header import script

In reply to Kory Maincent
Quoted 9 lines · On Tue, 09 Sep 2025 15:21:42 +0200 Kory Maincent <[email protected]>…

Add a script to automate importing Linux UAPI headers from kernel source. The script handles dependency resolution and creates a commit with proper attribution, similar to the ethtool project approach.

Usage:

    $ LINUX_GIT="$LINUX_PATH" iproute2-import-uapi [commit]

---

Script I use is much simpler.

#! /bin/bash

# script to copy sanitized kernel headers

if [ $# -ne 1 ]; then
echo "Usage: $0 kernel-directory"
exit 1
fi

SRC=$1
if [ ! -r $SRC/usr/include/linux/rtnetlink.h ]; then
echo "$SRC is missing headers"
exit 1
fi

if [ ! -r include/uapi/linux/rtnetlink.h ]; then
echo "$PWD is not iproute2 source"
exit 1
fi

for subdir in . rdma vdpa
do
DST=$subdir/include/uapi
echo Checking $DST

(cd $DST; find . -type f) | \
while read f
do
from=$SRC/usr/include/$f
to=$DST/$f
if ! cmp -s $from $to
then
echo Updating $f
cp $from $to
fi
done
done

#7 lore raw

Re: [PATCH iproute2-next 1/2] scripts: Add uapi header import script

Quoted 7 lines · On Tue, 16 Sep 2025 07:41:55 -0700 Stephen Hemminger…
Quoted 4 lines · On Tue, 09 Sep 2025 15:21:42 +0200 Kory Maincent <[email protected]>…

Add a script to automate importing Linux UAPI headers from kernel source. The script handles dependency resolution and creates a commit with proper attribution, similar to the ethtool project approach.

Quoted 7 lines
Quoted 5 lines

Usage:

    $ LINUX_GIT="$LINUX_PATH" iproute2-import-uapi [commit]

---

Script I use is much simpler.

The aim of my patch was to add a standard way of updating the uAPI header. Indeed I supposed you maintainers, already have a script for that but for developers that add support for new features they don't have such scripts. People even may do it manually, even if I hope that's not the case. We can see that the git commit messages on include/uapi/ are not really consistent.

IMHO using the same script as ethtool was natural.
The final decision is your call but I think we should have a standard script whatever it is.

Regards,

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#8 lore raw

Re: [PATCH iproute2-next 1/2] scripts: Add uapi header import script

Quoted 25 lines · Kory Maincent
Quoted 7 lines · On Tue, 16 Sep 2025 07:41:55 -0700 Stephen Hemminger…
Quoted 4 lines · On Tue, 09 Sep 2025 15:21:42 +0200 Kory Maincent <[email protected]>…

Add a script to automate importing Linux UAPI headers from kernel source. The script handles dependency resolution and creates a commit with proper attribution, similar to the ethtool project approach.

Quoted 7 lines
Quoted 5 lines

Usage:

    $ LINUX_GIT="$LINUX_PATH" iproute2-import-uapi [commit]

---

Script I use is much simpler.

The aim of my patch was to add a standard way of updating the uAPI header. Indeed I supposed you maintainers, already have a script for that but for developers that add support for new features they don't have such scripts. People even may do it manually, even if I hope that's not the case. We can see that the git commit messages on include/uapi/ are not really consistent.

Quoted 5 lines

IMHO using the same script as ethtool was natural.
The final decision is your call but I think we should have a standard script whatever it is.

Regards,

There are separate needs.

I sync include/uapi for iproute2-next based on net-next. rdma and vdpa have separate -next trees which is why they have their own include/uapi directories. This script makes this part much easier for me hence why I merged it.

Stephen will ensure all uapi headers match the kernel release meaning Linus' tree.

#9 lore raw

Re: [PATCH iproute2-next 1/2] scripts: Add uapi header import script

Quoted 26 lines · On Tue, 16 Sep 2025 10:05:16 -0600 David Ahern <[email protected]> wrote:
Quoted 6 lines · Kory Maincent
Quoted 3 lines · On Tue, 16 Sep 2025 07:41:55 -0700 Stephen Hemminger…

On Tue, 09 Sep 2025 15:21:42 +0200
Kory Maincent <[email protected]> wrote:

[...]

Quoted 10 lines
Quoted 2 lines

Script I use is much simpler.

The aim of my patch was to add a standard way of updating the uAPI header. Indeed I supposed you maintainers, already have a script for that but for developers that add support for new features they don't have such scripts. People even may do it manually, even if I hope that's not the case. We can see that the git commit messages on include/uapi/ are not really consistent.

Quoted 5 lines

IMHO using the same script as ethtool was natural.
The final decision is your call but I think we should have a standard script whatever it is.

Regards,

There are separate needs.

Quoted 7 lines

I sync include/uapi for iproute2-next based on net-next. rdma and vdpa have separate -next trees which is why they have their own include/uapi directories. This script makes this part much easier for me hence why I merged it.

Stephen will ensure all uapi headers match the kernel release meaning Linus' tree.

Oh, ok. Thanks for the clarification.

Regards,

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#10 lore raw

PATCH 2/2 Update kernel headers

In reply to Kory Maincent

Update kernel headers to commit:
aeb8d48ea92e: ("selftests: net: add test for ipv6 fragmentation")

---
 include/uapi/linux/devlink.h | 2 ++
 include/uapi/linux/if_link.h | 1 +
 include/uapi/linux/stddef.h  | 1 -
 3 files changed, 3 insertions(+), 1 deletion(-)
include/uapi/linux/devlink.h +2 -0
index a89df2a7..bcd5fde1 100644
@@ -636,6 +636,8 @@ enum devlink_attr {
 
 	DEVLINK_ATTR_RATE_TC_BWS,		/* nested */
 
+	DEVLINK_ATTR_HEALTH_REPORTER_BURST_PERIOD,	/* u64 */
+
 	/* Add new attributes above here, update the spec in
 	 * Documentation/netlink/specs/devlink.yaml and re-generate
 	 * net/devlink/netlink_gen.c.
include/uapi/linux/if_link.h +1 -0
index b450757c..8c460dc3 100644
@@ -1562,6 +1562,7 @@ enum {
 	IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE,
 	IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE,
 	IFLA_BOND_SLAVE_PRIO,
+	IFLA_BOND_SLAVE_ACTOR_PORT_PRIO,
 	__IFLA_BOND_SLAVE_MAX,
 };
 
include/uapi/linux/stddef.h +0 -1
index e1fcfcf3..48ee4438 100644
@@ -3,7 +3,6 @@
 #define _LINUX_STDDEF_H
 
 
-
 #ifndef __always_inline
 #define __always_inline __inline__
 #endif
Signature · 1 line
2.43.0