[lxc-devel] [lxd/master] networks: Fixes bug preventing 3rd party routes from being restored

tomponline on Github lxc-bot at linuxcontainers.org
Tue Jun 18 13:54:29 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 450 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190618/68e00d56/attachment.bin>
-------------- next part --------------
From f0cc1d5e8647f611460535ac18d38d369064b2cd Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Tue, 18 Jun 2019 14:53:25 +0100
Subject: [PATCH] networks: Fixes bug preventing 3rd party routes from being
 restored on network start

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/networks.go       | 24 ++++++++++++------------
 lxd/networks_utils.go |  4 ++--
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/lxd/networks.go b/lxd/networks.go
index acaf05653a..6d3a292eb5 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -1219,12 +1219,6 @@ func (n *network) Start() error {
 		return err
 	}
 
-	// Restore container specific IPv4 routes to interface.
-	err = networkApplyBootRoutesV4(n.name, ctRoutes)
-	if err != nil {
-		return err
-	}
-
 	_, err = shared.RunCommand("ip", "-4", "route", "flush", "dev", n.name, "proto", "static")
 	if err != nil {
 		return err
@@ -1375,6 +1369,12 @@ func (n *network) Start() error {
 				}
 			}
 		}
+
+		// Restore container specific IPv4 routes to interface.
+		err = networkApplyBootRoutesV4(n.name, ctRoutes)
+		if err != nil {
+			return err
+		}
 	}
 
 	// Remove any existing IPv6 iptables rules
@@ -1401,12 +1401,6 @@ func (n *network) Start() error {
 		return err
 	}
 
-	// Restore container specific IPv6 routes to interface.
-	err = networkApplyBootRoutesV6(n.name, ctRoutes)
-	if err != nil {
-		return err
-	}
-
 	_, err = shared.RunCommand("ip", "-6", "route", "flush", "dev", n.name, "proto", "static")
 	if err != nil {
 		return err
@@ -1562,6 +1556,12 @@ func (n *network) Start() error {
 				}
 			}
 		}
+
+		// Restore container specific IPv6 routes to interface.
+		err = networkApplyBootRoutesV6(n.name, ctRoutes)
+		if err != nil {
+			return err
+		}
 	}
 
 	// Configure the fan
diff --git a/lxd/networks_utils.go b/lxd/networks_utils.go
index 7fd48a5caa..5c19996fde 100644
--- a/lxd/networks_utils.go
+++ b/lxd/networks_utils.go
@@ -1391,7 +1391,7 @@ func networkListBootRoutesV4(devName string) ([]string, error) {
 	cmd.Start()
 	scanner := bufio.NewScanner(ipOut)
 	for scanner.Scan() {
-		route := scanner.Text()
+		route := strings.Replace(scanner.Text(), "linkdown", "", -1)
 		routes = append(routes, route)
 	}
 	cmd.Wait()
@@ -1409,7 +1409,7 @@ func networkListBootRoutesV6(devName string) ([]string, error) {
 	cmd.Start()
 	scanner := bufio.NewScanner(ipOut)
 	for scanner.Scan() {
-		route := scanner.Text()
+		route := strings.Replace(scanner.Text(), "linkdown", "", -1)
 		routes = append(routes, route)
 	}
 	cmd.Wait()


More information about the lxc-devel mailing list