From c6f03202551fccd68e7db8d6320c272895b82a1d Mon Sep 17 00:00:00 2001 From: Chas Williams Date: Thu, 25 Sep 2003 07:16:47 -0700 Subject: [PATCH] [ATM]: Use new ioctl code for lane [3/3] --- net/atm/ioctl.c | 75 ++----------------------------------------------- net/atm/lec.c | 52 ++++++++++++++++++++++++++-------- net/atm/lec.h | 12 -------- 3 files changed, 43 insertions(+), 96 deletions(-) diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c index 4eecce6070c55..a1a7811a9001c 100644 --- a/net/atm/ioctl.c +++ b/net/atm/ioctl.c @@ -16,42 +16,12 @@ #include #include #include +#include #include #include "resources.h" #include "signaling.h" /* for WAITING and sigd_attach */ -#if defined(CONFIG_ATM_LANE) || defined(CONFIG_ATM_LANE_MODULE) -#include -#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 LIST_HEAD(ioctl_list); @@ -137,47 +107,6 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) if (!error) sock->state = SS_CONNECTED; 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: break; } @@ -186,6 +115,8 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) request_module("mpoa"); if (cmd == ATMARPD_CTRL) request_module("clip"); + if (cmd == ATMLEC_CTRL) + request_module("lec"); error = -ENOIOCTLCMD; diff --git a/net/atm/lec.c b/net/atm/lec.c index 1cc7440a4e02d..725a52fdcafab 100644 --- a/net/atm/lec.c +++ b/net/atm/lec.c @@ -839,16 +839,6 @@ lecd_attach(struct atm_vcc *vcc, int arg) 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 static char* lec_arp_get_status_string(unsigned char status) { @@ -1096,6 +1086,44 @@ static struct file_operations lec_seq_fops = { }; #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) { #ifdef CONFIG_PROC_FS @@ -1106,7 +1134,7 @@ static int __init lane_module_init(void) p->proc_fops = &lec_seq_fops; #endif - atm_lane_ops_set(&__atm_lane_ops); + register_atm_ioctl(&lane_ioctl_ops); printk("lec.c: " __DATE__ " " __TIME__ " initialized\n"); return 0; } @@ -1118,7 +1146,7 @@ static void __exit lane_module_cleanup(void) 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++) { if (dev_lec[i] != NULL) { diff --git a/net/atm/lec.h b/net/atm/lec.h index d0e6b19ffc40e..fed862b741181 100644 --- a/net/atm/lec.h +++ b/net/atm/lec.h @@ -60,14 +60,6 @@ struct lane2_ops { 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 * frames. @@ -157,9 +149,5 @@ int send_to_lecd(struct lec_priv *priv, unsigned char *atm_addr, struct sk_buff *data); 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_ */ -- 2.53.0