On 1/22/21 9:53 PM, Edwin Peer wrote: > If a nested list of attributes is too long, then the length will > exceed the 16-bit nla_len of the parent nlattr. In such cases, > determine how many whole attributes can fit and truncate the > message to this length. This properly maintains the nesting > hierarchy, keeping the entire message valid, while fitting more > subelements inside the nest range than may result if the length > is wrapped modulo 64KB. > > Marking truncated attributes, such that user space can determine > the precise attribute truncated, by means of an additional bit in > the nla_type was considered and rejected. The NLA_F_NESTED and > NLA_F_NET_BYTEORDER flags are supposed to be mutually exclusive. > So, in theory, the latter bit could have been redefined for nested > attributes in order to indicate truncation, but user space tools > (most notably iproute2) cannot be relied on to honor NLA_TYPE_MASK, > resulting in alteration of the perceived nla_type and subsequent > catastrophic failure. >
Did you look at using NETLINK_CB / netlink_skb_parms to keep a running length of nested attributes to avoid the need to trim?