提交 ba7808ea 编写于 作者: F Frederik Deweerdt 提交者: David S. Miller

[TCP]: remove tcp header from tcp_v4_check (take #2)

The tcphdr struct passed to tcp_v4_check is not used, the following
patch removes it from the parameter list.

This adds the netfilter modifications missing in the patch I sent
for rc3-mm1.
Signed-off-by: NFrederik Deweerdt <frederik.deweerdt@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 a0d78ebf
...@@ -802,9 +802,8 @@ static inline void tcp_update_wl(struct tcp_sock *tp, u32 ack, u32 seq) ...@@ -802,9 +802,8 @@ static inline void tcp_update_wl(struct tcp_sock *tp, u32 ack, u32 seq)
/* /*
* Calculate(/check) TCP checksum * Calculate(/check) TCP checksum
*/ */
static inline __sum16 tcp_v4_check(struct tcphdr *th, int len, static inline __sum16 tcp_v4_check(int len, __be32 saddr,
__be32 saddr, __be32 daddr, __be32 daddr, __wsum base)
__wsum base)
{ {
return csum_tcpudp_magic(saddr,daddr,len,IPPROTO_TCP,base); return csum_tcpudp_magic(saddr,daddr,len,IPPROTO_TCP,base);
} }
......
...@@ -183,7 +183,7 @@ ip_nat_mangle_tcp_packet(struct sk_buff **pskb, ...@@ -183,7 +183,7 @@ ip_nat_mangle_tcp_packet(struct sk_buff **pskb,
datalen = (*pskb)->len - iph->ihl*4; datalen = (*pskb)->len - iph->ihl*4;
if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) { if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) {
tcph->check = 0; tcph->check = 0;
tcph->check = tcp_v4_check(tcph, datalen, tcph->check = tcp_v4_check(datalen,
iph->saddr, iph->daddr, iph->saddr, iph->daddr,
csum_partial((char *)tcph, csum_partial((char *)tcph,
datalen, 0)); datalen, 0));
......
...@@ -116,7 +116,7 @@ static void send_reset(struct sk_buff *oldskb, int hook) ...@@ -116,7 +116,7 @@ static void send_reset(struct sk_buff *oldskb, int hook)
/* Adjust TCP checksum */ /* Adjust TCP checksum */
tcph->check = 0; tcph->check = 0;
tcph->check = tcp_v4_check(tcph, sizeof(struct tcphdr), tcph->check = tcp_v4_check(sizeof(struct tcphdr),
nskb->nh.iph->saddr, nskb->nh.iph->saddr,
nskb->nh.iph->daddr, nskb->nh.iph->daddr,
csum_partial((char *)tcph, csum_partial((char *)tcph,
......
...@@ -176,7 +176,7 @@ nf_nat_mangle_tcp_packet(struct sk_buff **pskb, ...@@ -176,7 +176,7 @@ nf_nat_mangle_tcp_packet(struct sk_buff **pskb,
datalen = (*pskb)->len - iph->ihl*4; datalen = (*pskb)->len - iph->ihl*4;
if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) { if ((*pskb)->ip_summed != CHECKSUM_PARTIAL) {
tcph->check = 0; tcph->check = 0;
tcph->check = tcp_v4_check(tcph, datalen, tcph->check = tcp_v4_check(datalen,
iph->saddr, iph->daddr, iph->saddr, iph->daddr,
csum_partial((char *)tcph, csum_partial((char *)tcph,
datalen, 0)); datalen, 0));
......
...@@ -502,11 +502,11 @@ void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb) ...@@ -502,11 +502,11 @@ void tcp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb)
struct tcphdr *th = skb->h.th; struct tcphdr *th = skb->h.th;
if (skb->ip_summed == CHECKSUM_PARTIAL) { if (skb->ip_summed == CHECKSUM_PARTIAL) {
th->check = ~tcp_v4_check(th, len, th->check = ~tcp_v4_check(len, inet->saddr,
inet->saddr, inet->daddr, 0); inet->daddr, 0);
skb->csum_offset = offsetof(struct tcphdr, check); skb->csum_offset = offsetof(struct tcphdr, check);
} else { } else {
th->check = tcp_v4_check(th, len, inet->saddr, inet->daddr, th->check = tcp_v4_check(len, inet->saddr, inet->daddr,
csum_partial((char *)th, csum_partial((char *)th,
th->doff << 2, th->doff << 2,
skb->csum)); skb->csum));
...@@ -525,7 +525,7 @@ int tcp_v4_gso_send_check(struct sk_buff *skb) ...@@ -525,7 +525,7 @@ int tcp_v4_gso_send_check(struct sk_buff *skb)
th = skb->h.th; th = skb->h.th;
th->check = 0; th->check = 0;
th->check = ~tcp_v4_check(th, skb->len, iph->saddr, iph->daddr, 0); th->check = ~tcp_v4_check(skb->len, iph->saddr, iph->daddr, 0);
skb->csum_offset = offsetof(struct tcphdr, check); skb->csum_offset = offsetof(struct tcphdr, check);
skb->ip_summed = CHECKSUM_PARTIAL; skb->ip_summed = CHECKSUM_PARTIAL;
return 0; return 0;
...@@ -747,7 +747,7 @@ static int tcp_v4_send_synack(struct sock *sk, struct request_sock *req, ...@@ -747,7 +747,7 @@ static int tcp_v4_send_synack(struct sock *sk, struct request_sock *req,
if (skb) { if (skb) {
struct tcphdr *th = skb->h.th; struct tcphdr *th = skb->h.th;
th->check = tcp_v4_check(th, skb->len, th->check = tcp_v4_check(skb->len,
ireq->loc_addr, ireq->loc_addr,
ireq->rmt_addr, ireq->rmt_addr,
csum_partial((char *)th, skb->len, csum_partial((char *)th, skb->len,
...@@ -1514,7 +1514,7 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb) ...@@ -1514,7 +1514,7 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
static __sum16 tcp_v4_checksum_init(struct sk_buff *skb) static __sum16 tcp_v4_checksum_init(struct sk_buff *skb)
{ {
if (skb->ip_summed == CHECKSUM_COMPLETE) { if (skb->ip_summed == CHECKSUM_COMPLETE) {
if (!tcp_v4_check(skb->h.th, skb->len, skb->nh.iph->saddr, if (!tcp_v4_check(skb->len, skb->nh.iph->saddr,
skb->nh.iph->daddr, skb->csum)) { skb->nh.iph->daddr, skb->csum)) {
skb->ip_summed = CHECKSUM_UNNECESSARY; skb->ip_summed = CHECKSUM_UNNECESSARY;
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册