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

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) ===
Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 8cff1bbf8c9198bba49fead300d3c4cfff388b86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Wed, 5 Feb 2020 12:05:19 -0500
Subject: [PATCH] lxd/networks: Consider IPv6 neighborhood entries
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/network/network_utils.go | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/lxd/network/network_utils.go b/lxd/network/network_utils.go
index 5868310881..176abbfc8e 100644
--- a/lxd/network/network_utils.go
+++ b/lxd/network/network_utils.go
@@ -680,6 +680,36 @@ func GetHostDevice(parent string, vlan string) string {
 func GetLeaseAddresses(s *state.State, networkName string, hwaddr string) 
([]api.InstanceStateNetworkAddress, error) {
        addresses := []api.InstanceStateNetworkAddress{}
 
+       // Look for neighborhood entries for IPv6.
+       out, err := shared.RunCommand("ip", "-6", "neigh", "show", "dev", 
networkName)
+       if err == nil {
+               for _, line := range strings.Split(out, "\n") {
+                       // Split fields and early validation.
+                       fields := strings.Fields(line)
+                       if len(fields) != 4 {
+                               continue
+                       }
+
+                       if fields[2] != hwaddr {
+                               continue
+                       }
+
+                       // Prepare the entry.
+                       addr := api.InstanceStateNetworkAddress{}
+                       addr.Address = fields[0]
+                       addr.Family = "inet6"
+
+                       if strings.HasPrefix(fields[0], "fe80::") {
+                               addr.Scope = "link"
+                       } else {
+                               addr.Scope = "global"
+                       }
+
+                       addresses = append(addresses, addr)
+               }
+       }
+
+       // Look for DHCP leases.
        leaseFile := shared.VarPath("networks", networkName, "dnsmasq.leases")
        if !shared.PathExists(leaseFile) {
                return addresses, nil
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to