o pppoe: use revised net module infrastructure

Using sk_set_owner and having THIS_MODULE in the struct proto_ops registered 
with the core.
parent cfc7551c
...@@ -494,16 +494,21 @@ static int pppoe_create(struct socket *sock) ...@@ -494,16 +494,21 @@ static int pppoe_create(struct socket *sock)
struct sock *sk; struct sock *sk;
struct pppox_opt *po; struct pppox_opt *po;
sk = pppox_sk_alloc(sock, PX_PROTO_OE, GFP_KERNEL, 1, NULL); sk = sk_alloc(PF_PPPOX, GFP_KERNEL, 1, NULL);
if (!sk) if (!sk)
goto out; goto out;
sock_init_data(sock, sk);
sk_set_owner(sk, THIS_MODULE);
sock->state = SS_UNCONNECTED; sock->state = SS_UNCONNECTED;
sock->ops = &pppoe_ops; sock->ops = &pppoe_ops;
sk->backlog_rcv = pppoe_rcv_core; sk->backlog_rcv = pppoe_rcv_core;
sk->state = PPPOX_NONE; sk->state = PPPOX_NONE;
sk->type = SOCK_STREAM; sk->type = SOCK_STREAM;
sk->family = PF_PPPOX;
sk->protocol = PX_PROTO_OE;
sk->destruct = pppoe_sk_free;
po = pppox_sk(sk) = kmalloc(sizeof(*po), GFP_KERNEL); po = pppox_sk(sk) = kmalloc(sizeof(*po), GFP_KERNEL);
if (!po) if (!po)
...@@ -1062,10 +1067,12 @@ static struct file_operations pppoe_seq_fops = { ...@@ -1062,10 +1067,12 @@ static struct file_operations pppoe_seq_fops = {
}; };
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
/* ->release and ->ioctl are set at pppox_create */ /* ->ioctl are set at pppox_create */
struct proto_ops pppoe_ops = { struct proto_ops pppoe_ops = {
.family = AF_PPPOX, .family = AF_PPPOX,
.owner = THIS_MODULE,
.release = pppoe_release,
.bind = sock_no_bind, .bind = sock_no_bind,
.connect = pppoe_connect, .connect = pppoe_connect,
.socketpair = sock_no_socketpair, .socketpair = sock_no_socketpair,
...@@ -1084,8 +1091,6 @@ struct proto_ops pppoe_ops = { ...@@ -1084,8 +1091,6 @@ struct proto_ops pppoe_ops = {
struct pppox_proto pppoe_proto = { struct pppox_proto pppoe_proto = {
.create = pppoe_create, .create = pppoe_create,
.ioctl = pppoe_ioctl, .ioctl = pppoe_ioctl,
.release = pppoe_release,
.sk_free = pppoe_sk_free,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
......
...@@ -64,45 +64,9 @@ void pppox_unbind_sock(struct sock *sk) ...@@ -64,45 +64,9 @@ void pppox_unbind_sock(struct sock *sk)
} }
} }
static int pppox_release(struct socket *sock)
{
struct sock *sk = sock->sk;
int rc = pppox_protos[sk->protocol]->release(sock);
module_put(pppox_protos[sk->protocol]->owner);
return rc;
}
static void pppox_sk_free(struct sock *sk)
{
pppox_protos[sk->protocol]->sk_free(sk);
module_put(pppox_protos[sk->protocol]->owner);
}
struct sock *pppox_sk_alloc(struct socket *sock, int protocol, int priority,
int zero_it, kmem_cache_t *slab)
{
struct sock *sk = NULL;
if (!try_module_get(pppox_protos[protocol]->owner))
goto out;
sk = sk_alloc(PF_PPPOX, priority, zero_it, slab);
if (sk) {
sock_init_data(sock, sk);
sk->family = PF_PPPOX;
sk->protocol = protocol;
sk->destruct = pppox_sk_free;
} else
module_put(pppox_protos[protocol]->owner);
out:
return sk;
}
EXPORT_SYMBOL(register_pppox_proto); EXPORT_SYMBOL(register_pppox_proto);
EXPORT_SYMBOL(unregister_pppox_proto); EXPORT_SYMBOL(unregister_pppox_proto);
EXPORT_SYMBOL(pppox_unbind_sock); EXPORT_SYMBOL(pppox_unbind_sock);
EXPORT_SYMBOL(pppox_sk_alloc);
static int pppox_ioctl(struct socket* sock, unsigned int cmd, static int pppox_ioctl(struct socket* sock, unsigned int cmd,
unsigned long arg) unsigned long arg)
...@@ -156,11 +120,9 @@ static int pppox_create(struct socket *sock, int protocol) ...@@ -156,11 +120,9 @@ static int pppox_create(struct socket *sock, int protocol)
rc = pppox_protos[protocol]->create(sock); rc = pppox_protos[protocol]->create(sock);
if (!rc) { if (!rc) {
/* We get to set the ioctl handler. */ /* We get to set the ioctl handler. */
/* And the release handler, for module refcounting */
/* For everything else, pppox is just a shell. */ /* For everything else, pppox is just a shell. */
sock->ops->ioctl = pppox_ioctl; sock->ops->ioctl = pppox_ioctl;
sock->ops->release = pppox_release; }
} else
module_put(pppox_protos[protocol]->owner); module_put(pppox_protos[protocol]->owner);
out: out:
return rc; return rc;
......
...@@ -140,8 +140,6 @@ struct pppox_proto { ...@@ -140,8 +140,6 @@ struct pppox_proto {
int (*create)(struct socket *sock); int (*create)(struct socket *sock);
int (*ioctl)(struct socket *sock, unsigned int cmd, int (*ioctl)(struct socket *sock, unsigned int cmd,
unsigned long arg); unsigned long arg);
int (*release)(struct socket *sock);
void (*sk_free)(struct sock *sk);
struct module *owner; struct module *owner;
}; };
...@@ -150,9 +148,6 @@ extern void unregister_pppox_proto(int proto_num); ...@@ -150,9 +148,6 @@ extern void unregister_pppox_proto(int proto_num);
extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */ extern void pppox_unbind_sock(struct sock *sk);/* delete ppp-channel binding */
extern int pppox_channel_ioctl(struct ppp_channel *pc, unsigned int cmd, extern int pppox_channel_ioctl(struct ppp_channel *pc, unsigned int cmd,
unsigned long arg); unsigned long arg);
extern struct sock *pppox_sk_alloc(struct socket *sock, int protocol,
int priority, int zero_it,
kmem_cache_t *slab);
/* PPPoX socket states */ /* PPPoX socket states */
enum { enum {
......
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