Commit 53608418 authored by Hideaki Yoshifuji's avatar Hideaki Yoshifuji

[IPV6]: Use the cheaper ipv6_addr_is_multicast() for ipv6_addr_type() where possible.

parent 8e5afcc7
......@@ -111,7 +111,7 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr)
if (!capable(CAP_NET_ADMIN))
return -EPERM;
if (ipv6_addr_type(addr) & IPV6_ADDR_MULTICAST)
if (ipv6_addr_is_multicast(addr))
return -EINVAL;
if (ipv6_chk_addr(addr, NULL, 0))
return -EINVAL;
......
......@@ -218,7 +218,6 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp, unsigned int *nhoffp)
struct inet6_skb_parm *opt = (struct inet6_skb_parm *)skb->cb;
struct in6_addr *addr;
struct in6_addr daddr;
int addr_type;
int n, i;
struct ipv6_rt_hdr *hdr;
......@@ -233,7 +232,7 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp, unsigned int *nhoffp)
hdr = (struct ipv6_rt_hdr *) skb->h.raw;
if ((ipv6_addr_type(&skb->nh.ipv6h->daddr)&IPV6_ADDR_MULTICAST) ||
if (ipv6_addr_is_multicast(&skb->nh.ipv6h->daddr) ||
skb->pkt_type != PACKET_HOST) {
kfree_skb(skb);
return -1;
......@@ -293,9 +292,7 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp, unsigned int *nhoffp)
addr = rthdr->addr;
addr += i - 1;
addr_type = ipv6_addr_type(addr);
if (addr_type&IPV6_ADDR_MULTICAST) {
if (ipv6_addr_is_multicast(addr)) {
kfree_skb(skb);
return -1;
}
......
......@@ -175,7 +175,7 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, struct in6_addr *addr)
struct ipv6_pinfo *np = inet6_sk(sk);
int err;
if (!(ipv6_addr_type(addr) & IPV6_ADDR_MULTICAST))
if (!ipv6_addr_is_multicast(addr))
return -EINVAL;
mc_lst = sock_kmalloc(sk, sizeof(struct ipv6_mc_socklist), GFP_KERNEL);
......@@ -348,7 +348,7 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
source = &((struct sockaddr_in6 *)&pgsr->gsr_source)->sin6_addr;
group = &((struct sockaddr_in6 *)&pgsr->gsr_group)->sin6_addr;
if (!(ipv6_addr_type(group) & IPV6_ADDR_MULTICAST))
if (!ipv6_addr_is_multicast(group))
return -EINVAL;
idev = ip6_mc_find_dev(group, pgsr->gsr_interface);
......@@ -457,7 +457,7 @@ int ip6_mc_msfilter(struct sock *sk, struct group_filter *gsf)
group = &((struct sockaddr_in6 *)&gsf->gf_group)->sin6_addr;
if (!(ipv6_addr_type(group) & IPV6_ADDR_MULTICAST))
if (!ipv6_addr_is_multicast(group))
return -EINVAL;
if (gsf->gf_fmode != MCAST_INCLUDE &&
gsf->gf_fmode != MCAST_EXCLUDE)
......@@ -529,7 +529,7 @@ int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
group = &((struct sockaddr_in6 *)&gsf->gf_group)->sin6_addr;
if (!(ipv6_addr_type(group) & IPV6_ADDR_MULTICAST))
if (!ipv6_addr_is_multicast(group))
return -EINVAL;
idev = ip6_mc_find_dev(group, gsf->gf_interface);
......
......@@ -277,25 +277,21 @@ static int ndisc_constructor(struct neighbour *neigh)
struct in6_addr *addr = (struct in6_addr*)&neigh->primary_key;
struct net_device *dev = neigh->dev;
struct inet6_dev *in6_dev = in6_dev_get(dev);
int addr_type;
int is_multicast = ipv6_addr_is_multicast(addr);
if (in6_dev == NULL)
return -EINVAL;
addr_type = ipv6_addr_type(addr);
if (in6_dev->nd_parms)
neigh->parms = in6_dev->nd_parms;
if (addr_type&IPV6_ADDR_MULTICAST)
neigh->type = RTN_MULTICAST;
else
neigh->type = RTN_UNICAST;
neigh->type = is_multicast ? RTN_MULTICAST : RTN_UNICAST;
if (dev->hard_header == NULL) {
neigh->nud_state = NUD_NOARP;
neigh->ops = &ndisc_direct_ops;
neigh->output = neigh->ops->queue_xmit;
} else {
if (addr_type&IPV6_ADDR_MULTICAST) {
if (is_multicast) {
neigh->nud_state = NUD_NOARP;
ndisc_mc_map(addr, neigh->ha, dev, 1);
} else if (dev->flags&(IFF_NOARP|IFF_LOOPBACK)) {
......@@ -355,7 +351,7 @@ ndisc_build_ll_hdr(struct sk_buff *skb, struct net_device *dev,
unsigned char *h_dest = NULL;
if (dev->hard_header) {
if (ipv6_addr_type(daddr) & IPV6_ADDR_MULTICAST) {
if (ipv6_addr_is_multicast(daddr)) {
ndisc_mc_map(daddr, ha, dev, 1);
h_dest = ha;
} else if (neigh) {
......@@ -711,7 +707,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
struct neighbour *neigh;
int addr_type = ipv6_addr_type(saddr);
if (ipv6_addr_type(&msg->target)&IPV6_ADDR_MULTICAST) {
if (ipv6_addr_is_multicast(&msg->target)) {
if (net_ratelimit())
printk(KERN_WARNING "ICMP NS: target address is multicast\n");
return;
......@@ -797,9 +793,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
}
if (addr_type & IPV6_ADDR_UNICAST) {
int inc = ipv6_addr_type(daddr)&IPV6_ADDR_MULTICAST;
if (inc)
if (ipv6_addr_is_multicast(daddr))
nd_tbl.stats.rcv_probes_mcast++;
else
nd_tbl.stats.rcv_probes_ucast++;
......@@ -841,7 +835,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
}
if (addr_type & IPV6_ADDR_UNICAST) {
int inc = ipv6_addr_type(daddr)&IPV6_ADDR_MULTICAST;
int inc = ipv6_addr_is_multicast(daddr);
if (inc)
nd_tbl.stats.rcv_probes_mcast++;
else
......@@ -870,7 +864,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
(addr_type & IPV6_ADDR_UNICAST ||
addr_type == IPV6_ADDR_ANY) &&
pneigh_lookup(&nd_tbl, &msg->target, dev, 0)) {
int inc = ipv6_addr_type(daddr)&IPV6_ADDR_MULTICAST;
int inc = ipv6_addr_is_multicast(daddr);
if (skb->stamp.tv_sec == 0 ||
skb->pkt_type == PACKET_HOST ||
......@@ -929,13 +923,13 @@ static void ndisc_recv_na(struct sk_buff *skb)
return;
}
if (ipv6_addr_type(&msg->target)&IPV6_ADDR_MULTICAST) {
if (ipv6_addr_is_multicast(&msg->target)) {
if (net_ratelimit())
printk(KERN_WARNING "NDISC NA: target address is multicast\n");
return;
}
if ((ipv6_addr_type(daddr)&IPV6_ADDR_MULTICAST) &&
if (ipv6_addr_is_multicast(daddr) &&
msg->icmph.icmp6_solicited) {
ND_PRINTK0("NDISC: solicited NA is multicasted\n");
return;
......@@ -1229,7 +1223,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
target = (struct in6_addr *) (icmph + 1);
dest = target + 1;
if (ipv6_addr_type(dest) & IPV6_ADDR_MULTICAST) {
if (ipv6_addr_is_multicast(dest)) {
if (net_ratelimit())
printk(KERN_WARNING "ICMP redirect for multicast addr\n");
return;
......
......@@ -81,7 +81,7 @@ struct sock *__raw_v6_lookup(struct sock *sk, unsigned short num,
struct in6_addr *loc_addr, struct in6_addr *rmt_addr)
{
struct hlist_node *node;
int addr_type = ipv6_addr_type(loc_addr);
int is_multicast = ipv6_addr_is_multicast(loc_addr);
sk_for_each_from(sk, node)
if (inet_sk(sk)->num == num) {
......@@ -94,7 +94,7 @@ struct sock *__raw_v6_lookup(struct sock *sk, unsigned short num,
if (!ipv6_addr_any(&np->rcv_saddr)) {
if (!ipv6_addr_cmp(&np->rcv_saddr, loc_addr))
goto found;
if ((addr_type & IPV6_ADDR_MULTICAST) &&
if (is_multicast &&
inet6_mc_check(sk, loc_addr, rmt_addr))
goto found;
continue;
......
......@@ -658,7 +658,7 @@ static int udpv6_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
/*
* Multicast receive code
*/
if (ipv6_addr_type(daddr) & IPV6_ADDR_MULTICAST) {
if (ipv6_addr_is_multicast(daddr)) {
udpv6_mcast_deliver(uh, saddr, daddr, skb);
return 0;
}
......
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