diff options
author | Johannes Stezenbach <devnull@localhost> | 2003-06-23 15:29:53 +0000 |
---|---|---|
committer | Johannes Stezenbach <devnull@localhost> | 2003-06-23 15:29:53 +0000 |
commit | a7529311598bffe8a24a6b16b92f049828366ad5 (patch) | |
tree | 34974f75d309ddd4ddad2b313c653bed6fbcbe39 /linux/drivers/media/dvb | |
parent | 9e89b13daae6f9249c528c9d10c6a09b2ad9a5bc (diff) | |
download | mediapointer-dvb-s2-a7529311598bffe8a24a6b16b92f049828366ad5.tar.gz mediapointer-dvb-s2-a7529311598bffe8a24a6b16b92f049828366ad5.tar.bz2 |
- prevent interface from being removed while it is in use
- allow add/remove only for the superuser
- fix formatting
Diffstat (limited to 'linux/drivers/media/dvb')
-rw-r--r-- | linux/drivers/media/dvb/dvb-core/dvb_net.c | 95 |
1 files changed, 42 insertions, 53 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_net.c b/linux/drivers/media/dvb/dvb-core/dvb_net.c index fb4e0162d..b8e446068 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_net.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_net.c @@ -42,6 +42,7 @@ #define DVB_NET_MULTICAST_MAX 10 struct dvb_net_priv { + int in_use; struct net_device_stats stats; char name[6]; u16 pid; @@ -64,8 +65,7 @@ struct dvb_net_priv { * stolen from eth.c out of the linux kernel, hacked for dvb-device * by Michael Holzt <kju@debian.org> */ -static -unsigned short dvb_net_eth_type_trans(struct sk_buff *skb, +static unsigned short dvb_net_eth_type_trans(struct sk_buff *skb, struct net_device *dev) { struct ethhdr *eth; @@ -103,8 +103,7 @@ unsigned short dvb_net_eth_type_trans(struct sk_buff *skb, } -static -void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len) +static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len) { u8 *eth; struct sk_buff *skb; @@ -145,11 +144,10 @@ void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len) netif_rx(skb); } -static -int dvb_net_callback (const u8 *buffer1, size_t buffer1_len, - const u8 *buffer2, size_t buffer2_len, - struct dmx_section_filter *filter, - enum dmx_success success) +static int dvb_net_callback (const u8 *buffer1, size_t buffer1_len, + const u8 *buffer2, size_t buffer2_len, + struct dmx_section_filter *filter, + enum dmx_success success) { struct net_device *dev=(struct net_device *) filter->priv; @@ -162,8 +160,7 @@ int dvb_net_callback (const u8 *buffer1, size_t buffer1_len, } -static -int dvb_net_tx (struct sk_buff *skb, struct net_device *dev) +static int dvb_net_tx (struct sk_buff *skb, struct net_device *dev) { return 0; } @@ -174,10 +171,9 @@ static u8 mask_allmulti [6] = {0xff, 0xff, 0xff, 0x00, 0x00, 0x00}; static u8 mac_allmulti [6] = {0x01, 0x00, 0x5e, 0x00, 0x00, 0x00}; static u8 mask_promisc [6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -static -int dvb_net_filter_set (struct net_device *dev, - struct dmx_section_filter **secfilter, - u8 *mac, u8 *mac_mask) +static int dvb_net_filter_set (struct net_device *dev, + struct dmx_section_filter **secfilter, + u8 *mac, u8 *mac_mask) { struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; int ret; @@ -222,8 +218,7 @@ int dvb_net_filter_set (struct net_device *dev, return 0; } -static -int dvb_net_feed_start (struct net_device *dev) +static int dvb_net_feed_start (struct net_device *dev) { int ret, i; struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; @@ -276,8 +271,7 @@ int dvb_net_feed_start (struct net_device *dev) } -static -void dvb_net_feed_stop (struct net_device *dev) +static void dvb_net_feed_stop (struct net_device *dev) { struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; int i; @@ -305,8 +299,7 @@ void dvb_net_feed_stop (struct net_device *dev) } -static -int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc) +static int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc) { struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; @@ -320,8 +313,7 @@ int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc) } -static -void tq_set_multicast_list (void *data) +static void tq_set_multicast_list (void *data) { struct net_device *dev = data; struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; @@ -357,16 +349,14 @@ void tq_set_multicast_list (void *data) } -static -void dvb_net_set_multicast_list (struct net_device *dev) +static void dvb_net_set_multicast_list (struct net_device *dev) { struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; schedule_work(&priv->wq); } -static -int dvb_net_set_config (struct net_device *dev, struct ifmap *map) +static int dvb_net_set_config (struct net_device *dev, struct ifmap *map) { if (netif_running(dev)) return -EBUSY; @@ -374,8 +364,7 @@ int dvb_net_set_config (struct net_device *dev, struct ifmap *map) } -static -int dvb_net_set_mac (struct net_device *dev, void *p) +static int dvb_net_set_mac (struct net_device *dev, void *p) { struct sockaddr *addr=p; @@ -390,31 +379,33 @@ int dvb_net_set_mac (struct net_device *dev, void *p) } -static -int dvb_net_open (struct net_device *dev) +static int dvb_net_open (struct net_device *dev) { + struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; + + priv->in_use++; dvb_net_feed_start(dev); return 0; } -static -int dvb_net_stop (struct net_device *dev) +static int dvb_net_stop (struct net_device *dev) { + struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; + + priv->in_use--; dvb_net_feed_stop(dev); return 0; } -static -struct net_device_stats* dvb_net_get_stats (struct net_device *dev) +static struct net_device_stats* dvb_net_get_stats (struct net_device *dev) { return &((struct dvb_net_priv*) dev->priv)->stats; } -static -int dvb_net_init_dev (struct net_device *dev) +static int dvb_net_init_dev (struct net_device *dev) { ether_setup(dev); @@ -435,8 +426,7 @@ int dvb_net_init_dev (struct net_device *dev) } -static -int get_if (struct dvb_net *dvbnet) +static int get_if (struct dvb_net *dvbnet) { int i; @@ -452,8 +442,7 @@ int get_if (struct dvb_net *dvbnet) } -static -int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid) +static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid) { struct net_device *net; struct dmx_demux *demux; @@ -500,13 +489,14 @@ int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid) } -static -int dvb_net_remove_if(struct dvb_net *dvbnet, int num) +static int dvb_net_remove_if(struct dvb_net *dvbnet, int num) { struct dvb_net_priv *priv = dvbnet->device[num].priv; if (!dvbnet->state[num]) return -EINVAL; + if (priv->in_use) + return -EBUSY; dvb_net_stop(&dvbnet->device[num]); kfree(priv); @@ -516,8 +506,7 @@ int dvb_net_remove_if(struct dvb_net *dvbnet, int num) } -static -int dvb_net_do_ioctl(struct inode *inode, struct file *file, +static int dvb_net_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *parg) { struct dvb_device *dvbdev = (struct dvb_device *) file->private_data; @@ -532,6 +521,8 @@ int dvb_net_do_ioctl(struct inode *inode, struct file *file, struct dvb_net_if *dvbnetif = (struct dvb_net_if *)parg; int result; + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; result = dvb_net_add_if(dvbnet, dvbnetif->pid); if (result<0) return result; @@ -554,6 +545,8 @@ int dvb_net_do_ioctl(struct inode *inode, struct file *file, break; } case NET_REMOVE_IF: + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; return dvb_net_remove_if(dvbnet, (int) parg); default: return -EINVAL; @@ -563,16 +556,14 @@ int dvb_net_do_ioctl(struct inode *inode, struct file *file, } -static -int dvb_net_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) +static int dvb_net_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) { return dvb_usercopy(inode, file, cmd, arg, dvb_net_do_ioctl); } -static -struct file_operations dvb_net_fops = { +static struct file_operations dvb_net_fops = { .owner = THIS_MODULE, .read = 0, .write = 0, @@ -583,8 +574,7 @@ struct file_operations dvb_net_fops = { }; -static -struct dvb_device dvbdev_net = { +static struct dvb_device dvbdev_net = { .priv = 0, .users = 1, .writers = 1, @@ -621,4 +611,3 @@ int dvb_net_init (struct dvb_adapter *adap, struct dvb_net *dvbnet, return 0; } - |