Skip to contentSkip to conversation

Network namespace and device support

PATCH In review Dan Smith 5 participants 12 messages Jan 20, 2010 – Jan 21, 2010 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Dan Smith

author
#0 lore raw

This set adds support for checkpointing network namespaces and devices, with in-kernel restart.

Basic support includes veth pair and loopback adapters and allows me to checkpoint and restart a containerized copy of sendmail with a veth bridged to a physical network. Follow-on work is detailed in the header of the last patch.

author
#2 lore raw

PATCH 1/3 Expose rtnl_link_ops_get()

In reply to a message not in the archive
---
 include/net/rtnetlink.h |    1 +
 net/core/rtnetlink.c    |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)
include/net/rtnetlink.h +1 -0
index c3aa044..a165769 100644
@@ -82,6 +82,7 @@ extern void	rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops);
 extern int	rtnl_link_register(struct rtnl_link_ops *ops);
 extern void	rtnl_link_unregister(struct rtnl_link_ops *ops);
 
+extern const struct rtnl_link_ops *rtnl_link_ops_get(const char *kind);
 extern struct net_device *rtnl_create_link(struct net *net, char *ifname,
 		const struct rtnl_link_ops *ops, struct nlattr *tb[]);
 extern const struct nla_policy ifla_policy[IFLA_MAX+1];
net/core/rtnetlink.c +1 -1
index eb42873..2b2150c 100644
@@ -325,7 +325,7 @@ void rtnl_link_unregister(struct rtnl_link_ops *ops)
 
 EXPORT_SYMBOL_GPL(rtnl_link_unregister);
 
-static const struct rtnl_link_ops *rtnl_link_ops_get(const char *kind)
+const struct rtnl_link_ops *rtnl_link_ops_get(const char *kind)
 {
 	const struct rtnl_link_ops *ops;
 
Signature · 1 line
1.6.2.5
author
#3 lore raw

PATCH 2/3 Add a veth_get_peer() and veth_set_peer() functions

In reply to a message not in the archive

This is needed for C/R. For checkpoint, we need to be able to follow the link from one veth device to its peer. For restart, we need to be able to link two veth devices we've restored to re-establish their relationship.

---
 drivers/net/veth.c   |   14 ++++++++++++++
 include/linux/veth.h |    5 +++++
 2 files changed, 19 insertions(+), 0 deletions(-)
drivers/net/veth.c +14 -0
index ade5b34..eb47080 100644
@@ -454,6 +454,20 @@ static void veth_dellink(struct net_device *dev)
 	unregister_netdevice(peer);
 }
 
