[ovs-dev] [bugfixes 2/3] datapath: Fix behavior of NLA_NESTED for pre-2.6.29 kernels.
Ben Pfaff
blp at nicira.com
Tue Feb 1 00:48:24 UTC 2011
Before v2.6.29, a NLA_NESTED attribute, if it was present, was not allowed
to be empty. However, OVS depends on the ability to accept empty
attributes. For example, a present but empty ODP_FLOW_ATTR_ACTIONS on
ODP_FLOW_CMD_SET replaces the existing set of actions by an empty "drop"
action, whereas a missing ODP_FLOW_ATTR_ACTIONS leaves the existing
actions, if any, unchanged.
The datapath code currently doesn't otherwise depend on the NLA_NESTED
semantics (we only pass such attributes to nla_parse_nested() and
nla_for_each_nested(), which don't care if the attribute's length is
valid), so we might as well just use NLA_UNSPEC here.
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
.../linux-2.6/compat-2.6/include/net/netlink.h | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/datapath/linux-2.6/compat-2.6/include/net/netlink.h b/datapath/linux-2.6/compat-2.6/include/net/netlink.h
index 0f881f1..453de6f 100644
--- a/datapath/linux-2.6/compat-2.6/include/net/netlink.h
+++ b/datapath/linux-2.6/compat-2.6/include/net/netlink.h
@@ -4,6 +4,20 @@
#include <linux/version.h>
#include_next <net/netlink.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
+/* Before v2.6.29, a NLA_NESTED attribute, if it was present, was not allowed
+ * to be empty. However, we depend on the ability to accept empty attributes;
+ * for example, a present but empty ODP_FLOW_ATTR_ACTIONS on ODP_FLOW_CMD_SET
+ * replaces the existing set of actions by an empty "drop" action. We don't
+ * curently otherwise depend on the NLA_NESTED semantics (we only pass such
+ * attributes to nla_parse_nested() and nla_for_each_nested(), which don't
+ * care if the attribute's length is valid), so we might as well just use
+ * NLA_UNSPEC here.
+ */
+#undef NLA_NESTED
+#define NLA_NESTED NLA_UNSPEC
+#endif
+
#ifndef HAVE_NLA_NUL_STRING
static inline int VERIFY_NUL_STRING(struct nlattr *attr, int maxlen)
{
--
1.7.1
More information about the dev
mailing list