[lxc-devel] [lxd/master] network: only add --quiet-* options to dnsmasq if version supports them
albertodonato on Github
lxc-bot at linuxcontainers.org
Mon Sep 18 08:09:02 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 313 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170918/cbf4032a/attachment.bin>
-------------- next part --------------
From 0073b724e2fe383e4bec029ad3d847e1ee136921 Mon Sep 17 00:00:00 2001
From: Alberto Donato <alberto.donato at canonical.com>
Date: Mon, 18 Sep 2017 09:50:14 +0200
Subject: [PATCH] network: only add --quiet-* options to dnsmasq if version
supports them
Signed-off-by: Alberto Donato <alberto.donato at canonical.com>
---
lxd/networks.go | 11 ++++++++++-
lxd/networks_utils.go | 12 ++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/lxd/networks.go b/lxd/networks.go
index 939869556..353999bda 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -12,6 +12,7 @@ import (
"strconv"
"strings"
+ "github.com/blang/semver"
"github.com/gorilla/mux"
log "gopkg.in/inconshreveable/log15.v2"
@@ -778,7 +779,15 @@ func (n *network) Start() error {
fmt.Sprintf("--interface=%s", n.name)}
if !debug {
- dnsmasqCmd = append(dnsmasqCmd, []string{"--quiet-dhcp", "--quiet-dhcp6", "--quiet-ra"}...)
+ // --quiet options are only supported on >2.67
+ version, err := networkGetDnsmasqVersion()
+ if err != nil {
+ return err
+ }
+ minVer, _ := semver.ParseTolerant("2.67")
+ if version.GT(minVer) {
+ dnsmasqCmd = append(dnsmasqCmd, []string{"--quiet-dhcp", "--quiet-dhcp6", "--quiet-ra"}...)
+ }
}
// Configure IPv4
diff --git a/lxd/networks_utils.go b/lxd/networks_utils.go
index 37ab63d83..83c000bbe 100644
--- a/lxd/networks_utils.go
+++ b/lxd/networks_utils.go
@@ -20,6 +20,8 @@ import (
"syscall"
"time"
+ "github.com/blang/semver"
+
"github.com/lxc/lxd/lxd/db"
"github.com/lxc/lxd/lxd/state"
"github.com/lxc/lxd/shared"
@@ -727,6 +729,16 @@ func networkKillDnsmasq(name string, reload bool) error {
return nil
}
+func networkGetDnsmasqVersion() (*semver.Version, error) {
+ output, err := shared.TryRunCommand("dnsmasq", "--version")
+ if err != nil {
+ return nil, fmt.Errorf("Failed to check dnsmasq version")
+ }
+ lines := strings.Split(output, " ")
+ version, err := semver.ParseTolerant(lines[2])
+ return &version, err
+}
+
func networkUpdateStatic(s *state.State, networkName string) error {
// We don't want to race with ourselves here
networkStaticLock.Lock()
More information about the lxc-devel
mailing list