[Devel] [PATCH RHEL7 COMMIT] vzprivnet: Introduce constants for weakness
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Mar 24 08:53:39 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 37b15df47994305d8852b0f5d50f8d1eac5d72a1
Author: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
Date: Thu Mar 24 19:53:39 2016 +0400
vzprivnet: Introduce constants for weakness
Port diff-vzprivnet-contants-for-weakness
VZPRIVNET: types introduced
Declare named constants for weakness types. Will be used later.
Ported from rhel5
Signed-off-by: Stanislav Kinsbursky <skinsbursky at parallels.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
include/linux/vzprivnet.h | 3 +++
net/ipv4/netfilter/ip_vzprivnet.c | 26 +++++++++++++-------------
net/ipv6/netfilter/ip6_vzprivnet.c | 18 +++++++++---------
3 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/include/linux/vzprivnet.h b/include/linux/vzprivnet.h
index f93417c..fb345db 100644
--- a/include/linux/vzprivnet.h
+++ b/include/linux/vzprivnet.h
@@ -14,4 +14,7 @@ void vzprivnet_unreg_show(vzprivnet_show_fn);
#define is_eol(ch) ((ch) == '\0' || (ch) == '\n')
+#define VZPRIVNET_STRONG 0
+#define VZPRIVNET_WEAK 1
+
#endif
diff --git a/net/ipv4/netfilter/ip_vzprivnet.c b/net/ipv4/netfilter/ip_vzprivnet.c
index 4b5671bf..2c72dd3 100644
--- a/net/ipv4/netfilter/ip_vzprivnet.c
+++ b/net/ipv4/netfilter/ip_vzprivnet.c
@@ -191,7 +191,7 @@ static struct vzprivnet_range *legacy_next(struct vzprivnet_range *p)
static struct vzprivnet vzpriv_internet = {
.nmask = 0,
- .weak = 1
+ .weak = VZPRIVNET_WEAK
};
static struct vzprivnet *vzpriv_search(u32 ip)
@@ -452,10 +452,10 @@ static int parse_param(const char *param, int *add, u32 *net,
if (err < 4 || (a == 0 || a > 255 || b > 255 || c > 255 || d > 255))
return -EINVAL;
- *weak = 0;
+ *weak = VZPRIVNET_STRONG;
if (err == 7) {
if (e == '*')
- *weak = 1;
+ *weak = VZPRIVNET_WEAK;
else if (e != '\n' || !isspace(e))
return -EINVAL;
}
@@ -562,7 +562,7 @@ static int vzprivnet_seq_show(struct seq_file *s, void *v)
seq_printf(s, "%pI4/%u/%u", &p->netip,
to_prefix(p->rmask), to_prefix(p->pn->nmask));
- if (p->pn->weak)
+ if (p->pn->weak == VZPRIVNET_WEAK)
seq_printf(s, "*\n");
else
seq_printf(s, "\n");
@@ -616,7 +616,7 @@ static int sparse_add(unsigned int netid, u32 ip, u32 mask, int weak)
pns->netid = netid;
pns->pn.nmask = 0;
- pns->pn.weak = 0;
+ pns->pn.weak = VZPRIVNET_STRONG;
INIT_LIST_HEAD(&pns->entries);
found_net:
@@ -630,8 +630,8 @@ found_net:
list_add_tail(&pne->list, &pns->entries);
pne = NULL;
- } else if (weak) {
- pns->pn.weak = 1;
+ } else if (weak == VZPRIVNET_WEAK) {
+ pns->pn.weak = VZPRIVNET_WEAK;
} else if (pns == epns) {
err = -EEXIST;
goto out_unlock;
@@ -682,8 +682,8 @@ static int sparse_del_net(unsigned int netid, int weak)
list_for_each_entry(pns, &vzpriv_sparse, list)
if (pns->netid == netid) {
- if (weak)
- pns->pn.weak = 0;
+ if (weak == VZPRIVNET_WEAK)
+ pns->pn.weak = VZPRIVNET_STRONG;
else
sparse_free_one(pns);
return 0;
@@ -752,7 +752,7 @@ static int parse_sparse_add(const char *str, unsigned int *netid, u32 *ip, u32 *
if (!is_eol(*(str + 1)))
return -EINVAL;
- *weak = 1;
+ *weak = VZPRIVNET_WEAK;
return 0;
}
@@ -787,7 +787,7 @@ static int parse_sparse_remove(const char *str, unsigned int *netid, u32 *ip, in
*netid = simple_strtol(str, &end, 10);
if (end[0] == ':' && end[1] == '*') {
end += 2;
- *weak = 1;
+ *weak = VZPRIVNET_WEAK;
}
}
@@ -835,7 +835,7 @@ static ssize_t sparse_write(struct file * file, const char __user *buf,
err = -EINVAL;
while (*s) {
- int add, weak = 0;
+ int add, weak = VZPRIVNET_STRONG;
unsigned int netid = 0;
u32 ip = 0, mask = 0;
@@ -887,7 +887,7 @@ static int sparse_seq_show(struct seq_file *s, void *v)
pns = list_entry(lh, struct vzprivnet_sparse, list);
seq_printf(s, "%u: ", pns->netid);
- if (pns->pn.weak)
+ if (pns->pn.weak == VZPRIVNET_WEAK)
seq_puts(s, "* ");
list_for_each_entry(pne, &pns->entries, list) {
diff --git a/net/ipv6/netfilter/ip6_vzprivnet.c b/net/ipv6/netfilter/ip6_vzprivnet.c
index a3667f8..9d02cb5 100644
--- a/net/ipv6/netfilter/ip6_vzprivnet.c
+++ b/net/ipv6/netfilter/ip6_vzprivnet.c
@@ -120,7 +120,7 @@ static struct vzprivnet_entry *vzprivnet6_lookup(u32 *ip)
}
struct vzprivnet internet = {
- .weak = 1,
+ .weak = VZPRIVNET_WEAK,
};
static inline struct vzprivnet *vzprivnet6_lookup_net(u32 *ip)
@@ -197,8 +197,8 @@ found_net:
list_add_tail(&pne->list, &pn->entries);
vzprivnet6_hash_entry(pne, hash);
pne = NULL;
- } else if (weak) {
- pn->weak = 1;
+ } else if (weak == VZPRIVNET_WEAK) {
+ pn->weak = VZPRIVNET_WEAK;
} else if (pn == epn) {
err = -EEXIST;
goto out_unlock;
@@ -264,8 +264,8 @@ static int sparse6_del_net(unsigned netid, int weak)
if (pn->netid != netid)
continue;
- if (weak)
- pn->weak = 0;
+ if (weak == VZPRIVNET_WEAK)
+ pn->weak = VZPRIVNET_STRONG;
else
sparse6_del_one(pn);
@@ -427,7 +427,7 @@ static int parse_sparse6_add(const char *str, unsigned int *netid, u32 *ip, unsi
if (!is_eol(*(str + 1)))
return -EINVAL;
- *weak = 1;
+ *weak = VZPRIVNET_WEAK;
return 0;
}
@@ -461,7 +461,7 @@ static int parse_sparse6_remove(const char *str, unsigned int *netid, u32 *ip, i
*netid = simple_strtol(str, &end, 10);
if (end[0] == ':' && end[1] == '*') {
end += 2;
- *weak = 1;
+ *weak = VZPRIVNET_WEAK;
}
}
@@ -518,7 +518,7 @@ static ssize_t sparse6_write(struct file * file, const char __user *buf,
err = -EINVAL;
while (*s) {
- int add, weak = 0;
+ int add, weak = VZPRIVNET_STRONG;
unsigned int netid = 0, preflen = 0;
u32 ip[4] = { 0, 0, 0, 0 };
@@ -580,7 +580,7 @@ static int sparse6_seq_show(struct seq_file *s, void *v)
pn = list_entry(v, struct vzprivnet, list);
seq_printf(s, "%u: ", pn->netid);
- if (pn->weak)
+ if (pn->weak == VZPRIVNET_WEAK)
seq_puts(s, "* ");
list_for_each_entry(pne, &pn->entries, list)
More information about the Devel
mailing list