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 below: substract
skb->head from tcph.

Signed-off-by: Serhey Popovych <[email protected]>
---
 net/ipv4/netfilter/nf_reject_ipv4.c | 2 +-
 net/ipv6/netfilter/nf_reject_ipv6.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/netfilter/nf_reject_ipv4.c 
b/net/ipv4/netfilter/nf_reject_ipv4.c
index 5cd06ba..6698cb3 100644
--- a/net/ipv4/netfilter/nf_reject_ipv4.c
+++ b/net/ipv4/netfilter/nf_reject_ipv4.c
@@ -75,8 +75,8 @@ void nf_reject_ip_tcphdr_put(struct sk_buff *nskb, const 
struct sk_buff *oldskb,
        struct iphdr *niph = ip_hdr(nskb);
        struct tcphdr *tcph;
 
-       skb_reset_transport_header(nskb);
        tcph = skb_put_zero(nskb, sizeof(struct tcphdr));
+       nskb->transport_header = (unsigned char *)tcph - nskb->head;
        tcph->source    = oth->dest;
        tcph->dest      = oth->source;
        tcph->doff      = sizeof(struct tcphdr) / 4;
diff --git a/net/ipv6/netfilter/nf_reject_ipv6.c 
b/net/ipv6/netfilter/nf_reject_ipv6.c
index 2485840..e9ae4d2 100644
--- a/net/ipv6/netfilter/nf_reject_ipv6.c
+++ b/net/ipv6/netfilter/nf_reject_ipv6.c
@@ -94,8 +94,8 @@ void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb,
        struct tcphdr *tcph;
        int needs_ack;
 
-       skb_reset_transport_header(nskb);
        tcph = skb_put(nskb, sizeof(struct tcphdr));
+       nskb->transport_header = (unsigned char *)tcph - nskb->head;
        /* Truncate to length (no data) */
        tcph->doff = sizeof(struct tcphdr)/4;
        tcph->source = oth->dest;
-- 
1.8.3.1

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

Reply via email to