patch-2.0.36 linux/net/ipv4/ip_masq.c

Next file: linux/net/ipv4/ip_masq_quake.c
Previous file: linux/net/ipv4/ip_input.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.35/linux/net/ipv4/ip_masq.c linux/net/ipv4/ip_masq.c
@@ -1515,32 +1515,35 @@
                 else
                 {
 			struct tcphdr *th;
-                        skb->csum = csum_partial((void *)(((struct tcphdr *)portptr) + 1),
+			if(len>=sizeof(struct tcphdr))
+			{
+	                        skb->csum = csum_partial((void *)(((struct tcphdr *)portptr) + 1),
                                                  len - sizeof(struct tcphdr), 0);
-                        tcp_send_check((struct tcphdr *)portptr,iph->saddr,iph->daddr,len,skb);
+                        	tcp_send_check((struct tcphdr *)portptr,iph->saddr,iph->daddr,len,skb);
 
-			/* Check if TCP FIN or RST */
-			th = (struct tcphdr *)portptr;
-			if (th->fin)
-			{
-				ms->flags |= IP_MASQ_F_SAW_FIN_IN;
-			}
-			if (th->rst)
-			{
-				ms->flags |= IP_MASQ_F_SAW_RST;
-			}
+				/* Check if TCP FIN or RST */
+				th = (struct tcphdr *)portptr;
+				if (th->fin)
+				{
+					ms->flags |= IP_MASQ_F_SAW_FIN_IN;
+				}
+				if (th->rst)
+				{
+					ms->flags |= IP_MASQ_F_SAW_RST;
+				}
 			
-			/* Now set the timeouts */
-			if (ms->flags & IP_MASQ_F_SAW_RST)
-			{
-				timeout = 1;
-			}
-			else if ((ms->flags & IP_MASQ_F_SAW_FIN) == IP_MASQ_F_SAW_FIN)
-			{
-				timeout = ip_masq_expire->tcp_fin_timeout;
+				/* Now set the timeouts */
+				if (ms->flags & IP_MASQ_F_SAW_RST)
+				{
+					timeout = 1;
+				}
+				else if ((ms->flags & IP_MASQ_F_SAW_FIN) == IP_MASQ_F_SAW_FIN)
+				{
+					timeout = ip_masq_expire->tcp_fin_timeout;
+				}
+				else timeout = ip_masq_expire->tcp_timeout;
 			}
-			else timeout = ip_masq_expire->tcp_timeout;
-                }
+                }	
 		ip_masq_set_expire(ms, timeout);
                 ip_send_check(iph);
 #ifdef DEBUG_CONFIG_IP_MASQUERADE

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov