Skip to contentSkip to conversation

ipvs: drop the packets with port 0

PATCH New Julian Anastasov 1 participant 1 message Nov 12

Subsystems (3)
lore
Share & tools
lore

Julian Anastasov

author maintainer
#0 lore raw

PATCH 1/1 ipvs: drop the packets with port 0

Sashiko warns that ignoring connection with port 0 passes it to the local listener where it can be accepted. Instead of passing it we should drop it but after ensuring it is for IPVS service.

---
 net/netfilter/ipvs/ip_vs_proto_sctp.c | 10 ++++++----
 net/netfilter/ipvs/ip_vs_proto_tcp.c  | 10 ++++++----
 net/netfilter/ipvs/ip_vs_proto_udp.c  | 10 ++++++----
 3 files changed, 18 insertions(+), 12 deletions(-)
net/netfilter/ipvs/ip_vs_proto_sctp.c +6 -4
index 83d1443ebe01..cb34bcceb4f6 100644
@@ -48,10 +48,6 @@ sctp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
 		return 0;
 	}
 
-	/* Do not create connection for port 0, skip the packet */
-	if (!ports[0] || !ports[1])
-		return 1;
-
 	if (likely(!ip_vs_iph_inverse(iph)))
 		svc = ip_vs_service_find(ipvs, af, skb->mark, iph->protocol,
 					 &iph->daddr, ports[1]);
@@ -61,6 +57,12 @@ sctp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
 	if (svc) {
 		int ignored;
 
+		/* Do not create connection for port 0 */
+		if (!ports[0] || !ports[1]) {
+			*verdict = NF_DROP;
+			return 0;
+		}
+
 		if (ip_vs_todrop(ipvs)) {
 			/*
 			 * It seems that we are very loaded.
net/netfilter/ipvs/ip_vs_proto_tcp.c +6 -4
index 2e55b62445c6..25d4576d0e12 100644
@@ -63,10 +63,6 @@ tcp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
 		return 0;
 	}
 
-	/* Do not create connection for port 0, skip the packet */
-	if (!ports[0] || !ports[1])
-		return 1;
-
 	/* No !th->ack check to allow scheduling on SYN+ACK for Active FTP */
 
 	if (likely(!ip_vs_iph_inverse(iph)))
@@ -79,6 +75,12 @@ tcp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
 	if (svc) {
 		int ignored;
 
+		/* Do not create connection for port 0 */
+		if (!ports[0] || !ports[1]) {
+			*verdict = NF_DROP;
+			return 0;
+		}
+
 		if (ip_vs_todrop(ipvs)) {
 			/*
 			 * It seems that we are very loaded.
net/netfilter/ipvs/ip_vs_proto_udp.c +6 -4
index 92c0b76c1a02..ab3ab9524168 100644
@@ -52,10 +52,6 @@ udp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
 		return 0;
 	}
 
-	/* Do not create connection for port 0, skip the packet */
-	if (!ports[0] || !ports[1])
-		return 1;
-
 	if (likely(!ip_vs_iph_inverse(iph)))
 		svc = ip_vs_service_find(ipvs, af, skb->mark, iph->protocol,
 					 &iph->daddr, ports[1]);
@@ -66,6 +62,12 @@ udp_conn_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,
 	if (svc) {
 		int ignored;
 
+		/* Do not create connection for port 0 */
+		if (!ports[0] || !ports[1]) {
+			*verdict = NF_DROP;
+			return 0;
+		}
+
 		if (ip_vs_todrop(ipvs)) {
 			/*
 			 * It seems that we are very loaded.
Signature · 1 line
2.56.0