The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8261

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Addresses https://discuss.linuxcontainers.org/t/unknown-error-17-failed-to-setup-ipv4-address-route-for-network-device/9718
From fc834648941c72b9e09d1c9cb220d8da0e060bea Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Wed, 16 Dec 2020 09:39:19 +0000
Subject: [PATCH 1/2] lxd/device/nic/routed: Switches to
 network.InterfaceExists for clarity

Makes error quoting consistent.

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/device/nic_routed.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lxd/device/nic_routed.go b/lxd/device/nic_routed.go
index ed47d9dbd3..0a9ec6cbc0 100644
--- a/lxd/device/nic_routed.go
+++ b/lxd/device/nic_routed.go
@@ -81,8 +81,8 @@ func (d *nicRouted) validateEnvironment() error {
                return fmt.Errorf("Requires liblxc has following API 
extensions: network_veth_router, network_l2proxy")
        }
 
-       if d.config["parent"] != "" && 
!shared.PathExists(fmt.Sprintf("/sys/class/net/%s", d.config["parent"])) {
-               return fmt.Errorf("Parent device '%s' doesn't exist", 
d.config["parent"])
+       if d.config["parent"] != "" && 
!network.InterfaceExists(d.config["parent"]) {
+               return fmt.Errorf("Parent device %q doesn't exist", 
d.config["parent"])
        }
 
        if d.config["parent"] == "" && d.config["vlan"] != "" {
@@ -119,7 +119,7 @@ func (d *nicRouted) validateEnvironment() error {
 
        // If the effective parent doesn't exist and the vlan option is 
specified, it means we are going to create
        // the VLAN parent at start, and we will configure the needed sysctls 
so don't need to check them yet.
-       if d.config["vlan"] != "" && 
!shared.PathExists(fmt.Sprintf("/sys/class/net/%s", effectiveParentName)) {
+       if d.config["vlan"] != "" && 
network.InterfaceExists(effectiveParentName) {
                return nil
        }
 

From 8069dc8a371b1ce642c457be162b9838249d9f7d Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Wed, 16 Dec 2020 10:02:06 +0000
Subject: [PATCH 2/2] lxd/device/nic/routed: Remove host side veth interface if
 exists in postStop

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/device/nic_routed.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lxd/device/nic_routed.go b/lxd/device/nic_routed.go
index 0a9ec6cbc0..197972ad9d 100644
--- a/lxd/device/nic_routed.go
+++ b/lxd/device/nic_routed.go
@@ -414,8 +414,18 @@ func (d *nicRouted) postStop() error {
 
        v := d.volatileGet()
 
+       networkVethFillFromVolatile(d.config, v)
+
        errs := []error{}
 
+       if network.InterfaceExists(d.config["host_name"]) {
+               // Removing host-side end of veth pair will delete the peer end 
too.
+               err := network.InterfaceRemove(d.config["host_name"])
+               if err != nil {
+                       errs = append(errs, errors.Wrapf(err, "Failed to remove 
interface %q", d.config["host_name"]))
+               }
+       }
+
        // This will delete the parent interface if we created it for VLAN 
parent.
        if shared.IsTrue(v["last_state.created"]) {
                parentName := network.GetHostDevice(d.config["parent"], 
d.config["vlan"])
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to