[ovs-discuss] [NIC-19 3/8] brcompatd: Make parse_command() parse commands without dp arguments.

Ben Pfaff blp at nicira.com
Thu Jul 30 22:27:44 UTC 2009


The BRCTL_GET_BRIDGES ioctl is going to move to userspace, but that ioctl
doesn't provide a bridge name as argument, so we need to support that.
---
 vswitchd/ovs-brcompatd.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/vswitchd/ovs-brcompatd.c b/vswitchd/ovs-brcompatd.c
index 2384f5c..8bf3689 100644
--- a/vswitchd/ovs-brcompatd.c
+++ b/vswitchd/ovs-brcompatd.c
@@ -413,7 +413,7 @@ parse_command(struct ofpbuf *buffer, uint32_t *seq, const char **br_name,
               const char **port_name, uint64_t *count, uint64_t *skip)
 {
     static const struct nl_policy policy[] = {
-        [BRC_GENL_A_DP_NAME] = { .type = NL_A_STRING },
+        [BRC_GENL_A_DP_NAME] = { .type = NL_A_STRING, .optional = true },
         [BRC_GENL_A_PORT_NAME] = { .type = NL_A_STRING, .optional = true },
         [BRC_GENL_A_FDB_COUNT] = { .type = NL_A_U64, .optional = true },
         [BRC_GENL_A_FDB_SKIP] = { .type = NL_A_U64, .optional = true },
@@ -422,6 +422,7 @@ parse_command(struct ofpbuf *buffer, uint32_t *seq, const char **br_name,
 
     if (!nl_policy_parse(buffer, NLMSG_HDRLEN + GENL_HDRLEN, policy,
                          attrs, ARRAY_SIZE(policy))
+        || (br_name && !attrs[BRC_GENL_A_DP_NAME])
         || (port_name && !attrs[BRC_GENL_A_PORT_NAME])
         || (count && !attrs[BRC_GENL_A_FDB_COUNT])
         || (skip && !attrs[BRC_GENL_A_FDB_SKIP])) {
@@ -429,7 +430,9 @@ parse_command(struct ofpbuf *buffer, uint32_t *seq, const char **br_name,
     }
 
     *seq = ((struct nlmsghdr *) buffer->data)->nlmsg_seq;
-    *br_name = nl_attr_get_string(attrs[BRC_GENL_A_DP_NAME]);
+    if (br_name) {
+        *br_name = nl_attr_get_string(attrs[BRC_GENL_A_DP_NAME]);
+    }
     if (port_name) {
         *port_name = nl_attr_get_string(attrs[BRC_GENL_A_PORT_NAME]);
     }
-- 
1.6.3.3





More information about the discuss mailing list