All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/3] gtp: ynl spec for the GTP netlink family, a reply-command fix, and a selftest
@ 2026-10-08 18:10 Anil Kaushik
  2026-10-08 18:10 ` [PATCH net-next v2 1/3] gtp: set a valid genl command in PDP context get and dump replies Anil Kaushik
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Anil Kaushik @ 2026-10-08 18:10 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Harald Welte, Donald Hunter, Jakub Kicinski
  Cc: David S . Miller, Eric Dumazet, Paolo Abeni, Simon Horman, netdev,
	osmocom-net-gprs, linux-kernel, Anil Kaushik

This respins the RFC "netlink: specs: add genetlink-legacy spec for GTP"
(netdev, 2026-10-01) as a patch, and adds a driver fix the spec exposed
plus a selftest that uses it.

While writing a ynl-based selftest for the existing gtp family I found
that the GET and dump replies put the genl family id in the command
field instead of a GTP_CMD_* value. libgtpnl ignores the command so it
never mattered, but ynl rejects the reply as an unknown command and
drops it. Patch 1 fixes the driver; patches 2 and 3 then describe and
test the family.

The turnaround on the respin was slower than I would have liked: most
of the time went into pinning down the reply-command bug in patch 1
once the selftest surfaced it.

Patch 1 sets a valid command (GTP_CMD_GETPDP) in the get and dump
replies.

Patch 2 adds a genetlink-legacy ynl spec for the gtp family
(NEWPDP/DELPDP/GETPDP/ECHOREQ). Description only, no uapi change.

Patch 3 adds a selftest built on the spec: it creates a gtp device, adds
a PDP context with newpdp, checks getpdp lists it and delpdp removes it.
It skips when the kernel or iproute2 lack GTP support.

The 5G PDU Session Container / QFI work that first motivated the spec is
not part of this series; I have no mainline userspace consumer for it (my
5G user plane uses an OVS datapath, not the kernel gtp driver), so per the
discussion with Harald Welte it is parked.

Anil Kaushik (3):
  gtp: set a valid genl command in PDP context get and dump replies
  netlink: specs: add genetlink-legacy spec for GTP
  selftests: net: add a test for the gtp netlink family

 Documentation/netlink/specs/gtp.yaml          | 170 ++++++++++++++++++
 MAINTAINERS                                   |   2 +
 drivers/net/gtp.c                             |   4 +-
 tools/testing/selftests/net/Makefile          |   1 +
 tools/testing/selftests/net/gtp.py            |  77 ++++++++
 .../testing/selftests/net/lib/py/__init__.py  |   5 +-
 tools/testing/selftests/net/lib/py/ynl.py     |   8 +-
 7 files changed, 262 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/netlink/specs/gtp.yaml
 create mode 100644 tools/testing/selftests/net/gtp.py

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next v2 1/3] gtp: set a valid genl command in PDP context get and dump replies
  2026-10-08 18:10 [PATCH net-next v2 0/3] gtp: ynl spec for the GTP netlink family, a reply-command fix, and a selftest Anil Kaushik
@ 2026-10-08 18:10 ` Anil Kaushik
  2026-10-08 18:10 ` [PATCH net-next v2 2/3] netlink: specs: add genetlink-legacy spec for GTP Anil Kaushik
  2026-10-08 18:10 ` [PATCH net-next v2 3/3] selftests: net: add a test for the gtp netlink family Anil Kaushik
  2 siblings, 0 replies; 7+ messages in thread
From: Anil Kaushik @ 2026-10-08 18:10 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Harald Welte, Donald Hunter, Jakub Kicinski
  Cc: David S . Miller, Eric Dumazet, Paolo Abeni, Simon Horman, netdev,
	osmocom-net-gprs, linux-kernel, Anil Kaushik

gtp_genl_fill_info() stamps the reply with the command its callers pass
in. gtp_genl_get_pdp() and gtp_genl_dump_pdp() pass nlmsg_type, which in
a genl message is the dynamically assigned family id rather than a
GTP_CMD_* value, so replies to a PDP context get or dump carry a
meaningless command number.

libgtpnl ignores the command and is unaffected, but parsers that check
it (for example the ynl tooling) treat the reply as an unknown command
and discard it. Pass GTP_CMD_GETPDP, as gtp_tunnel_notify() already
passes a real command on the notification path. No uapi change.

Fixes: 459aa660eb1d ("gtp: add initial driver for datapath of GPRS Tunneling Protocol (GTP-U)")
Signed-off-by: Anil Kaushik <anilkaushikwireless@gmail.com>
---
 drivers/net/gtp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index 4aff23bcf..99836b773 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -2279,7 +2279,7 @@ static int gtp_genl_get_pdp(struct sk_buff *skb, struct genl_info *info)
 	}
 
 	err = gtp_genl_fill_info(skb2, NETLINK_CB(skb).portid, info->snd_seq,
-				 0, info->nlhdr->nlmsg_type, pctx);
+				 0, GTP_CMD_GETPDP, pctx);
 	if (err < 0)
 		goto err_unlock_free;
 
@@ -2326,7 +2326,7 @@ static int gtp_genl_dump_pdp(struct sk_buff *skb,
 					    NETLINK_CB(cb->skb).portid,
 					    cb->nlh->nlmsg_seq,
 					    NLM_F_MULTI,
-					    cb->nlh->nlmsg_type, pctx)) {
+					    GTP_CMD_GETPDP, pctx)) {
 					cb->args[0] = i;
 					cb->args[1] = j;
 					cb->args[2] = (unsigned long)gtp;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next v2 2/3] netlink: specs: add genetlink-legacy spec for GTP
  2026-10-08 18:10 [PATCH net-next v2 0/3] gtp: ynl spec for the GTP netlink family, a reply-command fix, and a selftest Anil Kaushik
  2026-10-08 18:10 ` [PATCH net-next v2 1/3] gtp: set a valid genl command in PDP context get and dump replies Anil Kaushik
@ 2026-10-08 18:10 ` Anil Kaushik
  2026-10-12 18:55   ` netdev-bot+sashiko
  2026-10-08 18:10 ` [PATCH net-next v2 3/3] selftests: net: add a test for the gtp netlink family Anil Kaushik
  2 siblings, 1 reply; 7+ messages in thread
