[CRIU] [PATCH 1/8] net: Move void devices dumping in a separate helper
Pavel Emelyanov
xemul at parallels.com
Thu Dec 26 04:59:12 PST 2013
To make it look symmetrical to over types dumping.
And for simpler further patching.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
net.c | 36 ++++++++++++++++++++++++------------
1 file changed, 24 insertions(+), 12 deletions(-)
diff --git a/net.c b/net.c
index 433f374..154a5b0 100644
--- a/net.c
+++ b/net.c
@@ -143,13 +143,34 @@ unk:
return -1;
}
+static int dump_one_voiddev(struct ifinfomsg *ifi,
+ struct rtattr **tb, struct cr_fdset *fds)
+{
+ char *kind;
+
+ kind = link_kind(ifi, tb);
+ if (!kind)
+ goto unk;
+
+ if (!strcmp(kind, "venet"))
+ /*
+ * If we meet a link we know about, such as
+ * OpenVZ's venet, save general parameters of
+ * it as external link.
+ */
+ return dump_one_netdev(ND_TYPE__EXTLINK, ifi, tb, fds, NULL);
+
+unk:
+ pr_err("Unknown VOID kind %s link %d\n", kind, ifi->ifi_index);
+ return -1;
+}
+
static int dump_one_link(struct nlmsghdr *hdr, void *arg)
{
struct cr_fdset *fds = arg;
struct ifinfomsg *ifi;
int ret = 0, len = hdr->nlmsg_len - NLMSG_LENGTH(sizeof(*ifi));
struct rtattr *tb[IFLA_MAX + 1];
- char *kind;
ifi = NLMSG_DATA(hdr);
@@ -173,17 +194,8 @@ static int dump_one_link(struct nlmsghdr *hdr, void *arg)
ret = dump_one_gendev(ifi, tb, fds);
break;
case ARPHRD_VOID:
- /*
- * If we meet a link we know about, such as
- * OpenVZ's venet, save general parameters of
- * it as external link.
- */
- kind = link_kind(ifi, tb);
- if (kind && !strcmp(kind, "venet")) {
- ret = dump_one_netdev(ND_TYPE__EXTLINK, ifi, tb, fds, NULL);
- break;
- }
- /* Fall through otherwise! */
+ ret = dump_one_voiddev(ifi, tb, fds);
+ break;
default:
pr_err("Unsupported link type %d, kind %s\n",
ifi->ifi_type, link_kind(ifi, tb));
--
1.8.3.1
More information about the CRIU
mailing list