Commit c6f03202 authored by Chas Williams's avatar Chas Williams Committed by David S. Miller

[ATM]: Use new ioctl code for lane [3/3]

parent 526d13dd
...@@ -16,42 +16,12 @@ ...@@ -16,42 +16,12 @@
#include <linux/atmsvc.h> #include <linux/atmsvc.h>
#include <linux/atmmpc.h> #include <linux/atmmpc.h>
#include <net/atmclip.h> #include <net/atmclip.h>
#include <linux/atmlec.h>
#include <asm/ioctls.h> #include <asm/ioctls.h>
#include "resources.h" #include "resources.h"
#include "signaling.h" /* for WAITING and sigd_attach */ #include "signaling.h" /* for WAITING and sigd_attach */
#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
#include <linux/atmlec.h>
#include "lec.h"
#include "lec_arpc.h"
struct atm_lane_ops *atm_lane_ops;
static DECLARE_MUTEX(atm_lane_ops_mutex);
void atm_lane_ops_set(struct atm_lane_ops *hook)
{
down(&atm_lane_ops_mutex);
atm_lane_ops = hook;
up(&atm_lane_ops_mutex);
}
int try_atm_lane_ops(void)
{
down(&atm_lane_ops_mutex);
if (atm_lane_ops && try_module_get(atm_lane_ops->owner)) {
up(&atm_lane_ops_mutex);
return 1;
}
up(&atm_lane_ops_mutex);
return 0;
}
#if defined(CONFIG_ATM_LANE_MODULE) || defined(CONFIG_ATM_MPOA_MODULE)
EXPORT_SYMBOL(atm_lane_ops);
EXPORT_SYMBOL(try_atm_lane_ops);
EXPORT_SYMBOL(atm_lane_ops_set);
#endif
#endif
static DECLARE_MUTEX(ioctl_mutex); static DECLARE_MUTEX(ioctl_mutex);
static LIST_HEAD(ioctl_list); static LIST_HEAD(ioctl_list);
...@@ -137,47 +107,6 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -137,47 +107,6 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
if (!error) if (!error)
sock->state = SS_CONNECTED; sock->state = SS_CONNECTED;
goto done; goto done;
#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE)
case ATMLEC_CTRL:
if (!capable(CAP_NET_ADMIN)) {
error = -EPERM;
goto done;
}
#if defined(CONFIG_ATM_LANE_MODULE)
if (!atm_lane_ops)
request_module("lec");
#endif
if (try_atm_lane_ops()) {
error = atm_lane_ops->lecd_attach(vcc, (int) arg);
module_put(atm_lane_ops->owner);
if (error >= 0)
sock->state = SS_CONNECTED;
} else
error = -ENOSYS;
goto done;
case ATMLEC_MCAST:
if (!capable(CAP_NET_ADMIN)) {
error = -EPERM;
goto done;
}
if (try_atm_lane_ops()) {
error = atm_lane_ops->mcast_attach(vcc, (int) arg);
module_put(atm_lane_ops->owner);
} else
error = -ENOSYS;
goto done;
case ATMLEC_DATA:
if (!capable(CAP_NET_ADMIN)) {
error = -EPERM;
goto done;
}
if (try_atm_lane_ops()) {
error = atm_lane_ops->vcc_attach(vcc, (void *) arg);
module_put(atm_lane_ops->owner);
} else
error = -ENOSYS;
goto done;
#endif
default: default:
break; break;
} }
...@@ -186,6 +115,8 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) ...@@ -186,6 +115,8 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
request_module("mpoa"); request_module("mpoa");
if (cmd == ATMARPD_CTRL) if (cmd == ATMARPD_CTRL)
request_module("clip"); request_module("clip");
if (cmd == ATMLEC_CTRL)
request_module("lec");
error = -ENOIOCTLCMD; error = -ENOIOCTLCMD;
......
...@@ -839,16 +839,6 @@ lecd_attach(struct atm_vcc *vcc, int arg) ...@@ -839,16 +839,6 @@ lecd_attach(struct atm_vcc *vcc, int arg)
return i; return i;
} }
static struct atm_lane_ops __atm_lane_ops =
{
.lecd_attach = lecd_attach,
.mcast_attach = lec_mcast_attach,
.vcc_attach = lec_vcc_attach,
.get_lec = get_dev_lec,
.owner = THIS_MODULE
};
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static char* lec_arp_get_status_string(unsigned char status) static char* lec_arp_get_status_string(unsigned char status)
{ {
...@@ -1096,6 +1086,44 @@ static struct file_operations lec_seq_fops = { ...@@ -1096,6 +1086,44 @@ static struct file_operations lec_seq_fops = {
}; };
#endif #endif
static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
{
struct atm_vcc *vcc = ATM_SD(sock);
int err = 0;
switch (cmd) {
case ATMLEC_CTRL:
case ATMLEC_MCAST:
case ATMLEC_DATA:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
break;
default:
return -ENOIOCTLCMD;
}
switch (cmd) {
case ATMLEC_CTRL:
err = lecd_attach(vcc, (int) arg);
if (err >= 0)
sock->state = SS_CONNECTED;
break;
case ATMLEC_MCAST:
err = lec_mcast_attach(vcc, (int) arg);
break;
case ATMLEC_DATA:
err = lec_vcc_attach(vcc, (void *) arg);
break;
}
return err;
}
static struct atm_ioctl lane_ioctl_ops = {
.owner = THIS_MODULE,
.ioctl = lane_ioctl,
};
static int __init lane_module_init(void) static int __init lane_module_init(void)
{ {
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
...@@ -1106,7 +1134,7 @@ static int __init lane_module_init(void) ...@@ -1106,7 +1134,7 @@ static int __init lane_module_init(void)
p->proc_fops = &lec_seq_fops; p->proc_fops = &lec_seq_fops;
#endif #endif
atm_lane_ops_set(&__atm_lane_ops); register_atm_ioctl(&lane_ioctl_ops);
printk("lec.c: " __DATE__ " " __TIME__ " initialized\n"); printk("lec.c: " __DATE__ " " __TIME__ " initialized\n");
return 0; return 0;
} }
...@@ -1118,7 +1146,7 @@ static void __exit lane_module_cleanup(void) ...@@ -1118,7 +1146,7 @@ static void __exit lane_module_cleanup(void)
remove_proc_entry("lec", atm_proc_root); remove_proc_entry("lec", atm_proc_root);
atm_lane_ops_set(NULL); deregister_atm_ioctl(&lane_ioctl_ops);
for (i = 0; i < MAX_LEC_ITF; i++) { for (i = 0; i < MAX_LEC_ITF; i++) {
if (dev_lec[i] != NULL) { if (dev_lec[i] != NULL) {
......
...@@ -60,14 +60,6 @@ struct lane2_ops { ...@@ -60,14 +60,6 @@ struct lane2_ops {
u8 *tlvs, u32 sizeoftlvs); u8 *tlvs, u32 sizeoftlvs);
}; };
struct atm_lane_ops {
int (*lecd_attach)(struct atm_vcc *vcc, int arg);
int (*mcast_attach)(struct atm_vcc *vcc, int arg);
int (*vcc_attach)(struct atm_vcc *vcc, void *arg);
struct net_device * (*get_lec)(int itf);
struct module *owner;
};
/* /*
* ATM LAN Emulation supports both LLC & Dix Ethernet EtherType * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
* frames. * frames.
...@@ -157,9 +149,5 @@ int send_to_lecd(struct lec_priv *priv, ...@@ -157,9 +149,5 @@ int send_to_lecd(struct lec_priv *priv,
unsigned char *atm_addr, struct sk_buff *data); unsigned char *atm_addr, struct sk_buff *data);
void lec_push(struct atm_vcc *vcc, struct sk_buff *skb); void lec_push(struct atm_vcc *vcc, struct sk_buff *skb);
extern struct atm_lane_ops *atm_lane_ops;
void atm_lane_ops_set(struct atm_lane_ops *hook);
int try_atm_lane_ops(void);
#endif /* _LEC_H_ */ #endif /* _LEC_H_ */
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