Subject: tcpdrop vs ipv6
To: None <tech-net@netbsd.org>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-net
Date: 06/28/2007 14:58:00
This is a multipart MIME message.

--==_Exmh_17736321408880
Content-Type: text/plain; charset=us-ascii


Somehow embarrassing that this doesn't work... how about
the appended patch? Scoped addresses still don't work,
this needs to be fixed in the kernel.

best regards
Matthias



Forschungszentrum Juelich GmbH
52425 Juelich

Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDirig'in Baerbel Brumme-Bothe
Vorstand: Prof. Dr. Achim Bachem (Vorsitzender), Dr. Ulrich Krafft (stellv. 
Vorsitzender)

--==_Exmh_17736321408880
Content-Type: text/plain ; name="drop6.txt"; charset=us-ascii
Content-Description: drop6.txt
Content-Disposition: attachment; filename="drop6.txt"

#
# old_revision [841de7b905d0d47bb9a7a148ff35313f9bee5ad7]
#
# patch "usr.sbin/tcpdrop/tcpdrop.c"
#  from [98e09b8bd1baac1997936d86213bd9aac5cd0fe4]
#    to [b17f572434b557dc58fc016af5a185981bcabeda]
#
============================================================
--- usr.sbin/tcpdrop/tcpdrop.c	98e09b8bd1baac1997936d86213bd9aac5cd0fe4
+++ usr.sbin/tcpdrop/tcpdrop.c	b17f572434b557dc58fc016af5a185981bcabeda
@@ -104,7 +104,9 @@ main(int argc, char **argv)
 int
 main(int argc, char **argv)
 {
-	static const int mib[] = { CTL_NET, PF_INET, IPPROTO_TCP, TCPCTL_DROP };
+	static const int mib4[] = { CTL_NET, PF_INET, IPPROTO_TCP, TCPCTL_DROP };
+	static const int mib6[] = { CTL_NET, PF_INET6, IPPROTO_TCP, TCPCTL_DROP };
+	const int *mib;
 	struct addrinfo *ail, *aif, *laddr, *faddr;
 	struct sockaddr_storage sa[2];
 	struct hpinfo fhp, lhp;
@@ -137,7 +139,14 @@ main(int argc, char **argv)
 			(void)memcpy(&sa[0], aif->ai_addr, aif->ai_addrlen);
 			(void)memcpy(&sa[1], ail->ai_addr, ail->ai_addrlen);
 
-			if (sysctl(mib, sizeof(mib) / sizeof(int), NULL,
+			if (ail->ai_family == AF_INET)
+				mib = mib4;
+			else if (ail->ai_family == AF_INET6)
+				mib = mib6;
+			else
+				continue;
+
+			if (sysctl(mib, sizeof(mib4) / sizeof(int), NULL,
 			    NULL, sa, sizeof(sa)) == -1) {
 				rval = 1;
 				warn("%s:%s, %s:%s", 

--==_Exmh_17736321408880--