[ovs-dev] [PATCH 1/3] datapath: Avoid possibility of negative 'n_flows' in struct odp_flowvec.

Ben Pfaff blp at nicira.com
Thu May 13 18:12:20 UTC 2010


On Wed, May 12, 2010 at 05:38:23PM -0700, Jesse Gross wrote:
> On Mon, May 10, 2010 at 2:13 PM, Ben Pfaff <blp at nicira.com> wrote:
> 
> > do_flowvec_ioctl() was checking for too-big 'n_flows' but not negative
> > 'n_flows'.  We could add that check too, but 'n_flows' should never be
> > negative so it's better to just use an unsigned type.
> >
> 
> This looks good but I think 'struct portvec' has the same issue with a
> signed 'n_ports' field so we should probably convert that as well.

Thanks.  I added this commit.  I didn't see anything that needed to
change other than the declaration itself.

--8<--------------------------cut here-------------------------->8--

>From 867dada13cf46a0073ad2e4fdab01c2bb0566901 Mon Sep 17 00:00:00 2001
From: Ben Pfaff <blp at nicira.com>
Date: Thu, 13 May 2010 11:04:56 -0700
Subject: [PATCH] datapath: Avoid possibility of negative 'n_ports' in struct odp_portvec.

'n_ports' should never be negative so it's better to use an unsigned type.

Suggested-by: Jesse Gross <jesse at nicira.com>
---
 include/openvswitch/datapath-protocol.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h
index 1c2dba9..0e8d5c9 100644
--- a/include/openvswitch/datapath-protocol.h
+++ b/include/openvswitch/datapath-protocol.h
@@ -181,7 +181,7 @@ struct odp_port {
 
 struct odp_portvec {
     struct odp_port *ports;
-    int n_ports;
+    __u32 n_ports;
 };
 
 struct odp_port_group {
-- 
1.6.5





More information about the dev mailing list