Commit be0ea7d5 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[NETFILTER]: Convert old checksum helper names

Kill the defines again, convert to the new checksum helper names and
remove the dependency of NET_ACT_NAT on NETFILTER.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a99a00cf
...@@ -298,11 +298,6 @@ extern void nf_invalidate_cache(int pf); ...@@ -298,11 +298,6 @@ extern void nf_invalidate_cache(int pf);
Returns true or false. */ Returns true or false. */
extern int skb_make_writable(struct sk_buff *skb, unsigned int writable_len); extern int skb_make_writable(struct sk_buff *skb, unsigned int writable_len);
#define nf_csum_replace4 csum_replace4
#define nf_csum_replace2 csum_replace2
#define nf_proto_csum_replace4 inet_proto_csum_replace4
#define nf_proto_csum_replace2 inet_proto_csum_replace2
struct nf_afinfo { struct nf_afinfo {
unsigned short family; unsigned short family;
__sum16 (*checksum)(struct sk_buff *skb, unsigned int hook, __sum16 (*checksum)(struct sk_buff *skb, unsigned int hook,
......
...@@ -38,7 +38,7 @@ set_ect_ip(struct sk_buff *skb, const struct ipt_ECN_info *einfo) ...@@ -38,7 +38,7 @@ set_ect_ip(struct sk_buff *skb, const struct ipt_ECN_info *einfo)
oldtos = iph->tos; oldtos = iph->tos;
iph->tos &= ~IPT_ECN_IP_MASK; iph->tos &= ~IPT_ECN_IP_MASK;
iph->tos |= (einfo->ip_ect & IPT_ECN_IP_MASK); iph->tos |= (einfo->ip_ect & IPT_ECN_IP_MASK);
nf_csum_replace2(&iph->check, htons(oldtos), htons(iph->tos)); csum_replace2(&iph->check, htons(oldtos), htons(iph->tos));
} }
return true; return true;
} }
...@@ -71,7 +71,7 @@ set_ect_tcp(struct sk_buff *skb, const struct ipt_ECN_info *einfo) ...@@ -71,7 +71,7 @@ set_ect_tcp(struct sk_buff *skb, const struct ipt_ECN_info *einfo)
if (einfo->operation & IPT_ECN_OP_SET_CWR) if (einfo->operation & IPT_ECN_OP_SET_CWR)
tcph->cwr = einfo->proto.tcp.cwr; tcph->cwr = einfo->proto.tcp.cwr;
nf_proto_csum_replace2(&tcph->check, skb, inet_proto_csum_replace2(&tcph->check, skb,
oldval, ((__be16 *)tcph)[6], 0); oldval, ((__be16 *)tcph)[6], 0);
return true; return true;
} }
......
...@@ -38,7 +38,7 @@ target(struct sk_buff *skb, ...@@ -38,7 +38,7 @@ target(struct sk_buff *skb,
iph = ip_hdr(skb); iph = ip_hdr(skb);
oldtos = iph->tos; oldtos = iph->tos;
iph->tos = (iph->tos & IPTOS_PREC_MASK) | tosinfo->tos; iph->tos = (iph->tos & IPTOS_PREC_MASK) | tosinfo->tos;
nf_csum_replace2(&iph->check, htons(oldtos), htons(iph->tos)); csum_replace2(&iph->check, htons(oldtos), htons(iph->tos));
} }
return XT_CONTINUE; return XT_CONTINUE;
} }
......
...@@ -54,7 +54,7 @@ ipt_ttl_target(struct sk_buff *skb, ...@@ -54,7 +54,7 @@ ipt_ttl_target(struct sk_buff *skb,
} }
if (new_ttl != iph->ttl) { if (new_ttl != iph->ttl) {
nf_csum_replace2(&iph->check, htons(iph->ttl << 8), csum_replace2(&iph->check, htons(iph->ttl << 8),
htons(new_ttl << 8)); htons(new_ttl << 8));
iph->ttl = new_ttl; iph->ttl = new_ttl;
} }
......
...@@ -372,10 +372,10 @@ manip_pkt(u_int16_t proto, ...@@ -372,10 +372,10 @@ manip_pkt(u_int16_t proto,
iph = (void *)skb->data + iphdroff; iph = (void *)skb->data + iphdroff;
if (maniptype == IP_NAT_MANIP_SRC) { if (maniptype == IP_NAT_MANIP_SRC) {
nf_csum_replace4(&iph->check, iph->saddr, target->src.u3.ip); csum_replace4(&iph->check, iph->saddr, target->src.u3.ip);
iph->saddr = target->src.u3.ip; iph->saddr = target->src.u3.ip;
} else { } else {
nf_csum_replace4(&iph->check, iph->daddr, target->dst.u3.ip); csum_replace4(&iph->check, iph->daddr, target->dst.u3.ip);
iph->daddr = target->dst.u3.ip; iph->daddr = target->dst.u3.ip;
} }
return 1; return 1;
......
...@@ -180,7 +180,7 @@ nf_nat_mangle_tcp_packet(struct sk_buff *skb, ...@@ -180,7 +180,7 @@ nf_nat_mangle_tcp_packet(struct sk_buff *skb,
datalen, 0)); datalen, 0));
} }
} else } else
nf_proto_csum_replace2(&tcph->check, skb, inet_proto_csum_replace2(&tcph->check, skb,
htons(oldlen), htons(datalen), 1); htons(oldlen), htons(datalen), 1);
if (rep_len != match_len) { if (rep_len != match_len) {
...@@ -270,7 +270,7 @@ nf_nat_mangle_udp_packet(struct sk_buff *skb, ...@@ -270,7 +270,7 @@ nf_nat_mangle_udp_packet(struct sk_buff *skb,
udph->check = CSUM_MANGLED_0; udph->check = CSUM_MANGLED_0;
} }
} else } else
nf_proto_csum_replace2(&udph->check, skb, inet_proto_csum_replace2(&udph->check, skb,
htons(oldlen), htons(datalen), 1); htons(oldlen), htons(datalen), 1);
return 1; return 1;
...@@ -310,9 +310,9 @@ sack_adjust(struct sk_buff *skb, ...@@ -310,9 +310,9 @@ sack_adjust(struct sk_buff *skb,
ntohl(sack->start_seq), new_start_seq, ntohl(sack->start_seq), new_start_seq,
ntohl(sack->end_seq), new_end_seq); ntohl(sack->end_seq), new_end_seq);
nf_proto_csum_replace4(&tcph->check, skb, inet_proto_csum_replace4(&tcph->check, skb,
sack->start_seq, new_start_seq, 0); sack->start_seq, new_start_seq, 0);
nf_proto_csum_replace4(&tcph->check, skb, inet_proto_csum_replace4(&tcph->check, skb,
sack->end_seq, new_end_seq, 0); sack->end_seq, new_end_seq, 0);
sack->start_seq = new_start_seq; sack->start_seq = new_start_seq;
sack->end_seq = new_end_seq; sack->end_seq = new_end_seq;
...@@ -397,8 +397,8 @@ nf_nat_seq_adjust(struct sk_buff *skb, ...@@ -397,8 +397,8 @@ nf_nat_seq_adjust(struct sk_buff *skb,
else else
newack = htonl(ntohl(tcph->ack_seq) - other_way->offset_before); newack = htonl(ntohl(tcph->ack_seq) - other_way->offset_before);
nf_proto_csum_replace4(&tcph->check, skb, tcph->seq, newseq, 0); inet_proto_csum_replace4(&tcph->check, skb, tcph->seq, newseq, 0);
nf_proto_csum_replace4(&tcph->check, skb, tcph->ack_seq, newack, 0); inet_proto_csum_replace4(&tcph->check, skb, tcph->ack_seq, newack, 0);
pr_debug("Adjusting sequence number from %u->%u, ack from %u->%u\n", pr_debug("Adjusting sequence number from %u->%u, ack from %u->%u\n",
ntohl(tcph->seq), ntohl(newseq), ntohl(tcph->ack_seq), ntohl(tcph->seq), ntohl(newseq), ntohl(tcph->ack_seq),
......
...@@ -65,7 +65,7 @@ icmp_manip_pkt(struct sk_buff *skb, ...@@ -65,7 +65,7 @@ icmp_manip_pkt(struct sk_buff *skb,
return 0; return 0;
hdr = (struct icmphdr *)(skb->data + hdroff); hdr = (struct icmphdr *)(skb->data + hdroff);
nf_proto_csum_replace2(&hdr->checksum, skb, inet_proto_csum_replace2(&hdr->checksum, skb,
hdr->un.echo.id, tuple->src.u.icmp.id, 0); hdr->un.echo.id, tuple->src.u.icmp.id, 0);
hdr->un.echo.id = tuple->src.u.icmp.id; hdr->un.echo.id = tuple->src.u.icmp.id;
return 1; return 1;
......
...@@ -132,8 +132,8 @@ tcp_manip_pkt(struct sk_buff *skb, ...@@ -132,8 +132,8 @@ tcp_manip_pkt(struct sk_buff *skb,
if (hdrsize < sizeof(*hdr)) if (hdrsize < sizeof(*hdr))
return 1; return 1;
nf_proto_csum_replace4(&hdr->check, skb, oldip, newip, 1); inet_proto_csum_replace4(&hdr->check, skb, oldip, newip, 1);
nf_proto_csum_replace2(&hdr->check, skb, oldport, newport, 0); inet_proto_csum_replace2(&hdr->check, skb, oldport, newport, 0);
return 1; return 1;
} }
......
...@@ -117,8 +117,8 @@ udp_manip_pkt(struct sk_buff *skb, ...@@ -117,8 +117,8 @@ udp_manip_pkt(struct sk_buff *skb,
portptr = &hdr->dest; portptr = &hdr->dest;
} }
if (hdr->check || skb->ip_summed == CHECKSUM_PARTIAL) { if (hdr->check || skb->ip_summed == CHECKSUM_PARTIAL) {
nf_proto_csum_replace4(&hdr->check, skb, oldip, newip, 1); inet_proto_csum_replace4(&hdr->check, skb, oldip, newip, 1);
nf_proto_csum_replace2(&hdr->check, skb, *portptr, newport, inet_proto_csum_replace2(&hdr->check, skb, *portptr, newport,
0); 0);
if (!hdr->check) if (!hdr->check)
hdr->check = CSUM_MANGLED_0; hdr->check = CSUM_MANGLED_0;
......
...@@ -95,8 +95,9 @@ tcpmss_mangle_packet(struct sk_buff *skb, ...@@ -95,8 +95,9 @@ tcpmss_mangle_packet(struct sk_buff *skb,
opt[i+2] = (newmss & 0xff00) >> 8; opt[i+2] = (newmss & 0xff00) >> 8;
opt[i+3] = newmss & 0x00ff; opt[i+3] = newmss & 0x00ff;
nf_proto_csum_replace2(&tcph->check, skb, inet_proto_csum_replace2(&tcph->check, skb,
htons(oldmss), htons(newmss), 0); htons(oldmss), htons(newmss),
0);
return 0; return 0;
} }
} }
...@@ -117,18 +118,18 @@ tcpmss_mangle_packet(struct sk_buff *skb, ...@@ -117,18 +118,18 @@ tcpmss_mangle_packet(struct sk_buff *skb,
opt = (u_int8_t *)tcph + sizeof(struct tcphdr); opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr)); memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
nf_proto_csum_replace2(&tcph->check, skb, inet_proto_csum_replace2(&tcph->check, skb,
htons(tcplen), htons(tcplen + TCPOLEN_MSS), 1); htons(tcplen), htons(tcplen + TCPOLEN_MSS), 1);
opt[0] = TCPOPT_MSS; opt[0] = TCPOPT_MSS;
opt[1] = TCPOLEN_MSS; opt[1] = TCPOLEN_MSS;
opt[2] = (newmss & 0xff00) >> 8; opt[2] = (newmss & 0xff00) >> 8;
opt[3] = newmss & 0x00ff; opt[3] = newmss & 0x00ff;
nf_proto_csum_replace4(&tcph->check, skb, 0, *((__be32 *)opt), 0); inet_proto_csum_replace4(&tcph->check, skb, 0, *((__be32 *)opt), 0);
oldval = ((__be16 *)tcph)[6]; oldval = ((__be16 *)tcph)[6];
tcph->doff += TCPOLEN_MSS/4; tcph->doff += TCPOLEN_MSS/4;
nf_proto_csum_replace2(&tcph->check, skb, inet_proto_csum_replace2(&tcph->check, skb,
oldval, ((__be16 *)tcph)[6], 0); oldval, ((__be16 *)tcph)[6], 0);
return TCPOLEN_MSS; return TCPOLEN_MSS;
} }
...@@ -152,7 +153,7 @@ xt_tcpmss_target4(struct sk_buff *skb, ...@@ -152,7 +153,7 @@ xt_tcpmss_target4(struct sk_buff *skb,
if (ret > 0) { if (ret > 0) {
iph = ip_hdr(skb); iph = ip_hdr(skb);
newlen = htons(ntohs(iph->tot_len) + ret); newlen = htons(ntohs(iph->tot_len) + ret);
nf_csum_replace2(&iph->check, iph->tot_len, newlen); csum_replace2(&iph->check, iph->tot_len, newlen);
iph->tot_len = newlen; iph->tot_len = newlen;
} }
return XT_CONTINUE; return XT_CONTINUE;
......
...@@ -445,7 +445,6 @@ config NET_ACT_IPT ...@@ -445,7 +445,6 @@ config NET_ACT_IPT
config NET_ACT_NAT config NET_ACT_NAT
tristate "Stateless NAT" tristate "Stateless NAT"
depends on NET_CLS_ACT depends on NET_CLS_ACT
select NETFILTER
---help--- ---help---
Say Y here to do stateless NAT on IPv4 packets. You should use Say Y here to do stateless NAT on IPv4 packets. You should use
netfilter for NAT unless you know what you are doing. netfilter for NAT unless you know what you are doing.
......
...@@ -151,7 +151,7 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a, ...@@ -151,7 +151,7 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a,
else else
iph->daddr = new_addr; iph->daddr = new_addr;
nf_csum_replace4(&iph->check, addr, new_addr); csum_replace4(&iph->check, addr, new_addr);
} }
ihl = iph->ihl * 4; ihl = iph->ihl * 4;
...@@ -169,7 +169,7 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a, ...@@ -169,7 +169,7 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a,
goto drop; goto drop;
tcph = (void *)(skb_network_header(skb) + ihl); tcph = (void *)(skb_network_header(skb) + ihl);
nf_proto_csum_replace4(&tcph->check, skb, addr, new_addr, 1); inet_proto_csum_replace4(&tcph->check, skb, addr, new_addr, 1);
break; break;
} }
case IPPROTO_UDP: case IPPROTO_UDP:
...@@ -184,7 +184,7 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a, ...@@ -184,7 +184,7 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a,
udph = (void *)(skb_network_header(skb) + ihl); udph = (void *)(skb_network_header(skb) + ihl);
if (udph->check || skb->ip_summed == CHECKSUM_PARTIAL) { if (udph->check || skb->ip_summed == CHECKSUM_PARTIAL) {
nf_proto_csum_replace4(&udph->check, skb, addr, inet_proto_csum_replace4(&udph->check, skb, addr,
new_addr, 1); new_addr, 1);
if (!udph->check) if (!udph->check)
udph->check = CSUM_MANGLED_0; udph->check = CSUM_MANGLED_0;
...@@ -232,7 +232,7 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a, ...@@ -232,7 +232,7 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a,
else else
iph->saddr = new_addr; iph->saddr = new_addr;
nf_proto_csum_replace4(&icmph->checksum, skb, addr, new_addr, inet_proto_csum_replace4(&icmph->checksum, skb, addr, new_addr,
1); 1);
break; break;
} }
......
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