[CRIU] [PATCH] sk: optimize dump size a bit
Kinsbursky Stanislav
skinsbursky at openvz.org
Thu Aug 2 06:39:43 EDT 2012
From: Stanislav Kinsbursky <skinsbursky at openvz.org>
Let's carry only on uint_32 for IPv4 address.
Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
sk-inet.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
-------------- next part --------------
diff --git a/sk-inet.c b/sk-inet.c
index ca0a1a9..af59223 100644
--- a/sk-inet.c
+++ b/sk-inet.c
@@ -200,8 +200,12 @@ static int dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p)
ie.fown = (FownEntry *)&p->fown;
ie.opts = &skopts;
- ie.n_src_addr = 4;
- ie.n_dst_addr = 4;
+ ie.n_src_addr = 1;
+ ie.n_dst_addr = 1;
+ if (ie.family == AF_INET6) {
+ ie.n_src_addr = 4;
+ ie.n_dst_addr = 4;
+ }
ie.src_addr = xmalloc(pb_repeated_size(&ie, src_addr));
ie.dst_addr = xmalloc(pb_repeated_size(&ie, dst_addr));
@@ -209,8 +213,8 @@ static int dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p)
if (!ie.src_addr || !ie.dst_addr)
goto err;
- memcpy(ie.src_addr, sk->src_addr, sizeof(u32) * 4);
- memcpy(ie.dst_addr, sk->dst_addr, sizeof(u32) * 4);
+ memcpy(ie.src_addr, sk->src_addr, sizeof(u32) * ie.n_src_addr);
+ memcpy(ie.dst_addr, sk->dst_addr, sizeof(u32) * ie.n_dst_addr);
if (dump_socket_opts(lfd, &skopts))
goto err;
@@ -279,10 +283,6 @@ static u32 zero_addr[4];
static bool is_bound(struct inet_sk_info *ii)
{
- BUG_ON(sizeof(zero_addr) <
- max(pb_repeated_size(ii->ie, dst_addr),
- pb_repeated_size(ii->ie, src_addr)));
-
return memcmp(zero_addr, ii->ie->src_addr, pb_repeated_size(ii->ie, src_addr)) ||
memcmp(zero_addr, ii->ie->dst_addr, pb_repeated_size(ii->ie, dst_addr));
}
More information about the CRIU
mailing list