Commit f31ab861 authored by David S. Miller's avatar David S. Miller

Merge bk://kernel.bkbits.net/acme/net-2.5

into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents f445a573 427375ed
...@@ -36,22 +36,22 @@ ...@@ -36,22 +36,22 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
static struct pppox_proto *proto[PX_MAX_PROTO+1]; static struct pppox_proto *pppox_protos[PX_MAX_PROTO + 1];
int register_pppox_proto(int proto_num, struct pppox_proto *pp) int register_pppox_proto(int proto_num, struct pppox_proto *pp)
{ {
if (proto_num < 0 || proto_num > PX_MAX_PROTO) if (proto_num < 0 || proto_num > PX_MAX_PROTO)
return -EINVAL; return -EINVAL;
if (proto[proto_num]) if (pppox_protos[proto_num])
return -EALREADY; return -EALREADY;
proto[proto_num] = pp; pppox_protos[proto_num] = pp;
return 0; return 0;
} }
void unregister_pppox_proto(int proto_num) void unregister_pppox_proto(int proto_num)
{ {
if (proto_num >= 0 && proto_num <= PX_MAX_PROTO) if (proto_num >= 0 && proto_num <= PX_MAX_PROTO)
proto[proto_num] = NULL; pppox_protos[proto_num] = NULL;
} }
void pppox_unbind_sock(struct sock *sk) void pppox_unbind_sock(struct sock *sk)
...@@ -73,57 +73,56 @@ static int pppox_ioctl(struct socket* sock, unsigned int cmd, ...@@ -73,57 +73,56 @@ static int pppox_ioctl(struct socket* sock, unsigned int cmd,
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct pppox_opt *po = pppox_sk(sk); struct pppox_opt *po = pppox_sk(sk);
int err = 0; int rc = 0;
lock_sock(sk); lock_sock(sk);
switch (cmd) { switch (cmd) {
case PPPIOCGCHAN:{ case PPPIOCGCHAN: {
int index; int index;
err = -ENOTCONN; rc = -ENOTCONN;
if (!(sk->state & PPPOX_CONNECTED)) if (!(sk->state & PPPOX_CONNECTED))
break; break;
err = -EINVAL; rc = -EINVAL;
index = ppp_channel_index(&po->chan); index = ppp_channel_index(&po->chan);
if (put_user(index , (int *) arg)) if (put_user(index , (int *) arg))
break; break;
err = 0; rc = 0;
sk->state |= PPPOX_BOUND; sk->state |= PPPOX_BOUND;
break; break;
} }
default: default:
if (proto[sk->protocol]->ioctl) if (pppox_protos[sk->protocol]->ioctl)
err = (*proto[sk->protocol]->ioctl)(sock, cmd, arg); rc = pppox_protos[sk->protocol]->ioctl(sock, cmd, arg);
break; break;
}; };
release_sock(sk); release_sock(sk);
return err; return rc;
} }
static int pppox_create(struct socket *sock, int protocol) static int pppox_create(struct socket *sock, int protocol)
{ {
int err = 0; int rc = -EPROTOTYPE;
if (protocol < 0 || protocol > PX_MAX_PROTO) if (protocol < 0 || protocol > PX_MAX_PROTO)
return -EPROTOTYPE; goto out;
if (proto[protocol] == NULL) rc = -EPROTONOSUPPORT;
return -EPROTONOSUPPORT; if (!pppox_protos[protocol])
goto out;
err = (*proto[protocol]->create)(sock); rc = pppox_protos[protocol]->create(sock);
if (!rc)
if (err == 0) {
/* We get to set the ioctl handler. */ /* We get to set the ioctl handler. */
/* 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;
} out:
return rc;
return err;
} }
static struct net_proto_family pppox_proto_family = { static struct net_proto_family pppox_proto_family = {
......
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