PERFORCE change 114233 for review

Paolo Pisati piso at FreeBSD.org
Thu Feb 8 11:00:05 UTC 2007


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

Change 114233 by piso at piso_newluxor on 2007/02/08 10:58:34

	o when pulling up an ip hdr, if present, pullup the options too.
	o rewrite some PULLUP macros, using PULLUP_SIZE.

Affected files ...

.. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_local.h#24 edit

Differences ...

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

@@ -181,59 +181,50 @@
 
 #define MYMTOD(p, foo) (p != NULL) ? mtod(p, foo) : NULL
 
+#define PULLUP_SIZE(pip, ptr, s) do {           \
+        *ptr = m_pullup((*ptr), s);             \
+        (pip) = MYMTOD(*ptr, struct ip *);      \
+} while (0)
+
 #define PULLUP_IPHDR(pip, ptr) do {             \
-	*ptr = m_pullup((*ptr), sizeof(struct ip)); \
-        (pip) = MYMTOD(*ptr, struct ip *);           \
+        PULLUP_SIZE(pip, ptr, sizeof(struct ip));       \
+        if (pip != NULL && ((pip->ip_hl << 2) > sizeof(struct ip)))     \
+                PULLUP_SIZE(pip, ptr, (pip->ip_hl << 2));       \
 } while (0)
 
 #define PULLUP_UDPHDR(pip, ptr) do {            \
-	pip = mtod(*ptr, struct ip *);             \
-	*ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct udphdr)); \
-	(pip) = MYMTOD(*ptr, struct ip *);           \
+	pip = mtod(*ptr, struct ip *);          \
+        PULLUP_SIZE(pip, ptr, (pip->ip_hl << 2) + sizeof(struct udphdr)); \
 } while (0)
 
 #define PULLUP_TCPHDR(pip, ptr) do {            \
-	pip = mtod(*ptr, struct ip *);             \
-	*ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct tcphdr)); \
-	(pip) = MYMTOD(*ptr, struct ip *);           \
+	pip = mtod(*ptr, struct ip *);          \
+        PULLUP_SIZE(pip, ptr, (pip->ip_hl << 2) + sizeof(struct tcphdr)); \
 } while (0)
 
 #define PULLUP_ICMPHDR(pip, ptr) do {           \
-	pip = mtod(*ptr, struct ip *);           \
-	*ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct icmp)); \
-	(pip) = MYMTOD(*ptr, struct ip *);           \
+	pip = mtod(*ptr, struct ip *);          \
+        PULLUP_SIZE(pip, ptr, (pip->ip_hl << 2) + sizeof(struct icmp)); \
 } while (0)
 
 #define PULLUP_ICMPIP64(pip, ptr, ic) do {      \
         int s;                                  \
-	pip = mtod(*ptr, struct ip *);             \
-        s = (pip->ip_hl << 2) + sizeof(struct icmp) + \
-            (ic->icmp_ip.ip_hl << 2) - sizeof(struct ip) + 8; \
-	*ptr = m_pullup((*ptr), s);                 \
-	(pip) = MYMTOD(*ptr, struct ip *);           \
+	pip = mtod(*ptr, struct ip *);          \
+        s = (pip->ip_hl << 2) + sizeof(struct icmp) +   \
+            (ic->icmp_ip.ip_hl << 2) - sizeof(struct ip) + 8;   \
+        PULLUP_SIZE(pip, ptr, s);               \
 } while (0)
 
 #define PULLUP_IPTCPHDR(pip, ptr) do {          \
-	*ptr = m_pullup((*ptr), sizeof(struct ip)); \
-        (pip) = MYMTOD(*ptr, struct ip *);           \
-        if (pip != NULL) {                       \
-                *ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct tcphdr)); \
-	        (pip) = MYMTOD(*ptr, struct ip *);           \
-        }                                       \
+        PULLUP_IPHDR(pip, ptr);                 \
+        if (pip != NULL)                        \
+		PULLUP_TCPHDR(pip, ptr);        \
 } while (0)
 
 #define PULLUP_IPUDPHDR(pip, ptr) do {          \
-	*ptr = m_pullup((*ptr), sizeof(struct ip)); \
-        (pip) = MYMTOD(*ptr, struct ip *);           \
-        if (pip != NULL) {                       \
-                *ptr = m_pullup((*ptr), (pip->ip_hl << 2) + sizeof(struct udphdr)); \
-	        (pip) = MYMTOD(*ptr, struct ip *);           \
-        }                                       \
-} while (0)
-
-#define PULLUP_SIZE(pip, ptr, s) do {           \
-        *ptr = m_pullup((*ptr), s);             \
-        (pip) = MYMTOD(*ptr, struct ip *);        \
+        PULLUP_IPHDR(pip, ptr);                 \
+        if (pip != NULL)                        \
+		PULLUP_UDPHDR(pip, ptr);        \
 } while (0)
 
 #else


More information about the p4-projects mailing list