+struct net_device *veth_get_peer(struct net_device *veth)
+{
+	struct veth_priv *priv = netdev_priv(veth);
+
+	return priv->peer;
+}
+
+void veth_set_peer(struct net_device *veth, struct net_device *peer)
+{
+	struct veth_priv *priv = netdev_priv(veth);
+
+	priv->peer = peer;
+}
+
 static const struct nla_policy veth_policy[VETH_INFO_MAX + 1];
 
 static struct rtnl_link_ops veth_link_ops = {
include/linux/veth.h +5 -0
index 3354c1e..eee059d 100644
@@ -9,4 +9,9 @@ enum {
 #define VETH_INFO_MAX	(__VETH_INFO_MAX - 1)
 };
 
+#ifdef __KERNEL__
+struct net_device *veth_get_peer(struct net_device *veth);
+void veth_set_peer(struct net_device *veth, struct net_device *peer);
+#endif
+
 #endif
Signature · 1 line
1.6.2.5
author
#5 lore raw

PATCH 3/3 C/R: Basic support for network namespaces and devices

In reply to a message not in the archive

When checkpointing a task tree with network namespaces, we hook into do_checkpoint_ns() along with the others. Any devices in a given namespace are checkpointed (including their peer, in the case of veth) sequentially. Each network device stores a list of protocol addresses, as well as other information, such as hardware address.

This patch supports veth pairs, as well as the loopback adapter. The loopback support is there to make sure that any additional addresses and state (such as up/down) is copied to the loopback adapter that we are given in the new network namespace.

On restart, we instantiate new network namespaces and veth pairs as necessary. Any device we encounter that isn't in a network namespace that was checkpointed as part of a task is left in the namespace of the restarting process. This will be the case for a veth half that exists in the init netns to provide network access to a container.

Still to do are:

1. Routes
2. Netfilter rules
3. IPv6 addresses
4. Other virtual device types (e.g. bridges)

---
 checkpoint/checkpoint.c          |   21 ++-
 checkpoint/objhash.c             |   48 ++++
 checkpoint/restart.c             |    8 +
 include/linux/checkpoint.h       |    5 +
 include/linux/checkpoint_hdr.h   |   50 ++++
 include/linux/checkpoint_types.h |    1 +
 kernel/nsproxy.c                 |   21 ++-
 net/Makefile                     |    1 +
 net/checkpoint_dev.c             |  518 ++++++++++++++++++++++++++++++++++++++
 9 files changed, 665 insertions(+), 8 deletions(-)
 create mode 100644 net/checkpoint_dev.c
checkpoint/checkpoint.c +16 -5
index c345773..eb3aba5 100644
@@ -180,16 +180,23 @@ static int checkpoint_write_header(struct ckpt_ctx *ctx)
 static int checkpoint_container(struct ckpt_ctx *ctx)
 {
 	struct ckpt_hdr_container *h;
+	int new;
 	int ret;
 
 	h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_CONTAINER);
 	if (!h)
 		return -ENOMEM;
-	ret = ckpt_write_obj(ctx, &h->h);
-	ckpt_hdr_put(ctx, h);
 
+	ret = ckpt_obj_lookup_add(ctx, current->nsproxy->net_ns,
+				  CKPT_OBJ_NET_NS, &new);
 	if (ret < 0)
-		return ret;
+		goto out;
+
+	ctx->init_netns_ref = h->init_netns_ref = ret;
+
+	ret = ckpt_write_obj(ctx, &h->h);
+	if (ret < 0)
+		goto out;
 
 	memset(ctx->lsm_name, 0, CHECKPOINT_LSM_NAME_MAX + 1);
 	strlcpy(ctx->lsm_name, security_get_lsm_name(),
@@ -197,9 +204,13 @@ static int checkpoint_container(struct ckpt_ctx *ctx)
 	ret = ckpt_write_buffer(ctx, ctx->lsm_name,
 				CHECKPOINT_LSM_NAME_MAX + 1);
 	if (ret < 0)
-		return ret;
+		goto out;
 
-	return security_checkpoint_header(ctx);
+	ret = security_checkpoint_header(ctx);
+ out:
+	ckpt_hdr_put(ctx, h);
+
+	return ret;
 }
 
 /* write the checkpoint trailer */
checkpoint/objhash.c +48 -0

60 lines not on this page · raw message

checkpoint/restart.c +8 -0
index 88d791b..d5e88d8 100644
@@ -689,6 +689,14 @@ static int restore_container(struct ckpt_ctx *ctx)
 		return PTR_ERR(h);
 	ckpt_hdr_put(ctx, h);
 
+	/* Store the ref of the init netns so we know to leave its
+	 * devices where they fall */
+	ctx->init_netns_ref = h->init_netns_ref;
+	ret = ckpt_obj_insert(ctx, current->nsproxy->net_ns,
+			      ctx->init_netns_ref, CKPT_OBJ_NET_NS);
+	if (ret < 0)
+		return ret;
+
 	/* read the LSM name and info which follow ("are a part of")
 	 * the ckpt_hdr_container */
 	ret = restore_lsm(ctx);
include/linux/checkpoint.h +5 -0
index 1f85162..b9d337c 100644
@@ -113,6 +113,11 @@ extern int ckpt_sock_getnames(struct ckpt_ctx *ctx,
 extern struct sk_buff *sock_restore_skb(struct ckpt_ctx *ctx, struct sock *sk);
 extern void sock_listening_list_free(struct list_head *head);
 
+int checkpoint_netns(struct ckpt_ctx *ctx, void *ptr);
+void *restore_netns(struct ckpt_ctx *ctx);
+int checkpoint_netdev(struct ckpt_ctx *ctx, void *ptr);
+void *restore_netdev(struct ckpt_ctx *ctx);
+
 /* ckpt kflags */
 #define ckpt_set_ctx_kflag(__ctx, __kflag)  \
 	set_bit(__kflag##_BIT, &(__ctx)->kflags)
include/linux/checkpoint_hdr.h +50 -0

80 lines not on this page · raw message

include/linux/checkpoint_types.h +1 -0
index f95c3ff..9d2a4ca 100644
@@ -85,6 +85,7 @@ struct ckpt_ctx {
 	wait_queue_head_t ghostq;	/* waitqueue for ghost tasks */
 	struct cred *realcred, *ecred;	/* tmp storage for cred at restart */
 	struct list_head listen_sockets;/* listening parent sockets */
+	int init_netns_ref;             /* Objref of root net namespace */
 
 	struct ckpt_stats stats;	/* statistics */
 
kernel/nsproxy.c +18 -3
index e7aaa00..88c48a0 100644
@@ -248,6 +248,9 @@ int ckpt_collect_ns(struct ckpt_ctx *ctx, struct task_struct *t)
 	ret = ckpt_obj_collect(ctx, nsproxy->uts_ns, CKPT_OBJ_UTS_NS);
 	if (ret < 0)
 		goto out;
+	ret = ckpt_obj_collect(ctx, nsproxy->net_ns, CKPT_OBJ_NET_NS);
+	if (ret < 0)
+		goto out;
 	ret = ckpt_obj_collect(ctx, nsproxy->ipc_ns, CKPT_OBJ_IPC_NS);
 	if (ret < 0)
 		goto out;
@@ -281,6 +284,10 @@ static int do_checkpoint_ns(struct ckpt_ctx *ctx, struct nsproxy *nsproxy)
 	if (ret < 0)
 		goto out;
 	h->ipc_objref = ret;
+	ret = checkpoint_obj(ctx, nsproxy->net_ns, CKPT_OBJ_NET_NS);
+	if (ret < 0)
+		goto out;
+	h->net_objref = ret;
 
 	/* TODO: Write other namespaces here */
 
@@ -302,6 +309,7 @@ static struct nsproxy *do_restore_ns(struct ckpt_ctx *ctx)
 	struct nsproxy *nsproxy = NULL;
 	struct uts_namespace *uts_ns;
 	struct ipc_namespace *ipc_ns;
+	struct net *net_ns;
 	int ret;
 
 	h = ckpt_read_obj_type(ctx, sizeof(*h), CKPT_HDR_NS);
@@ -310,7 +318,8 @@ static struct nsproxy *do_restore_ns(struct ckpt_ctx *ctx)
 
 	ret = -EINVAL;
 	if (h->uts_objref <= 0 ||
-	    h->ipc_objref <= 0)
+	    h->ipc_objref <= 0 ||
+	    h->net_objref <= 0)
 		goto out;
 
 	uts_ns = ckpt_obj_fetch(ctx, h->uts_objref, CKPT_OBJ_UTS_NS);
@@ -323,6 +332,11 @@ static struct nsproxy *do_restore_ns(struct ckpt_ctx *ctx)
 		ret = PTR_ERR(ipc_ns);
 		goto out;
 	}
+	net_ns = ckpt_obj_fetch(ctx, h->net_objref, CKPT_OBJ_NET_NS);
+	if (IS_ERR(net_ns)) {
+		ret = PTR_ERR(net_ns);
+		goto out;
+	}
 
 #if defined(COFNIG_UTS_NS) || defined(CONFIG_IPC_NS)
 	ret = -ENOMEM;
@@ -334,19 +348,20 @@ static struct nsproxy *do_restore_ns(struct ckpt_ctx *ctx)
 	nsproxy->uts_ns = uts_ns;
 	get_ipc_ns(ipc_ns);
 	nsproxy->ipc_ns = ipc_ns;
+	get_net(net_ns);
+	nsproxy->net_ns = net_ns;
 
 	get_pid_ns(current->nsproxy->pid_ns);
 	nsproxy->pid_ns = current->nsproxy->pid_ns;
 	get_mnt_ns(current->nsproxy->mnt_ns);
 	nsproxy->mnt_ns = current->nsproxy->mnt_ns;
-	get_net(current->nsproxy->net_ns);
-	nsproxy->net_ns = current->nsproxy->net_ns;
 #else
 	nsproxy = current->nsproxy;
 	get_nsproxy(nsproxy);
 
 	BUG_ON(nsproxy->uts_ns != uts_ns);
 	BUG_ON(nsproxy->ipc_ns != ipc_ns);
+	BUG_ON(nsproxy->net_ns != net_ns);
 #endif
 
 	/* TODO: add more namespaces here */
net/Makefile +1 -0
index 74b038f..9a9a6b8 100644
@@ -67,3 +67,4 @@ endif
 obj-$(CONFIG_WIMAX)		+= wimax/
 
 obj-$(CONFIG_CHECKPOINT)	+= checkpoint.o
+obj-$(CONFIG_CHECKPOINT)	+= checkpoint_dev.o
net/checkpoint_dev.c new file +518 -0

518 lines not on this page · raw message

Signature · 1 line
1.6.2.5
#7 lore raw

Re: [PATCH 3/3] C/R: Basic support for network namespaces and devices

In reply to a message not in the archive
Quoted 17 lines · Dan Smith

When checkpointing a task tree with network namespaces, we hook into do_checkpoint_ns() along with the others. Any devices in a given namespace are checkpointed (including their peer, in the case of veth) sequentially. Each network device stores a list of protocol addresses, as well as other information, such as hardware address.

This patch supports veth pairs, as well as the loopback adapter. The loopback support is there to make sure that any additional addresses and state (such as up/down) is copied to the loopback adapter that we are given in the new network namespace.

On restart, we instantiate new network namespaces and veth pairs as necessary. Any device we encounter that isn't in a network namespace that was checkpointed as part of a task is left in the namespace of the restarting process. This will be the case for a veth half that exists in the init netns to provide network access to a container.

Quoted 8 lines

Still to do are:

1. Routes
2. Netfilter rules
3. IPv6 addresses
4. Other virtual device types (e.g. bridges)

Cool - I don't see any issues in the patchset.

thanks,
-serge

#8 lore raw

Re: [PATCH 3/3] C/R: Basic support for network namespaces and devices

In reply to a message not in the archive

Cool - looks good !

Would this compile without CONFIG_NET ? without CONFIG_NET_NS ?

How can a user ask to not checkpoint the network-ns ? (e.g. in a subtree checkpoint)

And a few minor comments inline...

Quoted 25 lines · Dan Smith

When checkpointing a task tree with network namespaces, we hook into do_checkpoint_ns() along with the others. Any devices in a given namespace are checkpointed (including their peer, in the case of veth) sequentially. Each network device stores a list of protocol addresses, as well as other information, such as hardware address.

This patch supports veth pairs, as well as the loopback adapter. The loopback support is there to make sure that any additional addresses and state (such as up/down) is copied to the loopback adapter that we are given in the new network namespace.

On restart, we instantiate new network namespaces and veth pairs as necessary. Any device we encounter that isn't in a network namespace that was checkpointed as part of a task is left in the namespace of the restarting process. This will be the case for a veth half that exists in the init netns to provide network access to a container.

Still to do are:

1. Routes
2. Netfilter rules
3. IPv6 addresses
4. Other virtual device types (e.g. bridges)

[...]

Quoted 4 lines

+/*
+ * Determine if an interface should be checkpointed, skipped, or
+ * if it makes us uncheckpointable. This needs to be improved
+ * dramatically, but works for the moment.

Maybe be a bit more verbose about what's missing ?

Quoted 3 lines

+ *
+ * Return 1 for yes, 0 for skip, -ERRNO for error
+ */

[...]

Quoted 8 lines
net/checkpoint_dev.c new file +8 -0
+static int count_inet4_addrs(struct in_device *indev)
+{
+	int count = 0;
+	struct in_ifaddr *addr;
+
+	for (addr = indev->ifa_list; addr; addr = addr->ifa_next)
+		count++;
+

net/checkpoint_dev.c line 98

Quoted 10 lines
net/checkpoint_dev.c new file +10 -0
+	return count;
+}
+
+static int checkpoint_in_addrs(struct ckpt_ctx *ctx, struct in_device *indev)
+{
+	struct ckpt_hdr_netdev_addr *h;
+	struct in_ifaddr *addr = indev->ifa_list;
+	int ret;
+	int count = 0;
+

Is there a reason not to collect all addresses into one buffer (can there be more than a page worth of them ?) and write in one go ?

Quoted 24 lines
net/checkpoint_dev.c new file +24 -0
+	while (addr) {
+		h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_NETDEV_ADDR);
+		if (!h)
+			return -ENOMEM;
+
+		h->type = CKPT_NETDEV_ADDR_IPV4; /* Only IPv4 right now */
+
+		h->inet4_local = addr->ifa_local;
+		h->inet4_address = addr->ifa_address;
+		h->inet4_mask = addr->ifa_mask;
+		h->inet4_broadcast = addr->ifa_broadcast;
+
+		ret = ckpt_write_obj(ctx, (struct ckpt_hdr *) h);
+		ckpt_hdr_put(ctx, h);
+		if (ret < 0)
+			break;
+
+		addr = addr->ifa_next;
+
+		count++;
+	}
+
+	return ret < 0 ? ret : count;
+}

[...]

Quoted 7 lines
net/checkpoint_dev.c new file +7 -0
+
+int checkpoint_netdev(struct ckpt_ctx *ctx, void *ptr)
+{
+	struct ckpt_hdr_netdev *h;
+	struct net_device *dev = ptr;
+	struct net_device *peer = NULL;
+	struct net *net = dev->nd_net;

net/checkpoint_dev.c line 158

Quoted 10 lines
net/checkpoint_dev.c new file +10 -0
+	int ret = 0;
+	struct ifreq req;
+
+	h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_NETDEV);
+	if (!h)
+		return -ENOMEM;
+
+	if (strcmp(dev->name, "lo") == 0)
+		h->type = CKPT_NETDEV_LO;
+	else {

While this is correct, perhaps be more verbose and change to:

	else if (strncmp(dev->name, "veth", 4) == 0)

net/checkpoint_dev.c line 161

Quoted 3 lines
net/checkpoint_dev.c new file +3 -0
+		h->type = CKPT_NETDEV_VETH;
+		peer = veth_get_peer(dev);
+	}

and then

	} else {
		/* error */
	}
