The branch main has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c9d98c0134864d8bc69006b92d34a3b22c940870

commit c9d98c0134864d8bc69006b92d34a3b22c940870
Author:     Ishan Agrawal <[email protected]>
AuthorDate: 2026-06-28 04:14:28 +0000
Commit:     Kristof Provost <[email protected]>
CommitDate: 2026-07-03 08:20:12 +0000

    netlink: add const variants of NLA iteration macros
    
    Add const-qualified versions of the NLA iteration helpers to allow
    walking immutable netlink attribute buffers without discarding const
    qualifiers.
    
    This introduces NLA_NEXT_CONST(), _NLA_END_CONST(), and
    NLA_FOREACH_CONST() in netlink_snl.h.
    
    Signed-off-by: Ishan Agrawal <[email protected]>
    Sponsored-by : Google LLC (GSoC 2026)
---
 sys/netlink/netlink_snl.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sys/netlink/netlink_snl.h b/sys/netlink/netlink_snl.h
index 52b35e502c98..34a0f3791af2 100644
--- a/sys/netlink/netlink_snl.h
+++ b/sys/netlink/netlink_snl.h
@@ -69,6 +69,18 @@
                ((char *)NLA_NEXT(_attr) <= _NLA_END(_start, _len));    \
                _attr =  NLA_NEXT(_attr))
 
+#define NLA_NEXT_CONST(_attr) (const struct nlattr *)(const void *) \
+        ((const char *)_attr + NLA_ALIGN(_attr->nla_len))
+
+#define _NLA_END_CONST(_start, _len) \
+        ((const char *)(_start) + (_len))
+#define NLA_FOREACH_CONST(_attr, _start, _len)      \
+        for (_attr = (const struct nlattr *)(_start);          \
+               ((const char *)_attr < _NLA_END_CONST(_start, _len)) && \
+               ((const char *)NLA_NEXT_CONST(_attr) <= \
+               _NLA_END_CONST(_start, _len)); \
+               _attr =  NLA_NEXT_CONST(_attr))
+
 struct linear_buffer {
        char                    *base;  /* Base allocated memory pointer */
        uint32_t                offset; /* Currently used offset */

Reply via email to