[Devel] [PATCH RHEL7 COMMIT] vzprivnet: Netmask byte order toss
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Mar 24 08:53:29 PDT 2016
The commit is pushed to "branch-rh7-3.10.0-327.10.1.vz7.12.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.10.1.vz7.12.3
------>
commit 2e771e009a262825b6e372355a497a1d0e2a436a
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date: Thu Mar 24 19:53:29 2016 +0400
vzprivnet: Netmask byte order toss
Port diff-vz-privnet-netmask-byte-order-toss
vzprivnet: Toss htonl/ntohl conversions
Make the mask manipulation routines perform byte-ordering themselves.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
net/ipv4/netfilter/ip_vzprivnet.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/netfilter/ip_vzprivnet.c b/net/ipv4/netfilter/ip_vzprivnet.c
index e2eb344..8a8520a 100644
--- a/net/ipv4/netfilter/ip_vzprivnet.c
+++ b/net/ipv4/netfilter/ip_vzprivnet.c
@@ -240,11 +240,12 @@ static struct nf_hook_ops vzprivnet_ops = {
static inline u32 to_netmask(int prefix)
{
- return ((~0 << (32 - prefix)));
+ return htonl((~0 << (32 - prefix)));
}
static inline unsigned int to_prefix(u32 netmask)
{
+ netmask = ntohl(netmask);
return 32 - ilog2(~netmask + 1);
}
@@ -363,8 +364,8 @@ static int parse_param(const char *param, int *add, u32 *net,
if (err < 6 || m1 == 0 || m1 > 32 || m2 == 0 || m2 > 32)
return -EINVAL;
- *netmask1 = htonl(to_netmask(m1));
- *netmask2 = htonl(to_netmask(m2));
+ *netmask1 = to_netmask(m1);
+ *netmask2 = to_netmask(m2);
*net &= *netmask1;
} else
*netmask1 = *netmask2 = 0;
@@ -457,7 +458,7 @@ static int vzprivnet_seq_show(struct seq_file *s, void *v)
struct vzprivnet_range *p = v;
seq_printf(s, "%pI4/%u/%u", &p->netip,
- to_prefix(ntohl(p->rmask)), to_prefix(ntohl(p->pn->nmask)));
+ to_prefix(p->rmask), to_prefix(p->pn->nmask));
if (p->pn->weak)
seq_printf(s, "*\n");
else
More information about the Devel
mailing list