Skip to content

Commit

Permalink
ipv6: bool/const conversions phase2
Browse files Browse the repository at this point in the history
Mostly bool conversions, some inline removals and const additions.

Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed May 19, 2012
1 parent 32e9072 commit a50feda
Show file tree
Hide file tree
Showing 17 changed files with 131 additions and 130 deletions.
18 changes: 9 additions & 9 deletions include/net/addrconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ extern int ipv6_sock_mc_join(struct sock *sk, int ifindex,
extern int ipv6_sock_mc_drop(struct sock *sk, int ifindex,
const struct in6_addr *addr);
extern void ipv6_sock_mc_close(struct sock *sk);
extern int inet6_mc_check(struct sock *sk,
const struct in6_addr *mc_addr,
const struct in6_addr *src_addr);
extern bool inet6_mc_check(struct sock *sk,
const struct in6_addr *mc_addr,
const struct in6_addr *src_addr);

extern int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr);
extern int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr);
Expand All @@ -146,10 +146,10 @@ extern void ipv6_mc_init_dev(struct inet6_dev *idev);
extern void ipv6_mc_destroy_dev(struct inet6_dev *idev);
extern void addrconf_dad_failure(struct inet6_ifaddr *ifp);

extern int ipv6_chk_mcast_addr(struct net_device *dev,
const struct in6_addr *group,
const struct in6_addr *src_addr);
extern int ipv6_is_mld(struct sk_buff *skb, int nexthdr);
extern bool ipv6_chk_mcast_addr(struct net_device *dev,
const struct in6_addr *group,
const struct in6_addr *src_addr);
extern bool ipv6_is_mld(struct sk_buff *skb, int nexthdr);

extern void addrconf_prefix_rcv(struct net_device *dev,
u8 *opt, int len, bool sllao);
Expand All @@ -163,8 +163,8 @@ extern void ipv6_sock_ac_close(struct sock *sk);

extern int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr);
extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr);
extern int ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
const struct in6_addr *addr);
extern bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
const struct in6_addr *addr);


/* Device notifier */
Expand Down
2 changes: 1 addition & 1 deletion include/net/ip6_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
spin_unlock(&sk->sk_dst_lock);
}

static inline int ipv6_unicast_destination(struct sk_buff *skb)
static inline bool ipv6_unicast_destination(const struct sk_buff *skb)
{
struct rt6_info *rt = (struct rt6_info *) skb_dst(skb);

Expand Down
2 changes: 1 addition & 1 deletion include/net/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ extern void ipv6_push_frag_opts(struct sk_buff *skb,
extern int ipv6_skip_exthdr(const struct sk_buff *, int start,
u8 *nexthdrp, __be16 *frag_offp);

extern int ipv6_ext_hdr(u8 nexthdr);
extern bool ipv6_ext_hdr(u8 nexthdr);

extern int ipv6_find_tlv(struct sk_buff *skb, int offset, int type);

Expand Down
2 changes: 1 addition & 1 deletion include/net/rawv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

void raw6_icmp_error(struct sk_buff *, int nexthdr,
u8 type, u8 code, int inner_offset, __be32);
int raw6_local_deliver(struct sk_buff *, int);
bool raw6_local_deliver(struct sk_buff *, int);

extern int rawv6_rcv(struct sock *sk,
struct sk_buff *skb);
Expand Down
24 changes: 12 additions & 12 deletions net/ipv6/addrlabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static void ip6addrlbl_free_rcu(struct rcu_head *h)
ip6addrlbl_free(container_of(h, struct ip6addrlbl_entry, rcu));
}

static inline int ip6addrlbl_hold(struct ip6addrlbl_entry *p)
static bool ip6addrlbl_hold(struct ip6addrlbl_entry *p)
{
return atomic_inc_not_zero(&p->refcnt);
}
Expand All @@ -141,20 +141,20 @@ static inline void ip6addrlbl_put(struct ip6addrlbl_entry *p)
}

/* Find label */
static int __ip6addrlbl_match(struct net *net,
struct ip6addrlbl_entry *p,
const struct in6_addr *addr,
int addrtype, int ifindex)
static bool __ip6addrlbl_match(struct net *net,
const struct ip6addrlbl_entry *p,
const struct in6_addr *addr,
int addrtype, int ifindex)
{
if (!net_eq(ip6addrlbl_net(p), net))
return 0;
return false;
if (p->ifindex && p->ifindex != ifindex)
return 0;
return false;
if (p->addrtype && p->addrtype != addrtype)
return 0;
return false;
if (!ipv6_prefix_equal(addr, &p->prefix, p->prefixlen))
return 0;
return 1;
return false;
return true;
}