From: Anil Kaushik @ 2026-10-08 18:10 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Harald Welte, Donald Hunter, Jakub Kicinski
  Cc: David S . Miller, Eric Dumazet, Paolo Abeni, Simon Horman, netdev,
	osmocom-net-gprs, linux-kernel, Anil Kaushik

The GTP (GPRS Tunnelling Protocol, user plane) generic netlink family
has no YAML specification under Documentation/netlink/specs/, so it
cannot be consumed by the ynl tooling used for user-space clients,
documentation and selftests.

Add a genetlink-legacy spec describing the existing family: the PDP
context management commands (NEWPDP, DELPDP, GETPDP) and the GTP-U echo
request (ECHOREQ), the GTPA_* attribute set, and the "gtp" multicast
group. The spec is derived directly from include/uapi/linux/gtp.h and
the gtp_genl_policy / gtp_genl_ops tables in drivers/net/gtp.c; command
and attribute values match the existing uapi one-to-one.

This only adds the description; there is no kernel code or uapi change.

Signed-off-by: Anil Kaushik <anilkaushikwireless@gmail.com>
---
 Documentation/netlink/specs/gtp.yaml | 170 +++++++++++++++++++++++++++
 MAINTAINERS                          |   1 +
 2 files changed, 171 insertions(+)
 create mode 100644 Documentation/netlink/specs/gtp.yaml

diff --git a/Documentation/netlink/specs/gtp.yaml b/Documentation/netlink/specs/gtp.yaml
new file mode 100644
index 000000000..7193f5e53
--- /dev/null
+++ b/Documentation/netlink/specs/gtp.yaml
@@ -0,0 +1,170 @@
+# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
+---
+name: gtp
+
+protocol: genetlink-legacy
+
+doc: |
+  GPRS Tunnelling Protocol, user plane (GTP-U).
+
+  The gtp netdevice encapsulates and decapsulates user plane packets in
+  GTP-U tunnels (GTPv0 and GTPv1-U, see 3GPP TS 29.060 and TS 29.281).
+  This family manages the PDP contexts that describe the tunnels and
+  triggers GTP-U echo requests. It is driven by user space control planes
+  such as those built on libgtpnl.
+
+kernel-policy: global
+
+attribute-sets:
+  -
+    name: gtp
+    name-prefix: gtpa-
+    attributes:
+      -
+        name: link
+        type: u32
+        doc: ifindex of the gtp netdevice the context is attached to.
+      -
+        name: version
+        type: u32
+        doc: GTP version of the context, 0 for GTPv0 or 1 for GTPv1-U.
+      -
+        name: tid
+        type: u64
+        doc: Tunnel identifier, GTPv0 only.
+      -
+        name: peer-address
+        type: u32
+        byte-order: big-endian
+        display-hint: ipv4
+        doc: |
+          IPv4 address of the remote GSN peer (GGSN or SGSN). Also known
+          as GTPA_SGSN_ADDRESS, kept for legacy user space.
+      -
+        name: ms-address
+        type: u32
+        byte-order: big-endian
+        display-hint: ipv4
+        doc: IPv4 address of the mobile subscriber served by the context.
+      -
+        name: flow
+        type: u16
+        doc: Flow label, GTPv0 only.
+      -
+        name: net-ns-fd
+        type: u32
+        doc: File descriptor of the network namespace of the gtp netdevice.
+      -
+        name: i-tei
+        type: u32
+        doc: Ingress Tunnel Endpoint Identifier, GTPv1-U only.
+      -
+        name: o-tei
+        type: u32
+        doc: Egress Tunnel Endpoint Identifier, GTPv1-U only.
+      -
+        name: pad
+        type: pad
+      -
+        name: peer-addr6
+        type: binary
+        checks:
+          exact-len: 16
+        byte-order: big-endian
+        display-hint: ipv6
+        doc: IPv6 address of the remote GSN peer (GGSN or SGSN).
+      -
+        name: ms-addr6
+        type: binary
+        checks:
+          exact-len: 16
+        byte-order: big-endian
+        display-hint: ipv6
+        doc: IPv6 address of the mobile subscriber served by the context.
+      -
+        name: family
+        type: u8
+        doc: Address family (AF_INET or AF_INET6) of the context addresses.
+
+operations:
+  list:
+    -
+      name: newpdp
+      doc: Create or update a PDP context.
+      attribute-set: gtp
+      value: 0
+      dont-validate: [strict, dump]
+      flags: [admin-perm]
+      do:
+        request: &pdp-attrs
+          attributes:
+            - link
+            - version
+            - tid
+            - peer-address
+            - peer-addr6
+            - ms-address
+            - ms-addr6
+            - flow
+            - i-tei
+            - o-tei
+            - family
+            - net-ns-fd
+    -
+      name: delpdp
+      doc: Delete a PDP context.
+      attribute-set: gtp
+      dont-validate: [strict, dump]
+      flags: [admin-perm]
+      do:
+        request: *pdp-attrs
+    -
+      name: getpdp
+      doc: Get or dump one or more PDP contexts.
+      attribute-set: gtp
+      dont-validate: [strict, dump]
+      flags: [admin-perm]
+      do:
+        request:
+          attributes:
+            - link
+            - version
+            - tid
+            - ms-address
+            - ms-addr6
+            - i-tei
+            - family
+            - net-ns-fd
+        reply: &pdp-reply
+          attributes:
+            - version
+            - tid
+            - peer-address
+            - peer-addr6
+            - ms-address
+            - ms-addr6
+            - flow
+            - i-tei
+            - o-tei
+            - family
+      dump:
+        reply: *pdp-reply
+    -
+      name: echoreq
+      doc: Send a GTP-U echo request to a peer.
+      attribute-set: gtp
+      dont-validate: [strict, dump]
+      flags: [admin-perm]
+      do:
+        request:
+          attributes:
+            - link
+            - version
+            - peer-address
+            - peer-addr6
+            - family
+
+mcast-groups:
+  list:
+    -
+      name: gtp
diff --git a/MAINTAINERS b/MAINTAINERS
index 51873349b..a6e43995e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11421,6 +11421,7 @@ M:	Harald Welte <laforge@gnumonks.org>
 L:	osmocom-net-gprs@lists.osmocom.org
 S:	Maintained
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/pablo/gtp.git
+F:	Documentation/netlink/specs/gtp.yaml
 F:	drivers/net/gtp.c
 
 GUID PARTITION TABLE (GPT)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next v2 3/3] selftests: net: add a test for the gtp netlink family
  2026-10-08 18:10 [PATCH net-next v2 0/3] gtp: ynl spec for the GTP netlink family, a reply-command fix, and a selftest Anil Kaushik
  2026-10-08 18:10 ` [PATCH net-next v2 1/3] gtp: set a valid genl command in PDP context get and dump replies Anil Kaushik
  2026-10-08 18:10 ` [PATCH net-next v2 2/3] netlink: specs: add genetlink-legacy spec for GTP Anil Kaushik
