[ovs-dev] [PATCH] datapath: Make port numbers for UDP-based tunnels userspace configurable.

Ben Pfaff blp at nicira.com
Fri Oct 28 18:18:19 UTC 2011


On Thu, Oct 27, 2011 at 07:38:17PM -0700, Jesse Gross wrote:
> On Wed, Oct 26, 2011 at 3:27 PM, Ben Pfaff <blp at nicira.com> wrote:
> > diff --git a/datapath/tunnel.c b/datapath/tunnel.c
> > index 372d90e..047961f 100644
> > --- a/datapath/tunnel.c
> > +++ b/datapath/tunnel.c
> > @@ -1347,29 +1438,57 @@ static int tnl_set_config(struct nlattr *options, const struct tnl_ops *tnl_ops,
> > ?? ?? ?? ??struct nlattr *a[OVS_TUNNEL_ATTR_MAX + 1];
> > ?? ?? ?? ??int err;
> >
> > + ?? ?? ?? err = -EINVAL;
> > ?? ?? ?? ??if (!options)
> > - ?? ?? ?? ?? ?? ?? ?? return -EINVAL;
> > + ?? ?? ?? ?? ?? ?? ?? goto error;
> 
> One other small thing: I found this style of error handling (where the
> error is assigned before the condition) to be prone to problems when
> code is moved around and the error is no longer properly initialized.

Oops, I meant to use the set-after-condition style throughout but I
missed this one.

Fixed:

diff --git a/datapath/tunnel.c b/datapath/tunnel.c
index 047961f..cddae06 100644
--- a/datapath/tunnel.c
+++ b/datapath/tunnel.c
@@ -1438,9 +1438,10 @@ static int tnl_set_config(struct nlattr *options, const struct tnl_ops *tnl_ops,
 	struct nlattr *a[OVS_TUNNEL_ATTR_MAX + 1];
 	int err;
 
-	err = -EINVAL;
-	if (!options)
+	if (!options) {
+		err = -EINVAL;
 		goto error;
+	}
 
 	err = nla_parse_nested(a, OVS_TUNNEL_ATTR_MAX, options, tnl_policy);
 	if (err)



More information about the dev mailing list