Quoted 7 lines
net/checkpoint_dev.c new file +7 -0
+
+	memcpy(req.ifr_name, dev->name, IFNAMSIZ);
+	ret = __kern_dev_ioctl(net, SIOCGIFFLAGS, &req);
+	h->flags = req.ifr_flags;
+	if (ret < 0)
+		goto out;
+

[...]

Quoted 8 lines
net/checkpoint_dev.c new file +8 -0
+
+int checkpoint_netns(struct ckpt_ctx *ctx, void *ptr)
+{
+	struct net *net = ptr;
+	struct net_device *dev;
+	struct ckpt_hdr_netns *h;
+	int ret;
+

net/checkpoint_dev.c line 236

Quoted 10 lines
net/checkpoint_dev.c new file +10 -0
+	h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_NET_NS);
+	if (!h)
+		return -ENOMEM;
+
+	h->this_ref = ckpt_obj_lookup(ctx, net, CKPT_OBJ_NET_NS);
+	if (h->this_ref == 0) {
+		/* This shouldn't happen because we're called from
+		 * checkpoint_obj() which should have already put
+		 * us in the hash
+		 */

If this can only happen due to a bug, then BUG_ON(). Otherwise, maybe use ckpt_err() ?

Quoted 11 lines
net/checkpoint_dev.c new file +11 -0
+		ret = -EINVAL;
+		goto out;
+	}
+
+	ret = ckpt_write_obj(ctx, (struct ckpt_hdr *) h);
+	if (ret < 0)
+		goto out;
+
+	for_each_netdev(net, dev) {
+		ret = should_checkpoint_netdev(dev);
+		if (ret > 0)

net/checkpoint_dev.c line 257

Quoted 10 lines
net/checkpoint_dev.c new file +10 -0
+			ret = checkpoint_obj(ctx, dev, CKPT_OBJ_NETDEV);
+		if (ret < 0)
+			break;
+	}
+ out:
+	ckpt_hdr_put(ctx, h);
+
+	return ret;
+}
+

[...]

Thanks,

Oren.

#12 lore raw

Re: [PATCH 3/3] C/R: Basic support for network namespaces and devices

In reply to a message not in the archive
Quoted 17 lines · Dan Smith

When checkpointing a task tree with network namespaces, we hook into do_checkpoint_ns() along with the others. Any devices in a given namespace are checkpointed (including their peer, in the case of veth) sequentially. Each network device stores a list of protocol addresses, as well as other information, such as hardware address.

This patch supports veth pairs, as well as the loopback adapter. The loopback support is there to make sure that any additional addresses and state (such as up/down) is copied to the loopback adapter that we are given in the new network namespace.

On restart, we instantiate new network namespaces and veth pairs as necessary. Any device we encounter that isn't in a network namespace that was checkpointed as part of a task is left in the namespace of the restarting process. This will be the case for a veth half that exists in the init netns to provide network access to a container.

Quoted 6 lines

Still to do are:

1. Routes
2. Netfilter rules
3. IPv6 addresses
4. Other virtual device types (e.g. bridges)

What about:

1. Multicast
2. Device config info (ipv4_devconf)

Quoted 8 lines
net/checkpoint_dev.c new file +8 -0
+static int checkpoint_in_addrs(struct ckpt_ctx *ctx, struct in_device *indev)
+{
+	struct ckpt_hdr_netdev_addr *h;
+	struct in_ifaddr *addr = indev->ifa_list;
+	int ret;
+	int count = 0;
+
+	while (addr) {

net/checkpoint_dev.c line 109

Quoted 10 lines
net/checkpoint_dev.c new file +10 -0
+		h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_NETDEV_ADDR);
+		if (!h)
+			return -ENOMEM;
+
+		h->type = CKPT_NETDEV_ADDR_IPV4; /* Only IPv4 right now */
+
+		h->inet4_local = addr->ifa_local;
+		h->inet4_address = addr->ifa_address;
+		h->inet4_mask = addr->ifa_mask;
+		h->inet4_broadcast = addr->ifa_broadcast;

What about addr->ifa_flags and all the other elements like prefixlen, scope and label?

Quoted 57 lines
net/checkpoint_dev.c new file +57 -0
+int checkpoint_netdev(struct ckpt_ctx *ctx, void *ptr)
+{
+	struct ckpt_hdr_netdev *h;
+	struct net_device *dev = ptr;
+	struct net_device *peer = NULL;
+	struct net *net = dev->nd_net;
+	int ret = 0;
+	struct ifreq req;
+
+	h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_NETDEV);
+	if (!h)
+		return -ENOMEM;
+
+	if (strcmp(dev->name, "lo") == 0)
+		h->type = CKPT_NETDEV_LO;
+	else {
+		h->type = CKPT_NETDEV_VETH;
+		peer = veth_get_peer(dev);
+	}
+
+	memcpy(req.ifr_name, dev->name, IFNAMSIZ);
+	ret = __kern_dev_ioctl(net, SIOCGIFFLAGS, &req);
+	h->flags = req.ifr_flags;
+	if (ret < 0)
+		goto out;
+
+	ret = __kern_dev_ioctl(net, SIOCGIFHWADDR, &req);
+	if (ret < 0)
+		goto out;
+	memcpy(h->hwaddr, req.ifr_hwaddr.sa_data, sizeof(h->hwaddr));
+
+	h->netns_ref = ckpt_obj_lookup(ctx, net, CKPT_OBJ_NET_NS);
+	if (!h->netns_ref) {
+		ret = -EINVAL;
+		ckpt_err(ctx, ret, "Found netdev with no netns");
+		goto out;
+	}
+
+	h->inet4_addrs = count_inet4_addrs(dev->ip_ptr);
+
+	if (h->type == CKPT_NETDEV_VETH) {
+		ret = add_veth_refs(ctx, h, dev, peer);
+		if (ret < 0)
+			goto out;
+	}
+
+	ret = ckpt_write_obj(ctx, (struct ckpt_hdr *) h);
+	if (ret < 0)
+		goto out;
+
+	if (h->type == CKPT_NETDEV_VETH) {
+		ret = ckpt_write_buffer(ctx, dev->name, IFNAMSIZ);
+		if (ret < 0)
+			goto out;
+
+		ret = ckpt_write_buffer(ctx, peer->name, IFNAMSIZ);
+		if (ret < 0)

net/checkpoint_dev.c line 209

Quoted 10 lines
net/checkpoint_dev.c new file +10 -0
+			goto out;
+	}
+
+	ret = checkpoint_in_addrs(ctx, dev->ip_ptr);
+	if ((ret >= 0) && (ret != h->inet4_addrs)) {
+		ret = -EBUSY;
+		ckpt_err(ctx, ret,
+			 "Addresses on interface %s changed\n", dev->name);
+		goto out;
+	}

This isn't guaranteed to catch every change to the address list, just that the number of addresses is the same, is there no way to hold a lock the whole time?

-Brian

maintainer
#4 lore raw

Re: [PATCH 2/3] Add a veth_get_peer() and veth_set_peer() functions

In reply to Dan Smith

If you're going to CC: netdev on your first two patches that expose infrastructure, you should CC: us on the third patch too so we can see how in the world you're using this stuff.

author
#14 lore raw

Re: [PATCH 3/3] C/R: Basic support for network namespaces and devices

In reply to a message not in the archive

BH> What about:

BH> 1. Multicast
BH> 2. Device config info (ipv4_devconf)

<snip>

BH> What about addr->ifa_flags and all the other elements like BH> prefixlen, scope and label?

I thought I was covered by calling it "Basic support..." :)

