[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: USAGI IPv6 patches



In article <[🔎] 200103161934.WAA16352@ms2.inr.ac.ru> (at Fri, 16 Mar 2001 22:34:04 +0300 (MSK)), kuznet@ms2.inr.ac.ru says:

> So, you start listening port X on two wildcard tcp sockets. OK.
> What does pervent receiving ipv6 syns on v4 socket and vice versa?
> I see no new code. To me it looks like the second bind overrides
> the first one and the first socket is never used after this.

Hmm, HoraPe's patch is not complete; PCB-matching in BSD term was not updated 
in net/ipv4/udp.c:udp_v4_lookup_longway(), and 
net/ipv4/tcp_ipv4.c:__tcp_v6_lookup_listener() etc like this.

Index: udp.c
===================================================================
RCS file: /cvsroot/usagi/usagi/kernel/linux24/net/ipv4/udp.c,v
retrieving revision 1.1.1.10
retrieving revision 1.25
diff -u -r1.1.1.10 -r1.25
--- udp.c	2001/02/22 12:04:27	1.1.1.10
+++ udp.c	2001/02/22 12:20:27	1.25
@@ -213,31 +268,42 @@
 	struct sock *sk, *result = NULL;
 	unsigned short hnum = ntohs(dport);
 	int badness = -1;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+	static const int maxscore = 9;
+#else
+	static const int maxscore = 8;
+#endif
 
 	for(sk = udp_hash[hnum & (UDP_HTABLE_SIZE - 1)]; sk != NULL; sk = sk->next) {
 		if(sk->num == hnum) {
 			int score = 0;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+			if(sk->family == PF_INET)
+				score++;
+			else if (sk->net_pinfo.af_inet6.ipv6only)
+				continue;
+#endif
 			if(sk->rcv_saddr) {
 				if(sk->rcv_saddr != daddr)
 					continue;
-				score++;
+				score+=2;
 			}
 			if(sk->daddr) {
 				if(sk->daddr != saddr)
 					continue;
-				score++;
+				score+=2;
 			}
 			if(sk->dport) {
 				if(sk->dport != sport)
 					continue;
-				score++;
+				score+=2;
 			}
 			if(sk->bound_dev_if) {
 				if(sk->bound_dev_if != dif)
 					continue;
-				score++;
+				score+=2;
 			}
-			if(score == 4) {
+			if(score == maxscore) {
 				result = sk;
 				break;
 			} else if(score > badness) {

-- 
Hideaki YOSHIFUJI @ USAGI Project  <yoshfuji@linux-ipv6.org>
PGP5i FP: F731 6599 5EB2 BBA7 1515  1323 1806 A96F 5700 6B25 



Reply to: