Commit 9f7c824a authored by Liping Zhang's avatar Liping Zhang Committed by Pablo Neira Ayuso

netfilter: nf_dup4: remove redundant checksum recalculation

IP header checksum will be recalculated at ip_local_out, so
there's no need to calculated it here, remove it. Also update
code comments to illustrate it, and delete the misleading
comments about checksum recalculation.
Signed-off-by: default avatarLiping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent ceee4091
...@@ -74,21 +74,19 @@ void nf_dup_ipv4(struct net *net, struct sk_buff *skb, unsigned int hooknum, ...@@ -74,21 +74,19 @@ void nf_dup_ipv4(struct net *net, struct sk_buff *skb, unsigned int hooknum,
nf_conntrack_get(skb->nfct); nf_conntrack_get(skb->nfct);
#endif #endif
/* /*
* If we are in PREROUTING/INPUT, the checksum must be recalculated * If we are in PREROUTING/INPUT, decrease the TTL to mitigate potential
* since the length could have changed as a result of defragmentation. * loops between two hosts.
*
* We also decrease the TTL to mitigate potential loops between two
* hosts.
* *
* Set %IP_DF so that the original source is notified of a potentially * Set %IP_DF so that the original source is notified of a potentially
* decreased MTU on the clone route. IPv6 does this too. * decreased MTU on the clone route. IPv6 does this too.
*
* IP header checksum will be recalculated at ip_local_out.
*/ */
iph = ip_hdr(skb); iph = ip_hdr(skb);
iph->frag_off |= htons(IP_DF); iph->frag_off |= htons(IP_DF);
if (hooknum == NF_INET_PRE_ROUTING || if (hooknum == NF_INET_PRE_ROUTING ||
hooknum == NF_INET_LOCAL_IN) hooknum == NF_INET_LOCAL_IN)
--iph->ttl; --iph->ttl;
ip_send_check(iph);
if (nf_dup_ipv4_route(net, skb, gw, oif)) { if (nf_dup_ipv4_route(net, skb, gw, oif)) {
__this_cpu_write(nf_skb_duplicated, true); __this_cpu_write(nf_skb_duplicated, true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment