* [PATCH] ipvs: Add traffic statistic up even it is VS/DR or VS/TUN mode
@ 2020-09-29 5:03 longguang.yue
2020-09-29 5:17 ` yue longguang
2020-09-29 8:18 ` [PATCH v2] " longguang.yue
0 siblings, 2 replies; 5+ messages in thread
From: longguang.yue @ 2020-09-29 5:03 UTC (permalink / raw)
Cc: yuelongguang, longguang.yue, Wensong Zhang, Simon Horman,
Julian Anastasov, Pablo Neira Ayuso, Jozsef Kadlecsik,
Florian Westphal, David S. Miller, Jakub Kicinski,
open list:IPVS, open list:IPVS, open list:NETFILTER,
open list:NETFILTER, open list
It's ipvs's duty to do traffic statistic if packets get hit,
no matter what mode it is.
Signed-off-by: longguang.yue <bigclouds@163.com>
---
net/netfilter/ipvs/ip_vs_core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index e3668a6e54e4..ed523057f07f 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -1413,8 +1413,11 @@ ip_vs_out(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, in
ipvs, af, skb, &iph);
if (likely(cp)) {
- if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ)
+ if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ){
+ ip_vs_out_stats(cp, skb);
+ skb->ipvs_property = 1;
goto ignore_cp;
+ }
return handle_response(af, skb, pd, cp, &iph, hooknum);
}
--
2.20.1 (Apple Git-117)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ipvs: Add traffic statistic up even it is VS/DR or VS/TUN mode
2020-09-29 5:03 [PATCH] ipvs: Add traffic statistic up even it is VS/DR or VS/TUN mode longguang.yue
@ 2020-09-29 5:17 ` yue longguang
2020-09-29 8:18 ` [PATCH v2] " longguang.yue
1 sibling, 0 replies; 5+ messages in thread
From: yue longguang @ 2020-09-29 5:17 UTC (permalink / raw)
To: longguang.yue
Cc: Wensong Zhang, Simon Horman, Julian Anastasov, Pablo Neira Ayuso,
Jozsef Kadlecsik, Florian Westphal, David S. Miller,
Jakub Kicinski, open list:IPVS, open list:IPVS,
open list:NETFILTER, open list:NETFILTER, open list
especially in public cloud case, statistic is related to monitorring
and billing , both ingress and egress packets will go throught ipvs,
even dr/tun mode.
in dr/tun mode, ipvs need to do nothing except statistic, so
skb->ipvs_property = 1
regards
On Tue, Sep 29, 2020 at 1:04 PM longguang.yue <bigclouds@163.com> wrote:
>
> It's ipvs's duty to do traffic statistic if packets get hit,
> no matter what mode it is.
>
> Signed-off-by: longguang.yue <bigclouds@163.com>
> ---
> net/netfilter/ipvs/ip_vs_core.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
> index e3668a6e54e4..ed523057f07f 100644
> --- a/net/netfilter/ipvs/ip_vs_core.c
> +++ b/net/netfilter/ipvs/ip_vs_core.c
> @@ -1413,8 +1413,11 @@ ip_vs_out(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, in
> ipvs, af, skb, &iph);
>
> if (likely(cp)) {
> - if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ)
> + if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ){
> + ip_vs_out_stats(cp, skb);
> + skb->ipvs_property = 1;
> goto ignore_cp;
> + }
> return handle_response(af, skb, pd, cp, &iph, hooknum);
> }
>
> --
> 2.20.1 (Apple Git-117)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] ipvs: Add traffic statistic up even it is VS/DR or VS/TUN mode
2020-09-29 5:03 [PATCH] ipvs: Add traffic statistic up even it is VS/DR or VS/TUN mode longguang.yue
2020-09-29 5:17 ` yue longguang
@ 2020-09-29 8:18 ` longguang.yue
2020-09-29 14:41 ` Jakub Kicinski
1 sibling, 1 reply; 5+ messages in thread
From: longguang.yue @ 2020-09-29 8:18 UTC (permalink / raw)
Cc: yuelongguang, longguang.yue, Wensong Zhang, Simon Horman,
Julian Anastasov, Pablo Neira Ayuso, Jozsef Kadlecsik,
Florian Westphal, David S. Miller, Jakub Kicinski,
open list:IPVS, open list:IPVS, open list:NETFILTER,
open list:NETFILTER, open list
It's ipvs's duty to do traffic statistic if packets get hit,
no matter what mode it is.
Signed-off-by: longguang.yue <bigclouds@163.com>
---
net/netfilter/ipvs/ip_vs_conn.c | 13 +++++++++++--
net/netfilter/ipvs/ip_vs_core.c | 5 ++++-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index a90b8eac16ac..2620c585d0c0 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -401,6 +401,8 @@ struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p)
struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p)
{
unsigned int hash;
+ __be16 cport;
+ const union nf_inet_addr *caddr;
struct ip_vs_conn *cp, *ret=NULL;
/*
@@ -411,10 +413,17 @@ struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p)
rcu_read_lock();
hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[hash], c_list) {
- if (p->vport == cp->cport && p->cport == cp->dport &&
+ if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ){
+ cport = cp->vport;
+ caddr = &cp->vaddr;
+ } else {
+ cport = cp->dport;
+ caddr = &cp->daddr;
+ }
+ if (p->vport == cp->cport && p->cport == cport &&
cp->af == p->af &&
ip_vs_addr_equal(p->af, p->vaddr, &cp->caddr) &&
- ip_vs_addr_equal(p->af, p->caddr, &cp->daddr) &&
+ ip_vs_addr_equal(p->af, p->caddr, caddr) &&
p->protocol == cp->protocol &&
cp->ipvs == p->ipvs) {
if (!__ip_vs_conn_get(cp))
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index e3668a6e54e4..ed523057f07f 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -1413,8 +1413,11 @@ ip_vs_out(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, in
ipvs, af, skb, &iph);
if (likely(cp)) {
- if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ)
+ if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ){
+ ip_vs_out_stats(cp, skb);
+ skb->ipvs_property = 1;
goto ignore_cp;
+ }
return handle_response(af, skb, pd, cp, &iph, hooknum);
}
--
2.20.1 (Apple Git-117)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ipvs: Add traffic statistic up even it is VS/DR or VS/TUN mode
2020-09-29 8:18 ` [PATCH v2] " longguang.yue
@ 2020-09-29 14:41 ` Jakub Kicinski
2020-09-30 1:26 ` [PATCH v3] " longguang.yue
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2020-09-29 14:41 UTC (permalink / raw)
To: longguang.yue
Cc: yuelongguang, Wensong Zhang, Simon Horman, Julian Anastasov,
Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
David S. Miller, netdev, lvs-devel, netfilter-devel, coreteam,
linux-kernel
On Tue, 29 Sep 2020 16:18:11 +0800 longguang.yue wrote:
> @@ -411,10 +413,17 @@ struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p)
> rcu_read_lock();
>
> hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[hash], c_list) {
> - if (p->vport == cp->cport && p->cport == cp->dport &&
> + if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ){
> + cport = cp->vport;
checkpatch says:
ERROR: space required before the open brace '{'
#25: FILE: net/netfilter/ipvs/ip_vs_core.c:1416:
+ if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ){
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3] ipvs: Add traffic statistic up even it is VS/DR or VS/TUN mode
2020-09-29 14:41 ` Jakub Kicinski
@ 2020-09-30 1:26 ` longguang.yue
0 siblings, 0 replies; 5+ messages in thread
From: longguang.yue @ 2020-09-30 1:26 UTC (permalink / raw)
Cc: kuba, yuelongguang, longguang.yue, Wensong Zhang, Simon Horman,
Julian Anastasov, Pablo Neira Ayuso, Jozsef Kadlecsik,
Florian Westphal, David S. Miller, open list:IPVS,
open list:IPVS, open list:NETFILTER, open list:NETFILTER,
open list
It's ipvs's duty to do traffic statistic if packets get hit,
no matter what mode it is.
Signed-off-by: longguang.yue <bigclouds@163.com>
---
net/netfilter/ipvs/ip_vs_conn.c | 14 ++++++++++++--
net/netfilter/ipvs/ip_vs_core.c | 5 ++++-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index a90b8eac16ac..c4d164ce8ca7 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -401,6 +401,8 @@ struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p)
struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p)
{
unsigned int hash;
+ __be16 cport;
+ const union nf_inet_addr *caddr;
struct ip_vs_conn *cp, *ret=NULL;
/*
@@ -411,10 +413,18 @@ struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p)
rcu_read_lock();
hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[hash], c_list) {
- if (p->vport == cp->cport && p->cport == cp->dport &&
+ cport = cp->dport;
+ caddr = &cp->daddr;
+
+ if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ) {
+ cport = cp->vport;
+ caddr = &cp->vaddr;
+ }
+
+ if (p->vport == cp->cport && p->cport == cport &&
cp->af == p->af &&
ip_vs_addr_equal(p->af, p->vaddr, &cp->caddr) &&
- ip_vs_addr_equal(p->af, p->caddr, &cp->daddr) &&
+ ip_vs_addr_equal(p->af, p->caddr, caddr) &&
p->protocol == cp->protocol &&
cp->ipvs == p->ipvs) {
if (!__ip_vs_conn_get(cp))
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index e3668a6e54e4..7ba88dab297a 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -1413,8 +1413,11 @@ ip_vs_out(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, in
ipvs, af, skb, &iph);
if (likely(cp)) {
- if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ)
+ if (IP_VS_FWD_METHOD(cp) != IP_VS_CONN_F_MASQ) {
+ ip_vs_out_stats(cp, skb);
+ skb->ipvs_property = 1;
goto ignore_cp;
+ }
return handle_response(af, skb, pd, cp, &iph, hooknum);
}
--
2.20.1 (Apple Git-117)
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-09-30 1:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 5:03 [PATCH] ipvs: Add traffic statistic up even it is VS/DR or VS/TUN mode longguang.yue
2020-09-29 5:17 ` yue longguang
2020-09-29 8:18 ` [PATCH v2] " longguang.yue
2020-09-29 14:41 ` Jakub Kicinski
2020-09-30 1:26 ` [PATCH v3] " longguang.yue
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).