batman-adv: uapi: add note/clarification on access of reserved bytes/bits
PATCH v2 1/1 batman-adv: uapi: add note/clarification on access of reserved bytes/bits
Similar to the note in include/uapi/linux/ethtool.h, add a note regarding reserved fields to include/uapi/linux/batadv_packet.h.
Userspace must not access these fields directly, as they may be renamed or repurposed in the future. When creating packets, userspace should zero the whole struct (e.g. via memset or a struct initializer). When parsing packets, reserved fields must be ignored.
While at it, unify the kernel-doc text of all @reserved members.
--- include/uapi/linux/batadv_packet.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
include/uapi/linux/batadv_packet.h +18 -10
@@ -12,6 +12,14 @@#include <linux/stddef.h> #include <linux/types.h> +/* Note on reserved space. +* Reserved fields must not be accessed directly by user space because +* they may be replaced by a different field in the future. They must +* be initialized to zero before making the request, e.g. via memset +* of the entire structure or implicitly by not being set in a structure +* initializer. +*/ +/** * batadv_tp_is_error() - Check throughput meter return code for error * @n: throughput meter return code
@@ -216,7 +224,7 @@ struct batadv_bla_claim_dst {* @seqno: sequence identification * @orig: address of the source node * @prev_sender: address of the previous sender -* @reserved: reserved byte for alignment +* @reserved: reserved for alignment; also see note on reserved space * @tq: transmission quality * @tvlv_len: length of tvlv data following the ogm header */
@@ -312,7 +320,7 @@ struct batadv_icmp_header {* @dst: address of the destination node * @orig: address of the source node * @uid: local ICMP socket identifier -* @reserved: not used - useful for alignment +* @reserved: reserved for alignment; also see note on reserved space * @seqno: ICMP sequence number */ struct batadv_icmp_packet {
@@ -433,7 +441,7 @@ struct batadv_unicast_packet {* @u: common unicast packet header * @src: address of the source * @subtype: packet subtype -* @reserved: reserved byte for alignment +* @reserved: reserved for alignment; also see note on reserved space */ struct batadv_unicast_4addr_packet {struct batadv_unicast_packet u;
@@ -454,7 +462,7 @@ struct batadv_unicast_4addr_packet {* @orig: originator of the fragment used when merging the packet * @no: fragment number within this sequence * @priority: priority of frame, from ToS IP precedence or 802.1p -* @reserved: reserved byte for alignment +* @reserved: reserved for alignment; also see note on reserved space * @seqno: sequence identification * @total_size: size of the merged packet */
@@ -484,7 +492,7 @@ struct batadv_frag_packet {* @packet_type: batman-adv packet type, part of the general header * @version: batman-adv protocol version, part of the general header * @ttl: time to live for this packet, part of the general header -* @reserved: reserved byte for alignment +* @reserved: reserved for alignment; also see note on reserved space * @seqno: sequence identification * @orig: originator of the broadcast packet */
@@ -505,7 +513,7 @@ struct batadv_bcast_packet {* @packet_type: batman-adv packet type, part of the general header * @version: batman-adv protocol version, part of the general header * @ttl: time to live for this packet, part of the general header -* @reserved: reserved byte for alignment +* @reserved: reserved for alignment; also see note on reserved space * @tvlv_len: length of the appended tvlv buffer (in bytes) */ struct batadv_mcast_packet {
@@ -559,7 +567,7 @@ struct batadv_coded_packet {* @packet_type: batman-adv packet type, part of the general header * @version: batman-adv protocol version, part of the general header * @ttl: time to live for this packet, part of the general header -* @reserved: reserved field (for packet alignment) +* @reserved: reserved for alignment; also see note on reserved space * @dst: address of the destination * @src: address of the source * @tvlv_len: length of tvlv data following the unicast tvlv header
@@ -604,7 +612,7 @@ struct batadv_tvlv_gateway_data {* the tt tvlv container * @crc: crc32 checksum of the entries belonging to this vlan * @vid: vlan identifier -* @reserved: unused, useful for alignment purposes +* @reserved: reserved for alignment; also see note on reserved space */ struct batadv_tvlv_tt_vlan_data {__be32 crc;
@@ -631,7 +639,7 @@ struct batadv_tvlv_tt_data {* struct batadv_tvlv_tt_change - translation table diff data * @flags: status indicators concerning the non-mesh client (see * batadv_tt_client_flags) -* @reserved: reserved field - useful for alignment purposes only +* @reserved: reserved for alignment; also see note on reserved space * @addr: mac address of non-mesh client that triggered this tt change * @vid: VLAN identifier */
@@ -655,7 +663,7 @@ struct batadv_tvlv_roam_adv {/** * struct batadv_tvlv_mcast_data - payload of a multicast tvlv * @flags: multicast flags announced by the orig node -* @reserved: reserved field +* @reserved: reserved for alignment; also see note on reserved space */ struct batadv_tvlv_mcast_data {__u8 flags;
Signature · 1 line
2.55.0
Quoted 12 lines
Similar to the note in
include/uapi/linux/ethtool.h, add a note regarding reserved fields toinclude/uapi/linux/batadv_packet.h.Userspace must not access these fields directly, as they may be renamed or repurposed in the future. When creating packets, userspace should zero the whole struct (e.g. via memset or a struct initializer). When parsing packets, reserved fields must be ignored.
While at it, unify the kernel-doc text of all @reserved members.
Signed-off-by Linus Lüssing <[email protected]>
Will be applied later. Don't want to try to send out this patch to net-next while it is open for the last week (because a review takes roughly ~1 week).
Signature · 1 line
Sven Eckelmann <[email protected]>