openvswitch: Don't insert empty OVS_VPORT_ATTR_OPTIONS attribute
authorThomas Graf <tgraf@suug.ch>
Tue, 2 Apr 2013 22:30:43 +0000 (00:30 +0200)
committerJesse Gross <jesse@nicira.com>
Tue, 2 Apr 2013 23:31:58 +0000 (16:31 -0700)
The port specific options are currently unused resulting in an
empty OVS_VPORT_ATTR_OPTIONS nested attribute being inserted
into every OVS_VPORT_CMD_GET message.

Don't insert OVS_VPORT_ATTR_OPTIONS if no options are present.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Jesse Gross <jesse@nicira.com>
net/openvswitch/vport.c

index f6b8132ce4cb7380a6bca860b4e50a2aa6756772..71a2de8726cb65bca80ca14fbd2cec58f8d165d5 100644 (file)
@@ -301,17 +301,19 @@ void ovs_vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats)
 int ovs_vport_get_options(const struct vport *vport, struct sk_buff *skb)
 {
        struct nlattr *nla;
+       int err;
+
+       if (!vport->ops->get_options)
+               return 0;
 
        nla = nla_nest_start(skb, OVS_VPORT_ATTR_OPTIONS);
        if (!nla)
                return -EMSGSIZE;
 
-       if (vport->ops->get_options) {
-               int err = vport->ops->get_options(vport, skb);
-               if (err) {
-                       nla_nest_cancel(skb, nla);
-                       return err;
-               }
+       err = vport->ops->get_options(vport, skb);
+       if (err) {
+               nla_nest_cancel(skb, nla);
+               return err;
        }
 
        nla_nest_end(skb, nla);