net: Change pseudohdr argument of inet_proto_csum_replace* to be a bool
authorTom Herbert <tom@herbertland.com>
Mon, 17 Aug 2015 20:42:25 +0000 (13:42 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 18 Aug 2015 04:33:06 +0000 (21:33 -0700)
inet_proto_csum_replace4,2,16 take a pseudohdr argument which indicates
the checksum field carries a pseudo header. This argument should be a
boolean instead of an int.

Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
18 files changed:
include/net/checksum.h
net/core/filter.c
net/core/utils.c
net/ipv4/netfilter/ipt_ECN.c
net/ipv4/netfilter/nf_nat_l3proto_ipv4.c
net/ipv4/netfilter/nf_nat_proto_icmp.c
net/ipv6/netfilter/nf_nat_l3proto_ipv6.c
net/ipv6/netfilter/nf_nat_proto_icmpv6.c
net/netfilter/nf_conntrack_seqadj.c
net/netfilter/nf_nat_proto_dccp.c
net/netfilter/nf_nat_proto_tcp.c
net/netfilter/nf_nat_proto_udp.c
net/netfilter/nf_nat_proto_udplite.c
net/netfilter/nf_synproxy_core.c
net/netfilter/xt_TCPMSS.c
net/netfilter/xt_TCPOPTSTRIP.c
net/openvswitch/actions.c
net/sched/act_nat.c

index 2d1d73cb773e9bd160f5c43bb58981ee8597b87c..619f3445d57e73dc5601974b1185084b3d5f742a 100644 (file)
@@ -140,14 +140,14 @@ static inline void csum_replace2(__sum16 *sum, __be16 old, __be16 new)
 
 struct sk_buff;
 void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb,
-                             __be32 from, __be32 to, int pseudohdr);
+                             __be32 from, __be32 to, bool pseudohdr);
 void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb,
                               const __be32 *from, const __be32 *to,
-                              int pseudohdr);
+                              bool pseudohdr);
 
 static inline void inet_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb,
                                            __be16 from, __be16 to,
-                                           int pseudohdr)
+                                           bool pseudohdr)
 {
        inet_proto_csum_replace4(sum, skb, (__force __be32)from,
                                 (__force __be32)to, pseudohdr);
index f8184222465e3cab32375d79cc684a6129d8521d..83f08cefeab7d8ac2e86e990a0a089af2f490ec0 100644 (file)
@@ -1349,7 +1349,7 @@ const struct bpf_func_proto bpf_l3_csum_replace_proto = {
 static u64 bpf_l4_csum_replace(u64 r1, u64 r2, u64 from, u64 to, u64 flags)
 {
        struct sk_buff *skb = (struct sk_buff *) (long) r1;
-       u32 is_pseudo = BPF_IS_PSEUDO_HEADER(flags);
+       bool is_pseudo = !!BPF_IS_PSEUDO_HEADER(flags);
        int offset = (int) r2;
        __sum16 sum, *ptr;
 
index a7732a06804376aa321c9982faaf981ad3c51c87..cd7d202f340efe0a0cb92b65062e45d88a5cc05b 100644 (file)
@@ -301,7 +301,7 @@ out:
 EXPORT_SYMBOL(in6_pton);
 
 void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb,
-                             __be32 from, __be32 to, int pseudohdr)
+                             __be32 from, __be32 to, bool pseudohdr)
 {
        if (skb->ip_summed != CHECKSUM_PARTIAL) {
                csum_replace4(sum, from, to);
@@ -318,7 +318,7 @@ EXPORT_SYMBOL(inet_proto_csum_replace4);
 
 void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb,
                               const __be32 *from, const __be32 *to,
-                              int pseudohdr)
+                              bool pseudohdr)
 {
        __be32 diff[] = {
                ~from[0], ~from[1], ~from[2], ~from[3],
index 4bf3dc49ad1ea84d59815cb9a46aa3cd3fd374b5..270765236f5e8cc9e39c02f9b6fa0836f853f96d 100644 (file)
@@ -72,7 +72,7 @@ set_ect_tcp(struct sk_buff *skb, const struct ipt_ECN_info *einfo)
                tcph->cwr = einfo->proto.tcp.cwr;
 
        inet_proto_csum_replace2(&tcph->check, skb,
-                                oldval, ((__be16 *)tcph)[6], 0);
+                                oldval, ((__be16 *)tcph)[6], false);
        return true;
 }
 
index e59cc05c09e96c8f6996e5e0063c4d138d0dee11..22f4579b0c2aeba3ad637e4cff756042e86e4244 100644 (file)
@@ -120,7 +120,7 @@ static void nf_nat_ipv4_csum_update(struct sk_buff *skb,
                oldip = iph->daddr;
                newip = t->dst.u3.ip;
        }
-       inet_proto_csum_replace4(check, skb, oldip, newip, 1);
+       inet_proto_csum_replace4(check, skb, oldip, newip, true);
 }
 
 static void nf_nat_ipv4_csum_recalc(struct sk_buff *skb,
@@ -151,7 +151,7 @@ static void nf_nat_ipv4_csum_recalc(struct sk_buff *skb,
                }
        } else
                inet_proto_csum_replace2(check, skb,
-                                        htons(oldlen), htons(datalen), 1);
+                                        htons(oldlen), htons(datalen), true);
 }
 
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK)
index 4557b4ab8342740696b5fa4d3de8c6218ed70186..7b98baa13edeb1e9b944df54cffaa9ba669cef77 100644 (file)
@@ -67,7 +67,7 @@ icmp_manip_pkt(struct sk_buff *skb,
 
        hdr = (struct icmphdr *)(skb->data + hdroff);
        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, false);
        hdr->un.echo.id = tuple->src.u.icmp.id;
        return true;
 }
index e76900e0aa925a26c226f733f9a44e396ea7cc7f..70fbaed49edbc5511d9327be5c9c0e003dc12e7d 100644 (file)
@@ -124,7 +124,7 @@ static void nf_nat_ipv6_csum_update(struct sk_buff *skb,
                newip = &t->dst.u3.in6;
        }
        inet_proto_csum_replace16(check, skb, oldip->s6_addr32,
-                                 newip->s6_addr32, 1);
+                                 newip->s6_addr32, true);
 }
 
 static void nf_nat_ipv6_csum_recalc(struct sk_buff *skb,
@@ -155,7 +155,7 @@ static void nf_nat_ipv6_csum_recalc(struct sk_buff *skb,
                }
        } else
                inet_proto_csum_replace2(check, skb,
-                                        htons(oldlen), htons(datalen), 1);
+                                        htons(oldlen), htons(datalen), true);
 }
 
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK)
index 2205e8eeeacfa2ff56980cbeb73b6d52c77089fe..57593b00c5b4327164b79567be619f0f7561f5a2 100644 (file)
@@ -73,7 +73,7 @@ icmpv6_manip_pkt(struct sk_buff *skb,
            hdr->icmp6_type == ICMPV6_ECHO_REPLY) {
                inet_proto_csum_replace2(&hdr->icmp6_cksum, skb,
                                         hdr->icmp6_identifier,
-                                        tuple->src.u.icmp.id, 0);
+                                        tuple->src.u.icmp.id, false);
                hdr->icmp6_identifier = tuple->src.u.icmp.id;
        }
        return true;
index ce3e840c870452b705744f9b64fb32661b6c82a5..dff0f0cc59e456171d81b8c5400bf30378f5ea66 100644 (file)
@@ -103,9 +103,9 @@ static void nf_ct_sack_block_adjust(struct sk_buff *skb,
                         ntohl(sack->end_seq), ntohl(new_end_seq));
 
                inet_proto_csum_replace4(&tcph->check, skb,
-                                        sack->start_seq, new_start_seq, 0);
+                                        sack->start_seq, new_start_seq, false);
                inet_proto_csum_replace4(&tcph->check, skb,
-                                        sack->end_seq, new_end_seq, 0);
+                                        sack->end_seq, new_end_seq, false);
                sack->start_seq = new_start_seq;
                sack->end_seq = new_end_seq;
                sackoff += sizeof(*sack);
@@ -193,8 +193,9 @@ int nf_ct_seq_adjust(struct sk_buff *skb,
        newseq = htonl(ntohl(tcph->seq) + seqoff);
        newack = htonl(ntohl(tcph->ack_seq) - ackoff);
 
-       inet_proto_csum_replace4(&tcph->check, skb, tcph->seq, newseq, 0);
-       inet_proto_csum_replace4(&tcph->check, skb, tcph->ack_seq, newack, 0);
+       inet_proto_csum_replace4(&tcph->check, skb, tcph->seq, newseq, false);
+       inet_proto_csum_replace4(&tcph->check, skb, tcph->ack_seq, newack,
+                                false);
 
        pr_debug("Adjusting sequence number from %u->%u, ack from %u->%u\n",
                 ntohl(tcph->seq), ntohl(newseq), ntohl(tcph->ack_seq),
index b8067b53ff3a8579e9ba126288c65ee89702fbac..15c47b246d0d0a0632574e56d2caa9d12514966d 100644 (file)
@@ -69,7 +69,7 @@ dccp_manip_pkt(struct sk_buff *skb,
        l3proto->csum_update(skb, iphdroff, &hdr->dccph_checksum,
                             tuple, maniptype);
        inet_proto_csum_replace2(&hdr->dccph_checksum, skb, oldport, newport,
-                                0);
+                                false);
        return true;
 }
 
index 37f5505f4529be54f45ef773088ca7aadbbccaed..4f8820fc514804d775274330f590fe0d1dbab54f 100644 (file)
@@ -70,7 +70,7 @@ tcp_manip_pkt(struct sk_buff *skb,
                return true;
 
        l3proto->csum_update(skb, iphdroff, &hdr->check, tuple, maniptype);
-       inet_proto_csum_replace2(&hdr->check, skb, oldport, newport, 0);
+       inet_proto_csum_replace2(&hdr->check, skb, oldport, newport, false);
        return true;
 }
 
index b0ede2f0d8bcbd0c7ee156cec4c73a432b9438cd..b1e627227b6e2670fb6ce9d151e8965a4c8731c3 100644 (file)
@@ -57,7 +57,7 @@ udp_manip_pkt(struct sk_buff *skb,
                l3proto->csum_update(skb, iphdroff, &hdr->check,
                                     tuple, maniptype);
                inet_proto_csum_replace2(&hdr->check, skb, *portptr, newport,
-                                        0);
+                                        false);
                if (!hdr->check)
                        hdr->check = CSUM_MANGLED_0;
        }
index 368f14e01e758d9771534eee7744d5d5a66cf8ba..58340c97bd836ffedd512a895cc02f56ee05f169 100644 (file)
@@ -56,7 +56,7 @@ udplite_manip_pkt(struct sk_buff *skb,
        }
 
        l3proto->csum_update(skb, iphdroff, &hdr->check, tuple, maniptype);
-       inet_proto_csum_replace2(&hdr->check, skb, *portptr, newport, 0);
+       inet_proto_csum_replace2(&hdr->check, skb, *portptr, newport, false);
        if (!hdr->check)
                hdr->check = CSUM_MANGLED_0;
 
index d7f1685279034b5e3b62748284d24c52cc1f8907..14f8b43ec5a7c736bbdafa6a8dd8b3f1fed2afa8 100644 (file)
@@ -225,7 +225,7 @@ unsigned int synproxy_tstamp_adjust(struct sk_buff *skb,
                                                     synproxy->tsoff);
                                }
                                inet_proto_csum_replace4(&th->check, skb,
-                                                        old, *ptr, 0);
+                                                        old, *ptr, false);
                                return 1;
                        }
                        optoff += op[1];
index 8c3190e2fc6abad6394ba5498762ba0502c34d58..8c02501a530f4b481f9a6f4248957893801af2b2 100644 (file)
@@ -144,7 +144,7 @@ tcpmss_mangle_packet(struct sk_buff *skb,
 
                        inet_proto_csum_replace2(&tcph->check, skb,
                                                 htons(oldmss), htons(newmss),
-                                                0);
+                                                false);
                        return 0;
                }
        }
@@ -185,18 +185,18 @@ tcpmss_mangle_packet(struct sk_buff *skb,
        memmove(opt + TCPOLEN_MSS, opt, len - sizeof(struct tcphdr));
 
        inet_proto_csum_replace2(&tcph->check, skb,
-                                htons(len), htons(len + TCPOLEN_MSS), 1);
+                                htons(len), htons(len + TCPOLEN_MSS), true);
        opt[0] = TCPOPT_MSS;
        opt[1] = TCPOLEN_MSS;
        opt[2] = (newmss & 0xff00) >> 8;
        opt[3] = newmss & 0x00ff;
 
-       inet_proto_csum_replace4(&tcph->check, skb, 0, *((__be32 *)opt), 0);
+       inet_proto_csum_replace4(&tcph->check, skb, 0, *((__be32 *)opt), false);
 
        oldval = ((__be16 *)tcph)[6];
        tcph->doff += TCPOLEN_MSS/4;
        inet_proto_csum_replace2(&tcph->check, skb,
-                                oldval, ((__be16 *)tcph)[6], 0);
+                                oldval, ((__be16 *)tcph)[6], false);
        return TCPOLEN_MSS;
 }
 
index 625fa1d636a01ccacb43c2fcae902d65a466b9db..eb92bffff11ccb22690ec0cf76ff25076d6a8cb6 100644 (file)
@@ -80,7 +80,7 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
                                n <<= 8;
                        }
                        inet_proto_csum_replace2(&tcph->check, skb, htons(o),
-                                                htons(n), 0);
+                                                htons(n), false);
                }
                memset(opt + i, TCPOPT_NOP, optl);
        }
index 14da52ddd327dcd35827bea6c9581528cbd96087..4f4200717bef984d02b9232ea764180f9e8203d7 100644 (file)
@@ -284,14 +284,14 @@ static void update_ip_l4_checksum(struct sk_buff *skb, struct iphdr *nh,
        if (nh->protocol == IPPROTO_TCP) {
                if (likely(transport_len >= sizeof(struct tcphdr)))
                        inet_proto_csum_replace4(&tcp_hdr(skb)->check, skb,
-                                                addr, new_addr, 1);
+                                                addr, new_addr, true);
        } else if (nh->protocol == IPPROTO_UDP) {
                if (likely(transport_len >= sizeof(struct udphdr))) {
                        struct udphdr *uh = udp_hdr(skb);
 
                        if (uh->check || skb->ip_summed == CHECKSUM_PARTIAL) {
                                inet_proto_csum_replace4(&uh->check, skb,
-                                                        addr, new_addr, 1);
+                                                        addr, new_addr, true);
                                if (!uh->check)
                                        uh->check = CSUM_MANGLED_0;
                        }
@@ -316,14 +316,14 @@ static void update_ipv6_checksum(struct sk_buff *skb, u8 l4_proto,
        if (l4_proto == NEXTHDR_TCP) {
                if (likely(transport_len >= sizeof(struct tcphdr)))
                        inet_proto_csum_replace16(&tcp_hdr(skb)->check, skb,
-                                                 addr, new_addr, 1);
+                                                 addr, new_addr, true);
        } else if (l4_proto == NEXTHDR_UDP) {
                if (likely(transport_len >= sizeof(struct udphdr))) {
                        struct udphdr *uh = udp_hdr(skb);
 
                        if (uh->check || skb->ip_summed == CHECKSUM_PARTIAL) {
                                inet_proto_csum_replace16(&uh->check, skb,
-                                                         addr, new_addr, 1);
+                                                         addr, new_addr, true);
                                if (!uh->check)
                                        uh->check = CSUM_MANGLED_0;
                        }
@@ -331,7 +331,7 @@ static void update_ipv6_checksum(struct sk_buff *skb, u8 l4_proto,
        } else if (l4_proto == NEXTHDR_ICMP) {
                if (likely(transport_len >= sizeof(struct icmp6hdr)))
                        inet_proto_csum_replace16(&icmp6_hdr(skb)->icmp6_cksum,
-                                                 skb, addr, new_addr, 1);
+                                                 skb, addr, new_addr, true);
        }
 }
 
@@ -498,7 +498,7 @@ static int set_ipv6(struct sk_buff *skb, struct sw_flow_key *flow_key,
 static void set_tp_port(struct sk_buff *skb, __be16 *port,
                        __be16 new_port, __sum16 *check)
 {
-       inet_proto_csum_replace2(check, skb, *port, new_port, 0);
+       inet_proto_csum_replace2(check, skb, *port, new_port, false);
        *port = new_port;
 }
 
index 5be0b3c1c5b0c9f17e3fbd4e1dc1c92c7a8e5aed..b7c4ead8b5a8e863d87f8c1c4c1e37840fe50577 100644 (file)
@@ -162,7 +162,8 @@ static int tcf_nat(struct sk_buff *skb, const struct tc_action *a,
                        goto drop;
 
                tcph = (void *)(skb_network_header(skb) + ihl);
-               inet_proto_csum_replace4(&tcph->check, skb, addr, new_addr, 1);
+               inet_proto_csum_replace4(&tcph->check, skb, addr, new_addr,
+                                        true);
                break;
        }
        case IPPROTO_UDP:
@@ -178,7 +179,7 @@ static int tcf_nat(struct sk_buff *skb, const struct tc_action *a,
                udph = (void *)(skb_network_header(skb) + ihl);
                if (udph->check || skb->ip_summed == CHECKSUM_PARTIAL) {
                        inet_proto_csum_replace4(&udph->check, skb, addr,
-                                                new_addr, 1);
+                                                new_addr, true);
                        if (!udph->check)
                                udph->check = CSUM_MANGLED_0;
                }
@@ -231,7 +232,7 @@ static int tcf_nat(struct sk_buff *skb, const struct tc_action *a,
                        iph->saddr = new_addr;
 
                inet_proto_csum_replace4(&icmph->checksum, skb, addr, new_addr,
-                                        0);
+                                        false);
                break;
        }
        default: