diff -Nur linux-2.4.30/include/net/sock.h linux-2.4.30-zph/include/net/sock.h
--- linux-2.4.30/include/net/sock.h	2004-11-17 13:54:22.000000000 +0200
+++ linux-2.4.30-zph/include/net/sock.h	2005-05-25 23:06:14.000000000 +0300
@@ -224,6 +224,8 @@
 	int			mc_index;		/* Multicast device index */
 	__u32			mc_addr;
 	struct ip_mc_socklist	*mc_list;		/* Group array */
+	__u8                    zph_tos; 		/* ZPH patch - hold the received
+							* TOS for initiated TCPv4 connections */
 };
 #endif
 
diff -Nur linux-2.4.30/net/ipv4/ip_sockglue.c linux-2.4.30-zph/net/ipv4/ip_sockglue.c
--- linux-2.4.30/net/ipv4/ip_sockglue.c	2005-01-19 16:10:13.000000000 +0200
+++ linux-2.4.30-zph/net/ipv4/ip_sockglue.c	2005-05-25 23:06:31.000000000 +0300
@@ -1030,6 +1030,12 @@
 				int hlim = sk->protinfo.af_inet.mc_ttl;
 				put_cmsg(&msg, SOL_IP, IP_TTL, sizeof(hlim), &hlim);
 			}
+
+			if (sk->protinfo.af_inet.cmsg_flags&IP_CMSG_TOS) {
+				int hlim = sk->protinfo.af_inet.zph_tos;
+				put_cmsg(&msg, SOL_IP, IP_TOS, sizeof(hlim), &hlim);
+			}
+
 			len -= msg.msg_controllen;
 			return put_user(len, optlen);
 		}
diff -Nur linux-2.4.30/net/ipv4/tcp_input.c linux-2.4.30-zph/net/ipv4/tcp_input.c
--- linux-2.4.30/net/ipv4/tcp_input.c	2005-04-04 04:42:20.000000000 +0300
+++ linux-2.4.30-zph/net/ipv4/tcp_input.c	2005-05-25 23:06:39.000000000 +0300
@@ -4396,6 +4396,11 @@
 		 *    state to ESTABLISHED..."
 		 */
 
+	    	/* ZPH, copy TOS field from the SYNACK packet to zph_tos field
+		 * of the af_inet member of sock structure */
+		
+		sk->protinfo.af_inet.zph_tos = skb->nh.iph->tos; 
+
 		TCP_ECN_rcv_synack(tp, th);
 
 		tp->snd_wl1 = TCP_SKB_CB(skb)->seq;
