| Message ID | 20260920054708.988867-2-adrianox@gmail.com |
|---|---|
| State | Changes Requested |
| Headers | show |
| Series | ipvs: add per-service secure_tcp | expand |
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] Reported for policy completeness only; my verification concludes this is NOT a defect in the series. Pre-existing issues: - [Low] Reported for policy completeness only; verified as a pre-existing cosmetic discrepancy with no functional effect. -- ipvs: add flags for per-service secure TCP state table This adds the uAPI bits IP_VS_SVC_F_SECURE_TCP (0x0100) and IP_VS_CONN_F_SECURE_TCP (1 << 17), and stamps the connection flag in ip_vs_bind_dest() for connections bound to a destination whose service carries the service flag, plus in the cache_bypass path of ip_vs_leave(). A couple of small observations on the new header bits below. > 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 */ [Severity: Low] Both new bits are documented as "use the hardened TCP table", but nothing in this commit reads either of them, so in this tree state the bits are accepted from user space and stamped onto connections without changing behaviour. Checking the rest of the series, the consumer does arrive in the following patch, "ipvs: tcp: enable per-connection secure_tcp in state machine", which changes set_tcp_state() in net/netfilter/ipvs/ip_vs_proto_tcp.c to: table = pd->tcp_state_table; if (cp->flags & IP_VS_CONN_F_SECURE_TCP) table = tcp_states_dos; new_state = table[state_off + state_idx].next_state[cp->state]; So by the end of the series the header comment matches the implementation and this looks like a plain producer/consumer split rather than a defect. Noting it only in case the intermediate state matters for bisect, since the bit is settable by CAP_NET_ADMIN through ip_vs_ctl.c before it has any effect. > > /* > * 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 */ [Severity: Low] This isn't an issue introduced by this patch, but the new bit lands under the comment saying these flags are not sent to the backup server, while the v1 serializer actually puts the whole flags word on the wire. net/netfilter/ipvs/ip_vs_sync.c:ip_vs_sync_conn() s->v4.flags = htonl(cp->flags & ~IP_VS_CONN_F_HASHED); So a connection carrying IP_VS_CONN_F_SECURE_TCP does transmit bit 17. The receiving side drops it again in ip_vs_process_message_v1(): flags = ntohl(s->v4.flags) & IP_VS_CONN_F_BACKUP_MASK; and IP_VS_CONN_F_BACKUP_MASK only contains FWD_MASK, NOOUTPUT, INACTIVE, SEQ_MASK, NO_CPORT and TEMPLATE, so no high bit survives on the backup. IP_VS_CONN_F_NFCT at bit 16 is already transmitted the same way, so the mismatch between the comment and the wire format predates this change; this just adds one more flag to it. Would it be worth adjusting the comment to say the backup masks these bits off on receive rather than that they are not sent? > > /* Connection flags from destination that can be changed by user space */ > #define IP_VS_CONN_F_DEST_MASK (IP_VS_CONN_F_FWD_MASK | \ [ ... ]
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 | \ 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__); {
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. 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: - 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. - Set the flag in ip_vs_bind_dest() instead of at every ip_vs_conn_new() call site. Changes in v3: - Merge the uapi flag definition and the ip_vs_bind_dest() stamping into a single patch. (no changes since v3) include/uapi/linux/ip_vs.h | 2 ++ net/netfilter/ipvs/ip_vs_conn.c | 4 ++++ net/netfilter/ipvs/ip_vs_core.c | 3 +++ 3 files changed, 9 insertions(+)