PERFORCE change 114085 for review

Paolo Pisati piso at FreeBSD.org
Tue Feb 6 01:21:02 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=114085

Change 114085 by piso at piso_newluxor on 2007/02/06 01:20:42

	Pass down a **mbuf (and thus let libalias modify the actual
	mbuf's content).

Affected files ...

.. //depot/projects/soc2005/libalias/sys/netgraph/ng_nat.c#8 edit
.. //depot/projects/soc2005/libalias/sys/netinet/ip_fw2.c#41 edit

Differences ...

==== //depot/projects/soc2005/libalias/sys/netgraph/ng_nat.c#8 (text+ko) ====

@@ -226,14 +226,14 @@
 	    ("ng_nat: ip_len != m_pkthdr.len"));
 
 	if (hook == priv->in) {
-		rval = LibAliasIn(priv->lib, m, MCLBYTES);
+		rval = LibAliasIn(priv->lib, &m, MCLBYTES);
 		if (rval != PKT_ALIAS_OK &&
 		    rval != PKT_ALIAS_FOUND_HEADER_FRAGMENT) {
 			NG_FREE_ITEM(item);
 			return (EINVAL);
 		}
 	} else if (hook == priv->out) {
-		rval = LibAliasOut(priv->lib, m, MCLBYTES);
+		rval = LibAliasOut(priv->lib, &m, MCLBYTES);
 		if (rval != PKT_ALIAS_OK) {
 			NG_FREE_ITEM(item);
 			return (EINVAL);

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

@@ -3496,8 +3496,11 @@
 						((ipfw_insn_nat *)cmd)->nat = 
 						    t;
 				}
-				if ((m = m_pullup(m, sizeof(struct ip))) == NULL)
+				if ((m = m_pullup(m, sizeof(struct ip))) == 
+				    NULL) {
+					printf("1\n");
 					goto badnat;
+				}
 				ip = mtod(m, struct ip *);
 				if (args->eh == NULL) {
 					ip->ip_len = htons(ip->ip_len);
@@ -3558,21 +3561,30 @@
 					ldt = 1;
 
 				if (oif == NULL)
-					retval = LibAliasIn(t->lib, m, 
+					retval = LibAliasIn(t->lib, &m, 
 					    MCLBYTES);
 				else
-					retval = LibAliasOut(t->lib, m, 
+					retval = LibAliasOut(t->lib, &m, 
 					    MCLBYTES);
 				if (retval != PKT_ALIAS_OK) {
 					/* XXX - should i add some logging? */
 					m_free(m);
 				badnat:
+					printf("badnat ");
+					if (oif == NULL)
+						printf("LibAliasIn()");
+					else
+						printf("LibAliasOut()");
+					printf("\n");
 					args->m = NULL;
 					retval = IP_FW_DENY;
 					goto done;
 				}
-				if ((m = m_pullup(m, sizeof(struct ip))) == NULL)
+				if ((m = m_pullup(m, sizeof(struct ip))) == 
+				    NULL) {
+					printf("2\n");
 					goto badnat;
+				}
 				ip = mtod(m, struct ip *);
 				m->m_pkthdr.len = m->m_len = 
 				    ntohs(ip->ip_len);
@@ -3587,8 +3599,10 @@
 					struct tcphdr 	*th; 
 
 					if ((m = m_pullup(m, (ip->ip_hl << 2) +
-					    sizeof(struct tcphdr))) == NULL)
+					    sizeof(struct tcphdr))) == NULL) {
+						printf("3\n");
 						goto badnat;
+					}
 					ip = mtod(m, struct ip *);
 					th = (struct tcphdr *)(ip + 1);
 					if (th->th_x2)
@@ -3613,8 +3627,10 @@
 						if ((m = m_pullup(m, 
 						    (ip->ip_hl << 2) + 
 						    sizeof(struct tcphdr))) ==
-						    NULL)
+						    NULL) {
+							printf("4\n");
 							goto badnat;
+						}
 						ip = mtod(m, struct ip *);
 						th = (struct tcphdr *)(ip + 1);
 						/* 
@@ -3630,16 +3646,18 @@
 					case IPPROTO_UDP:
 						if ((m = m_pullup(m, 
 						    (ip->ip_hl << 2) + 
-						    sizeof(struct tcphdr))) ==
-						    NULL)
+						    sizeof(struct udphdr))) ==
+						    NULL) {
+							printf("5\n");
 							goto badnat;
+						}
 						ip = mtod(m, struct ip *);
 						uh = (struct udphdr *)(ip + 1);
 						uh->uh_sum = cksum;
 						m->m_pkthdr.csum_data = 
 						    offsetof(struct udphdr,
 						    uh_sum);
-						break;		
+						break;
 					}
 					/* 
 					 * No hw checksum offloading: do it 


More information about the p4-projects mailing list