[lxc-devel] [lxc/master] network: Adds short sleep between veth setup and neighbour proxy add

tomponline on Github lxc-bot at linuxcontainers.org
Sun Mar 8 18:33:44 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 1020 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200308/5690524c/attachment.bin>
-------------- next part --------------
From 954e36b490b9b961641cf030817d10dba2a4ddea Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Sun, 8 Mar 2020 18:28:44 +0000
Subject: [PATCH] network: Adds short sleep between veth setup and neighbour
 proxy add

There is an intermittent issue, experienced on at least Ubuntu 18.04 (5.3.0-40-generic) and Alpine 3.11 (5.4.12-1-virt) when using the router network interface type that causes the IP proxy neighbour entries on the host side of the veth pair to not be created.

The `ip neigh add proxy` command returns without an error, however by the time the network up hook has started the IP neighbour proxy entries are no longer there (if they ever were).

I've also tested this using netlink rather than the ip command to add and both are equally affected.

Adding a short sleep between setting up the veth pair and adding the proxy entries appears to fix it.

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 src/lxc/network.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/lxc/network.c b/src/lxc/network.c
index 7b9ea1f25a..c87a7d3201 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -382,6 +382,13 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
 	}
 
 	if (netdev->priv.veth_attr.mode == VETH_MODE_ROUTER) {
+		/* sleep for a short period of time to work around a bug that intermittently prevents IP neighbour
+		   proxy entries from being added using lxc_ip_neigh_proxy below. When the issue occurs the entries
+		   appear to be added successfully but then do not appear in the proxy list. The length of time
+		   slept doesn't appear to be important, only that the process sleeps for a short period of time.
+		*/
+		nanosleep((const struct timespec[]){{0, 1000}}, NULL);
+
 		if (netdev->ipv4_gateway) {
 			char bufinet4[INET_ADDRSTRLEN];
 			if (!inet_ntop(AF_INET, netdev->ipv4_gateway, bufinet4, sizeof(bufinet4))) {


More information about the lxc-devel mailing list