Commit a7e9ff73 authored by Jianjun Kong's avatar Jianjun Kong Committed by David S. Miller

net: clean up net/ipv4/igmp.c

Signed-off-by: default avatarJianjun Kong <jianjun@zeuux.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6ed2533e
...@@ -167,7 +167,7 @@ static __inline__ void igmp_stop_timer(struct ip_mc_list *im) ...@@ -167,7 +167,7 @@ static __inline__ void igmp_stop_timer(struct ip_mc_list *im)
spin_lock_bh(&im->lock); spin_lock_bh(&im->lock);
if (del_timer(&im->timer)) if (del_timer(&im->timer))
atomic_dec(&im->refcnt); atomic_dec(&im->refcnt);
im->tm_running=0; im->tm_running = 0;
im->reporter = 0; im->reporter = 0;
im->unsolicit_count = 0; im->unsolicit_count = 0;
spin_unlock_bh(&im->lock); spin_unlock_bh(&im->lock);
...@@ -176,9 +176,9 @@ static __inline__ void igmp_stop_timer(struct ip_mc_list *im) ...@@ -176,9 +176,9 @@ static __inline__ void igmp_stop_timer(struct ip_mc_list *im)
/* It must be called with locked im->lock */ /* It must be called with locked im->lock */
static void igmp_start_timer(struct ip_mc_list *im, int max_delay) static void igmp_start_timer(struct ip_mc_list *im, int max_delay)
{ {
int tv=net_random() % max_delay; int tv = net_random() % max_delay;
im->tm_running=1; im->tm_running = 1;
if (!mod_timer(&im->timer, jiffies+tv+2)) if (!mod_timer(&im->timer, jiffies+tv+2))
atomic_inc(&im->refcnt); atomic_inc(&im->refcnt);
} }
...@@ -207,7 +207,7 @@ static void igmp_mod_timer(struct ip_mc_list *im, int max_delay) ...@@ -207,7 +207,7 @@ static void igmp_mod_timer(struct ip_mc_list *im, int max_delay)
if (del_timer(&im->timer)) { if (del_timer(&im->timer)) {
if ((long)(im->timer.expires-jiffies) < max_delay) { if ((long)(im->timer.expires-jiffies) < max_delay) {
add_timer(&im->timer); add_timer(&im->timer);
im->tm_running=1; im->tm_running = 1;
spin_unlock_bh(&im->lock); spin_unlock_bh(&im->lock);
return; return;
} }
...@@ -358,7 +358,7 @@ static int igmpv3_sendpack(struct sk_buff *skb) ...@@ -358,7 +358,7 @@ static int igmpv3_sendpack(struct sk_buff *skb)
static int grec_size(struct ip_mc_list *pmc, int type, int gdel, int sdel) static int grec_size(struct ip_mc_list *pmc, int type, int gdel, int sdel)
{ {
return sizeof(struct igmpv3_grec) + 4*igmp_scount(pmc,type,gdel,sdel); return sizeof(struct igmpv3_grec) + 4*igmp_scount(pmc, type, gdel, sdel);
} }
static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc, static struct sk_buff *add_grhead(struct sk_buff *skb, struct ip_mc_list *pmc,
...@@ -653,7 +653,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc, ...@@ -653,7 +653,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
return -1; return -1;
} }
skb=alloc_skb(IGMP_SIZE+LL_ALLOCATED_SPACE(dev), GFP_ATOMIC); skb = alloc_skb(IGMP_SIZE+LL_ALLOCATED_SPACE(dev), GFP_ATOMIC);
if (skb == NULL) { if (skb == NULL) {
ip_rt_put(rt); ip_rt_put(rt);
return -1; return -1;
...@@ -682,11 +682,11 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc, ...@@ -682,11 +682,11 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
((u8*)&iph[1])[3] = 0; ((u8*)&iph[1])[3] = 0;
ih = (struct igmphdr *)skb_put(skb, sizeof(struct igmphdr)); ih = (struct igmphdr *)skb_put(skb, sizeof(struct igmphdr));
ih->type=type; ih->type = type;
ih->code=0; ih->code = 0;
ih->csum=0; ih->csum = 0;
ih->group=group; ih->group = group;
ih->csum=ip_compute_csum((void *)ih, sizeof(struct igmphdr)); ih->csum = ip_compute_csum((void *)ih, sizeof(struct igmphdr));
return ip_local_out(skb); return ip_local_out(skb);
} }
...@@ -728,7 +728,7 @@ static void igmp_timer_expire(unsigned long data) ...@@ -728,7 +728,7 @@ static void igmp_timer_expire(unsigned long data)
struct in_device *in_dev = im->interface; struct in_device *in_dev = im->interface;
spin_lock(&im->lock); spin_lock(&im->lock);
im->tm_running=0; im->tm_running = 0;
if (im->unsolicit_count) { if (im->unsolicit_count) {
im->unsolicit_count--; im->unsolicit_count--;
...@@ -997,7 +997,7 @@ static void ip_mc_filter_add(struct in_device *in_dev, __be32 addr) ...@@ -997,7 +997,7 @@ static void ip_mc_filter_add(struct in_device *in_dev, __be32 addr)
--ANK --ANK
*/ */
if (arp_mc_map(addr, buf, dev, 0) == 0) if (arp_mc_map(addr, buf, dev, 0) == 0)
dev_mc_add(dev,buf,dev->addr_len,0); dev_mc_add(dev, buf, dev->addr_len, 0);
} }
/* /*
...@@ -1010,7 +1010,7 @@ static void ip_mc_filter_del(struct in_device *in_dev, __be32 addr) ...@@ -1010,7 +1010,7 @@ static void ip_mc_filter_del(struct in_device *in_dev, __be32 addr)
struct net_device *dev = in_dev->dev; struct net_device *dev = in_dev->dev;
if (arp_mc_map(addr, buf, dev, 0) == 0) if (arp_mc_map(addr, buf, dev, 0) == 0)
dev_mc_delete(dev,buf,dev->addr_len,0); dev_mc_delete(dev, buf, dev->addr_len, 0);
} }
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
...@@ -1210,10 +1210,10 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) ...@@ -1210,10 +1210,10 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
if (!im) if (!im)
goto out; goto out;
im->users=1; im->users = 1;
im->interface=in_dev; im->interface = in_dev;
in_dev_hold(in_dev); in_dev_hold(in_dev);
im->multiaddr=addr; im->multiaddr = addr;
/* initial mode is (EX, empty) */ /* initial mode is (EX, empty) */
im->sfmode = MCAST_EXCLUDE; im->sfmode = MCAST_EXCLUDE;
im->sfcount[MCAST_INCLUDE] = 0; im->sfcount[MCAST_INCLUDE] = 0;
...@@ -1224,7 +1224,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) ...@@ -1224,7 +1224,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
atomic_set(&im->refcnt, 1); atomic_set(&im->refcnt, 1);
spin_lock_init(&im->lock); spin_lock_init(&im->lock);
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
im->tm_running=0; im->tm_running = 0;
setup_timer(&im->timer, &igmp_timer_expire, (unsigned long)im); setup_timer(&im->timer, &igmp_timer_expire, (unsigned long)im);
im->unsolicit_count = IGMP_Unsolicited_Report_Count; im->unsolicit_count = IGMP_Unsolicited_Report_Count;
im->reporter = 0; im->reporter = 0;
...@@ -1232,8 +1232,8 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) ...@@ -1232,8 +1232,8 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
#endif #endif
im->loaded = 0; im->loaded = 0;
write_lock_bh(&in_dev->mc_list_lock); write_lock_bh(&in_dev->mc_list_lock);
im->next=in_dev->mc_list; im->next = in_dev->mc_list;
in_dev->mc_list=im; in_dev->mc_list = im;
in_dev->mc_count++; in_dev->mc_count++;
write_unlock_bh(&in_dev->mc_list_lock); write_unlock_bh(&in_dev->mc_list_lock);
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
...@@ -1279,7 +1279,7 @@ void ip_mc_dec_group(struct in_device *in_dev, __be32 addr) ...@@ -1279,7 +1279,7 @@ void ip_mc_dec_group(struct in_device *in_dev, __be32 addr)
ASSERT_RTNL(); ASSERT_RTNL();
for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) { for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) {
if (i->multiaddr==addr) { if (i->multiaddr == addr) {
if (--i->users == 0) { if (--i->users == 0) {
write_lock_bh(&in_dev->mc_list_lock); write_lock_bh(&in_dev->mc_list_lock);
*ip = i->next; *ip = i->next;
...@@ -1738,7 +1738,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr) ...@@ -1738,7 +1738,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
{ {
int err; int err;
__be32 addr = imr->imr_multiaddr.s_addr; __be32 addr = imr->imr_multiaddr.s_addr;
struct ip_mc_socklist *iml=NULL, *i; struct ip_mc_socklist *iml = NULL, *i;
struct in_device *in_dev; struct in_device *in_dev;
struct inet_sock *inet = inet_sk(sk); struct inet_sock *inet = inet_sk(sk);
struct net *net = sock_net(sk); struct net *net = sock_net(sk);
...@@ -1769,7 +1769,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr) ...@@ -1769,7 +1769,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
err = -ENOBUFS; err = -ENOBUFS;
if (count >= sysctl_igmp_max_memberships) if (count >= sysctl_igmp_max_memberships)
goto done; goto done;
iml = sock_kmalloc(sk,sizeof(*iml),GFP_KERNEL); iml = sock_kmalloc(sk, sizeof(*iml), GFP_KERNEL);
if (iml == NULL) if (iml == NULL)
goto done; goto done;
......
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