static struct ip6addrlbl_entry *__ipv6_addr_label(struct net *net,
Expand Down Expand Up @@ -456,8 +456,8 @@ static int ip6addrlbl_newdel(struct sk_buff *skb, struct nlmsghdr *nlh,
return err;
}

static inline void ip6addrlbl_putmsg(struct nlmsghdr *nlh,
int prefixlen, int ifindex, u32 lseq)
static void ip6addrlbl_putmsg(struct nlmsghdr *nlh,
int prefixlen, int ifindex, u32 lseq)
{
struct ifaddrlblmsg *ifal = nlmsg_data(nlh);
ifal->ifal_family = AF_INET6;
Expand Down
6 changes: 3 additions & 3 deletions net/ipv6/ah6.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static inline struct scatterlist *ah_req_sg(struct crypto_ahash *ahash,
__alignof__(struct scatterlist));
}

static int zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr)
static bool zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr)
{
u8 *opt = (u8 *)opthdr;
int len = ipv6_optlen(opthdr);
Expand Down Expand Up @@ -145,10 +145,10 @@ static int zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr)
len -= optlen;
}
if (len == 0)
return 1;
return true;

bad:
return 0;
return false;
}

#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
Expand Down
12 changes: 6 additions & 6 deletions net/ipv6/anycast.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ static int ipv6_dev_ac_dec(struct net_device *dev, const struct in6_addr *addr)
* check if the interface has this anycast address
* called with rcu_read_lock()
*/
static int ipv6_chk_acast_dev(struct net_device *dev, const struct in6_addr *addr)
static bool ipv6_chk_acast_dev(struct net_device *dev, const struct in6_addr *addr)
{
struct inet6_dev *idev;
struct ifacaddr6 *aca;
Expand All @@ -356,24 +356,24 @@ static int ipv6_chk_acast_dev(struct net_device *dev, const struct in6_addr *add
read_unlock_bh(&idev->lock);
return aca != NULL;
}
return 0;
return false;
}

/*
* check if given interface (or any, if dev==0) has this anycast address
*/
int ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
const struct in6_addr *addr)
bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
const struct in6_addr *addr)
{
int found = 0;
bool found = false;

rcu_read_lock();
if (dev)
found = ipv6_chk_acast_dev(dev, addr);
else
for_each_netdev_rcu(net, dev)
if (ipv6_chk_acast_dev(dev, addr)) {
found = 1;
found = true;
break;
}
rcu_read_unlock();
Expand Down
4 changes: 2 additions & 2 deletions net/ipv6/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
#include <linux/errqueue.h>
#include <asm/uaccess.h>

static inline int ipv6_mapped_addr_any(const struct in6_addr *a)
static bool ipv6_mapped_addr_any(const struct in6_addr *a)
{
return (ipv6_addr_v4mapped(a) && (a->s6_addr32[3] == 0));
return ipv6_addr_v4mapped(a) && (a->s6_addr32[3] == 0);
}

int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
Expand Down
54 changes: 27 additions & 27 deletions net/ipv6/exthdrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ EXPORT_SYMBOL_GPL(ipv6_find_tlv);
/*
* Parsing tlv encoded headers.
*
* Parsing function "func" returns 1, if parsing succeed
* and 0, if it failed.
* Parsing function "func" returns true, if parsing succeed
* and false, if it failed.
* It MUST NOT touch skb->h.
*/

struct tlvtype_proc {
int type;
int (*func)(struct sk_buff *skb, int offset);
bool (*func)(struct sk_buff *skb, int offset);
};

/*********************
Expand All @@ -112,11 +112,11 @@ struct tlvtype_proc {

/* An unknown option is detected, decide what to do */

static int ip6_tlvopt_unknown(struct sk_buff *skb, int optoff)
static bool ip6_tlvopt_unknown(struct sk_buff *skb, int optoff)
{
switch ((skb_network_header(skb)[optoff] & 0xC0) >> 6) {
case 0: /* ignore */
return 1;
return true;

case 1: /* drop packet */
break;
Expand All @@ -129,18 +129,18 @@ static int ip6_tlvopt_unknown(struct sk_buff *skb, int optoff)
break;
case 2: /* send ICMP PARM PROB regardless and drop packet */
icmpv6_param_prob(skb, ICMPV6_UNK_OPTION, optoff);
return 0;
return false;
}

kfree_skb(skb);
return 0;
return false;
}

/* Parse tlv encoded option header (hop-by-hop or destination) */

static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff *skb)
static bool ip6_parse_tlv(const struct tlvtype_proc *procs, struct sk_buff *skb)
{
struct tlvtype_proc *curr;
const struct tlvtype_proc *curr;
const unsigned char *nh = skb_network_header(skb);
int off = skb_network_header_len(skb);
int len = (skb_transport_header(skb)[1] + 1) << 3;
Expand Down Expand Up @@ -186,33 +186,33 @@ static int ip6_parse_tlv(struct tlvtype_proc *procs, struct sk_buff *skb)
/* type specific length/alignment
checks will be performed in the
func(). */
if (curr->func(skb, off) == 0)
return 0;
if (curr->func(skb, off) == false)
return false;
break;
}
}
if (curr->type < 0) {
if (ip6_tlvopt_unknown(skb, off) == 0)
return 0;
return false;
}
break;
}
off += optlen;
len -= optlen;
}
if (len == 0)
return 1;
return true;
bad:
kfree_skb(skb);
return 0;
return false;
}

