[PATCH nf-next 1/2] netfilter: SYNPROXY: set transport header properly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We can't use skb_reset_transport_header() together with skb_put() to set
skb->transport_header field because skb_put() does not touch skb->data.

Do this same way as we did for csum_data in code: substract skb->head
from tcph.

Signed-off-by: Serhey Popovych <serhe.popovych@xxxxxxxxx>
---
 net/ipv4/netfilter/ipt_SYNPROXY.c  | 8 ++++----
 net/ipv6/netfilter/ip6t_SYNPROXY.c | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/net/ipv4/netfilter/ipt_SYNPROXY.c b/net/ipv4/netfilter/ipt_SYNPROXY.c
index f75fc6b..4953390 100644
--- a/net/ipv4/netfilter/ipt_SYNPROXY.c
+++ b/net/ipv4/netfilter/ipt_SYNPROXY.c
@@ -90,8 +90,8 @@
 
 	niph = synproxy_build_ip(net, nskb, iph->daddr, iph->saddr);
 
-	skb_reset_transport_header(nskb);
 	nth = skb_put(nskb, tcp_hdr_size);
+	nskb->transport_header = (unsigned char *)nth - nskb->head;
 	nth->source	= th->dest;
 	nth->dest	= th->source;
 	nth->seq	= htonl(__cookie_v4_init_sequence(iph, th, &mss));
@@ -132,8 +132,8 @@
 
 	niph = synproxy_build_ip(net, nskb, iph->saddr, iph->daddr);
 
-	skb_reset_transport_header(nskb);
 	nth = skb_put(nskb, tcp_hdr_size);
+	nskb->transport_header = (unsigned char *)nth - nskb->head;
 	nth->source	= th->source;
 	nth->dest	= th->dest;
 	nth->seq	= htonl(recv_seq - 1);
@@ -177,8 +177,8 @@
 
 	niph = synproxy_build_ip(net, nskb, iph->daddr, iph->saddr);
 
-	skb_reset_transport_header(nskb);
 	nth = skb_put(nskb, tcp_hdr_size);
+	nskb->transport_header = (unsigned char *)nth - nskb->head;
 	nth->source	= th->dest;
 	nth->dest	= th->source;
 	nth->seq	= htonl(ntohl(th->ack_seq));
@@ -215,8 +215,8 @@
 
 	niph = synproxy_build_ip(net, nskb, iph->saddr, iph->daddr);
 
-	skb_reset_transport_header(nskb);
 	nth = skb_put(nskb, tcp_hdr_size);
+	nskb->transport_header = (unsigned char *)nth - nskb->head;
 	nth->source	= th->source;
 	nth->dest	= th->dest;
 	nth->seq	= htonl(ntohl(th->seq) + 1);
diff --git a/net/ipv6/netfilter/ip6t_SYNPROXY.c b/net/ipv6/netfilter/ip6t_SYNPROXY.c
index 437af8c..46c1e28 100644
--- a/net/ipv6/netfilter/ip6t_SYNPROXY.c
+++ b/net/ipv6/netfilter/ip6t_SYNPROXY.c
@@ -104,8 +104,8 @@
 
 	niph = synproxy_build_ip(net, nskb, &iph->daddr, &iph->saddr);
 
-	skb_reset_transport_header(nskb);
 	nth = skb_put(nskb, tcp_hdr_size);
+	nskb->transport_header = (unsigned char *)nth - nskb->head;
 	nth->source	= th->dest;
 	nth->dest	= th->source;
 	nth->seq	= htonl(__cookie_v6_init_sequence(iph, th, &mss));
@@ -146,8 +146,8 @@
 
 	niph = synproxy_build_ip(net, nskb, &iph->saddr, &iph->daddr);
 
-	skb_reset_transport_header(nskb);
 	nth = skb_put(nskb, tcp_hdr_size);
+	nskb->transport_header = (unsigned char *)nth - nskb->head;
 	nth->source	= th->source;
 	nth->dest	= th->dest;
 	nth->seq	= htonl(recv_seq - 1);
@@ -191,8 +191,8 @@
 
 	niph = synproxy_build_ip(net, nskb, &iph->daddr, &iph->saddr);
 
-	skb_reset_transport_header(nskb);
 	nth = skb_put(nskb, tcp_hdr_size);
+	nskb->transport_header = (unsigned char *)nth - nskb->head;
 	nth->source	= th->dest;
 	nth->dest	= th->source;
 	nth->seq	= htonl(ntohl(th->ack_seq));
@@ -229,8 +229,8 @@
 
 	niph = synproxy_build_ip(net, nskb, &iph->saddr, &iph->daddr);
 
-	skb_reset_transport_header(nskb);
 	nth = skb_put(nskb, tcp_hdr_size);
+	nskb->transport_header = (unsigned char *)nth - nskb->head;
 	nth->source	= th->source;
 	nth->dest	= th->dest;
 	nth->seq	= htonl(ntohl(th->seq) + 1);
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux