From fa05dcf6eee7db0bfccc33641bc2355eac847f41 Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Tue, 20 Dec 2016 17:11:00 +0200 Subject: [PATCH] Do not segfault if the datapath exists If the datapath exists when creating it, dpif.CreateDatapath will return an empty handle which access will cause the segfault. --- common/odp/odp.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/odp/odp.go b/common/odp/odp.go index de5e7da2..0ea0b8b1 100644 --- a/common/odp/odp.go +++ b/common/odp/odp.go @@ -21,8 +21,13 @@ func CreateDatapath(dpname string) (supported bool, err error) { defer dpif.Close() dp, err := dpif.CreateDatapath(dpname) - if err != nil && !odp.IsDatapathNameAlreadyExistsError(err) { - return true, err + if err != nil { + if !odp.IsDatapathNameAlreadyExistsError(err) { + return true, err + } + if dp, err = dpif.LookupDatapath(dpname); err != nil { + return true, err + } } // Pick an ephemeral port number to use in probing for vxlan