/*****************************
Destination options header.
*****************************/

#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
static int ipv6_dest_hao(struct sk_buff *skb, int optoff)
static bool ipv6_dest_hao(struct sk_buff *skb, int optoff)
{
struct ipv6_destopt_hao *hao;
struct inet6_skb_parm *opt = IP6CB(skb);
Expand Down Expand Up @@ -266,15 +266,15 @@ static int ipv6_dest_hao(struct sk_buff *skb, int optoff)
if (skb->tstamp.tv64 == 0)
__net_timestamp(skb);

return 1;
return true;

discard:
kfree_skb(skb);
return 0;
return false;
}
#endif

static struct tlvtype_proc tlvprocdestopt_lst[] = {
static const struct tlvtype_proc tlvprocdestopt_lst[] = {
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
{
.type = IPV6_TLV_HAO,
Expand Down Expand Up @@ -579,23 +579,23 @@ static inline struct net *ipv6_skb_net(struct sk_buff *skb)

/* Router Alert as of RFC 2711 */

static int ipv6_hop_ra(struct sk_buff *skb, int optoff)
static bool ipv6_hop_ra(struct sk_buff *skb, int optoff)
{
const unsigned char *nh = skb_network_header(skb);

if (nh[optoff + 1] == 2) {
IP6CB(skb)->ra = optoff;
return 1;
return true;
}
LIMIT_NETDEBUG(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n",
nh[optoff + 1]);
kfree_skb(skb);
return 0;
return false;
}

/* Jumbo payload */

static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
static bool ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
{
const unsigned char *nh = skb_network_header(skb);
struct net *net = ipv6_skb_net(skb);
Expand All @@ -614,13 +614,13 @@ static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
IPSTATS_MIB_INHDRERRORS);
icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff+2);
return 0;
return false;
}
if (ipv6_hdr(skb)->payload_len) {
IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
IPSTATS_MIB_INHDRERRORS);
icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff);
return 0;
return false;
}

if (pkt_len > skb->len - sizeof(struct ipv6hdr)) {
Expand All @@ -632,14 +632,14 @@ static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
if (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr)))
goto drop;

return 1;
return true;

drop:
kfree_skb(skb);
return 0;
return false;
}

static struct tlvtype_proc tlvprochopopt_lst[] = {
static const struct tlvtype_proc tlvprochopopt_lst[] = {
{
.type = IPV6_TLV_ROUTERALERT,
.func = ipv6_hop_ra,
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/exthdrs_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* find out if nexthdr is a well-known extension header or a protocol
*/

int ipv6_ext_hdr(u8 nexthdr)
bool ipv6_ext_hdr(u8 nexthdr)
{
/*
* find out if nexthdr is an extension header or a protocol
Expand Down
Loading

0 comments on commit a50feda

Please sign in to comment.