Commit 92113bfd authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

ipv6: bool conversions phase1

ipv6_opt_accepted() returns a bool, and can use const pointers

ipv6_addr_equal(), ipv6_addr_any(), ipv6_addr_loopback(),
ipv6_addr_orchid() return a bool.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cbc264ca
...@@ -263,7 +263,7 @@ extern struct ipv6_txoptions * ipv6_renew_options(struct sock *sk, struct ipv6_t ...@@ -263,7 +263,7 @@ extern struct ipv6_txoptions * ipv6_renew_options(struct sock *sk, struct ipv6_t
struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space, struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
struct ipv6_txoptions *opt); struct ipv6_txoptions *opt);
extern int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb); extern bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb);
int ip6_frag_nqueues(struct net *net); int ip6_frag_nqueues(struct net *net);
int ip6_frag_mem(struct net *net); int ip6_frag_mem(struct net *net);
...@@ -332,7 +332,7 @@ static inline void ipv6_addr_set(struct in6_addr *addr, ...@@ -332,7 +332,7 @@ static inline void ipv6_addr_set(struct in6_addr *addr,
addr->s6_addr32[3] = w4; addr->s6_addr32[3] = w4;
} }
static inline int ipv6_addr_equal(const struct in6_addr *a1, static inline bool ipv6_addr_equal(const struct in6_addr *a1,
const struct in6_addr *a2) const struct in6_addr *a2)
{ {
return ((a1->s6_addr32[0] ^ a2->s6_addr32[0]) | return ((a1->s6_addr32[0] ^ a2->s6_addr32[0]) |
...@@ -341,7 +341,7 @@ static inline int ipv6_addr_equal(const struct in6_addr *a1, ...@@ -341,7 +341,7 @@ static inline int ipv6_addr_equal(const struct in6_addr *a1,
(a1->s6_addr32[3] ^ a2->s6_addr32[3])) == 0; (a1->s6_addr32[3] ^ a2->s6_addr32[3])) == 0;
} }
static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2, static inline bool __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2,
unsigned int prefixlen) unsigned int prefixlen)
{ {
unsigned int pdw, pbi; unsigned int pdw, pbi;
...@@ -349,17 +349,17 @@ static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2, ...@@ -349,17 +349,17 @@ static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2,
/* check complete u32 in prefix */ /* check complete u32 in prefix */
pdw = prefixlen >> 5; pdw = prefixlen >> 5;
if (pdw && memcmp(a1, a2, pdw << 2)) if (pdw && memcmp(a1, a2, pdw << 2))
return 0; return false;
/* check incomplete u32 in prefix */ /* check incomplete u32 in prefix */
pbi = prefixlen & 0x1f; pbi = prefixlen & 0x1f;
if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi)))) if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi))))
return 0; return false;
return 1; return true;
} }
static inline int ipv6_prefix_equal(const struct in6_addr *a1, static inline bool ipv6_prefix_equal(const struct in6_addr *a1,
const struct in6_addr *a2, const struct in6_addr *a2,
unsigned int prefixlen) unsigned int prefixlen)
{ {
...@@ -389,19 +389,19 @@ struct ip6_create_arg { ...@@ -389,19 +389,19 @@ struct ip6_create_arg {
void ip6_frag_init(struct inet_frag_queue *q, void *a); void ip6_frag_init(struct inet_frag_queue *q, void *a);
bool ip6_frag_match(struct inet_frag_queue *q, void *a); bool ip6_frag_match(struct inet_frag_queue *q, void *a);
static inline int ipv6_addr_any(const struct in6_addr *a) static inline bool ipv6_addr_any(const struct in6_addr *a)
{ {
return (a->s6_addr32[0] | a->s6_addr32[1] | return (a->s6_addr32[0] | a->s6_addr32[1] |
a->s6_addr32[2] | a->s6_addr32[3]) == 0; a->s6_addr32[2] | a->s6_addr32[3]) == 0;
} }
static inline int ipv6_addr_loopback(const struct in6_addr *a) static inline bool ipv6_addr_loopback(const struct in6_addr *a)
{ {
return (a->s6_addr32[0] | a->s6_addr32[1] | return (a->s6_addr32[0] | a->s6_addr32[1] |
a->s6_addr32[2] | (a->s6_addr32[3] ^ htonl(1))) == 0; a->s6_addr32[2] | (a->s6_addr32[3] ^ htonl(1))) == 0;
} }
static inline int ipv6_addr_v4mapped(const struct in6_addr *a) static inline bool ipv6_addr_v4mapped(const struct in6_addr *a)
{ {
return (a->s6_addr32[0] | a->s6_addr32[1] | return (a->s6_addr32[0] | a->s6_addr32[1] |
(a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0; (a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0;
...@@ -411,7 +411,7 @@ static inline int ipv6_addr_v4mapped(const struct in6_addr *a) ...@@ -411,7 +411,7 @@ static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
* Check for a RFC 4843 ORCHID address * Check for a RFC 4843 ORCHID address
* (Overlay Routable Cryptographic Hash Identifiers) * (Overlay Routable Cryptographic Hash Identifiers)
*/ */
static inline int ipv6_addr_orchid(const struct in6_addr *a) static inline bool ipv6_addr_orchid(const struct in6_addr *a)
{ {
return (a->s6_addr32[0] & htonl(0xfffffff0)) == htonl(0x20010010); return (a->s6_addr32[0] & htonl(0xfffffff0)) == htonl(0x20010010);
} }
......
...@@ -678,10 +678,10 @@ int inet6_sk_rebuild_header(struct sock *sk) ...@@ -678,10 +678,10 @@ int inet6_sk_rebuild_header(struct sock *sk)
} }
EXPORT_SYMBOL_GPL(inet6_sk_rebuild_header); EXPORT_SYMBOL_GPL(inet6_sk_rebuild_header);
int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb) bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb)
{ {
struct ipv6_pinfo *np = inet6_sk(sk); const struct ipv6_pinfo *np = inet6_sk(sk);
struct inet6_skb_parm *opt = IP6CB(skb); const struct inet6_skb_parm *opt = IP6CB(skb);
if (np->rxopt.all) { if (np->rxopt.all) {
if ((opt->hop && (np->rxopt.bits.hopopts || if ((opt->hop && (np->rxopt.bits.hopopts ||
...@@ -693,9 +693,9 @@ int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb) ...@@ -693,9 +693,9 @@ int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb)
np->rxopt.bits.osrcrt)) || np->rxopt.bits.osrcrt)) ||
((opt->dst1 || opt->dst0) && ((opt->dst1 || opt->dst0) &&
(np->rxopt.bits.dstopts || np->rxopt.bits.odstopts))) (np->rxopt.bits.dstopts || np->rxopt.bits.odstopts)))
return 1; return true;
} }
return 0; return false;
} }
EXPORT_SYMBOL_GPL(ipv6_opt_accepted); EXPORT_SYMBOL_GPL(ipv6_opt_accepted);
......
...@@ -818,7 +818,7 @@ static void init_tel_txopt(struct ipv6_tel_txoption *opt, __u8 encap_limit) ...@@ -818,7 +818,7 @@ static void init_tel_txopt(struct ipv6_tel_txoption *opt, __u8 encap_limit)
* 0 else * 0 else
**/ **/
static inline int static inline bool
ip6_tnl_addr_conflict(const struct ip6_tnl *t, const struct ipv6hdr *hdr) ip6_tnl_addr_conflict(const struct ip6_tnl *t, const struct ipv6hdr *hdr)
{ {
return ipv6_addr_equal(&t->parms.raddr, &hdr->saddr); return ipv6_addr_equal(&t->parms.raddr, &hdr->saddr);
......
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