From a5f25889216411ad7492047fafe6de03b8408440 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso <pablo@netfilter.org> Date: Sun, 9 May 2010 20:17:54 +0200 Subject: relax mnl_attr_type_valid() checkings and change errno value This patch relaxes strict attribute checkings in the example files. I have also changed the errno value, now it's EOPNOTSUPP instead of EINVAL. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> --- src/attr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/attr.c b/src/attr.c index 37fa798..d220652 100644 --- a/src/attr.c +++ b/src/attr.c @@ -115,11 +115,16 @@ struct nlattr *mnl_attr_next(const struct nlattr *attr, int *len) * This function allows to check if the attribute type is higher than the * maximum supported type. If the attribute type is invalid, this function * returns -1 and errno is explicitly set. On success, this function returns 1. + * + * Strict attribute checking in user-space is not a good idea since you may + * run an old application with a newer kernel that supports new attributes. + * This leads to backward compatibility breakages in user-space. Better check + * if you support an attribute, if not, skip it. */ int mnl_attr_type_valid(const struct nlattr *attr, uint16_t max) { if (mnl_attr_get_type(attr) > max) { - errno = EINVAL; + errno = EOPNOTSUPP; return -1; } return 1; -- cgit v1.2.3