{
size_t total_size = NLA_HDRLEN + size;
struct nlattr* nla = nl_msg_push_uninit(msg, total_size);
- ovs_assert(NLA_ALIGN(total_size) <= UINT16_MAX);
+ ovs_assert(!nl_attr_oversized(size));
nla->nla_len = total_size;
nla->nla_type = type;
return nla + 1;
msg->size = 0;
return NULL;
}
+
+/* Returns true if a Netlink attribute with a payload that is 'payload_size'
+ * bytes long would be oversized, that is, if it's not possible to create an
+ * nlattr of that size because its size wouldn't fit in the 16-bit nla_len
+ * field. */
+bool
+nl_attr_oversized(size_t payload_size)
+{
+ return NL_ATTR_SIZE(payload_size) > UINT16_MAX;
+}
\f
/* Attributes. */
/*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define NL_A_BE32_SIZE NL_ATTR_SIZE(sizeof(ovs_be32))
#define NL_A_BE64_SIZE NL_ATTR_SIZE(sizeof(ovs_be64))
#define NL_A_FLAG_SIZE NL_ATTR_SIZE(0)
+
+bool nl_attr_oversized(size_t payload_size);
\f
/* Netlink attribute types. */
enum nl_attr_type
}
}
+ if (nl_attr_oversized(ctx.xout->odp_actions.size)) {
+ /* These datapath actions are too big for a Netlink attribute, so we
+ * can't execute them. */
+ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
+
+ VLOG_ERR_RL(&rl, "discarding oversize datapath actions");
+ ofpbuf_clear(&ctx.xout->odp_actions);
+ }
+
ofpbuf_uninit(&ctx.stack);
/* Clear the metadata and register wildcard masks, because we won't
echo "in_port=$i, actions=resubmit:$j, resubmit:$j, local"
done
echo "in_port=13, actions=local,local,local,local,local,local,local,local") > flows
- AT_CHECK([ovs-ofctl add-flows br0 flows])
+AT_CHECK([ovs-ofctl add-flows br0 flows])
AT_CHECK([ovs-appctl ofproto/trace br0 'in_port=1'], [0], [stdout])
AT_CHECK([grep -c 'resubmits yielded over 64 kB of actions' ovs-vswitchd.log], [0], [1
])
-OVS_VSWITCHD_STOP(["/resubmits yielded over 64 kB of actions/d"])
+AT_CHECK([grep -c 'discarding oversize datapath actions' ovs-vswitchd.log], [0], [1
+])
+OVS_VSWITCHD_STOP(["/resubmits yielded over 64 kB of actions/d
+/discarding oversize datapath actions/d"])
AT_CLEANUP
AT_SETUP([ofproto-dpif - stack too deep])