Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 133888
b: refs/heads/master
c: 70a269e
h: refs/heads/master
v: v3
  • Loading branch information
Benjamin Thery authored and David S. Miller committed Jan 22, 2009
1 parent 9eaaad5 commit d3e8f6f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e35fac80ed0bb878f652cc0f70ca268656d275f7
refs/heads/master: 70a269e6c9c9b38b1a37dce068c59e9a912f8578
4 changes: 4 additions & 0 deletions trunk/include/net/netns/ipv4.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,9 @@ struct netns_ipv4 {

struct timer_list rt_secret_timer;
atomic_t rt_genid;

#ifdef CONFIG_IP_MROUTE
struct sock *mroute_sk;
#endif
};
#endif
28 changes: 13 additions & 15 deletions trunk/net/ipv4/ipmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@
#define CONFIG_IP_PIMSM 1
#endif

static struct sock *mroute_socket;


/* Big lock, protecting vif table, mrt cache and mroute socket state.
Note that the changes are semaphored via rtnl_lock.
*/
Expand Down Expand Up @@ -658,15 +655,16 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert)
skb->transport_header = skb->network_header;
}

if (mroute_socket == NULL) {
if (init_net.ipv4.mroute_sk == NULL) {
kfree_skb(skb);
return -EINVAL;
}

/*
* Deliver to mrouted
*/
if ((ret = sock_queue_rcv_skb(mroute_socket, skb))<0) {
ret = sock_queue_rcv_skb(init_net.ipv4.mroute_sk, skb);
if (ret < 0) {
if (net_ratelimit())
printk(KERN_WARNING "mroute: pending queue full, dropping entries.\n");
kfree_skb(skb);
Expand Down Expand Up @@ -896,11 +894,11 @@ static void mroute_clean_tables(struct sock *sk)
static void mrtsock_destruct(struct sock *sk)
{
rtnl_lock();
if (sk == mroute_socket) {
if (sk == init_net.ipv4.mroute_sk) {
IPV4_DEVCONF_ALL(sock_net(sk), MC_FORWARDING)--;

write_lock_bh(&mrt_lock);
mroute_socket = NULL;
init_net.ipv4.mroute_sk = NULL;
write_unlock_bh(&mrt_lock);

mroute_clean_tables(sk);
Expand All @@ -922,7 +920,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int
struct mfcctl mfc;

if (optname != MRT_INIT) {
if (sk != mroute_socket && !capable(CAP_NET_ADMIN))
if (sk != init_net.ipv4.mroute_sk && !capable(CAP_NET_ADMIN))
return -EACCES;
}

Expand All @@ -935,23 +933,23 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int
return -ENOPROTOOPT;

rtnl_lock();
if (mroute_socket) {
if (init_net.ipv4.mroute_sk) {
rtnl_unlock();
return -EADDRINUSE;
}

ret = ip_ra_control(sk, 1, mrtsock_destruct);
if (ret == 0) {
write_lock_bh(&mrt_lock);
mroute_socket = sk;
init_net.ipv4.mroute_sk = sk;
write_unlock_bh(&mrt_lock);

IPV4_DEVCONF_ALL(sock_net(sk), MC_FORWARDING)++;
}
rtnl_unlock();
return ret;
case MRT_DONE:
if (sk != mroute_socket)
if (sk != init_net.ipv4.mroute_sk)
return -EACCES;
return ip_ra_control(sk, 0, NULL);
case MRT_ADD_VIF:
Expand All @@ -964,7 +962,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int
return -ENFILE;
rtnl_lock();
if (optname == MRT_ADD_VIF) {
ret = vif_add(&vif, sk==mroute_socket);
ret = vif_add(&vif, sk == init_net.ipv4.mroute_sk);
} else {
ret = vif_delete(vif.vifc_vifi, 0);
}
Expand All @@ -985,7 +983,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int
if (optname == MRT_DEL_MFC)
ret = ipmr_mfc_delete(&mfc);
else
ret = ipmr_mfc_add(&mfc, sk==mroute_socket);
ret = ipmr_mfc_add(&mfc, sk == init_net.ipv4.mroute_sk);
rtnl_unlock();
return ret;
/*
Expand Down Expand Up @@ -1425,9 +1423,9 @@ int ip_mr_input(struct sk_buff *skb)
that we can forward NO IGMP messages.
*/
read_lock(&mrt_lock);
if (mroute_socket) {
if (init_net.ipv4.mroute_sk) {
nf_reset(skb);
raw_rcv(mroute_socket, skb);
raw_rcv(init_net.ipv4.mroute_sk, skb);
read_unlock(&mrt_lock);
return 0;
}
Expand Down

0 comments on commit d3e8f6f

Please sign in to comment.