* [PATCH v2 0/4] ipvs: add per-service secure_tcp
@ 2026-09-15 22:41 Adriano Cordova
2026-09-15 22:41 ` [PATCH v2 1/4] ipvs: add flags for per-service secure TCP state table Adriano Cordova
2026-09-15 22:41 ` [PATCH v2 2/4] ipvs: stamp per-service secure_tcp on connections Adriano Cordova
0 siblings, 2 replies; 3+ messages in thread
From: Adriano Cordova @ 2026-09-15 22:41 UTC (permalink / raw)
To: Simon Horman, Julian Anastasov
Cc: Pablo Neira Ayuso, Florian Westphal, Phil Sutter,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Shuah Khan, netdev, lvs-devel, netfilter-devel, Adriano Cordova
IPVS currently exposes secure_tcp as a per-netns sysctl. It switches the
TCP state machine to the hardened tcp_states_dos table.
These patches make it per-service: a virtual service can set
IP_VS_SVC_F_SECURE_TCP which is passed into IP_VS_CONN_F_SECURE_TCP at
connection creation. set_tcp_state() then selects tcp_states_dos for those
connections with IP_VS_CONN_F_SECURE_TCP set and keeps pd->tcp_state_table
(the netns default, including the nomem floor) otherwise.
1. uapi: define the per-service secure_tcp flags
2. stamp the flag in ip_vs_bind_dest() (cache-bypass has no dest)
3. honor it in the TCP state machine, resolving the stale FIXME
4. kselftest contrasting a secure vs. a plain service
Changes in v2:
- Let IP_VS_SVC_F_SECURE_TCP be 0x0100, leaving 0x0040/0x0080 for the
scheduler flags. Let IP_VS_CONN_F_SECURE_TCP be (1 << 17) and no longer
in IP_VS_CONN_F_BACKUP_MASK.
- Set flag in ip_vs_bind_dest() instead of at every ip_vs_conn_new()
call site.
- selftest: send probes with TTL=1 instead of an nft drop, and fix
Sashiko comments.
Not sure about patch 4... could be dropped or absorbed into ipvs.sh
Adriano Cordova (4):
ipvs: add flags for per-service secure TCP state table
ipvs: stamp per-service secure_tcp on connections
ipvs: tcp: enable per-connection secure_tcp in state machine
selftests: netfilter: ipvs: add per-service secure_tcp test
include/uapi/linux/ip_vs.h | 2 +
net/netfilter/ipvs/ip_vs_conn.c | 4 +
net/netfilter/ipvs/ip_vs_core.c | 3 +
net/netfilter/ipvs/ip_vs_proto_tcp.c | 16 +-
.../testing/selftests/net/netfilter/Makefile | 6 +
.../selftests/net/netfilter/gen_tcp_probe.c | 141 ++++++++
.../net/netfilter/ipvs_secure_tcp.sh | 153 +++++++++
.../net/netfilter/ipvs_secure_tcp_mln.c | 323 ++++++++++++++++++
8 files changed, 641 insertions(+), 7 deletions(-)
create mode 100644 tools/testing/selftests/net/netfilter/gen_tcp_probe.c
create mode 100755 tools/testing/selftests/net/netfilter/ipvs_secure_tcp.sh
create mode 100644 tools/testing/selftests/net/netfilter/ipvs_secure_tcp_mln.c
--
2.51.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/4] ipvs: add flags for per-service secure TCP state table
2026-09-15 22:41 [PATCH v2 0/4] ipvs: add per-service secure_tcp Adriano Cordova
@ 2026-09-15 22:41 ` Adriano Cordova
2026-09-15 22:41 ` [PATCH v2 2/4] ipvs: stamp per-service secure_tcp on connections Adriano Cordova
1 sibling, 0 replies; 3+ messages in thread
From: Adriano Cordova @ 2026-09-15 22:41 UTC (permalink / raw)
To: Simon Horman, Julian Anastasov
Cc: Pablo Neira Ayuso, Florian Westphal, Phil Sutter,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Shuah Khan, netdev, lvs-devel, netfilter-devel, Adriano Cordova
Add IP_VS_SVC_F_SECURE_TCP to mark a virtual service for the
DoS-hardened TCP connection state table, and
IP_VS_CONN_F_SECURE_TCP to carry that capability on a connection
so the TCP state machine can select the hardened table for it.
The service flag is 0x0100: bits 0x0008/0x0010/0x0020 are the
scheduler bits, so leave 0x0040/0x0080 free for schedulers.
Signed-off-by: Adriano Cordova <adrianox@gmail.com>
---
Changes in v2:
- Let IP_VS_SVC_F_SECURE_TCP be 0x0100, leaving 0x0040/0x0080 free for
scheduler flags.
- Let IP_VS_CONN_F_SECURE_TCP be (1 << 17) and drop it from
IP_VS_CONN_F_BACKUP_MASK.
include/uapi/linux/ip_vs.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/uapi/linux/ip_vs.h b/include/uapi/linux/ip_vs.h
index 2c37c6ac7525..ade170109ff4 100644
--- a/include/uapi/linux/ip_vs.h
+++ b/include/uapi/linux/ip_vs.h
@@ -27,6 +27,7 @@
#define IP_VS_SVC_F_SCHED_SH_FALLBACK IP_VS_SVC_F_SCHED1 /* SH fallback */
#define IP_VS_SVC_F_SCHED_SH_PORT IP_VS_SVC_F_SCHED2 /* SH use port */
+#define IP_VS_SVC_F_SECURE_TCP 0x0100 /* use the hardened TCP table */
/*
* IPVS sync daemon states
@@ -105,6 +106,7 @@
/* Flags that are not sent to backup server start from bit 16 */
#define IP_VS_CONN_F_NFCT (1 << 16) /* use netfilter conntrack */
+#define IP_VS_CONN_F_SECURE_TCP (1 << 17) /* use the hardened TCP table */
/* Connection flags from destination that can be changed by user space */
#define IP_VS_CONN_F_DEST_MASK (IP_VS_CONN_F_FWD_MASK | \
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/4] ipvs: stamp per-service secure_tcp on connections
2026-09-15 22:41 [PATCH v2 0/4] ipvs: add per-service secure_tcp Adriano Cordova
2026-09-15 22:41 ` [PATCH v2 1/4] ipvs: add flags for per-service secure TCP state table Adriano Cordova
@ 2026-09-15 22:41 ` Adriano Cordova
1 sibling, 0 replies; 3+ messages in thread
From: Adriano Cordova @ 2026-09-15 22:41 UTC (permalink / raw)
To: Simon Horman, Julian Anastasov
Cc: Pablo Neira Ayuso, Florian Westphal, Phil Sutter,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Shuah Khan, netdev, lvs-devel, netfilter-devel, Adriano Cordova
Set IP_VS_CONN_F_SECURE_TCP on every connection bound to a
destination whose service carries IP_VS_SVC_F_SECURE_TCP.
Signed-off-by: Adriano Cordova <adrianox@gmail.com>
---
Changes in v2:
- Set the flag in ip_vs_bind_dest() instead of at every ip_vs_conn_new()
call site.
net/netfilter/ipvs/ip_vs_conn.c | 4 ++++
net/netfilter/ipvs/ip_vs_core.c | 3 +++
2 files changed, 7 insertions(+)
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 6fa3e1dc534c..0b465298b64b 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -1090,6 +1090,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
{
unsigned int conn_flags;
__u32 flags;
+ struct ip_vs_service *svc;
/* if dest is NULL, then return directly */
if (!dest)
@@ -1102,6 +1103,9 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
if (cp->protocol != IPPROTO_UDP)
conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
flags = cp->flags;
+ svc = rcu_dereference(dest->svc);
+ if (svc && (svc->flags & IP_VS_SVC_F_SECURE_TCP))
+ flags |= IP_VS_CONN_F_SECURE_TCP;
/* Bind with the destination and its corresponding transmitter */
if (flags & IP_VS_CONN_F_SYNC) {
/* Synced conns are hashed, so they can not get this flag */
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index ba0957798bad..aa8a3a964ffd 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -784,6 +784,9 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
IP_VS_CONN_F_ONE_PACKET : 0;
union nf_inet_addr daddr = { .all = { 0, 0, 0, 0 } };
+ if (svc->flags & IP_VS_SVC_F_SECURE_TCP)
+ flags |= IP_VS_CONN_F_SECURE_TCP;
+
/* create a new connection entry */
IP_VS_DBG(6, "%s(): create a cache_bypass entry\n", __func__);
{
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-15 22:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-15 22:41 [PATCH v2 0/4] ipvs: add per-service secure_tcp Adriano Cordova
2026-09-15 22:41 ` [PATCH v2 1/4] ipvs: add flags for per-service secure TCP state table Adriano Cordova
2026-09-15 22:41 ` [PATCH v2 2/4] ipvs: stamp per-service secure_tcp on connections Adriano Cordova
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox