netfilter: fix sparse warnings in reject handling
authorFlorian Westphal <fw@strlen.de>
Mon, 9 Mar 2015 22:04:15 +0000 (23:04 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 10 Mar 2015 14:01:32 +0000 (15:01 +0100)
make C=1 CF=-D__CHECK_ENDIAN__ shows following:

net/bridge/netfilter/nft_reject_bridge.c:65:50: warning: incorrect type in argument 3 (different base types)
net/bridge/netfilter/nft_reject_bridge.c:65:50:    expected restricted __be16 [usertype] protocol [..]
net/bridge/netfilter/nft_reject_bridge.c:102:37: warning: cast from restricted __be16
net/bridge/netfilter/nft_reject_bridge.c:102:37: warning: incorrect type in argument 1 (different base types) [..]
net/bridge/netfilter/nft_reject_bridge.c:121:50: warning: incorrect type in argument 3 (different base types) [..]
net/bridge/netfilter/nft_reject_bridge.c:168:52: warning: incorrect type in argument 3 (different base types) [..]
net/bridge/netfilter/nft_reject_bridge.c:233:52: warning: incorrect type in argument 3 (different base types) [..]

Caused by two (harmless) errors:
1. htons() instead of ntohs()
2. __be16 for protocol in nf_reject_ipXhdr_put API, use u8 instead.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/ipv4/nf_reject.h
include/net/netfilter/ipv6/nf_reject.h
net/bridge/netfilter/nft_reject_bridge.c
net/ipv4/netfilter/nf_reject_ipv4.c
net/ipv6/netfilter/nf_reject_ipv6.c

index 864127573c3209f7a039cfb96fd53a80ec8e08d8..77862c3645f07000070f94e4838ca8b8cd792110 100644 (file)
@@ -12,7 +12,7 @@ const struct tcphdr *nf_reject_ip_tcphdr_get(struct sk_buff *oldskb,
                                             struct tcphdr *_oth, int hook);
 struct iphdr *nf_reject_iphdr_put(struct sk_buff *nskb,
                                  const struct sk_buff *oldskb,
-                                 __be16 protocol, int ttl);
+                                 __u8 protocol, int ttl);
 void nf_reject_ip_tcphdr_put(struct sk_buff *nskb, const struct sk_buff *oldskb,
                             const struct tcphdr *oth);
 
index 0ae445d3f21794d51a16d00f2de5f69b9305cd74..0ea4fa37db16d87cf5ed9b72feb8c50d24cb05f5 100644 (file)
@@ -13,7 +13,7 @@ const struct tcphdr *nf_reject_ip6_tcphdr_get(struct sk_buff *oldskb,
                                              unsigned int *otcplen, int hook);
 struct ipv6hdr *nf_reject_ip6hdr_put(struct sk_buff *nskb,
                                     const struct sk_buff *oldskb,
-                                    __be16 protocol, int hoplimit);
+                                    __u8 protocol, int hoplimit);
 void nf_reject_ip6_tcphdr_put(struct sk_buff *nskb,
                              const struct sk_buff *oldskb,
                              const struct tcphdr *oth, unsigned int otcplen);
index 5c6c96585acd575f521f1fbdfc329d694708dcff..54a2fdf0f4574a4db6ba23193a511ffcf09293da 100644 (file)
@@ -99,7 +99,7 @@ static void nft_reject_br_send_v4_unreach(struct sk_buff *oldskb,
        if (!pskb_may_pull(oldskb, len))
                return;
 
-       if (pskb_trim_rcsum(oldskb, htons(ip_hdr(oldskb)->tot_len)))
+       if (pskb_trim_rcsum(oldskb, ntohs(ip_hdr(oldskb)->tot_len)))
                return;
 
        if (ip_hdr(oldskb)->protocol == IPPROTO_TCP ||
index b7405eb7f1ef566570f8f5d6cd4aa20a591bb40a..c5b794da51a91fd8b2236379b532910cafc0568f 100644 (file)
@@ -43,7 +43,7 @@ EXPORT_SYMBOL_GPL(nf_reject_ip_tcphdr_get);
 
 struct iphdr *nf_reject_iphdr_put(struct sk_buff *nskb,
                                  const struct sk_buff *oldskb,
-                                 __be16 protocol, int ttl)
+                                 __u8 protocol, int ttl)
 {
        struct iphdr *niph, *oiph = ip_hdr(oldskb);
 
index 68e0bb4db1bf4bee9988ff410bc0942c4ca0749f..3afdce03d94e7c2dd27d19fabff9250c0f5aaddc 100644 (file)
@@ -65,7 +65,7 @@ EXPORT_SYMBOL_GPL(nf_reject_ip6_tcphdr_get);
 
 struct ipv6hdr *nf_reject_ip6hdr_put(struct sk_buff *nskb,
                                     const struct sk_buff *oldskb,
-                                    __be16 protocol, int hoplimit)
+                                    __u8 protocol, int hoplimit)
 {
        struct ipv6hdr *ip6h;
        const struct ipv6hdr *oip6h = ipv6_hdr(oldskb);