Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Apr 2009 21:22:29 +0000 (UTC)
From:      Paolo Pisati <piso@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r191123 - user/piso/ipfw/sys/netinet/libalias
Message-ID:  <200904152122.n3FLMTFE055163@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: piso
Date: Wed Apr 15 21:22:29 2009
New Revision: 191123
URL: http://svn.freebsd.org/changeset/base/191123

Log:
  Make AliasHandlePptpGreOut & AliasHandlePptpGreIn mbuf safe.

Modified:
  user/piso/ipfw/sys/netinet/libalias/alias_pptp.c

Modified: user/piso/ipfw/sys/netinet/libalias/alias_pptp.c
==============================================================================
--- user/piso/ipfw/sys/netinet/libalias/alias_pptp.c	Wed Apr 15 20:55:20 2009	(r191122)
+++ user/piso/ipfw/sys/netinet/libalias/alias_pptp.c	Wed Apr 15 21:22:29 2009	(r191123)
@@ -75,10 +75,10 @@ static void
 AliasHandlePptpIn(struct libalias *, struct ip *, struct alias_link *);
 
 static int
-AliasHandlePptpGreOut(struct libalias *, struct ip *);
+AliasHandlePptpGreOut(struct libalias *, pkt_t);
 
 static int
-AliasHandlePptpGreIn(struct libalias *, struct ip *);
+AliasHandlePptpGreIn(struct libalias *, pkt_t);
 
 static int 
 fingerprint(struct libalias *la, struct alias_data *ah)
@@ -132,16 +132,9 @@ protohandlerout(struct libalias *la, pkt
 static int 
 protohandlergrein(struct libalias *la, pkt_t ptr, struct alias_data *ah)
 {
-        struct ip *pip; 
  
-#ifdef _KERNEL
-        if (ptr == NULL)
-                pip = (struct ip *)la->buf;
-        else
-#endif
-        PULLUP_IPHDR(pip, ptr);
 	if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY ||
-	    AliasHandlePptpGreIn(la, pip) == 0)
+	    AliasHandlePptpGreIn(la, ptr) == 0)
 		return (0);
 	return (-1);
 }
@@ -149,15 +142,8 @@ protohandlergrein(struct libalias *la, p
 static int 
 protohandlergreout(struct libalias *la, pkt_t ptr, struct alias_data *ah)
 {
-        struct ip *pip; 
  
-#ifdef _KERNEL
-        if (ptr == NULL)
-                pip = (struct ip *)la->buf;
-        else
-#endif
-        PULLUP_IPHDR(pip, ptr);
-	if (AliasHandlePptpGreOut(la, pip) == 0)
+	if (AliasHandlePptpGreOut(la, ptr) == 0)
 		return (0);
 	return (-1);
 }
@@ -189,7 +175,7 @@ struct proto_handler handlers[] = {
 	  .pri = INT_MAX, 
 	  .dir = IN, 
 	  .proto = IP, 
-	  .legacy = 1,
+	  .legacy = 0,
 	  .fingerprint = &fingerprintgre, 
 	  .protohandler = &protohandlergrein
 	},
@@ -197,7 +183,7 @@ struct proto_handler handlers[] = {
 	  .pri = INT_MAX, 
 	  .dir = OUT, 
 	  .proto = IP, 
-	  .legacy = 1,
+	  .legacy = 0,
 	  .fingerprint = &fingerprintgre, 
 	  .protohandler = &protohandlergreout
 	}, 
@@ -506,11 +492,14 @@ AliasVerifyPptp(struct ip *pip, u_int16_
 }
 
 static int
-AliasHandlePptpGreOut(struct libalias *la, struct ip *pip)
+AliasHandlePptpGreOut(struct libalias *la, pkt_t ptr)
 {
+	struct ip *pip;
 	GreHdr *gr;
 	struct alias_link *lnk;
 
+	PULLUP_IPHDR(pip, ptr);
+	PULLUP_SIZE(pip, ptr, (pip->ip_len << 2) + sizeof(GreHdr));
 	gr = (GreHdr *) ip_next(pip);
 
 	/* Check GRE header bits. */
@@ -530,11 +519,14 @@ AliasHandlePptpGreOut(struct libalias *l
 }
 
 static int
-AliasHandlePptpGreIn(struct libalias *la, struct ip *pip)
+AliasHandlePptpGreIn(struct libalias *la, pkt_t ptr)
 {
+	struct ip *pip;
 	GreHdr *gr;
 	struct alias_link *lnk;
 
+	PULLUP_IPHDR(pip, ptr);
+	PULLUP_SIZE(pip, ptr, (pip->ip_len << 2) + sizeof(GreHdr));
 	gr = (GreHdr *) ip_next(pip);
 
 	/* Check GRE header bits. */



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