@ 2026-10-08 18:10 ` Anil Kaushik
  2026-10-09  0:11   ` Jakub Kicinski
  2026-10-12 18:55   ` netdev-bot+sashiko
  2 siblings, 2 replies; 7+ messages in thread
From: Anil Kaushik @ 2026-10-08 18:10 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Harald Welte, Donald Hunter, Jakub Kicinski
  Cc: David S . Miller, Eric Dumazet, Paolo Abeni, Simon Horman, netdev,
	osmocom-net-gprs, linux-kernel, Anil Kaushik

Exercise the gtp generic netlink family through its ynl spec: create a
gtp device, add a PDP context with newpdp, check getpdp lists it and
delpdp removes it. Two more cases check that two contexts are dumped and
that deleting an unknown context fails.

Add a GtpFamily ynl wrapper and register the test.

Signed-off-by: Anil Kaushik <anilkaushikwireless@gmail.com>
---
 MAINTAINERS                                   |  1 +
 tools/testing/selftests/net/Makefile          |  1 +
 tools/testing/selftests/net/gtp.py            | 77 +++++++++++++++++++
 .../testing/selftests/net/lib/py/__init__.py  |  5 +-
 tools/testing/selftests/net/lib/py/ynl.py     |  8 +-
 5 files changed, 89 insertions(+), 3 deletions(-)
 create mode 100644 tools/testing/selftests/net/gtp.py

diff --git a/MAINTAINERS b/MAINTAINERS
index a6e43995e..8ac817a78 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11423,6 +11423,7 @@ S:	Maintained
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/pablo/gtp.git
 F:	Documentation/netlink/specs/gtp.yaml
 F:	drivers/net/gtp.c
+F:	tools/testing/selftests/net/gtp.py
 
 GUID PARTITION TABLE (GPT)
 M:	Davidlohr Bueso <dave@stgolabs.net>
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index d4ca82fec..5366de878 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -44,6 +44,7 @@ TEST_PROGS := \
 	fin_ack_lat.sh \
 	fou_mcast_encap.sh \
 	fq_band_pktlimit.sh \
+	gtp.py \
 	gre_gso.sh \
 	gre_ipv6_lladdr.sh \
 	icmp.sh \
diff --git a/tools/testing/selftests/net/gtp.py b/tools/testing/selftests/net/gtp.py
new file mode 100644
index 000000000..984c626b7
--- /dev/null
+++ b/tools/testing/selftests/net/gtp.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+
+"""Tests for the gtp netlink family."""
+
+from lib.py import ksft_run, ksft_exit
+from lib.py import ksft_eq, ksft_in, ksft_not_in, ksft_raises
+from lib.py import KsftSkipEx
+from lib.py import NetNS, NetNSEnter
+from lib.py import GtpFamily, NlError
+from lib.py import CmdExitFailure
+from lib.py import ip, defer
+
+
+def _add_gtp_dev(ns):
+    try:
+        ip("link add gtp0 type gtp role ggsn", ns=str(ns))
+    except CmdExitFailure:
+        raise KsftSkipEx("no gtp support (CONFIG_GTP, iproute2)")
+    defer(ip, "link del gtp0", ns=str(ns))
+    ip("link set gtp0 up", ns=str(ns))
+    return ip("-d link show gtp0", ns=str(ns), json=True)[0]["ifindex"]
+
+
+def _iteis(contexts):
+    return [c.get("i-tei") for c in contexts]
+
+
+def add_del_pdp(gtp, ns) -> None:
+    link = _add_gtp_dev(ns)
+
+    gtp.newpdp({"link": link, "version": 1,
+                "i-tei": 0x100, "o-tei": 0x200,
+                "ms-address": "10.0.0.1", "peer-address": "192.0.2.1"})
+
+    pdp = [c for c in gtp.getpdp({}, dump=True) if c.get("i-tei") == 0x100]
+    ksft_eq(len(pdp), 1)
+    ksft_eq(pdp[0]["o-tei"], 0x200)
+    ksft_eq(pdp[0]["ms-address"], "10.0.0.1")
+    ksft_eq(pdp[0]["peer-address"], "192.0.2.1")
+
+    gtp.delpdp({"link": link, "version": 1,
+                "i-tei": 0x100, "ms-address": "10.0.0.1"})
+    ksft_not_in(0x100, _iteis(gtp.getpdp({}, dump=True)))
+
+
+def add_two_pdp(gtp, ns) -> None:
+    link = _add_gtp_dev(ns)
+
+    for i_tei, o_tei, ms in ((0x111, 0x211, "10.0.1.1"),
+                             (0x112, 0x212, "10.0.1.2")):
+        gtp.newpdp({"link": link, "version": 1,
+                    "i-tei": i_tei, "o-tei": o_tei,
+                    "ms-address": ms, "peer-address": "192.0.2.5"})
+
+    iteis = _iteis(gtp.getpdp({}, dump=True))
+    ksft_in(0x111, iteis)
+    ksft_in(0x112, iteis)
+
+
+def del_unknown_pdp(gtp, ns) -> None:
+    link = _add_gtp_dev(ns)
+    with ksft_raises(NlError):
+        gtp.delpdp({"link": link, "version": 1,
+                    "i-tei": 0x999, "ms-address": "10.9.9.9"})
+
+
+def main() -> None:
+    with NetNS() as ns:
+        with NetNSEnter(str(ns)):
+            gtp = GtpFamily()
+        ksft_run([add_del_pdp, add_two_pdp, del_unknown_pdp], args=(gtp, ns))
+    ksft_exit()
+
+
+if __name__ == "__main__":
+    main()
diff --git a/tools/testing/selftests/net/lib/py/__init__.py b/tools/testing/selftests/net/lib/py/__init__.py
index 71df5880b..8d34f2659 100644
--- a/tools/testing/selftests/net/lib/py/__init__.py
+++ b/tools/testing/selftests/net/lib/py/__init__.py
@@ -18,7 +18,7 @@ from .utils import CmdExitFailure, fd_read_timeout, cmd, bkg, defer, \
 from .bpf import bpf_map_set, bpf_map_dump, bpf_prog_map_ids
 from .ynl import NlError, NlctrlFamily, YnlFamily, \
     EthtoolFamily, NetdevFamily, RtnlFamily, RtnlAddrFamily, RtnlRouteFamily
-from .ynl import NetshaperFamily, DevlinkFamily, PSPFamily, Netlink
+from .ynl import NetshaperFamily, DevlinkFamily, PSPFamily, GtpFamily, Netlink
 
 __all__ = ["KSRC",
            "KsftFailEx", "KsftSkipEx", "KsftXfailEx", "ksft_pr", "ksft_eq",
@@ -32,6 +32,7 @@ __all__ = ["KSRC",
            "wait_port_listen", "ctl_file_write", "wait_file", "tool", "tc",
            "bpf_map_set", "bpf_map_dump", "bpf_prog_map_ids",
            "NetdevSim", "NetdevSimDev",
-           "NetshaperFamily", "DevlinkFamily", "PSPFamily", "NlError",
+           "NetshaperFamily", "DevlinkFamily", "PSPFamily", "GtpFamily",
+           "NlError",
            "YnlFamily", "EthtoolFamily", "NetdevFamily", "RtnlFamily",
            "NlctrlFamily", "RtnlAddrFamily", "RtnlRouteFamily", "Netlink"]
diff --git a/tools/testing/selftests/net/lib/py/ynl.py b/tools/testing/selftests/net/lib/py/ynl.py
index 08deff756..492994812 100644
--- a/tools/testing/selftests/net/lib/py/ynl.py
+++ b/tools/testing/selftests/net/lib/py/ynl.py
@@ -31,7 +31,7 @@ __all__ = [
     "NlError", "NlPolicy", "Netlink", "YnlFamily", "SPEC_PATH",
     "EthtoolFamily", "RtnlFamily", "RtnlAddrFamily", "RtnlRouteFamily",
     "NetdevFamily", "NetshaperFamily", "NlctrlFamily", "DevlinkFamily",
-    "PSPFamily",
+    "PSPFamily", "GtpFamily",
 ]
 
 #
@@ -85,3 +85,9 @@ class PSPFamily(YnlFamily):
     def __init__(self, recv_size=0):
         super().__init__((SPEC_PATH / Path('psp.yaml')).as_posix(),
                          schema='', recv_size=recv_size)
+
+
+class GtpFamily(YnlFamily):
+    def __init__(self, recv_size=0):
+        super().__init__((SPEC_PATH / Path('gtp.yaml')).as_posix(),
+                         schema='', recv_size=recv_size)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v2 3/3] selftests: net: add a test for the gtp netlink family
  2026-10-08 18:10 ` [PATCH net-next v2 3/3] selftests: net: add a test for the gtp netlink family Anil Kaushik
@ 2026-10-09  0:11   ` Jakub Kicinski
  2026-10-12 18:55   ` netdev-bot+sashiko
  1 sibling, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2026-10-09  0:11 UTC (permalink / raw)
  To: Anil Kaushik
  Cc: Pablo Neira Ayuso, Harald Welte, Donald Hunter, David S . Miller,
	Eric Dumazet, Paolo Abeni, Simon Horman, netdev, osmocom-net-gprs,
	linux-kernel

On Thu,  8 Oct 2026 18:10:31 +0000 Anil Kaushik wrote:
> Exercise the gtp generic netlink family through its ynl spec: create a
> gtp device, add a PDP context with newpdp, check getpdp lists it and
> delpdp removes it. Two more cases check that two contexts are dumped and
> that deleting an unknown context fails.
> 
> Add a GtpFamily ynl wrapper and register the test.
> 
> Signed-off-by: Anil Kaushik <anilkaushikwireless@gmail.com>
> ---
>  MAINTAINERS                                   |  1 +
>  tools/testing/selftests/net/Makefile          |  1 +
>  tools/testing/selftests/net/gtp.py            | 77 +++++++++++++++++++
>  .../testing/selftests/net/lib/py/__init__.py  |  5 +-
>  tools/testing/selftests/net/lib/py/ynl.py     |  8 +-
>  5 files changed, 89 insertions(+), 3 deletions(-)
>  create mode 100644 tools/testing/selftests/net/gtp.py

You need to add GTP to the config (please not that configs are sorted)

> diff --git a/MAINTAINERS b/MAINTAINERS
> index a6e43995e..8ac817a78 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -11423,6 +11423,7 @@ S:	Maintained
>  T:	git git://git.kernel.org/pub/scm/linux/kernel/git/pablo/gtp.git
>  F:	Documentation/netlink/specs/gtp.yaml
>  F:	drivers/net/gtp.c
> +F:	tools/testing/selftests/net/gtp.py
>  
>  GUID PARTITION TABLE (GPT)
>  M:	Davidlohr Bueso <dave@stgolabs.net>
> diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
> index d4ca82fec..5366de878 100644
> --- a/tools/testing/selftests/net/Makefile
> +++ b/tools/testing/selftests/net/Makefile
> @@ -44,6 +44,7 @@ TEST_PROGS := \
>  	fin_ack_lat.sh \
>  	fou_mcast_encap.sh \
>  	fq_band_pktlimit.sh \
> +	gtp.py \
>  	gre_gso.sh \
>  	gre_ipv6_lladdr.sh \

this is not the correct alphabetical order

