* [PATCH bpf-next v2 0/2] Documentation/bpf: Fix stale references in map docs
@ 2026-11-23 15:51 Ahmad Wicaksono
2026-11-23 15:51 ` [PATCH bpf-next v2 1/2] Documentation/bpf: Update sockmap docs for mutation restrictions Ahmad Wicaksono
2026-11-23 15:52 ` [PATCH bpf-next v2 2/2] Documentation/bpf: Fix stale selftests file references Ahmad Wicaksono
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Wicaksono @ 2026-11-23 15:51 UTC (permalink / raw)
To: bpf
Cc: jakub, mhal, ast, daniel, andrii, eddyz87, memxor, martin.lau,
song, yonghong.song, jolsa, emil, ihor.solodrai, corbet, skhan,
rdunlap, davem, kuba, hawk, john.fastabend, sdf, linux-doc,
netdev, Ahmad Wicaksono
Two documentation fixes for the BPF map pages.
Patch 1 records which program types may still mutate a sockmap or
sockhash: tracing programs attached to the sockmap iterator, sock_ops
(delete only), sk_reuseport and sk_lookup. Anything else is rejected
with "cannot update sockmap in this context". The kernel-side sections
of map_sockmap.rst did not mention this. It also drops the reference to
progs/test_sockmap_update.c, removed by
commit 5de7a6eaed89 ("selftests/bpf: Drop
tc/xdp/flow_dissector/socket_filter sockmap mutation tests").
Patch 2 fixes two moved selftests paths: test_lpm_map.c, now
map_tests/lpm_trie_map_basic_ops.c, and test_xdp_noinline.c, now under
progs/.
Documentation only; no functional change.
Changes in v2:
- Patch 1: narrow the note to the sockmap iterator, after
commit 18f6c47d1097 ("bpf, sockmap: Restrict iter-context sockmap
updates to iter/sockmap") (Alexei)
- Rebased onto bpf-next, which now has the bpf tree merged in
- Kept Jakub's Reviewed-by tags, as Alexei asked
- Link to v1: https://lore.kernel.org/bpf/20261114170117.196552-1-supersonix03@gmail.com/
Ahmad Wicaksono (2):
Documentation/bpf: Update sockmap docs for mutation restrictions
Documentation/bpf: Fix stale selftests file references
Documentation/bpf/btf.rst | 2 +-
Documentation/bpf/map_lpm_trie.rst | 6 +++---
Documentation/bpf/map_sockmap.rst | 18 ++++++++++++++++--
3 files changed, 20 insertions(+), 6 deletions(-)
checkpatch.pl --strict is clean. make SPHINXDIRS=bpf htmldocs gives
identical warnings before and after. Documentation only, so nothing to
run-test.
base-commit: 2bf3351c5f894697e8443eeef5333d4c4ce90cab
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH bpf-next v2 1/2] Documentation/bpf: Update sockmap docs for mutation restrictions
2026-11-23 15:51 [PATCH bpf-next v2 0/2] Documentation/bpf: Fix stale references in map docs Ahmad Wicaksono
@ 2026-11-23 15:51 ` Ahmad Wicaksono
2026-11-23 15:52 ` [PATCH bpf-next v2 2/2] Documentation/bpf: Fix stale selftests file references Ahmad Wicaksono
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Wicaksono @ 2026-11-23 15:51 UTC (permalink / raw)
To: bpf
Cc: jakub, mhal, ast, daniel, andrii, eddyz87, memxor, martin.lau,
song, yonghong.song, jolsa, emil, ihor.solodrai, corbet, skhan,
rdunlap, davem, kuba, hawk, john.fastabend, sdf, linux-doc,
netdev, Ahmad Wicaksono
Commit be39165224d0 ("bpf, sockmap: Disallow update and delete from tc,
xdp, socket_filter and flow_dissector") dropped those program types from
may_update_sockmap(), so tc, tc act, XDP, socket_filter and
flow_dissector programs can no longer call bpf_map_update_elem() or
bpf_map_delete_elem() on a sockmap or sockhash; the verifier rejects
them at load time with "cannot update sockmap in this context".
Commit 18f6c47d1097 ("bpf, sockmap: Restrict iter-context sockmap
updates to iter/sockmap") then narrowed the tracing case to programs
attached to the sockmap iterator. The kernel-side sections of
map_sockmap.rst mention none of this.
Record which program types may still mutate these maps, and note that
sock_ops programs may delete entries but have to use
bpf_sock_map_update() or bpf_sock_hash_update() to add them.
Also drop the reference to
tools/testing/selftests/bpf/progs/test_sockmap_update.c and its link
target. That file was removed by commit 5de7a6eaed89 ("selftests/bpf:
Drop tc/xdp/flow_dissector/socket_filter sockmap mutation tests").
Signed-off-by: Ahmad Wicaksono <supersonix03@gmail.com>
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
---
v2: Only sockmap iterator programs (iter/sockmap) may update, after
commit 18f6c47d1097. (Alexei)
Documentation/bpf/map_sockmap.rst | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/Documentation/bpf/map_sockmap.rst b/Documentation/bpf/map_sockmap.rst
index eb466b86d..0b7fdfca3 100644
--- a/Documentation/bpf/map_sockmap.rst
+++ b/Documentation/bpf/map_sockmap.rst
@@ -287,6 +287,16 @@ The flags argument can be one of the following:
Returns 0 on success, or a negative error in case of failure.
+.. note::
+ The verifier only accepts this helper on a sockmap or sockhash from
+ ``BPF_PROG_TYPE_SK_REUSEPORT`` and ``BPF_PROG_TYPE_SK_LOOKUP``
+ programs, and from ``BPF_PROG_TYPE_TRACING`` programs attached to
+ the sockmap iterator (``SEC(iter/sockmap)``). Other program types,
+ such as tc, XDP, socket_filter and flow_dissector, are rejected at
+ load time with "cannot update sockmap in this context".
+ ``BPF_PROG_TYPE_SOCK_OPS`` programs must use
+ ``bpf_sock_map_update()`` or ``bpf_sock_hash_update()`` instead.
+
bpf_map_delete_elem()
^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: c
@@ -297,6 +307,12 @@ Delete a socket entry from a sockmap or a sockhash.
Returns 0 on success, or a negative error in case of failure.
+.. note::
+ The same program type restriction as for ``bpf_map_update_elem()``
+ applies, except that ``BPF_PROG_TYPE_SOCK_OPS`` programs may delete
+ entries. Other program types are rejected at load time with
+ "cannot update sockmap in this context".
+
User space
----------
bpf_map_update_elem()
@@ -351,7 +367,6 @@ Several examples of the use of sockmap APIs can be found in:
- `tools/testing/selftests/bpf/progs/sockmap_parse_prog.c`_
- `tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c`_
- `tools/testing/selftests/bpf/progs/test_sockmap_listen.c`_
-- `tools/testing/selftests/bpf/progs/test_sockmap_update.c`_
The following code snippet shows how to declare a sockmap.
@@ -497,4 +512,3 @@ References
.. _`tools/testing/selftests/bpf/test_sockmap.c`: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/test_sockmap.c
.. _`tools/testing/selftests/bpf/test_maps.c`: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/test_maps.c
.. _`tools/testing/selftests/bpf/progs/test_sockmap_listen.c`: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/progs/test_sockmap_listen.c
-.. _`tools/testing/selftests/bpf/progs/test_sockmap_update.c`: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/progs/test_sockmap_update.c
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH bpf-next v2 2/2] Documentation/bpf: Fix stale selftests file references
2026-11-23 15:51 [PATCH bpf-next v2 0/2] Documentation/bpf: Fix stale references in map docs Ahmad Wicaksono
2026-11-23 15:51 ` [PATCH bpf-next v2 1/2] Documentation/bpf: Update sockmap docs for mutation restrictions Ahmad Wicaksono
@ 2026-11-23 15:52 ` Ahmad Wicaksono
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Wicaksono @ 2026-11-23 15:52 UTC (permalink / raw)
To: bpf
Cc: jakub, mhal, ast, daniel, andrii, eddyz87, memxor, martin.lau,
song, yonghong.song, jolsa, emil, ihor.solodrai, corbet, skhan,
rdunlap, davem, kuba, hawk, john.fastabend, sdf, linux-doc,
netdev, Ahmad Wicaksono
Two selftests paths in the BPF docs no longer exist:
map_lpm_trie.rst points at tools/testing/selftests/bpf/test_lpm_map.c,
which was moved by commit 3e18f5f1e5a1 ("selftests/bpf: Move
test_lpm_map.c to map_tests") and now lives at
tools/testing/selftests/bpf/map_tests/lpm_trie_map_basic_ops.c.
btf.rst points at tools/testing/selftests/bpf/test_xdp_noinline.c, which
is now tools/testing/selftests/bpf/progs/test_xdp_noinline.c.
Update both so readers can find the code.
Signed-off-by: Ahmad Wicaksono <supersonix03@gmail.com>
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
---
v2: No change.
Documentation/bpf/btf.rst | 2 +-
Documentation/bpf/map_lpm_trie.rst | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Documentation/bpf/btf.rst b/Documentation/bpf/btf.rst
index b61881239..94a81a9e9 100644
--- a/Documentation/bpf/btf.rst
+++ b/Documentation/bpf/btf.rst
@@ -1148,7 +1148,7 @@ information.::
The following is an example of how line_info can help debugging verification
failure.::
- /* The code at tools/testing/selftests/bpf/test_xdp_noinline.c
+ /* The code at tools/testing/selftests/bpf/progs/test_xdp_noinline.c
* is modified as below.
*/
data = (void *)(long)xdp->data;
diff --git a/Documentation/bpf/map_lpm_trie.rst b/Documentation/bpf/map_lpm_trie.rst
index f9cd57949..37ef39d0b 100644
--- a/Documentation/bpf/map_lpm_trie.rst
+++ b/Documentation/bpf/map_lpm_trie.rst
@@ -108,9 +108,9 @@ specific keys before less specific ones.
Examples
========
-Please see ``tools/testing/selftests/bpf/test_lpm_map.c`` for examples
-of LPM trie usage from userspace. The code snippets below demonstrate
-API usage.
+Please see ``tools/testing/selftests/bpf/map_tests/lpm_trie_map_basic_ops.c``
+for examples of LPM trie usage from userspace. The code snippets below
+demonstrate API usage.
Kernel BPF
----------
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-23 15:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 15:51 [PATCH bpf-next v2 0/2] Documentation/bpf: Fix stale references in map docs Ahmad Wicaksono
2026-11-23 15:51 ` [PATCH bpf-next v2 1/2] Documentation/bpf: Update sockmap docs for mutation restrictions Ahmad Wicaksono
2026-11-23 15:52 ` [PATCH bpf-next v2 2/2] Documentation/bpf: Fix stale selftests file references Ahmad Wicaksono
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox