[ovs-dev] datapath-windows: check vport attribute before access
diff mbox

Message ID 1441288909-7326-1-git-send-email-nithin@vmware.com
State Accepted
Headers show

Commit Message

Nithin Raju Sept. 3, 2015, 2:01 p.m. UTC
OVS_VPORT_ATTR_OPTIONS being an optional attribute should be
preceded by a check for valid value before access.

Signed-off-by: Nithin Raju <nithin@vmware.com>
---
 datapath-windows/ovsext/Vport.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Sairam Venugopal Sept. 4, 2015, 6:01 p.m. UTC | #1
Acked-by: Sairam Venugopal <vsairam@vmware.com>


On 9/3/15, 7:01 AM, "Nithin Raju" <nithin@vmware.com> wrote:

>OVS_VPORT_ATTR_OPTIONS being an optional attribute should be
>preceded by a check for valid value before access.
>
>Signed-off-by: Nithin Raju <nithin@vmware.com>
>---
> datapath-windows/ovsext/Vport.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
>diff --git a/datapath-windows/ovsext/Vport.c
>b/datapath-windows/ovsext/Vport.c
>index 6b74ec2..dd615e4 100644
>--- a/datapath-windows/ovsext/Vport.c
>+++ b/datapath-windows/ovsext/Vport.c
>@@ -2177,10 +2177,12 @@ OvsNewVportCmdHandler(POVS_USER_PARAMS_CONTEXT
>usrParamsCtx,
>                 break;
>             }
> 
>-            PNL_ATTR attr =
>NlAttrFindNested(vportAttrs[OVS_VPORT_ATTR_OPTIONS],
>-                                             OVS_TUNNEL_ATTR_DST_PORT);
>-            if (attr) {
>-                transportPortDest = NlAttrGetU16(attr);
>+            if (vportAttrs[OVS_VPORT_ATTR_OPTIONS]) {
>+                PNL_ATTR attr =
>NlAttrFindNested(vportAttrs[OVS_VPORT_ATTR_OPTIONS],
>+                 
>OVS_TUNNEL_ATTR_DST_PORT);
>+                if (attr) {
>+                    transportPortDest = NlAttrGetU16(attr);
>+                }
>             }
> 
>             status = OvsInitTunnelVport(usrParamsCtx,
>-- 
>1.8.5.6
>
>_______________________________________________
>dev mailing list
>dev@openvswitch.org
>https://urldefense.proofpoint.com/v2/url?u=http-3A__openvswitch.org_mailma
>n_listinfo_dev&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=Dc
>ruz40PROJ40ROzSpxyQSLw6fcrOWpJgEcEmNR3JEQ&m=M6HsLmOuYm_fYoAFouyGOA8j2eLADC
>Xwt6z5nSZ_nig&s=OhvXMw1uly8zT4V_RJmeHY9zTieLgVoooGIzOIN7nRU&e=
Ben Pfaff Sept. 4, 2015, 6:27 p.m. UTC | #2
Thanks Nithin and Sairam, applied to master and branch-2.4.

On Fri, Sep 04, 2015 at 06:01:19PM +0000, Sairam Venugopal wrote:
> Acked-by: Sairam Venugopal <vsairam@vmware.com>
> 
> 
> On 9/3/15, 7:01 AM, "Nithin Raju" <nithin@vmware.com> wrote:
> 
> >OVS_VPORT_ATTR_OPTIONS being an optional attribute should be
> >preceded by a check for valid value before access.
> >
> >Signed-off-by: Nithin Raju <nithin@vmware.com>
> >---
> > datapath-windows/ovsext/Vport.c | 10 ++++++----
> > 1 file changed, 6 insertions(+), 4 deletions(-)
> >
> >diff --git a/datapath-windows/ovsext/Vport.c
> >b/datapath-windows/ovsext/Vport.c
> >index 6b74ec2..dd615e4 100644
> >--- a/datapath-windows/ovsext/Vport.c
> >+++ b/datapath-windows/ovsext/Vport.c
> >@@ -2177,10 +2177,12 @@ OvsNewVportCmdHandler(POVS_USER_PARAMS_CONTEXT
> >usrParamsCtx,
> >                 break;
> >             }
> > 
> >-            PNL_ATTR attr =
> >NlAttrFindNested(vportAttrs[OVS_VPORT_ATTR_OPTIONS],
> >-                                             OVS_TUNNEL_ATTR_DST_PORT);
> >-            if (attr) {
> >-                transportPortDest = NlAttrGetU16(attr);
> >+            if (vportAttrs[OVS_VPORT_ATTR_OPTIONS]) {
> >+                PNL_ATTR attr =
> >NlAttrFindNested(vportAttrs[OVS_VPORT_ATTR_OPTIONS],
> >+                 
> >OVS_TUNNEL_ATTR_DST_PORT);
> >+                if (attr) {
> >+                    transportPortDest = NlAttrGetU16(attr);
> >+                }
> >             }
> > 
> >             status = OvsInitTunnelVport(usrParamsCtx,
> >-- 
> >1.8.5.6
> >
> >_______________________________________________
> >dev mailing list
> >dev@openvswitch.org
> >https://urldefense.proofpoint.com/v2/url?u=http-3A__openvswitch.org_mailma
> >n_listinfo_dev&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=Dc
> >ruz40PROJ40ROzSpxyQSLw6fcrOWpJgEcEmNR3JEQ&m=M6HsLmOuYm_fYoAFouyGOA8j2eLADC
> >Xwt6z5nSZ_nig&s=OhvXMw1uly8zT4V_RJmeHY9zTieLgVoooGIzOIN7nRU&e= 
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev

Patch
diff mbox

diff --git a/datapath-windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c
index 6b74ec2..dd615e4 100644
--- a/datapath-windows/ovsext/Vport.c
+++ b/datapath-windows/ovsext/Vport.c
@@ -2177,10 +2177,12 @@  OvsNewVportCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
                 break;
             }
 
-            PNL_ATTR attr = NlAttrFindNested(vportAttrs[OVS_VPORT_ATTR_OPTIONS],
-                                             OVS_TUNNEL_ATTR_DST_PORT);
-            if (attr) {
-                transportPortDest = NlAttrGetU16(attr);
+            if (vportAttrs[OVS_VPORT_ATTR_OPTIONS]) {
+                PNL_ATTR attr = NlAttrFindNested(vportAttrs[OVS_VPORT_ATTR_OPTIONS],
+                                                 OVS_TUNNEL_ATTR_DST_PORT);
+                if (attr) {
+                    transportPortDest = NlAttrGetU16(attr);
+                }
             }
 
             status = OvsInitTunnelVport(usrParamsCtx,