phonet: use phonet_pernet instead of directly net_generic
As in for example pppoe introduce phonet_pernet and use it instead of calling net_generic directly. Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b3c981d2bb
commit
0db3f0f49a
|
@ -46,9 +46,16 @@ struct phonet_net {
|
||||||
|
|
||||||
int phonet_net_id __read_mostly;
|
int phonet_net_id __read_mostly;
|
||||||
|
|
||||||
|
static struct phonet_net *phonet_pernet(struct net *net)
|
||||||
|
{
|
||||||
|
BUG_ON(!net);
|
||||||
|
|
||||||
|
return net_generic(net, phonet_net_id);
|
||||||
|
}
|
||||||
|
|
||||||
struct phonet_device_list *phonet_device_list(struct net *net)
|
struct phonet_device_list *phonet_device_list(struct net *net)
|
||||||
{
|
{
|
||||||
struct phonet_net *pnn = net_generic(net, phonet_net_id);
|
struct phonet_net *pnn = phonet_pernet(net);
|
||||||
return &pnn->pndevs;
|
return &pnn->pndevs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +268,7 @@ static int phonet_device_autoconf(struct net_device *dev)
|
||||||
|
|
||||||
static void phonet_route_autodel(struct net_device *dev)
|
static void phonet_route_autodel(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct phonet_net *pnn = net_generic(dev_net(dev), phonet_net_id);
|
struct phonet_net *pnn = phonet_pernet(dev_net(dev));
|
||||||
unsigned i;
|
unsigned i;
|
||||||
DECLARE_BITMAP(deleted, 64);
|
DECLARE_BITMAP(deleted, 64);
|
||||||
|
|
||||||
|
@ -313,7 +320,7 @@ static struct notifier_block phonet_device_notifier = {
|
||||||
/* Per-namespace Phonet devices handling */
|
/* Per-namespace Phonet devices handling */
|
||||||
static int __net_init phonet_init_net(struct net *net)
|
static int __net_init phonet_init_net(struct net *net)
|
||||||
{
|
{
|
||||||
struct phonet_net *pnn = net_generic(net, phonet_net_id);
|
struct phonet_net *pnn = phonet_pernet(net);
|
||||||
|
|
||||||
if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops))
|
if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -326,7 +333,7 @@ static int __net_init phonet_init_net(struct net *net)
|
||||||
|
|
||||||
static void __net_exit phonet_exit_net(struct net *net)
|
static void __net_exit phonet_exit_net(struct net *net)
|
||||||
{
|
{
|
||||||
struct phonet_net *pnn = net_generic(net, phonet_net_id);
|
struct phonet_net *pnn = phonet_pernet(net);
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
@ -376,7 +383,7 @@ void phonet_device_exit(void)
|
||||||
|
|
||||||
int phonet_route_add(struct net_device *dev, u8 daddr)
|
int phonet_route_add(struct net_device *dev, u8 daddr)
|
||||||
{
|
{
|
||||||
struct phonet_net *pnn = net_generic(dev_net(dev), phonet_net_id);
|
struct phonet_net *pnn = phonet_pernet(dev_net(dev));
|
||||||
struct phonet_routes *routes = &pnn->routes;
|
struct phonet_routes *routes = &pnn->routes;
|
||||||
int err = -EEXIST;
|
int err = -EEXIST;
|
||||||
|
|
||||||
|
@ -393,7 +400,7 @@ int phonet_route_add(struct net_device *dev, u8 daddr)
|
||||||
|
|
||||||
int phonet_route_del(struct net_device *dev, u8 daddr)
|
int phonet_route_del(struct net_device *dev, u8 daddr)
|
||||||
{
|
{
|
||||||
struct phonet_net *pnn = net_generic(dev_net(dev), phonet_net_id);
|
struct phonet_net *pnn = phonet_pernet(dev_net(dev));
|
||||||
struct phonet_routes *routes = &pnn->routes;
|
struct phonet_routes *routes = &pnn->routes;
|
||||||
|
|
||||||
daddr = daddr >> 2;
|
daddr = daddr >> 2;
|
||||||
|
@ -413,7 +420,7 @@ int phonet_route_del(struct net_device *dev, u8 daddr)
|
||||||
|
|
||||||
struct net_device *phonet_route_get(struct net *net, u8 daddr)
|
struct net_device *phonet_route_get(struct net *net, u8 daddr)
|
||||||
{
|
{
|
||||||
struct phonet_net *pnn = net_generic(net, phonet_net_id);
|
struct phonet_net *pnn = phonet_pernet(net);
|
||||||
struct phonet_routes *routes = &pnn->routes;
|
struct phonet_routes *routes = &pnn->routes;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
|
||||||
|
@ -428,7 +435,7 @@ struct net_device *phonet_route_get(struct net *net, u8 daddr)
|
||||||
|
|
||||||
struct net_device *phonet_route_output(struct net *net, u8 daddr)
|
struct net_device *phonet_route_output(struct net *net, u8 daddr)
|
||||||
{
|
{
|
||||||
struct phonet_net *pnn = net_generic(net, phonet_net_id);
|
struct phonet_net *pnn = phonet_pernet(net);
|
||||||
struct phonet_routes *routes = &pnn->routes;
|
struct phonet_routes *routes = &pnn->routes;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue