History

netlink: export policy in extended ACK

Add a new attribute NLMSGERR_ATTR_POLICY to the extended ACK to advertise the policy, e.g. if an attribute was out of range, you'll know the range that's permissible. Add new NL_SET_ERR_MSG_ATTR_POL() and NL_SET_ERR_MSG_ATTR_POL() macros to set this, since realistically it's only useful to do this when the bad attribute (offset) is also returned. Use it in lib/nlattr.c which practically does all the policy validation. v2: - add and use netlink_policy_dump_attr_size_estimate() v3: - remove redundant break v4: - really remove redundant break ... sorry

Johannes Berg committed 6 years ago

Commit 44f36251 parent d2681e96 files · +110 −27Browse files

Showing the changes to include/uapi/linux (1 of 6 files). Show all

Unified · Split

include/uapi/linux/netlink.h+2−0
@@ -129,6 +129,7 @@ struct nlmsgerr { · 128 unmodified lines
129129 * @NLMSGERR_ATTR_COOKIE: arbitrary subsystem specific cookie to
130130 * be used - in the success case - to identify a created
131131 * object or operation or similar (binary)
132+ * @NLMSGERR_ATTR_POLICY: policy for a rejected attribute
132133 * @__NLMSGERR_ATTR_MAX: number of attributes
133134 * @NLMSGERR_ATTR_MAX: highest attribute number
134135 */
@@ -137,6 +138,7 @@ enum nlmsgerr_attrs { · 2 unmodified lines
137138 NLMSGERR_ATTR_MSG,
138139 NLMSGERR_ATTR_OFFS,
139140 NLMSGERR_ATTR_COOKIE,
141+ NLMSGERR_ATTR_POLICY,
140142
141143 __NLMSGERR_ATTR_MAX,
142144 NLMSGERR_ATTR_MAX = __NLMSGERR_ATTR_MAX - 1