* [GIT PULL nf-next 0/1] Second Round of IPVS Updates for v4.7
@ 2016-05-06 7:32 Simon Horman
2016-05-06 7:32 ` [PATCH nf-next 1/1] ipvs: make drop_entry protection effective for SIP-pe Simon Horman
2016-05-08 22:19 ` [GIT PULL nf-next 0/1] Second Round of IPVS Updates for v4.7 Pablo Neira Ayuso
0 siblings, 2 replies; 3+ messages in thread
From: Simon Horman @ 2016-05-06 7:32 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: lvs-devel, netdev, netfilter-devel, Wensong Zhang,
Julian Anastasov, Simon Horman
Hi Pablo,
please consider these enhancements to the IPVS. They allow its
DoS mitigation strategy effective in conjunction with the SIP persistence
engine.
The following changes since commit cb39ad8b8ef224c544074962780bf763077d6141:
netfilter: nf_tables: allow set names up to 32 bytes (2016-05-05 16:39:51 +0200)
are available in the git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs-next.git tags/ipvs2-for-v4.7
for you to fetch changes up to 698e2a8dca98e4de32f3f630e6d9cd93753c52e1:
ipvs: make drop_entry protection effective for SIP-pe (2016-05-06 16:26:23 +0900)
----------------------------------------------------------------
Marco Angaroni (1):
ipvs: make drop_entry protection effective for SIP-pe
net/netfilter/ipvs/ip_vs_conn.c | 22 +++++++++++++++++++---
net/netfilter/ipvs/ip_vs_core.c | 8 +++++++-
2 files changed, 26 insertions(+), 4 deletions(-)
Marco Angaroni (1):
ipvs: make drop_entry protection effective for SIP-pe
net/netfilter/ipvs/ip_vs_conn.c | 22 +++++++++++++++++++---
net/netfilter/ipvs/ip_vs_core.c | 8 +++++++-
2 files changed, 26 insertions(+), 4 deletions(-)
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH nf-next 1/1] ipvs: make drop_entry protection effective for SIP-pe
2016-05-06 7:32 [GIT PULL nf-next 0/1] Second Round of IPVS Updates for v4.7 Simon Horman
@ 2016-05-06 7:32 ` Simon Horman
2016-05-08 22:19 ` [GIT PULL nf-next 0/1] Second Round of IPVS Updates for v4.7 Pablo Neira Ayuso
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2016-05-06 7:32 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: lvs-devel, netdev, netfilter-devel, Wensong Zhang,
Julian Anastasov, Marco Angaroni, Simon Horman
From: Marco Angaroni <marcoangaroni@gmail.com>
DoS protection policy that deletes connections to avoid out of memory is
currently not effective for SIP-pe plus OPS-mode for two reasons:
1) connection templates (holding SIP call-id) are always skipped in
ip_vs_random_dropentry()
2) in_pkts counter (used by drop_entry algorithm) is not incremented
for connection templates
This patch addresses such problems with the following changes:
a) connection templates associated (via their dest) to virtual-services
configured in OPS mode are included in ip_vs_random_dropentry()
monitoring. This applies to SIP-pe over UDP (which requires OPS mode),
but is more general principle: when OPS is controlled by templates
memory can be used only by templates themselves, since OPS conns are
deleted after packet is forwarded.
b) OPS connections, if controlled by a template, cause increment of
in_pkts counter of their template. This is already happening but only
in case director is in master-slave mode (see ip_vs_sync_conn()).
Signed-off-by: Marco Angaroni <marcoangaroni@gmail.com>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
net/netfilter/ipvs/ip_vs_conn.c | 22 +++++++++++++++++++---
net/netfilter/ipvs/ip_vs_core.c | 8 +++++++-
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 292365ffa4f0..2cb3c626cd43 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -1261,6 +1261,16 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
return 1;
}
+static inline bool ip_vs_conn_ops_mode(struct ip_vs_conn *cp)
+{
+ struct ip_vs_service *svc;
+
+ if (!cp->dest)
+ return false;
+ svc = rcu_dereference(cp->dest->svc);
+ return svc && (svc->flags & IP_VS_SVC_F_ONEPACKET);
+}
+
/* Called from keventd and must protect itself from softirqs */
void ip_vs_random_dropentry(struct netns_ipvs *ipvs)
{
@@ -1275,11 +1285,16 @@ void ip_vs_random_dropentry(struct netns_ipvs *ipvs)
unsigned int hash = prandom_u32() & ip_vs_conn_tab_mask;
hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[hash], c_list) {
- if (cp->flags & IP_VS_CONN_F_TEMPLATE)
- /* connection template */
- continue;
if (cp->ipvs != ipvs)
continue;
+ if (cp->flags & IP_VS_CONN_F_TEMPLATE) {
+ if (atomic_read(&cp->n_control) ||
+ !ip_vs_conn_ops_mode(cp))
+ continue;
+ else
+ /* connection template of OPS */
+ goto try_drop;
+ }
if (cp->protocol == IPPROTO_TCP) {
switch(cp->state) {
case IP_VS_TCP_S_SYN_RECV:
@@ -1307,6 +1322,7 @@ void ip_vs_random_dropentry(struct netns_ipvs *ipvs)
continue;
}
} else {
+try_drop:
if (!todrop_entry(cp))
continue;
}
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index f3bac2e9a25a..1207f20d24e4 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -612,7 +612,10 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
ret = cp->packet_xmit(skb, cp, pd->pp, iph);
/* do not touch skb anymore */
- atomic_inc(&cp->in_pkts);
+ if ((cp->flags & IP_VS_CONN_F_ONE_PACKET) && cp->control)
+ atomic_inc(&cp->control->in_pkts);
+ else
+ atomic_inc(&cp->in_pkts);
ip_vs_conn_put(cp);
return ret;
}
@@ -1991,6 +1994,9 @@ ip_vs_in(struct netns_ipvs *ipvs, unsigned int hooknum, struct sk_buff *skb, int
if (ipvs->sync_state & IP_VS_STATE_MASTER)
ip_vs_sync_conn(ipvs, cp, pkts);
+ else if ((cp->flags & IP_VS_CONN_F_ONE_PACKET) && cp->control)
+ /* increment is done inside ip_vs_sync_conn too */
+ atomic_inc(&cp->control->in_pkts);
ip_vs_conn_put(cp);
return ret;
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [GIT PULL nf-next 0/1] Second Round of IPVS Updates for v4.7
2016-05-06 7:32 [GIT PULL nf-next 0/1] Second Round of IPVS Updates for v4.7 Simon Horman
2016-05-06 7:32 ` [PATCH nf-next 1/1] ipvs: make drop_entry protection effective for SIP-pe Simon Horman
@ 2016-05-08 22:19 ` Pablo Neira Ayuso
1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2016-05-08 22:19 UTC (permalink / raw)
To: Simon Horman
Cc: lvs-devel, netdev, netfilter-devel, Wensong Zhang,
Julian Anastasov
On Fri, May 06, 2016 at 04:32:38PM +0900, Simon Horman wrote:
> Hi Pablo,
>
> please consider these enhancements to the IPVS. They allow its
> DoS mitigation strategy effective in conjunction with the SIP persistence
> engine.
>
> The following changes since commit cb39ad8b8ef224c544074962780bf763077d6141:
>
> netfilter: nf_tables: allow set names up to 32 bytes (2016-05-05 16:39:51 +0200)
>
> are available in the git repository at:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs-next.git tags/ipvs2-for-v4.7
Pulled, thanks Simon.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-08 22:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-06 7:32 [GIT PULL nf-next 0/1] Second Round of IPVS Updates for v4.7 Simon Horman
2016-05-06 7:32 ` [PATCH nf-next 1/1] ipvs: make drop_entry protection effective for SIP-pe Simon Horman
2016-05-08 22:19 ` [GIT PULL nf-next 0/1] Second Round of IPVS Updates for v4.7 Pablo Neira Ayuso
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).