* [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; 5+ 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] 5+ 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-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; 5+ 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] 5+ 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
2 siblings, 1 reply; 5+ 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] 5+ messages in thread