Datapath IDs are unsigned, but dpid_from_string() was parsing them as
signed integers, which caused high values to be capped at INT64_MAX.
Also, document that datapath IDs may not be all-zero.
Reported-by: Pankaj Thakkar <thakkar@nicira.com>
Reported-by: Teemu Koponen <koponen@nicira.com>
John Galgay john@galgay.net
Luiz Henrique Ozaki luiz.ozaki@gmail.com
Michael Mao mmao@nicira.com
John Galgay john@galgay.net
Luiz Henrique Ozaki luiz.ozaki@gmail.com
Michael Mao mmao@nicira.com
+Pankaj Thakkar thakkar@nicira.com
Paulo Cravero pcravero@as2594.net
Peter Balland peter@nicira.com
Ram Jothikumar rjothikumar@nicira.com
Paulo Cravero pcravero@as2594.net
Peter Balland peter@nicira.com
Ram Jothikumar rjothikumar@nicira.com
- * Copyright (c) 2009 Nicira Networks.
+ * Copyright (c) 2009, 2010 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <stdlib.h>
#include "ofpbuf.h"
#include <stdlib.h>
#include "ofpbuf.h"
+/* Parses 's' as a 16-digit hexadecimal number representing a datapath ID. On
+ * success stores the dpid into '*dpidp' and returns true, on failure stores 0
+ * into '*dpidp' and returns false.
+ *
+ * Rejects an all-zeros dpid as invalid. */
bool
dpid_from_string(const char *s, uint64_t *dpidp)
{
*dpidp = (strlen(s) == 16 && strspn(s, "0123456789abcdefABCDEF") == 16
bool
dpid_from_string(const char *s, uint64_t *dpidp)
{
*dpidp = (strlen(s) == 16 && strspn(s, "0123456789abcdefABCDEF") == 16
+ ? strtoull(s, NULL, 16)
: 0);
return *dpidp != 0;
}
: 0);
return *dpidp != 0;
}
.SS "OpenFlow Options"
.TP
\fB\-\-datapath\-id=\fIdpid\fR
.SS "OpenFlow Options"
.TP
\fB\-\-datapath\-id=\fIdpid\fR
-Sets \fIdpid\fR, which must consist of exactly 16 hexadecimal digits,
+Sets \fIdpid\fR, which must consist of exactly 16 hexadecimal digits
+and may not be all-zero,
as the datapath ID that the switch will use to identify itself to
OpenFlow controllers.
.IP
as the datapath ID that the switch will use to identify itself to
OpenFlow controllers.
.IP
<dt><code>datapath-id</code></dt>
<dd>Exactly 16 hex
digits to set the OpenFlow datapath ID to a specific
<dt><code>datapath-id</code></dt>
<dd>Exactly 16 hex
digits to set the OpenFlow datapath ID to a specific
+ value. May not be all-zero.</dd>
<dt><code>disable-in-band</code></dt>
<dd>If set to <code>true</code>, disable in-band control on
the bridge regardless of controller and manager settings.</dd>
<dt><code>disable-in-band</code></dt>
<dd>If set to <code>true</code>, disable in-band control on
the bridge regardless of controller and manager settings.</dd>