I've added these to the list of TODOs and will cook those up once the basic bits are in.

Quoted 6 lines

net/checkpoint_dev.c line 209

Quoted 6 lines
net/checkpoint_dev.c new file +6 -0
+	if ((ret >= 0) && (ret != h->inet4_addrs)) {
+		ret = -EBUSY;
+		ckpt_err(ctx, ret,
+			 "Addresses on interface %s changed\n", dev->name);
+		goto out;
+	}

BH> This isn't guaranteed to catch every change to the address list, BH> just that the number of addresses is the same, is there no way to BH> hold a lock the whole time?

Yeah, there probably is. I'll take a look.

Thanks!

Signature · 3 lines
Dan Smith
IBM Linux Technology Center
email: danms-r/[email protected]
author
#9 lore raw

Re: [PATCH 3/3] C/R: Basic support for network namespaces and devices

In reply to Oren Laadan

OL> Would this compile without CONFIG_NET ? without CONFIG_NET_NS ?

Nope, but it does depend on CONFIG_CHECKPOINT, of course. I'll add some Kconfig magic to try to straighten that out.

OL> How can a user ask to not checkpoint the network-ns ? (e.g. in OL> a subtree checkpoint)

Do we really want to start adding fine-grained control over everything that we checkpoint? Can you ask it to not checkpoint the ipc_ns, uts_ns, etc? The previous example of this was connected sockets, which I think is different, given the potential for a long delay before restart ensuring the sockets will be dead anyway.

OL> Is there a reason not to collect all addresses into one buffer OL> (can there be more than a page worth of them ?) and write in one OL> go ?

I don't really see anywhere that the list is bounded. I'd say that in most cases each interface will only have one address anyway.

Signature · 3 lines
Dan Smith
IBM Linux Technology Center
email: danms-r/[email protected]
#16 lore raw

Re: [PATCH 3/3] C/R: Basic support for network namespaces and devices

In reply to a message not in the archive
Quoted 26 lines · Dan Smith

BH> What about:

BH> 1. Multicast
BH> 2. Device config info (ipv4_devconf)

<snip>

BH> What about addr->ifa_flags and all the other elements like BH> prefixlen, scope and label?

I thought I was covered by calling it "Basic support..." :)

I've added these to the list of TODOs and will cook those up once the basic bits are in.

Quoted 6 lines

net/checkpoint_dev.c line 209

Quoted 6 lines
net/checkpoint_dev.c new file +6 -0
+	if ((ret >= 0) && (ret != h->inet4_addrs)) {
+		ret = -EBUSY;
+		ckpt_err(ctx, ret,
+			 "Addresses on interface %s changed\n", dev->name);
+		goto out;
+	}

BH> This isn't guaranteed to catch every change to the address list, BH> just that the number of addresses is the same, is there no way to BH> hold a lock the whole time?

Quoted 1 line

Yeah, there probably is. I'll take a look.

Qouting from your reply to my email:

Quoted 6 lines

OL> Is there a reason not to collect all addresses into one buffer OL> (can there be more than a page worth of them ?) and write in one OL> go ?

I don't really see anywhere that the list is bounded. I'd say that in most cases each interface will only have one address anyway.

So collecting them in one buffer (if one page isn't enough then realloc and retry) would solve this too.

Oren

#11 lore raw

Re: [PATCH 3/3] C/R: Basic support for network namespaces and devices

In reply to a message not in the archive
Quoted 11 lines · Dan Smith

OL> Would this compile without CONFIG_NET ? without CONFIG_NET_NS ?

Nope, but it does depend on CONFIG_CHECKPOINT, of course. I'll add some Kconfig magic to try to straighten that out.

OL> How can a user ask to not checkpoint the network-ns ? (e.g. in OL> a subtree checkpoint)

Do we really want to start adding fine-grained control over everything that we checkpoint? Can you ask it to not checkpoint the ipc_ns, uts_ns, etc?

Basically yes. So far we didn't address how to do that.

With network-ns it's a bit different, because, iiuc, it will require root for a restart even of a subtree checkpoint (that doesn't care about pids), just by being there.

Quoted 3 lines

The previous example of this was connected sockets, which I think is different, given the potential for a long delay before restart ensuring the sockets will be dead anyway.

Agreed.

Oren.