From: Ben Pfaff Date: Thu, 21 Oct 2010 17:40:05 +0000 (-0700) Subject: Fix bug in parsing large datapath IDs. X-Git-Tag: v1.1.0~989 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=093ca5b366899cb187ac0fb70b9308eeb8f452eb;p=sliver-openvswitch.git Fix bug in parsing large datapath IDs. 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 Reported-by: Teemu Koponen --- diff --git a/AUTHORS b/AUTHORS index 9adaa6d3d..6a8166878 100644 --- a/AUTHORS +++ b/AUTHORS @@ -49,6 +49,7 @@ Joan Cirer joan@ev0.net 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 diff --git a/lib/packets.c b/lib/packets.c index 5c51feb1f..2dc82fe12 100644 --- a/lib/packets.c +++ b/lib/packets.c @@ -1,5 +1,5 @@ /* - * 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. @@ -20,11 +20,16 @@ #include #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 - ? strtoll(s, NULL, 16) + ? strtoull(s, NULL, 16) : 0); return *dpidp != 0; } diff --git a/utilities/ovs-openflowd.8.in b/utilities/ovs-openflowd.8.in index 30b3705a1..176459ca4 100644 --- a/utilities/ovs-openflowd.8.in +++ b/utilities/ovs-openflowd.8.in @@ -173,7 +173,8 @@ the local port network device, and start the DHCP client afterward. .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 diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index 74ac27797..c9a6e5786 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -329,7 +329,7 @@
datapath-id
Exactly 16 hex digits to set the OpenFlow datapath ID to a specific - value.
+ value. May not be all-zero.
disable-in-band
If set to true, disable in-band control on the bridge regardless of controller and manager settings.