* [PATCH net-next 0/6] Phonet improvements
@ 2009-01-23 12:59 Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 1/6] Phonet: move to Networking options like other protocol stacks Rémi Denis-Courmont
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Rémi Denis-Courmont @ 2009-01-23 12:59 UTC (permalink / raw)
To: netdev
Hello,
There come a few fixes and cleanups of the Phonet stack.
Comments welcome.
Diff stat:
include/net/phonet/phonet.h | 1
include/net/phonet/pn_dev.h | 7 +-
net/Kconfig | 2
net/phonet/af_phonet.c | 29 +++++-----
net/phonet/pn_dev.c | 127 +++++++++++++++++++++++++++++---------------
net/phonet/pn_netlink.c | 24 ++++----
6 files changed, 119 insertions(+), 71 deletions(-)
--
Rémi Denis-Courmont
Maemo Software, Nokia Devices R&D
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/6] Phonet: move to Networking options like other protocol stacks
2009-01-23 12:59 [PATCH net-next 0/6] Phonet improvements Rémi Denis-Courmont
@ 2009-01-23 13:00 ` Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 2/6] Phonet: check destination before delivering packets locally Rémi Denis-Courmont
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Rémi Denis-Courmont @ 2009-01-23 13:00 UTC (permalink / raw)
To: netdev
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
---
net/Kconfig | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/Kconfig b/net/Kconfig
index bf27760..4640c3b 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -193,6 +193,7 @@ source "net/x25/Kconfig"
source "net/lapb/Kconfig"
source "net/econet/Kconfig"
source "net/wanrouter/Kconfig"
+source "net/phonet/Kconfig"
source "net/sched/Kconfig"
source "net/dcb/Kconfig"
@@ -237,7 +238,6 @@ source "net/can/Kconfig"
source "net/irda/Kconfig"
source "net/bluetooth/Kconfig"
source "net/rxrpc/Kconfig"
-source "net/phonet/Kconfig"
config FIB_RULES
bool
--
1.5.6.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/6] Phonet: check destination before delivering packets locally
2009-01-23 12:59 [PATCH net-next 0/6] Phonet improvements Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 1/6] Phonet: move to Networking options like other protocol stacks Rémi Denis-Courmont
@ 2009-01-23 13:00 ` Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 3/6] Phonet: allow phonet_device_init() to fail, put it to __init section Rémi Denis-Courmont
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Rémi Denis-Courmont @ 2009-01-23 13:00 UTC (permalink / raw)
To: netdev
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
---
net/phonet/af_phonet.c | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
index 13cb323..c7c39d9 100644
--- a/net/phonet/af_phonet.c
+++ b/net/phonet/af_phonet.c
@@ -275,8 +275,6 @@ static inline int can_respond(struct sk_buff *skb)
return 0;
ph = pn_hdr(skb);
- if (phonet_address_get(skb->dev, ph->pn_rdev) != ph->pn_rdev)
- return 0; /* we are not the destination */
if (ph->pn_res == PN_PREFIX && !pskb_may_pull(skb, 5))
return 0;
if (ph->pn_res == PN_COMMGR) /* indications */
@@ -344,8 +342,8 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pkttype,
struct net_device *orig_dev)
{
+ struct net *net = dev_net(dev);
struct phonethdr *ph;
- struct sock *sk;
struct sockaddr_pn sa;
u16 len;
@@ -364,21 +362,21 @@ static int phonet_rcv(struct sk_buff *skb, struct net_device *dev,
skb_reset_transport_header(skb);
pn_skb_get_dst_sockaddr(skb, &sa);
- if (pn_sockaddr_get_addr(&sa) == 0)
- goto out; /* currently, we cannot be device 0 */
- sk = pn_find_sock_by_sa(dev_net(dev), &sa);
- if (sk == NULL) {
+ /* check if we are the destination */
+ if (phonet_address_lookup(net, pn_sockaddr_get_addr(&sa)) == 0) {
+ /* Phonet packet input */
+ struct sock *sk = pn_find_sock_by_sa(net, &sa);
+
+ if (sk)
+ return sk_receive_skb(sk, skb, 0);
+
if (can_respond(skb)) {
send_obj_unreachable(skb);
send_reset_indications(skb);
}
- goto out;
}
- /* Push data to the socket (or other sockets connected to it). */
- return sk_receive_skb(sk, skb, 0);
-
out:
kfree_skb(skb);
return NET_RX_DROP;
--
1.5.6.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/6] Phonet: allow phonet_device_init() to fail, put it to __init section
2009-01-23 12:59 [PATCH net-next 0/6] Phonet improvements Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 1/6] Phonet: move to Networking options like other protocol stacks Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 2/6] Phonet: check destination before delivering packets locally Rémi Denis-Courmont
@ 2009-01-23 13:00 ` Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 4/6] Phonet: handle rtnetlink registration failure Rémi Denis-Courmont
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Rémi Denis-Courmont @ 2009-01-23 13:00 UTC (permalink / raw)
To: netdev
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
---
include/net/phonet/phonet.h | 1 -
include/net/phonet/pn_dev.h | 3 ++-
net/phonet/af_phonet.c | 9 ++++++---
net/phonet/pn_dev.c | 4 +++-
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h
index 057b0a8..d43f71b 100644
--- a/include/net/phonet/phonet.h
+++ b/include/net/phonet/phonet.h
@@ -105,7 +105,6 @@ void phonet_proto_unregister(int protocol, struct phonet_protocol *pp);
int phonet_sysctl_init(void);
void phonet_sysctl_exit(void);
-void phonet_netlink_register(void);
int isi_register(void);
void isi_unregister(void);
diff --git a/include/net/phonet/pn_dev.h b/include/net/phonet/pn_dev.h
index aa1c59a..59ae628 100644
--- a/include/net/phonet/pn_dev.h
+++ b/include/net/phonet/pn_dev.h
@@ -36,8 +36,9 @@ struct phonet_device {
DECLARE_BITMAP(addrs, 64);
};
-void phonet_device_init(void);
+int phonet_device_init(void);
void phonet_device_exit(void);
+void phonet_netlink_register(void);
struct net_device *phonet_device_get(struct net *net);
int phonet_address_add(struct net_device *dev, u8 addr);
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
index c7c39d9..95bc49d 100644
--- a/net/phonet/af_phonet.c
+++ b/net/phonet/af_phonet.c
@@ -426,16 +426,18 @@ static int __init phonet_init(void)
{
int err;
+ err = phonet_device_init();
+ if (err)
+ return err;
+
err = sock_register(&phonet_proto_family);
if (err) {
printk(KERN_ALERT
"phonet protocol family initialization failed\n");
- return err;
+ goto err_sock;
}
- phonet_device_init();
dev_add_pack(&phonet_packet_type);
- phonet_netlink_register();
phonet_sysctl_init();
err = isi_register();
@@ -447,6 +449,7 @@ err:
phonet_sysctl_exit();
sock_unregister(PF_PHONET);
dev_remove_pack(&phonet_packet_type);
+err_sock:
phonet_device_exit();
return err;
}
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index 5491bf5..af49db0 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -188,9 +188,11 @@ static struct notifier_block phonet_device_notifier = {
};
/* Initialize Phonet devices list */
-void phonet_device_init(void)
+int __init phonet_device_init(void)
{
register_netdevice_notifier(&phonet_device_notifier);
+ phonet_netlink_register();
+ return 0;
}
void phonet_device_exit(void)
--
1.5.6.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/6] Phonet: handle rtnetlink registration failure
2009-01-23 12:59 [PATCH net-next 0/6] Phonet improvements Rémi Denis-Courmont
` (2 preceding siblings ...)
2009-01-23 13:00 ` [PATCH 3/6] Phonet: allow phonet_device_init() to fail, put it to __init section Rémi Denis-Courmont
@ 2009-01-23 13:00 ` Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 5/6] Phonet: remove useless locking in device cleanup Rémi Denis-Courmont
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Rémi Denis-Courmont @ 2009-01-23 13:00 UTC (permalink / raw)
To: netdev
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
---
include/net/phonet/pn_dev.h | 2 +-
net/phonet/pn_dev.c | 8 ++++++--
net/phonet/pn_netlink.c | 13 +++++++++----
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/include/net/phonet/pn_dev.h b/include/net/phonet/pn_dev.h
index 59ae628..4ba2aed 100644
--- a/include/net/phonet/pn_dev.h
+++ b/include/net/phonet/pn_dev.h
@@ -38,7 +38,7 @@ struct phonet_device {
int phonet_device_init(void);
void phonet_device_exit(void);
-void phonet_netlink_register(void);
+int phonet_netlink_register(void);
struct net_device *phonet_device_get(struct net *net);
int phonet_address_add(struct net_device *dev, u8 addr);
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index af49db0..fd41810 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -190,9 +190,13 @@ static struct notifier_block phonet_device_notifier = {
/* Initialize Phonet devices list */
int __init phonet_device_init(void)
{
+ int err;
+
register_netdevice_notifier(&phonet_device_notifier);
- phonet_netlink_register();
- return 0;
+ err = phonet_netlink_register();
+ if (err)
+ phonet_device_exit();
+ return err;
}
void phonet_device_exit(void)
diff --git a/net/phonet/pn_netlink.c b/net/phonet/pn_netlink.c
index 242fe8f..918a4f0 100644
--- a/net/phonet/pn_netlink.c
+++ b/net/phonet/pn_netlink.c
@@ -160,9 +160,14 @@ out:
return skb->len;
}
-void __init phonet_netlink_register(void)
+int __init phonet_netlink_register(void)
{
- rtnl_register(PF_PHONET, RTM_NEWADDR, addr_doit, NULL);
- rtnl_register(PF_PHONET, RTM_DELADDR, addr_doit, NULL);
- rtnl_register(PF_PHONET, RTM_GETADDR, NULL, getaddr_dumpit);
+ int err = __rtnl_register(PF_PHONET, RTM_NEWADDR, addr_doit, NULL);
+ if (err)
+ return err;
+
+ /* Further __rtnl_register() cannot fail */
+ __rtnl_register(PF_PHONET, RTM_DELADDR, addr_doit, NULL);
+ __rtnl_register(PF_PHONET, RTM_GETADDR, NULL, getaddr_dumpit);
+ return 0;
}
--
1.5.6.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/6] Phonet: remove useless locking in device cleanup
2009-01-23 12:59 [PATCH net-next 0/6] Phonet improvements Rémi Denis-Courmont
` (3 preceding siblings ...)
2009-01-23 13:00 ` [PATCH 4/6] Phonet: handle rtnetlink registration failure Rémi Denis-Courmont
@ 2009-01-23 13:00 ` Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 6/6] Phonet: use per-namespace devices list Rémi Denis-Courmont
2009-01-27 5:04 ` [PATCH net-next 0/6] Phonet improvements David Miller
6 siblings, 0 replies; 8+ messages in thread
From: Rémi Denis-Courmont @ 2009-01-23 13:00 UTC (permalink / raw)
To: netdev
Incoming packets and sockets are already gone.
The netdevice notifier is unregistered under the RTNL lock
There remains a race with the rtnetlink handlers unregistration, but it
is a generic RTNL issue that was already present before this change.
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
---
net/phonet/pn_dev.c | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index fd41810..3e24c05 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -204,13 +204,8 @@ void phonet_device_exit(void)
struct phonet_device *pnd, *n;
rtnl_unregister_all(PF_PHONET);
- rtnl_lock();
- spin_lock_bh(&pndevs.lock);
+ unregister_netdevice_notifier(&phonet_device_notifier);
list_for_each_entry_safe(pnd, n, &pndevs.list, list)
__phonet_device_free(pnd);
-
- spin_unlock_bh(&pndevs.lock);
- rtnl_unlock();
- unregister_netdevice_notifier(&phonet_device_notifier);
}
--
1.5.6.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/6] Phonet: use per-namespace devices list
2009-01-23 12:59 [PATCH net-next 0/6] Phonet improvements Rémi Denis-Courmont
` (4 preceding siblings ...)
2009-01-23 13:00 ` [PATCH 5/6] Phonet: remove useless locking in device cleanup Rémi Denis-Courmont
@ 2009-01-23 13:00 ` Rémi Denis-Courmont
2009-01-27 5:04 ` [PATCH net-next 0/6] Phonet improvements David Miller
6 siblings, 0 replies; 8+ messages in thread
From: Rémi Denis-Courmont @ 2009-01-23 13:00 UTC (permalink / raw)
To: netdev
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
---
include/net/phonet/pn_dev.h | 2 +-
net/phonet/pn_dev.c | 108 ++++++++++++++++++++++++++++++-------------
net/phonet/pn_netlink.c | 11 ++--
3 files changed, 81 insertions(+), 40 deletions(-)
diff --git a/include/net/phonet/pn_dev.h b/include/net/phonet/pn_dev.h
index 4ba2aed..5054dc5 100644
--- a/include/net/phonet/pn_dev.h
+++ b/include/net/phonet/pn_dev.h
@@ -28,7 +28,7 @@ struct phonet_device_list {
spinlock_t lock;
};
-extern struct phonet_device_list pndevs;
+struct phonet_device_list *phonet_device_list(struct net *net);
struct phonet_device {
struct list_head list;
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index 3e24c05..80a322d 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -28,32 +28,41 @@
#include <linux/netdevice.h>
#include <linux/phonet.h>
#include <net/sock.h>
+#include <net/netns/generic.h>
#include <net/phonet/pn_dev.h>
-/* when accessing, remember to lock with spin_lock(&pndevs.lock); */
-struct phonet_device_list pndevs = {
- .list = LIST_HEAD_INIT(pndevs.list),
- .lock = __SPIN_LOCK_UNLOCKED(pndevs.lock),
+struct phonet_net {
+ struct phonet_device_list pndevs;
};
+int phonet_net_id;
+
+struct phonet_device_list *phonet_device_list(struct net *net)
+{
+ struct phonet_net *pnn = net_generic(net, phonet_net_id);
+ return &pnn->pndevs;
+}
+
/* Allocate new Phonet device. */
static struct phonet_device *__phonet_device_alloc(struct net_device *dev)
{
+ struct phonet_device_list *pndevs = phonet_device_list(dev_net(dev));
struct phonet_device *pnd = kmalloc(sizeof(*pnd), GFP_ATOMIC);
if (pnd == NULL)
return NULL;
pnd->netdev = dev;
bitmap_zero(pnd->addrs, 64);
- list_add(&pnd->list, &pndevs.list);
+ list_add(&pnd->list, &pndevs->list);
return pnd;
}
static struct phonet_device *__phonet_get(struct net_device *dev)
{
+ struct phonet_device_list *pndevs = phonet_device_list(dev_net(dev));
struct phonet_device *pnd;
- list_for_each_entry(pnd, &pndevs.list, list) {
+ list_for_each_entry(pnd, &pndevs->list, list) {
if (pnd->netdev == dev)
return pnd;
}
@@ -68,32 +77,33 @@ static void __phonet_device_free(struct phonet_device *pnd)
struct net_device *phonet_device_get(struct net *net)
{
+ struct phonet_device_list *pndevs = phonet_device_list(net);
struct phonet_device *pnd;
struct net_device *dev;
- spin_lock_bh(&pndevs.lock);
- list_for_each_entry(pnd, &pndevs.list, list) {
+ spin_lock_bh(&pndevs->lock);
+ list_for_each_entry(pnd, &pndevs->list, list) {
dev = pnd->netdev;
BUG_ON(!dev);
- if (net_eq(dev_net(dev), net) &&
- (dev->reg_state == NETREG_REGISTERED) &&
+ if ((dev->reg_state == NETREG_REGISTERED) &&
((pnd->netdev->flags & IFF_UP)) == IFF_UP)
break;
dev = NULL;
}
if (dev)
dev_hold(dev);
- spin_unlock_bh(&pndevs.lock);
+ spin_unlock_bh(&pndevs->lock);
return dev;
}
int phonet_address_add(struct net_device *dev, u8 addr)
{
+ struct phonet_device_list *pndevs = phonet_device_list(dev_net(dev));
struct phonet_device *pnd;
int err = 0;
- spin_lock_bh(&pndevs.lock);
+ spin_lock_bh(&pndevs->lock);
/* Find or create Phonet-specific device data */
pnd = __phonet_get(dev);
if (pnd == NULL)
@@ -102,31 +112,33 @@ int phonet_address_add(struct net_device *dev, u8 addr)
err = -ENOMEM;
else if (test_and_set_bit(addr >> 2, pnd->addrs))
err = -EEXIST;
- spin_unlock_bh(&pndevs.lock);
+ spin_unlock_bh(&pndevs->lock);
return err;
}
int phonet_address_del(struct net_device *dev, u8 addr)
{
+ struct phonet_device_list *pndevs = phonet_device_list(dev_net(dev));
struct phonet_device *pnd;
int err = 0;
- spin_lock_bh(&pndevs.lock);
+ spin_lock_bh(&pndevs->lock);
pnd = __phonet_get(dev);
if (!pnd || !test_and_clear_bit(addr >> 2, pnd->addrs))
err = -EADDRNOTAVAIL;
else if (bitmap_empty(pnd->addrs, 64))
__phonet_device_free(pnd);
- spin_unlock_bh(&pndevs.lock);
+ spin_unlock_bh(&pndevs->lock);
return err;
}
/* Gets a source address toward a destination, through a interface. */
u8 phonet_address_get(struct net_device *dev, u8 addr)
{
+ struct phonet_device_list *pndevs = phonet_device_list(dev_net(dev));
struct phonet_device *pnd;
- spin_lock_bh(&pndevs.lock);
+ spin_lock_bh(&pndevs->lock);
pnd = __phonet_get(dev);
if (pnd) {
BUG_ON(bitmap_empty(pnd->addrs, 64));
@@ -136,30 +148,31 @@ u8 phonet_address_get(struct net_device *dev, u8 addr)
addr = find_first_bit(pnd->addrs, 64) << 2;
} else
addr = PN_NO_ADDR;
- spin_unlock_bh(&pndevs.lock);
+ spin_unlock_bh(&pndevs->lock);
return addr;
}
int phonet_address_lookup(struct net *net, u8 addr)
{
+ struct phonet_device_list *pndevs = phonet_device_list(net);
struct phonet_device *pnd;
+ int err = -EADDRNOTAVAIL;
- spin_lock_bh(&pndevs.lock);
- list_for_each_entry(pnd, &pndevs.list, list) {
- if (!net_eq(dev_net(pnd->netdev), net))
- continue;
+ spin_lock_bh(&pndevs->lock);
+ list_for_each_entry(pnd, &pndevs->list, list) {
/* Don't allow unregistering devices! */
if ((pnd->netdev->reg_state != NETREG_REGISTERED) ||
((pnd->netdev->flags & IFF_UP)) != IFF_UP)
continue;
if (test_bit(addr >> 2, pnd->addrs)) {
- spin_unlock_bh(&pndevs.lock);
- return 0;
+ err = 0;
+ goto found;
}
}
- spin_unlock_bh(&pndevs.lock);
- return -EADDRNOTAVAIL;
+found:
+ spin_unlock_bh(&pndevs->lock);
+ return err;
}
/* notify Phonet of device events */
@@ -169,14 +182,16 @@ static int phonet_device_notify(struct notifier_block *me, unsigned long what,
struct net_device *dev = arg;
if (what == NETDEV_UNREGISTER) {
+ struct phonet_device_list *pndevs;
struct phonet_device *pnd;
/* Destroy phonet-specific device data */
- spin_lock_bh(&pndevs.lock);
+ pndevs = phonet_device_list(dev_net(dev));
+ spin_lock_bh(&pndevs->lock);
pnd = __phonet_get(dev);
if (pnd)
__phonet_device_free(pnd);
- spin_unlock_bh(&pndevs.lock);
+ spin_unlock_bh(&pndevs->lock);
}
return 0;
@@ -187,10 +202,41 @@ static struct notifier_block phonet_device_notifier = {
.priority = 0,
};
+/* Per-namespace Phonet devices handling */
+static int phonet_init_net(struct net *net)
+{
+ struct phonet_net *pnn = kmalloc(sizeof(*pnn), GFP_KERNEL);
+ if (!pnn)
+ return -ENOMEM;
+
+ INIT_LIST_HEAD(&pnn->pndevs.list);
+ spin_lock_init(&pnn->pndevs.lock);
+ net_assign_generic(net, phonet_net_id, pnn);
+ return 0;
+}
+
+static void phonet_exit_net(struct net *net)
+{
+ struct phonet_net *pnn = net_generic(net, phonet_net_id);
+ struct phonet_device *pnd, *n;
+
+ list_for_each_entry_safe(pnd, n, &pnn->pndevs.list, list)
+ __phonet_device_free(pnd);
+
+ kfree(pnn);
+}
+
+static struct pernet_operations phonet_net_ops = {
+ .init = phonet_init_net,
+ .exit = phonet_exit_net,
+};
+
/* Initialize Phonet devices list */
int __init phonet_device_init(void)
{
- int err;
+ int err = register_pernet_gen_device(&phonet_net_id, &phonet_net_ops);
+ if (err)
+ return err;
register_netdevice_notifier(&phonet_device_notifier);
err = phonet_netlink_register();
@@ -201,11 +247,7 @@ int __init phonet_device_init(void)
void phonet_device_exit(void)
{
- struct phonet_device *pnd, *n;
-
rtnl_unregister_all(PF_PHONET);
unregister_netdevice_notifier(&phonet_device_notifier);
-
- list_for_each_entry_safe(pnd, n, &pndevs.list, list)
- __phonet_device_free(pnd);
+ unregister_pernet_gen_device(phonet_net_id, &phonet_net_ops);
}
diff --git a/net/phonet/pn_netlink.c b/net/phonet/pn_netlink.c
index 918a4f0..1ceea1f 100644
--- a/net/phonet/pn_netlink.c
+++ b/net/phonet/pn_netlink.c
@@ -123,17 +123,16 @@ nla_put_failure:
static int getaddr_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
{
- struct net *net = sock_net(skb->sk);
+ struct phonet_device_list *pndevs;
struct phonet_device *pnd;
int dev_idx = 0, dev_start_idx = cb->args[0];
int addr_idx = 0, addr_start_idx = cb->args[1];
- spin_lock_bh(&pndevs.lock);
- list_for_each_entry(pnd, &pndevs.list, list) {
+ pndevs = phonet_device_list(sock_net(skb->sk));
+ spin_lock_bh(&pndevs->lock);
+ list_for_each_entry(pnd, &pndevs->list, list) {
u8 addr;
- if (!net_eq(dev_net(pnd->netdev), net))
- continue;
if (dev_idx > dev_start_idx)
addr_start_idx = 0;
if (dev_idx++ < dev_start_idx)
@@ -153,7 +152,7 @@ static int getaddr_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
}
out:
- spin_unlock_bh(&pndevs.lock);
+ spin_unlock_bh(&pndevs->lock);
cb->args[0] = dev_idx;
cb->args[1] = addr_idx;
--
1.5.6.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 0/6] Phonet improvements
2009-01-23 12:59 [PATCH net-next 0/6] Phonet improvements Rémi Denis-Courmont
` (5 preceding siblings ...)
2009-01-23 13:00 ` [PATCH 6/6] Phonet: use per-namespace devices list Rémi Denis-Courmont
@ 2009-01-27 5:04 ` David Miller
6 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2009-01-27 5:04 UTC (permalink / raw)
To: remi.denis-courmont; +Cc: netdev
From: "Rémi Denis-Courmont" <remi.denis-courmont@nokia.com>
Date: Fri, 23 Jan 2009 14:59:29 +0200
> There come a few fixes and cleanups of the Phonet stack.
> Comments welcome.
All applied, thanks Rémi.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-01-27 5:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-23 12:59 [PATCH net-next 0/6] Phonet improvements Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 1/6] Phonet: move to Networking options like other protocol stacks Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 2/6] Phonet: check destination before delivering packets locally Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 3/6] Phonet: allow phonet_device_init() to fail, put it to __init section Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 4/6] Phonet: handle rtnetlink registration failure Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 5/6] Phonet: remove useless locking in device cleanup Rémi Denis-Courmont
2009-01-23 13:00 ` [PATCH 6/6] Phonet: use per-namespace devices list Rémi Denis-Courmont
2009-01-27 5:04 ` [PATCH net-next 0/6] Phonet improvements David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).