Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 May 2008 14:48:34 GMT
From:      Paolo Pisati <piso@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 142390 for review
Message-ID:  <200805271448.m4REmY7U093497@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=142390

Change 142390 by piso@piso_ferret on 2008/05/27 14:48:33

	Reenable modules: 
	-push the megapullup hack down one level, around modules call.
	-pass the pkt_t abstraction to modules, this way in kernel land
	 they have access to the mbuf. 
	
	Next step: convert, one by one, all the modules so they can
	natively handle mbufs.

Affected files ...

.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#79 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.c#32 edit
.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.h#27 edit

Differences ...

==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias.c#79 (text+ko) ====

@@ -752,7 +752,10 @@
 		ud->uh_dport = GetOriginalPort(lnk);
 
 		/* Walk out chain. */		
-		error = find_handler(IN, UDP, la, pip, &ad);
+		error = find_handler(IN, UDP, la, ptr, &ad);
+		PULLUP_IPHDR(pip, ptr);
+		PULLUP_UDPHDR(pip, ptr);
+		ud = (struct udphdr *)ip_next(pip);
 
 /* If UDP checksum is not zero, then adjust since destination port */
 /* is being unaliased and destination address is being altered.    */
@@ -815,7 +818,10 @@
 		alias_port = GetAliasPort(lnk);
 
 		/* Walk out chain. */		
-		error = find_handler(OUT, UDP, la, pip, &ad);
+		error = find_handler(OUT, UDP, la, ptr, &ad);
+		PULLUP_IPHDR(pip, ptr);
+		PULLUP_UDPHDR(pip, ptr);
+		ud = (struct udphdr *)ip_next(pip);
 
 /* If UDP checksum is not zero, adjust since source port is */
 /* being aliased and source address is being altered        */
@@ -883,7 +889,10 @@
 		};
 
 		/* Walk out chain. */		
-		error = find_handler(IN, TCP, la, pip, &ad);
+		error = find_handler(IN, TCP, la, ptr, &ad);
+		PULLUP_IPHDR(pip, ptr);
+		PULLUP_TCPHDR(pip, ptr);
+		tc = (struct tcphdr *)ip_next(pip);
 
 		alias_address = GetAliasAddress(lnk);
 		original_address = GetOriginalAddress(lnk);
@@ -909,7 +918,10 @@
 				};
 		
 				/* Walk out chain. */
-				error = find_handler(la, pip, &ad);
+				error = find_handler(la, ptr, &ad);
+				PULLUP_IPHDR(pip, ptr);
+				PULLUP_TCPHDR(pip, ptr);
+				tc = (struct tcphdr *)ip_next(pip);
 				if (error == EHDNOF)
 					printf("Protocol handler not found\n");
 #endif
@@ -1049,7 +1061,10 @@
 		TcpMonitorOut(tc->th_flags, lnk);
 		
 		/* Walk out chain. */		
-		error = find_handler(OUT, TCP, la, pip, &ad);
+		error = find_handler(OUT, TCP, la, ptr, &ad);
+		PULLUP_IPHDR(pip, ptr);
+		PULLUP_TCPHDR(pip, ptr);
+		tc = (struct tcphdr *)ip_next(pip);
 
 /* Adjust TCP checksum since source port is being aliased */
 /* and source address is being altered                    */
@@ -1298,7 +1313,9 @@
 			};
 			
 			/* Walk out chain. */		
-			error = find_handler(IN, IP, la, pip, &ad);
+			error = find_handler(IN, IP, la, ptr, &ad);
+			PULLUP_IPHDR(pip, ptr);
+
 			if (error ==  0)
 				iresult = PKT_ALIAS_OK;
 			else
@@ -1443,7 +1460,8 @@
 				.maxpktsize = 0                  
 			};
 			/* Walk out chain. */		
-			error = find_handler(OUT, IP, la, pip, &ad);
+			error = find_handler(OUT, IP, la, ptr, &ad);
+			PULLUP_IPHDR(pip, ptr);
 			error = 0;
 			if (error == 0)
  				iresult = PKT_ALIAS_OK;

==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.c#32 (text+ko) ====

@@ -30,6 +30,8 @@
 #ifdef _KERNEL
 #include <sys/libkern.h>
 #include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
 #include <sys/lock.h>
 #include <sys/rwlock.h>
 #else
@@ -44,9 +46,11 @@
 #include <netinet/ip.h>
 
 #ifdef _KERNEL
+#include <netinet/libalias/alias.h>
 #include <netinet/libalias/alias_local.h>
 #include <netinet/libalias/alias_mod.h>
 #else
+#include "alias.h"
 #include "alias_local.h"
 #include "alias_mod.h"
 #endif
@@ -218,11 +222,13 @@
 	return (error);
 }
 
+// XXX pullup again after calling this function...
 int
-find_handler(int8_t dir, int8_t proto, struct libalias *la, __unused struct ip *pip, 
+find_handler(int8_t dir, int8_t proto, struct libalias *la, pkt_t pkt, 
     struct alias_data *ad)
 {
 	struct proto_handler *p;
+	struct ip *pip;
 	int error;
 
 	LIBALIAS_RLOCK();
@@ -230,7 +236,17 @@
 	LIST_FOREACH(p, &handler_chain, entries) {
 		if ((p->dir & dir) && (p->proto & proto))
 			if (p->fingerprint(la, ad) == 0) {
-				//error = p->protohandler(la, pip, ad);
+#ifdef _KERNEL
+				*pkt = m_megapullup(*pkt, (*pkt)->m_pkthdr.len);
+				if (*pkt == NULL) {
+					error = EPERM;
+					break;
+				}
+				pip = mtod(*pkt, struct ip *);
+#else
+				pip = (struct ip *)pkt;
+#endif
+				error = p->protohandler(la, pip, ad);
 				break;
 			}
 	}

==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.h#27 (text+ko) ====

@@ -34,6 +34,12 @@
 #ifndef _ALIAS_MOD_H_
 #define _ALIAS_MOD_H_
 
+#ifdef _KERNEL  
+#include <netinet/libalias/alias.h>
+#else
+#include "alias.h"
+#endif
+
 #ifdef _KERNEL
 MALLOC_DECLARE(M_ALIAS);
 
@@ -114,7 +120,7 @@
 int             LibAliasDetachHandlers(struct proto_handler *);
 int             detach_handler(struct proto_handler *);
 int             find_handler(int8_t, int8_t, struct libalias *, 
-			   struct ip *, struct alias_data *);
+    pkt_t, struct alias_data *);
 struct proto_handler *first_handler(void);
 
 /* Functions used with dll module. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805271448.m4REmY7U093497>