>  	icmp.sh \
> diff --git a/tools/testing/selftests/net/gtp.py b/tools/testing/selftests/net/gtp.py
> new file mode 100644
> index 000000000..984c626b7
> --- /dev/null
> +++ b/tools/testing/selftests/net/gtp.py
> @@ -0,0 +1,77 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: GPL-2.0
> +
> +"""Tests for the gtp netlink family."""
> +
> +from lib.py import ksft_run, ksft_exit
> +from lib.py import ksft_eq, ksft_in, ksft_not_in, ksft_raises
> +from lib.py import KsftSkipEx
> +from lib.py import NetNS, NetNSEnter
> +from lib.py import GtpFamily, NlError
> +from lib.py import CmdExitFailure
> +from lib.py import ip, defer
> +
> +
> +def _add_gtp_dev(ns):
> +    try:
> +        ip("link add gtp0 type gtp role ggsn", ns=str(ns))
> +    except CmdExitFailure:
> +        raise KsftSkipEx("no gtp support (CONFIG_GTP, iproute2)")
> +    defer(ip, "link del gtp0", ns=str(ns))
> +    ip("link set gtp0 up", ns=str(ns))
> +    return ip("-d link show gtp0", ns=str(ns), json=True)[0]["ifindex"]
> +
> +
> +def _iteis(contexts):
> +    return [c.get("i-tei") for c in contexts]
> +
> +
> +def add_del_pdp(gtp, ns) -> None:

We need a sentence or three describing what the test is trying to
validate

> +    link = _add_gtp_dev(ns)
> +
> +    gtp.newpdp({"link": link, "version": 1,
> +                "i-tei": 0x100, "o-tei": 0x200,
> +                "ms-address": "10.0.0.1", "peer-address": "192.0.2.1"})
> +
> +    pdp = [c for c in gtp.getpdp({}, dump=True) if c.get("i-tei") == 0x100]
> +    ksft_eq(len(pdp), 1)
> +    ksft_eq(pdp[0]["o-tei"], 0x200)
> +    ksft_eq(pdp[0]["ms-address"], "10.0.0.1")
> +    ksft_eq(pdp[0]["peer-address"], "192.0.2.1")
> +
> +    gtp.delpdp({"link": link, "version": 1,
> +                "i-tei": 0x100, "ms-address": "10.0.0.1"})
> +    ksft_not_in(0x100, _iteis(gtp.getpdp({}, dump=True)))
> +
> +
> +def add_two_pdp(gtp, ns) -> None:
> +    link = _add_gtp_dev(ns)
> +
> +    for i_tei, o_tei, ms in ((0x111, 0x211, "10.0.1.1"),
> +                             (0x112, 0x212, "10.0.1.2")):
> +        gtp.newpdp({"link": link, "version": 1,
> +                    "i-tei": i_tei, "o-tei": o_tei,
> +                    "ms-address": ms, "peer-address": "192.0.2.5"})
> +
> +    iteis = _iteis(gtp.getpdp({}, dump=True))
> +    ksft_in(0x111, iteis)
> +    ksft_in(0x112, iteis)
> +
> +
> +def del_unknown_pdp(gtp, ns) -> None:
> +    link = _add_gtp_dev(ns)
> +    with ksft_raises(NlError):
> +        gtp.delpdp({"link": link, "version": 1,
> +                    "i-tei": 0x999, "ms-address": "10.9.9.9"})
> +
> +
> +def main() -> None:

add some docstring here too, to avoid pylint warnings
please make sure ruff check is also clean

> +    with NetNS() as ns:
> +        with NetNSEnter(str(ns)):
> +            gtp = GtpFamily()
> +        ksft_run([add_del_pdp, add_two_pdp, del_unknown_pdp], args=(gtp, ns))
> +    ksft_exit()
> +
> +
> +if __name__ == "__main__":
> +    main()
> diff --git a/tools/testing/selftests/net/lib/py/__init__.py b/tools/testing/selftests/net/lib/py/__init__.py
> index 71df5880b..8d34f2659 100644
> --- a/tools/testing/selftests/net/lib/py/__init__.py
> +++ b/tools/testing/selftests/net/lib/py/__init__.py
> @@ -18,7 +18,7 @@ from .utils import CmdExitFailure, fd_read_timeout, cmd, bkg, defer, \
>  from .bpf import bpf_map_set, bpf_map_dump, bpf_prog_map_ids
>  from .ynl import NlError, NlctrlFamily, YnlFamily, \
>      EthtoolFamily, NetdevFamily, RtnlFamily, RtnlAddrFamily, RtnlRouteFamily
> -from .ynl import NetshaperFamily, DevlinkFamily, PSPFamily, Netlink
> +from .ynl import NetshaperFamily, DevlinkFamily, PSPFamily, GtpFamily, Netlink
>  
>  __all__ = ["KSRC",
>             "KsftFailEx", "KsftSkipEx", "KsftXfailEx", "ksft_pr", "ksft_eq",
> @@ -32,6 +32,7 @@ __all__ = ["KSRC",
>             "wait_port_listen", "ctl_file_write", "wait_file", "tool", "tc",
>             "bpf_map_set", "bpf_map_dump", "bpf_prog_map_ids",
>             "NetdevSim", "NetdevSimDev",
> -           "NetshaperFamily", "DevlinkFamily", "PSPFamily", "NlError",
> +           "NetshaperFamily", "DevlinkFamily", "PSPFamily", "GtpFamily",

strange place to insert the GtpFamily, alphabetically would be before
PSP ?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v2 2/3] netlink: specs: add genetlink-legacy spec for GTP
  2026-10-08 18:10 ` [PATCH net-next v2 2/3] netlink: specs: add genetlink-legacy spec for GTP Anil Kaushik
@ 2026-10-12 18:55   ` netdev-bot+sashiko
  0 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-10-12 18:55 UTC (permalink / raw)
  To: anilkaushikwireless
  Cc: pablo, laforge, donald.hunter, kuba, davem, edumazet, pabeni,
	horms, netdev, osmocom-net-gprs, linux-kernel

Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 4 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The echoreq request attribute list in
  Documentation/netlink/specs/gtp.yaml (lines 159-165: link, version,…
- [Medium] The getpdp reply attribute list (&pdp-reply,
  Documentation/netlink/specs/gtp.yaml lines 138-149), which the dump…
- [Medium] The spec declares the 'gtp' multicast group
  (Documentation/netlink/specs/gtp.yaml lines 167-170) but describes no…
- [Medium] Adding Documentation/netlink/specs/gtp.yaml makes
  tools/net/ynl/generated/Makefile generate and compile gtp-user.c/gtp-…
- [Low] peer-addr6 and ms-addr6 are declared in
  Documentation/netlink/specs/gtp.yaml with `checks: exact-len: 16`…
- [Low] delpdp in Documentation/netlink/specs/gtp.yaml (line 120,
  `request: *pdp-attrs`) reuses the full newpdp request list, so it…

--

netlink: specs: add genetlink-legacy spec for GTP

This commit adds a genetlink-legacy YAML spec for the existing GTP generic
netlink family. It covers the NEWPDP, DELPDP, GETPDP and ECHOREQ commands,
the GTPA_* attribute set and the "gtp" multicast group. It also adds the
spec to the GTP entry in MAINTAINERS.

> diff --git a/Documentation/netlink/specs/gtp.yaml b/Documentation/netlink/specs/gtp.yaml
> new file mode 100644
> index 0000000000000..7193f5e53a257
> --- /dev/null
> +++ b/Documentation/netlink/specs/gtp.yaml
> @@ -0,0 +1,170 @@

[ ... ]

> +      -
> +        name: peer-addr6
> +        type: binary
> +        checks:
> +          exact-len: 16
> +        byte-order: big-endian
> +        display-hint: ipv6
> +        doc: IPv6 address of the remote GSN peer (GGSN or SGSN).
> +      -
> +        name: ms-addr6
> +        type: binary
> +        checks:
> +          exact-len: 16
> +        byte-order: big-endian
> +        display-hint: ipv6
> +        doc: IPv6 address of the mobile subscriber served by the context.

[Severity: Low]
Does exact-len: 16 match what the kernel accepts for these two attributes?
In gtp_genl_policy in drivers/net/gtp.c they have no type:

	[GTPA_PEER_ADDR6]	= { .len = sizeof(struct in6_addr), },
	[GTPA_MS_ADDR6]		= { .len = sizeof(struct in6_addr), },

That makes them NLA_UNSPEC. With the family's liberal validation, .len is
a minimum length, so the kernel accepts longer payloads and
nla_get_in6_addr() reads the first 16 bytes.

ynl_gen_c.py turns exact-len into NLA_POLICY_EXACT_LEN(). A policy
generated from this spec would therefore reject input the kernel accepts
today.

For the same .len = sizeof(struct in6_addr) pattern, mptcp_pm.yaml,
nfsd.yaml and wireguard.yaml use min-len: 16. Should these two use min-len
as well?

> +      -
> +        name: family
> +        type: u8
> +        doc: Address family (AF_INET or AF_INET6) of the context addresses.

[Severity: Medium]
With this spec in place, tools/net/ynl/generated/Makefile will start
generating and compiling gtp-user.c. That Makefile picks up every spec
via SPECS_PATHS=$(wildcard $(SPECS_DIR)/*.yaml), and GENS_UNSUP only
excludes conntrack and nftables.

The compile uses -idirafter $(UAPI_PATH), so #include <linux/gtp.h> finds
the build host's /usr/include/linux/gtp.h before the in-tree uAPI header.
The generated tables use GTPA_PEER_ADDR6, GTPA_MS_ADDR6, GTPA_FAMILY and
GTP_CMD_ECHOREQ.

Older installed kernel headers (for example 6.1-era distro headers) don't
define these identifiers. On such hosts, would make -C tools/net/ynl fail
to build gtp-user.o?

Other families with recent uAPI additions (ovpn, psp, wireguard, ovs_*,
mptcp_pm and others) force the in-tree header in
tools/net/ynl/Makefile.deps. Does gtp need a similar entry, like this:

CFLAGS_gtp:=$(call get_hdr_inc,_LINUX_GTP_H_,gtp.h)

> +
> +operations:
> +  list:

[ ... ]

> +    -
> +      name: delpdp
> +      doc: Delete a PDP context.
> +      attribute-set: gtp
> +      dont-validate: [strict, dump]
> +      flags: [admin-perm]
> +      do:
> +        request: *pdp-attrs

[Severity: Low]
Is reusing the full newpdp request list correct for delpdp?

gtp_genl_del_pdp() only checks GTPA_VERSION, then calls
gtp_find_pdp()->gtp_find_pdp_by_link(). That lookup reads only LINK,
NET_NS_FD (through gtp_find_dev()), FAMILY, MS_ADDRESS, MS_ADDR6, VERSION,
TID and I_TEI.

The kernel silently ignores peer-address, peer-addr6, flow and o-tei on
delete. Listing them here suggests in the spec, generated docs and
generated C API that they help pick which context gets deleted.

The getpdp request list below matches the lookup. Could delpdp use that
list instead?

> +    -
> +      name: getpdp
> +      doc: Get or dump one or more PDP contexts.

[ ... ]

> +        reply: &pdp-reply
> +          attributes:
> +            - version
> +            - tid
> +            - peer-address
> +            - peer-addr6
> +            - ms-address
> +            - ms-addr6
> +            - flow
> +            - i-tei
> +            - o-tei
> +            - family
> +      dump:
> +        reply: *pdp-reply

[Severity: Medium]
Should link be in this reply list? gtp_genl_fill_info() always emits it:

	if (nla_put_u32(skb, GTPA_VERSION, pctx->gtp_version) ||
	    nla_put_u32(skb, GTPA_LINK, pctx->dev->ifindex) ||
	    nla_put_u8(skb, GTPA_FAMILY, pctx->af))
		goto nla_put_failure;

That layout is used for GETPDP replies, for dump entries and for the
NEWPDP/DELPDP notifications. ynl-gen-c builds reply structs and parsers
only from the listed attributes, so generated C clients will drop the
ifindex.

gtp_genl_dump_pdp() walks every gtp netdevice in the namespace. The
per-message GTPA_LINK is the only way to tell which device a dumped
context belongs to.

> +    -
> +      name: echoreq
> +      doc: Send a GTP-U echo request to a peer.
> +      attribute-set: gtp
> +      dont-validate: [strict, dump]
> +      flags: [admin-perm]
> +      do:
> +        request:
> +          attributes:
> +            - link
> +            - version
> +            - peer-address
> +            - peer-addr6
> +            - family

[Severity: Medium]
This list doesn't seem to match gtp_genl_send_echo_req(), which requires
ms-address:

	if (!info->attrs[GTPA_VERSION] ||
	    !info->attrs[GTPA_LINK] ||
	    !info->attrs[GTPA_PEER_ADDRESS] ||
	    !info->attrs[GTPA_MS_ADDRESS])
		return -EINVAL;
	...
	src_ip = nla_get_be32(info->attrs[GTPA_MS_ADDRESS]);

ynl-gen-c only generates setters for the attributes listed for the op, so
a generated C client has no way to send ms-address. Would every echoreq
from such a client fail with -EINVAL?

The handler is also IPv4-only. It uses ip4_route_output_gtp() and an IPv4
udp_tunnel_xmit_skb(), and it never reads GTPA_PEER_ADDR6 or GTPA_FAMILY.
Should peer-addr6 and family be dropped from this list?

net-ns-fd is not listed either, but gtp_find_dev() honours it when
resolving GTPA_LINK for this command:

	if (nla[GTPA_NET_NS_FD])
		net = get_net_ns_by_fd(nla_get_u32(nla[GTPA_NET_NS_FD]));

Finally, the ms-address doc reads "IPv4 address of the mobile subscriber
served by the context". For echoreq the value is used as the local source
address of the echo request instead.

> +
> +mcast-groups:
> +  list:
> +    -
> +      name: gtp

[Severity: Medium]
The gtp multicast group is declared, but no operation has notify:, event:
or mcgrp:. Where are the messages the kernel multicasts on this group
described?

The kernel sends three kinds of message on GTP_GENL_MCGRP:

  gtp_genl_new_pdp()->gtp_tunnel_notify(pctx, GTP_CMD_NEWPDP, ...)
  gtp_genl_del_pdp()->gtp_tunnel_notify(pctx, GTP_CMD_DELPDP, ...)
  gtp0_handle_echo_resp() / gtp1u_handle_echo_resp()
      ->gtp_genl_fill_echo(msg, 0, 0, 0, GTP_CMD_ECHOREQ, echo)

The first two use the gtp_genl_fill_info() layout. The echo responses
carry version, peer-address and ms-address.

In tools/net/ynl/pyynl/lib/ynl.py, pyynl only accepts notifications whose
IDs are in async_msg_ids. YnlFamily.__init__() fills that set only from
async ops.

A ynl client that subscribes to gtp would therefore drop each of these
messages with "Unexpected msg id while checking for ntf". C codegen also
won't produce any notification parsers.

Echo responses only arrive through this multicast. Can a spec-based client
send echoreq but never see the result?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261008181031.4129029-1-anilkaushikwireless%40gmail.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v2 3/3] selftests: net: add a test for the gtp netlink family
  2026-10-08 18:10 ` [PATCH net-next v2 3/3] selftests: net: add a test for the gtp netlink family Anil Kaushik
  2026-10-09  0:11   ` Jakub Kicinski
@ 2026-10-12 18:55   ` netdev-bot+sashiko
  1 sibling, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-10-12 18:55 UTC (permalink / raw)
  To: anilkaushikwireless
  Cc: pablo, laforge, donald.hunter, kuba, davem, edumazet, pabeni,
	horms, netdev, osmocom-net-gprs, linux-kernel

Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 3 · Low: 3

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In tools/testing/selftests/net/gtp.py, main() calls
  GtpFamily() (line 71) inside NetNSEnter, before ksft_run() and before…
- [Medium] The patch adds gtp.py to TEST_PROGS in
  tools/testing/selftests/net/Makefile (line 47) but does not add…
- [Medium] Documentation/netlink/specs/gtp.yaml was added by commit
  "netlink: specs: add genetlink-legacy spec for GTP" in this series and…
- [Low] Both delpdp calls in gtp.py, add_del_pdp (lines 42-43) and
  del_unknown_pdp (lines 64-65), send 'i-tei' together with 'ms-address'.
- [Low] _add_gtp_dev() in tools/testing/selftests/net/gtp.py catches
  every CmdExitFailure from `ip link add gtp0 type gtp role ggsn` and…
- [Low] tools/testing/selftests/net/gtp.py is added with `new file mode
  100644` (confirmed in the commit diff) but is listed in TEST_PROGS,…

--

selftests: net: add a test for the gtp netlink family

This adds a Python selftest for the gtp generic netlink family, driven by
its ynl spec. It creates a gtp device and checks newpdp, getpdp and
delpdp. It also adds a GtpFamily ynl wrapper to the selftest library and
registers gtp.py in TEST_PROGS.

> diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
> index 54beea2e348c4..3b9279bcdb6ec 100644
> --- a/tools/testing/selftests/net/Makefile
> +++ b/tools/testing/selftests/net/Makefile
> @@ -44,6 +44,7 @@ TEST_PROGS := \
>  	fin_ack_lat.sh \
>  	fou_mcast_encap.sh \
>  	fq_band_pktlimit.sh \
> +	gtp.py \

[Severity: Medium]
Should CONFIG_GTP=m also be added to tools/testing/selftests/net/config?

The config fragment has no CONFIG_GTP entry, and GTP is an opt-in
tristate. Kernels built from the net selftest config fragment, as CI
does, will not have the gtp driver or the gtp genl family. On those
kernels newpdp, getpdp and delpdp never get exercised.

Other tests in this directory that need a driver list it there, for
example CONFIG_GENEVE=m, CONFIG_VXLAN=m, CONFIG_AMT=m and
CONFIG_BAREUDP=m.

Because of the GtpFamily() ordering in main() (see below), those runs
would also be reported as failures, not skips.

[ ... ]

> diff --git a/tools/testing/selftests/net/gtp.py b/tools/testing/selftests/net/gtp.py
> new file mode 100644
> index 0000000000000..984c626b7172a
> --- /dev/null
> +++ b/tools/testing/selftests/net/gtp.py
> @@ -0,0 +1,77 @@
> +#!/usr/bin/env python3

[Severity: Low]
This isn't a bug, but gtp.py is added with mode 100644 even though it is
listed in TEST_PROGS.

For a non-executable test, run_one() in
tools/testing/selftests/kselftest/runner.sh prints:

    Warning: file $TEST is not executable

It then falls back to parsing the shebang. Running ./gtp.py directly
fails with permission denied.

Could the file be committed with the executable bit set?

[ ... ]

> +def _add_gtp_dev(ns):
> +    try:
> +        ip("link add gtp0 type gtp role ggsn", ns=str(ns))
> +    except CmdExitFailure:
> +        raise KsftSkipEx("no gtp support (CONFIG_GTP, iproute2)")

[Severity: Low]
Should this skip only when gtp is actually unsupported?

Right now any CmdExitFailure from ip link add becomes a KsftSkipEx. A
real failure would be reported by ksft_run() as a skip, not a fail. That
covers a regression in gtp_newlink() or gtp_create_sockets(), and also
an EEXIST for gtp0, which all three cases share in one netns.

> +    defer(ip, "link del gtp0", ns=str(ns))
> +    ip("link set gtp0 up", ns=str(ns))
> +    return ip("-d link show gtp0", ns=str(ns), json=True)[0]["ifindex"]

[ ... ]

> +    pdp = [c for c in gtp.getpdp({}, dump=True) if c.get("i-tei") == 0x100]

[Severity: Medium]
Is the link attribute missing from the getpdp reply in
Documentation/netlink/specs/gtp.yaml? That spec was added earlier in this
series by "netlink: specs: add genetlink-legacy spec for GTP", and this
test is its first user.

The reply attribute list is:

        reply: &pdp-reply
          attributes:
            - version
            - tid
            - peer-address
            - peer-addr6
            - ms-address
            - ms-addr6
            - flow
            - i-tei
            - o-tei
            - family

The dump reply reuses the same list. However, gtp_genl_fill_info() in
drivers/net/gtp.c always sends it:

	if (nla_put_u32(skb, GTPA_VERSION, pctx->gtp_version) ||
	    nla_put_u32(skb, GTPA_LINK, pctx->dev->ifindex) ||
	    nla_put_u8(skb, GTPA_FAMILY, pctx->af))

Python ynl decodes against the whole attribute set, so this test is not
affected. The generated C ynl code only parses the reply attributes
that are listed. C users of getpdp would therefore not see which gtp
device a dumped context belongs to.

Should link be added to pdp-reply?

[ ... ]

> +def del_unknown_pdp(gtp, ns) -> None:
> +    link = _add_gtp_dev(ns)
> +    with ksft_raises(NlError):
> +        gtp.delpdp({"link": link, "version": 1,
> +                    "i-tei": 0x999, "ms-address": "10.9.9.9"})

[Severity: Low]
Is i-tei actually used for the lookup in this call, and in the delpdp
call in add_del_pdp()?

gtp_find_pdp_by_link() in drivers/net/gtp.c checks the MS address first:

	if (nla[GTPA_MS_ADDRESS]) {
		__be32 ip = nla_get_be32(nla[GTPA_MS_ADDRESS]);
		...
		return ipv4_pdp_find(gtp, ip);
	} else if (nla[GTPA_MS_ADDR6]) {
		...
	} else if (nla[GTPA_VERSION]) {

When ms-address is passed, the i-tei values (0x999 here, 0x100 in
add_del_pdp()) are ignored. The GTPv1 TEI lookup through gtp1_pdp_find()
is never exercised on the delete path.

Also, ksft_raises(NlError) accepts any netlink error. gtp_find_pdp()
maps a failed lookup to ENOENT:

	if (!pctx)
		pctx = ERR_PTR(-ENOENT);

Could this case check for ENOENT? Otherwise an unrelated EINVAL, ENODEV
or EPERM would also pass.

> +
> +
> +def main() -> None:
> +    with NetNS() as ns:
> +        with NetNSEnter(str(ns)):
> +            gtp = GtpFamily()
> +        ksft_run([add_del_pdp, add_two_pdp, del_unknown_pdp], args=(gtp, ns))

[Severity: Medium]
Can this fail instead of skip when the gtp module is not loaded yet?

GtpFamily() runs before any test has done ip link add ... type gtp.
YnlFamily resolves the family id in _genl_load_families(), which uses a
CTRL_CMD_GETFAMILY dump.

ctrl_dumpfamily() only walks families that are already registered.
request_module() is only called from ctrl_getfamily(), so the dump does
not autoload gtp.ko.

This happens with CONFIG_GTP=m before gtp.ko is loaded (the default
after boot), and with CONFIG_GTP=n:

main()
  GtpFamily()
    YnlFamily.__init__()
      GenlProtocol.__init__()
        _genl_load_families()      -> KeyError on 'gtp'
      raise YnlException("Family 'gtp' not supported by the kernel")

Nothing in main() catches this exception. The script exits with
status 1, and the KsftSkipEx in _add_gtp_dev() is never reached.

Could the module be loaded before GtpFamily() is created, for example by
creating the device first? A missing family could then be turned into a
skip.

> +    ksft_exit()
> +
> +
> +if __name__ == "__main__":
> +    main()

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261008181031.4129029-1-anilkaushikwireless%40gmail.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-12 18:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-08 18:10 [PATCH net-next v2 0/3] gtp: ynl spec for the GTP netlink family, a reply-command fix, and a selftest Anil Kaushik
2026-10-08 18:10 ` [PATCH net-next v2 1/3] gtp: set a valid genl command in PDP context get and dump replies Anil Kaushik
2026-10-08 18:10 ` [PATCH net-next v2 2/3] netlink: specs: add genetlink-legacy spec for GTP Anil Kaushik
2026-10-12 18:55   ` netdev-bot+sashiko
2026-10-08 18:10 ` [PATCH net-next v2 3/3] selftests: net: add a test for the gtp netlink family Anil Kaushik
2026-10-09  0:11   ` Jakub Kicinski
2026-10-12 18:55   ` netdev-bot+sashiko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.