Commit b9bf3d83 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 ac59d5f3 3c81501f
VERSION = 2
PATCHLEVEL = 5
SUBLEVEL = 71
SUBLEVEL = 72
EXTRAVERSION =
# *DOCUMENTATION*
......
......@@ -153,9 +153,9 @@ static void atmtcp_v_close(struct atm_vcc *vcc)
static int atmtcp_v_ioctl(struct atm_dev *dev,unsigned int cmd,void *arg)
{
unsigned long flags;
struct atm_cirange ci;
struct atm_vcc *vcc;
struct sock *s;
if (cmd != ATM_SETCIRANGE) return -ENOIOCTLCMD;
if (copy_from_user(&ci,(void *) arg,sizeof(ci))) return -EFAULT;
......@@ -163,14 +163,18 @@ static int atmtcp_v_ioctl(struct atm_dev *dev,unsigned int cmd,void *arg)
if (ci.vci_bits == ATM_CI_MAX) ci.vci_bits = MAX_VCI_BITS;
if (ci.vpi_bits > MAX_VPI_BITS || ci.vpi_bits < 0 ||
ci.vci_bits > MAX_VCI_BITS || ci.vci_bits < 0) return -EINVAL;
spin_lock_irqsave(&dev->lock, flags);
for (vcc = dev->vccs; vcc; vcc = vcc->next)
read_lock(&vcc_sklist_lock);
for (s = vcc_sklist; s; s = s->sk_next) {
vcc = atm_sk(s);
if (vcc->dev != dev)
continue;
if ((vcc->vpi >> ci.vpi_bits) ||
(vcc->vci >> ci.vci_bits)) {
spin_unlock_irqrestore(&dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return -EBUSY;
}
spin_unlock_irqrestore(&dev->lock, flags);
}
read_unlock(&vcc_sklist_lock);
dev->ci_range = ci;
return 0;
}
......@@ -233,9 +237,9 @@ static int atmtcp_v_proc(struct atm_dev *dev,loff_t *pos,char *page)
static void atmtcp_c_close(struct atm_vcc *vcc)
{
unsigned long flags;
struct atm_dev *atmtcp_dev;
struct atmtcp_dev_data *dev_data;
struct sock *s;
struct atm_vcc *walk;
atmtcp_dev = (struct atm_dev *) vcc->dev_data;
......@@ -246,19 +250,23 @@ static void atmtcp_c_close(struct atm_vcc *vcc)
kfree(dev_data);
shutdown_atm_dev(atmtcp_dev);
vcc->dev_data = NULL;
spin_lock_irqsave(&atmtcp_dev->lock, flags);
for (walk = atmtcp_dev->vccs; walk; walk = walk->next)
read_lock(&vcc_sklist_lock);
for (s = vcc_sklist; s; s = s->sk_next) {
walk = atm_sk(s);
if (walk->dev != atmtcp_dev)
continue;
wake_up(&walk->sleep);
spin_unlock_irqrestore(&atmtcp_dev->lock, flags);
}
read_unlock(&vcc_sklist_lock);
}
static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
{
unsigned long flags;
struct atm_dev *dev;
struct atmtcp_hdr *hdr;
struct atm_vcc *out_vcc;
struct sock *s;
struct atm_vcc *out_vcc = NULL;
struct sk_buff *new_skb;
int result = 0;
......@@ -270,13 +278,17 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
(struct atmtcp_control *) skb->data);
goto done;
}
spin_lock_irqsave(&dev->lock, flags);
for (out_vcc = dev->vccs; out_vcc; out_vcc = out_vcc->next)
read_lock(&vcc_sklist_lock);
for (s = vcc_sklist; s; s = s->sk_next) {
out_vcc = atm_sk(s);
if (out_vcc->dev != dev)
continue;
if (out_vcc->vpi == ntohs(hdr->vpi) &&
out_vcc->vci == ntohs(hdr->vci) &&
out_vcc->qos.rxtp.traffic_class != ATM_NONE)
break;
spin_unlock_irqrestore(&dev->lock, flags);
}
read_unlock(&vcc_sklist_lock);
if (!out_vcc) {
atomic_inc(&vcc->stats->tx_err);
goto done;
......@@ -366,7 +378,7 @@ int atmtcp_attach(struct atm_vcc *vcc,int itf)
if (itf != -1) dev = atm_dev_lookup(itf);
if (dev) {
if (dev->ops != &atmtcp_v_dev_ops) {
atm_dev_release(dev);
atm_dev_put(dev);
return -EMEDIUMTYPE;
}
if (PRIV(dev)->vcc) return -EBUSY;
......@@ -378,7 +390,8 @@ int atmtcp_attach(struct atm_vcc *vcc,int itf)
if (error) return error;
}
PRIV(dev)->vcc = vcc;
bind_vcc(vcc,&atmtcp_control_dev);
vcc->dev = &atmtcp_control_dev;
vcc_insert_socket(vcc->sk);
set_bit(ATM_VF_META,&vcc->flags);
set_bit(ATM_VF_READY,&vcc->flags);
vcc->dev_data = dev;
......@@ -402,7 +415,7 @@ int atmtcp_remove_persistent(int itf)
dev = atm_dev_lookup(itf);
if (!dev) return -ENODEV;
if (dev->ops != &atmtcp_v_dev_ops) {
atm_dev_release(dev);
atm_dev_put(dev);
return -EMEDIUMTYPE;
}
dev_data = PRIV(dev);
......@@ -410,7 +423,7 @@ int atmtcp_remove_persistent(int itf)
dev_data->persist = 0;
if (PRIV(dev)->vcc) return 0;
kfree(dev_data);
atm_dev_release(dev);
atm_dev_put(dev);
shutdown_atm_dev(dev);
return 0;
}
......
......@@ -1887,10 +1887,10 @@ static void eni_close(struct atm_vcc *vcc)
static int get_ci(struct atm_vcc *vcc,short *vpi,int *vci)
{
unsigned long flags;
struct sock *s;
struct atm_vcc *walk;
spin_lock_irqsave(&vcc->dev->lock, flags);
read_lock(&vcc_sklist_lock);
if (*vpi == ATM_VPI_ANY) *vpi = 0;
if (*vci == ATM_VCI_ANY) {
for (*vci = ATM_NOT_RSV_VCI; *vci < NR_VCI; (*vci)++) {
......@@ -1898,40 +1898,47 @@ static int get_ci(struct atm_vcc *vcc,short *vpi,int *vci)
ENI_DEV(vcc->dev)->rx_map[*vci])
continue;
if (vcc->qos.txtp.traffic_class != ATM_NONE) {
for (walk = vcc->dev->vccs; walk;
walk = walk->next)
for (s = vcc_sklist; s; s = s->sk_next) {
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if (test_bit(ATM_VF_ADDR,&walk->flags)
&& walk->vci == *vci &&
walk->qos.txtp.traffic_class !=
ATM_NONE)
break;
if (walk) continue;
}
if (s) continue;
}
break;
}
spin_unlock_irqrestore(&vcc->dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return *vci == NR_VCI ? -EADDRINUSE : 0;
}
if (*vci == ATM_VCI_UNSPEC) {
spin_unlock_irqrestore(&vcc->dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return 0;
}
if (vcc->qos.rxtp.traffic_class != ATM_NONE &&
ENI_DEV(vcc->dev)->rx_map[*vci]) {
spin_unlock_irqrestore(&vcc->dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return -EADDRINUSE;
}
if (vcc->qos.txtp.traffic_class == ATM_NONE) {
spin_unlock_irqrestore(&vcc->dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return 0;
}
for (walk = vcc->dev->vccs; walk; walk = walk->next)
for (s = vcc_sklist; s; s = s->sk_next) {
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if (test_bit(ATM_VF_ADDR,&walk->flags) && walk->vci == *vci &&
walk->qos.txtp.traffic_class != ATM_NONE) {
spin_unlock_irqrestore(&vcc->dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return -EADDRINUSE;
}
spin_unlock_irqrestore(&vcc->dev->lock, flags);
}
read_unlock(&vcc_sklist_lock);
return 0;
}
......@@ -2139,7 +2146,7 @@ static unsigned char eni_phy_get(struct atm_dev *dev,unsigned long addr)
static int eni_proc_read(struct atm_dev *dev,loff_t *pos,char *page)
{
unsigned long flags;
struct sock *s;
static const char *signal[] = { "LOST","unknown","okay" };
struct eni_dev *eni_dev = ENI_DEV(dev);
struct atm_vcc *vcc;
......@@ -2212,11 +2219,15 @@ static int eni_proc_read(struct atm_dev *dev,loff_t *pos,char *page)
return sprintf(page,"%10sbacklog %u packets\n","",
skb_queue_len(&tx->backlog));
}
spin_lock_irqsave(&dev->lock, flags);
for (vcc = dev->vccs; vcc; vcc = vcc->next) {
struct eni_vcc *eni_vcc = ENI_VCC(vcc);
read_lock(&vcc_sklist_lock);
for (s = vcc_sklist; s; s = s->sk_next) {
struct eni_vcc *eni_vcc;
int length;
vcc = atm_sk(s);
if (vcc->dev != dev)
continue;
eni_vcc = ENI_VCC(vcc);
if (--left) continue;
length = sprintf(page,"vcc %4d: ",vcc->vci);
if (eni_vcc->rx) {
......@@ -2231,10 +2242,10 @@ static int eni_proc_read(struct atm_dev *dev,loff_t *pos,char *page)
length += sprintf(page+length,"tx[%d], txing %d bytes",
eni_vcc->tx->index,eni_vcc->txing);
page[length] = '\n';
spin_unlock_irqrestore(&dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return length+1;
}
spin_unlock_irqrestore(&dev->lock, flags);
read_unlock(&vcc_sklist_lock);
for (i = 0; i < eni_dev->free_len; i++) {
struct eni_free *fe = eni_dev->free_list+i;
unsigned long offset;
......
......@@ -1069,18 +1069,22 @@ fore200e_supply(struct fore200e* fore200e)
static struct atm_vcc*
fore200e_find_vcc(struct fore200e* fore200e, struct rpd* rpd)
{
unsigned long flags;
struct sock *s;
struct atm_vcc* vcc;
spin_lock_irqsave(&fore200e->atm_dev->lock, flags);
for (vcc = fore200e->atm_dev->vccs; vcc; vcc = vcc->next) {
if (vcc->vpi == rpd->atm_header.vpi && vcc->vci == rpd->atm_header.vci)
break;
read_lock(&vcc_sklist_lock);
for(s = vcc_sklist; s; s = s->sk_next) {
vcc = atm_sk(s);
if (vcc->dev != fore200e->atm_dev)
continue;
if (vcc->vpi == rpd->atm_header.vpi && vcc->vci == rpd->atm_header.vci) {
read_unlock(&vcc_sklist_lock);
return vcc;
}
}
spin_unlock_irqrestore(&fore200e->atm_dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return vcc;
return NULL;
}
......@@ -1350,20 +1354,23 @@ fore200e_activate_vcin(struct fore200e* fore200e, int activate, struct atm_vcc*
static int
fore200e_walk_vccs(struct atm_vcc *vcc, short *vpi, int *vci)
{
unsigned long flags;
struct atm_vcc* walk;
struct sock *s;
/* find a free VPI */
spin_lock_irqsave(&vcc->dev->lock, flags);
read_lock(&vcc_sklist_lock);
if (*vpi == ATM_VPI_ANY) {
for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next) {
for (*vpi = 0, s = vcc_sklist; s; s = s->sk_next) {
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if ((walk->vci == *vci) && (walk->vpi == *vpi)) {
(*vpi)++;
walk = vcc->dev->vccs;
s = vcc_sklist;
}
}
}
......@@ -1371,16 +1378,19 @@ fore200e_walk_vccs(struct atm_vcc *vcc, short *vpi, int *vci)
/* find a free VCI */
if (*vci == ATM_VCI_ANY) {
for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk; walk = walk->next) {
for (*vci = ATM_NOT_RSV_VCI, s = vcc_sklist; s; s = s->sk_next) {
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if ((walk->vpi = *vpi) && (walk->vci == *vci)) {
*vci = walk->vci + 1;
walk = vcc->dev->vccs;
s = vcc_sklist;
}
}
}
spin_unlock_irqrestore(&vcc->dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return 0;
}
......@@ -2642,7 +2652,7 @@ fore200e_module_cleanup(void)
static int
fore200e_proc_read(struct atm_dev *dev,loff_t* pos,char* page)
{
unsigned long flags;
struct sock *s;
struct fore200e* fore200e = FORE200E_DEV(dev);
int len, left = *pos;
......@@ -2889,8 +2899,12 @@ fore200e_proc_read(struct atm_dev *dev,loff_t* pos,char* page)
len = sprintf(page,"\n"
" VCCs:\n address\tVPI.VCI:AAL\t(min/max tx PDU size) (min/max rx PDU size)\n");
spin_lock_irqsave(&fore200e->atm_dev->lock, flags);
for (vcc = fore200e->atm_dev->vccs; vcc; vcc = vcc->next) {
read_lock(&vcc_sklist_lock);
for (s = vcc_sklist; s; s = s->sk_next) {
vcc = atm_sk(s);
if (vcc->dev != fore200e->atm_dev)
continue;
fore200e_vcc = FORE200E_VCC(vcc);
......@@ -2904,7 +2918,7 @@ fore200e_proc_read(struct atm_dev *dev,loff_t* pos,char* page)
fore200e_vcc->rx_max_pdu
);
}
spin_unlock_irqrestore(&fore200e->atm_dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return len;
}
......
......@@ -79,7 +79,6 @@
#include <linux/sonet.h>
#define USE_TASKLET
#define USE_HE_FIND_VCC
#undef USE_SCATTERGATHER
#undef USE_CHECKSUM_HW /* still confused about this */
#define USE_RBPS
......@@ -328,25 +327,24 @@ he_readl_internal(struct he_dev *he_dev, unsigned addr, unsigned flags)
he_writel_rcm(dev, val, 0x00000 | (cid << 3) | 7)
static __inline__ struct atm_vcc*
he_find_vcc(struct he_dev *he_dev, unsigned cid)
__find_vcc(struct he_dev *he_dev, unsigned cid)
{
unsigned long flags;
struct atm_vcc *vcc;
struct sock *s;
short vpi;
int vci;
vpi = cid >> he_dev->vcibits;
vci = cid & ((1 << he_dev->vcibits) - 1);
spin_lock_irqsave(&he_dev->atm_dev->lock, flags);
for (vcc = he_dev->atm_dev->vccs; vcc; vcc = vcc->next)
if (vcc->vci == vci && vcc->vpi == vpi
&& vcc->qos.rxtp.traffic_class != ATM_NONE) {
spin_unlock_irqrestore(&he_dev->atm_dev->lock, flags);
for (s = vcc_sklist; s; s = s->sk_next) {
vcc = atm_sk(s);
if (vcc->dev == he_dev->atm_dev &&
vcc->vci == vci && vcc->vpi == vpi &&
vcc->qos.rxtp.traffic_class != ATM_NONE) {
return vcc;
}
spin_unlock_irqrestore(&he_dev->atm_dev->lock, flags);
}
return NULL;
}
......@@ -1566,17 +1564,6 @@ he_start(struct atm_dev *dev)
reg |= RX_ENABLE;
he_writel(he_dev, reg, RC_CONFIG);
#ifndef USE_HE_FIND_VCC
he_dev->he_vcc_table = kmalloc(sizeof(struct he_vcc_table) *
(1 << (he_dev->vcibits + he_dev->vpibits)), GFP_KERNEL);
if (he_dev->he_vcc_table == NULL) {
hprintk("failed to alloc he_vcc_table\n");
return -ENOMEM;
}
memset(he_dev->he_vcc_table, 0, sizeof(struct he_vcc_table) *
(1 << (he_dev->vcibits + he_dev->vpibits)));
#endif
for (i = 0; i < HE_NUM_CS_STPER; ++i) {
he_dev->cs_stper[i].inuse = 0;
he_dev->cs_stper[i].pcr = -1;
......@@ -1712,11 +1699,6 @@ he_stop(struct he_dev *he_dev)
he_dev->tpd_base, he_dev->tpd_base_phys);
#endif
#ifndef USE_HE_FIND_VCC
if (he_dev->he_vcc_table)
kfree(he_dev->he_vcc_table);
#endif
if (he_dev->pci_dev) {
pci_read_config_word(he_dev->pci_dev, PCI_COMMAND, &command);
command &= ~(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
......@@ -1798,6 +1780,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
int pdus_assembled = 0;
int updated = 0;
read_lock(&vcc_sklist_lock);
while (he_dev->rbrq_head != rbrq_tail) {
++updated;
......@@ -1823,13 +1806,10 @@ he_service_rbrq(struct he_dev *he_dev, int group)
buf_len = RBRQ_BUFLEN(he_dev->rbrq_head) * 4;
cid = RBRQ_CID(he_dev->rbrq_head);
#ifdef USE_HE_FIND_VCC
if (cid != lastcid)
vcc = he_find_vcc(he_dev, cid);
vcc = __find_vcc(he_dev, cid);
lastcid = cid;
#else
vcc = HE_LOOKUP_VCC(he_dev, cid);
#endif
if (vcc == NULL) {
hprintk("vcc == NULL (cid 0x%x)\n", cid);
if (!RBRQ_HBUF_ERR(he_dev->rbrq_head))
......@@ -1966,6 +1946,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
RBRQ_MASK(++he_dev->rbrq_head));
}
read_unlock(&vcc_sklist_lock);
if (updated) {
if (updated > he_dev->rbrq_peak)
......@@ -2565,10 +2546,6 @@ he_open(struct atm_vcc *vcc, short vpi, int vci)
#endif
spin_unlock_irqrestore(&he_dev->global_lock, flags);
#ifndef USE_HE_FIND_VCC
HE_LOOKUP_VCC(he_dev, cid) = vcc;
#endif
}
open_failed:
......@@ -2634,9 +2611,6 @@ he_close(struct atm_vcc *vcc)
if (timeout == 0)
hprintk("close rx timeout cid 0x%x\n", cid);
#ifndef USE_HE_FIND_VCC
HE_LOOKUP_VCC(he_dev, cid) = NULL;
#endif
HPRINTK("close rx cid 0x%x complete\n", cid);
}
......
......@@ -2403,37 +2403,43 @@ idt77252_init_rx(struct idt77252_dev *card, struct vc_map *vc,
static int
idt77252_find_vcc(struct atm_vcc *vcc, short *vpi, int *vci)
{
unsigned long flags;
struct sock *s;
struct atm_vcc *walk;
spin_lock_irqsave(&vcc->dev->lock, flags);
read_lock(&vcc_sklist_lock);
if (*vpi == ATM_VPI_ANY) {
*vpi = 0;
walk = vcc->dev->vccs;
while (walk) {
s = vcc_sklist;
while (s) {
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if ((walk->vci == *vci) && (walk->vpi == *vpi)) {
(*vpi)++;
walk = vcc->dev->vccs;
s = vcc_sklist;
continue;
}
walk = walk->next;
s = s->sk_next;
}
}
if (*vci == ATM_VCI_ANY) {
*vci = ATM_NOT_RSV_VCI;
walk = vcc->dev->vccs;
while (walk) {
s = vcc_sklist;
while (s) {
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if ((walk->vci == *vci) && (walk->vpi == *vpi)) {
(*vci)++;
walk = vcc->dev->vccs;
s = vcc_sklist;
continue;
}
walk = walk->next;
s = s->sk_next;
}
}
spin_unlock_irqrestore(&vcc->dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return 0;
}
......
......@@ -297,13 +297,14 @@ int dm_hash_rename(const char *old, const char *new)
/*
* rename and move the name cell.
*/
unregister_with_devfs(hc);
list_del(&hc->name_list);
old_name = hc->name;
hc->name = new_name;
list_add(&hc->name_list, _name_buckets + hash_str(new_name));
/* rename the device node in devfs */
unregister_with_devfs(hc);
register_with_devfs(hc);
up_write(&_hash_lock);
......
......@@ -952,8 +952,6 @@ static int bond_open(struct net_device *dev)
add_timer(alb_timer);
}
MOD_INC_USE_COUNT;
if (miimon > 0) { /* link check interval, in milliseconds. */
init_timer(timer);
timer->expires = jiffies + (miimon * HZ / 1000);
......@@ -1027,7 +1025,6 @@ static int bond_close(struct net_device *master)
bond_alb_deinitialize(bond);
}
MOD_DEC_USE_COUNT;
return 0;
}
......@@ -3694,6 +3691,8 @@ static int __init bond_init(struct net_device *dev)
kfree(bond);
return -ENOMEM;
}
bond->bond_proc_dir->owner = THIS_MODULE;
bond->bond_proc_info_file =
create_proc_info_entry("info", 0, bond->bond_proc_dir,
bond_get_info);
......@@ -3705,6 +3704,7 @@ static int __init bond_init(struct net_device *dev)
kfree(bond);
return -ENOMEM;
}
bond->bond_proc_info_file->owner = THIS_MODULE;
#endif /* CONFIG_PROC_FS */
if (first_pass == 1) {
......
......@@ -630,7 +630,7 @@ static void shaper_init_priv(struct net_device *dev)
* Add a shaper device to the system
*/
static int __init shaper_probe(struct net_device *dev)
static void __init shaper_setup(struct net_device *dev)
{
/*
* Set up the shaper.
......@@ -642,6 +642,7 @@ static int __init shaper_probe(struct net_device *dev)
dev->open = shaper_open;
dev->stop = shaper_close;
dev->destructor = (void (*)(struct net_device *))kfree;
dev->hard_start_xmit = shaper_start_xmit;
dev->get_stats = shaper_get_stats;
dev->set_multicast_list = NULL;
......@@ -669,12 +670,6 @@ static int __init shaper_probe(struct net_device *dev)
dev->addr_len = 0;
dev->tx_queue_len = 10;
dev->flags = 0;
/*
* Shaper is ok
*/
return 0;
}
static int shapers = 1;
......@@ -695,35 +690,38 @@ __setup("shapers=", set_num_shapers);
#endif /* MODULE */
static struct net_device *devs;
static struct net_device **devs;
static unsigned int shapers_registered = 0;
static int __init shaper_init(void)
{
int i, err;
int i;
size_t alloc_size;
struct shaper *sp;
struct net_device *dev;
char name[IFNAMSIZ];
if (shapers < 1)
return -ENODEV;
alloc_size = (sizeof(*devs) * shapers) +
(sizeof(struct shaper) * shapers);
alloc_size = sizeof(*dev) * shapers;
devs = kmalloc(alloc_size, GFP_KERNEL);
if (!devs)
return -ENOMEM;
memset(devs, 0, alloc_size);
sp = (struct shaper *) &devs[shapers];
for (i = 0; i < shapers; i++) {
err = dev_alloc_name(&devs[i], "shaper%d");
if (err < 0)
snprintf(name, IFNAMSIZ, "shaper%d", i);
dev = alloc_netdev(sizeof(struct shaper), name,
shaper_setup);
if (!dev)
break;
devs[i].init = shaper_probe;
devs[i].priv = &sp[i];
if (register_netdev(&devs[i]))
if (register_netdev(dev))
break;
devs[i] = dev;
shapers_registered++;
}
......@@ -740,7 +738,8 @@ static void __exit shaper_exit (void)
int i;
for (i = 0; i < shapers_registered; i++)
unregister_netdev(&devs[i]);
if (devs[i])
unregister_netdev(devs[i]);
kfree(devs);
devs = NULL;
......
......@@ -985,6 +985,8 @@ static inline int check_sticky(struct inode *dir, struct inode *inode)
* 7. If we were asked to remove a directory and victim isn't one - ENOTDIR.
* 8. If we were asked to remove a non-directory and victim isn't one - EISDIR.
* 9. We can't remove a root or mountpoint.
* 10. We don't allow removal of NFS sillyrenamed files; it's handled by
* nfs_async_unlink().
*/
static inline int may_delete(struct inode *dir,struct dentry *victim, int isdir)
{
......@@ -1008,6 +1010,8 @@ static inline int may_delete(struct inode *dir,struct dentry *victim, int isdir)
return -EISDIR;
if (IS_DEADDIR(dir))
return -ENOENT;
if (victim->d_flags & DCACHE_NFSFS_RENAMED)
return -EBUSY;
return 0;
}
......
......@@ -715,7 +715,6 @@ __nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
if (fattr->valid & NFS_ATTR_FATTR_V4)
nfsi->change_attr = fattr->change_attr;
inode->i_size = nfs_size_to_loff_t(fattr->size);
inode->i_mode = fattr->mode;
inode->i_nlink = fattr->nlink;
inode->i_uid = fattr->uid;
inode->i_gid = fattr->gid;
......
......@@ -293,7 +293,6 @@ struct atm_vcc {
struct k_atm_aal_stats *stats; /* pointer to AAL stats group */
wait_queue_head_t sleep; /* if socket is busy */
struct sock *sk; /* socket backpointer */
struct atm_vcc *prev,*next;
/* SVC part --- may move later ------------------------------------- */
short itf; /* interface number */
struct sockaddr_atmsvc local;
......@@ -320,8 +319,6 @@ struct atm_dev {
/* (NULL) */
const char *type; /* device type name */
int number; /* device index */
struct atm_vcc *vccs; /* VCC table (or NULL) */
struct atm_vcc *last; /* last VCC (or undefined) */
void *dev_data; /* per-device data */
void *phy_data; /* private PHY date */
unsigned long flags; /* device flags (ATM_DF_*) */
......@@ -390,6 +387,9 @@ struct atm_skb_data {
unsigned long atm_options; /* ATM layer options */
};
extern struct sock *vcc_sklist;
extern rwlock_t vcc_sklist_lock;
#define ATM_SKB(skb) (((struct atm_skb_data *) (skb)->cb))
struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops,
......@@ -397,7 +397,8 @@ struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops,
struct atm_dev *atm_dev_lookup(int number);
void atm_dev_deregister(struct atm_dev *dev);
void shutdown_atm_dev(struct atm_dev *dev);
void bind_vcc(struct atm_vcc *vcc,struct atm_dev *dev);
void vcc_insert_socket(struct sock *sk);
void vcc_remove_socket(struct sock *sk);
/*
......@@ -436,7 +437,7 @@ static inline void atm_dev_hold(struct atm_dev *dev)
}
static inline void atm_dev_release(struct atm_dev *dev)
static inline void atm_dev_put(struct atm_dev *dev)
{
atomic_dec(&dev->refcnt);
......@@ -452,7 +453,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,
int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci);
int atm_pcr_goal(struct atm_trafprm *tp);
void atm_async_release_vcc(struct atm_vcc *vcc,int reply);
void vcc_release_async(struct atm_vcc *vcc, int reply);
#endif /* __KERNEL__ */
......
......@@ -47,15 +47,20 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size,
static int check_ci(struct atm_vcc *vcc,short vpi,int vci)
{
struct sock *s;
struct atm_vcc *walk;
for (walk = vcc->dev->vccs; walk; walk = walk->next)
for (s = vcc_sklist; s; s = s->sk_next) {
walk = atm_sk(s);
if (walk->dev != vcc->dev)
continue;
if (test_bit(ATM_VF_ADDR,&walk->flags) && walk->vpi == vpi &&
walk->vci == vci && ((walk->qos.txtp.traffic_class !=
ATM_NONE && vcc->qos.txtp.traffic_class != ATM_NONE) ||
(walk->qos.rxtp.traffic_class != ATM_NONE &&
vcc->qos.rxtp.traffic_class != ATM_NONE)))
return -EADDRINUSE;
}
/* allow VCCs with same VPI/VCI iff they don't collide on
TX/RX (but we may refuse such sharing for other reasons,
e.g. if protocol requires to have both channels) */
......@@ -65,17 +70,16 @@ static int check_ci(struct atm_vcc *vcc,short vpi,int vci)
int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci)
{
unsigned long flags;
static short p = 0; /* poor man's per-device cache */
static int c = 0;
short old_p;
int old_c;
int err;
spin_lock_irqsave(&vcc->dev->lock, flags);
read_lock(&vcc_sklist_lock);
if (*vpi != ATM_VPI_ANY && *vci != ATM_VCI_ANY) {
err = check_ci(vcc,*vpi,*vci);
spin_unlock_irqrestore(&vcc->dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return err;
}
/* last scan may have left values out of bounds for current device */
......@@ -90,7 +94,7 @@ int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci)
if (!check_ci(vcc,p,c)) {
*vpi = p;
*vci = c;
spin_unlock_irqrestore(&vcc->dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return 0;
}
if (*vci == ATM_VCI_ANY) {
......@@ -105,7 +109,7 @@ int atm_find_ci(struct atm_vcc *vcc,short *vpi,int *vci)
}
}
while (old_p != p || old_c != c);
spin_unlock_irqrestore(&vcc->dev->lock, flags);
read_unlock(&vcc_sklist_lock);
return -EADDRINUSE;
}
......
......@@ -140,7 +140,7 @@ static void idle_timer_check(unsigned long dummy)
DPRINTK("releasing vcc %p->%p of "
"entry %p\n",clip_vcc,clip_vcc->vcc,
entry);
atm_async_release_vcc(clip_vcc->vcc,
vcc_release_async(clip_vcc->vcc,
-ETIMEDOUT);
}
if (entry->vccs ||
......@@ -737,7 +737,8 @@ static int atm_init_atmarp(struct atm_vcc *vcc)
set_bit(ATM_VF_META,&vcc->flags);
set_bit(ATM_VF_READY,&vcc->flags);
/* allow replies and avoid getting closed if signaling dies */
bind_vcc(vcc,&atmarpd_dev);
vcc->dev = &atmarpd_dev;
vcc_insert_socket(vcc->sk);
vcc->push = NULL;
vcc->pop = NULL; /* crash */
vcc->push_oam = NULL; /* crash */
......
This diff is collapsed.
......@@ -10,22 +10,20 @@
#include <linux/poll.h> /* for poll_table */
int atm_create(struct socket *sock,int protocol,int family);
int atm_release(struct socket *sock);
int atm_connect(struct socket *sock,int itf,short vpi,int vci);
int atm_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
int total_len, int flags);
int atm_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
int vcc_create(struct socket *sock, int protocol, int family);
int vcc_release(struct socket *sock);
int vcc_connect(struct socket *sock, int itf, short vpi, int vci);
int vcc_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
int size, int flags);
int vcc_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *m,
int total_len);
unsigned int atm_poll(struct file *file,struct socket *sock,poll_table *wait);
int atm_ioctl(struct socket *sock,unsigned int cmd,unsigned long arg);
int atm_setsockopt(struct socket *sock,int level,int optname,char *optval,
int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
int vcc_setsockopt(struct socket *sock, int level, int optname, char *optval,
int optlen);
int atm_getsockopt(struct socket *sock,int level,int optname,char *optval,
int vcc_getsockopt(struct socket *sock, int level, int optname, char *optval,
int *optlen);
int atm_connect_vcc(struct atm_vcc *vcc,int itf,short vpi,int vci);
void atm_release_vcc_sk(struct sock *sk,int free_sk);
void atm_shutdown_dev(struct atm_dev *dev);
int atmpvc_init(void);
......
......@@ -48,7 +48,7 @@ extern void (*br_fdb_put_hook)(struct net_bridge_fdb_entry *ent);
#include "lec.h"
#include "lec_arpc.h"
#include "resources.h" /* for bind_vcc() */
#include "resources.h"
#if 0
#define DPRINTK printk
......@@ -810,7 +810,8 @@ lecd_attach(struct atm_vcc *vcc, int arg)
lec_arp_init(priv);
priv->itfnum = i; /* LANE2 addition */
priv->lecd = vcc;
bind_vcc(vcc, &lecatm_dev);
vcc->dev = &lecatm_dev;
vcc_insert_socket(vcc->sk);
vcc->proto_data = dev_lec[i];
set_bit(ATM_VF_META,&vcc->flags);
......@@ -1079,7 +1080,7 @@ lec_arp_clear_vccs(struct lec_arp_table *entry)
clear_bit(ATM_VF_READY,&entry->vcc->flags);
entry->vcc->push(entry->vcc, NULL);
#endif
atm_async_release_vcc(entry->vcc, -EPIPE);
vcc_release_async(entry->vcc, -EPIPE);
entry->vcc = NULL;
}
if (entry->recv_vcc) {
......@@ -1089,7 +1090,7 @@ lec_arp_clear_vccs(struct lec_arp_table *entry)
clear_bit(ATM_VF_READY,&entry->recv_vcc->flags);
entry->recv_vcc->push(entry->recv_vcc, NULL);
#endif
atm_async_release_vcc(entry->recv_vcc, -EPIPE);
vcc_release_async(entry->recv_vcc, -EPIPE);
entry->recv_vcc = NULL;
}
}
......
......@@ -28,7 +28,7 @@
#include "lec.h"
#include "mpc.h"
#include "resources.h" /* for bind_vcc() */
#include "resources.h"
/*
* mpc.c: Implementation of MPOA client kernel part
......@@ -789,7 +789,8 @@ int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg)
}
mpc->mpoad_vcc = vcc;
bind_vcc(vcc, &mpc_dev);
vcc->dev = &mpc_dev;
vcc_insert_socket(vcc->sk);
set_bit(ATM_VF_META,&vcc->flags);
set_bit(ATM_VF_READY,&vcc->flags);
......
......@@ -212,7 +212,7 @@ static void in_cache_remove_entry(in_cache_entry *entry,
client->eg_ops->put(eg_entry);
return;
}
atm_async_release_vcc(vcc, -EPIPE);
vcc_release_async(vcc, -EPIPE);
}
return;
......@@ -447,7 +447,7 @@ static void eg_cache_remove_entry(eg_cache_entry *entry,
client->in_ops->put(in_entry);
return;
}
atm_async_release_vcc(vcc, -EPIPE);
vcc_release_async(vcc, -EPIPE);
}
return;
......
......@@ -334,9 +334,7 @@ static int atm_devices_info(loff_t pos,char *buf)
static int atm_pvc_info(loff_t pos,char *buf)
{
unsigned long flags;
struct atm_dev *dev;
struct list_head *p;
struct sock *s;
struct atm_vcc *vcc;
int left, clip_info = 0;
......@@ -349,25 +347,20 @@ static int atm_pvc_info(loff_t pos,char *buf)
if (try_atm_clip_ops())
clip_info = 1;
#endif
spin_lock(&atm_dev_lock);
list_for_each(p, &atm_devs) {
dev = list_entry(p, struct atm_dev, dev_list);
spin_lock_irqsave(&dev->lock, flags);
for (vcc = dev->vccs; vcc; vcc = vcc->next)
if (vcc->sk->sk_family == PF_ATMPVC &&
vcc->dev && !left--) {
read_lock(&vcc_sklist_lock);
for(s = vcc_sklist; s; s = s->sk_next) {
vcc = atm_sk(s);
if (vcc->sk->sk_family == PF_ATMPVC && vcc->dev && !left--) {
pvc_info(vcc,buf,clip_info);
spin_unlock_irqrestore(&dev->lock, flags);
spin_unlock(&atm_dev_lock);
read_unlock(&vcc_sklist_lock);
#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
if (clip_info)
module_put(atm_clip_ops->owner);
#endif
return strlen(buf);
}
spin_unlock_irqrestore(&dev->lock, flags);
}
spin_unlock(&atm_dev_lock);
read_unlock(&vcc_sklist_lock);
#if defined(CONFIG_ATM_CLIP) || defined(CONFIG_ATM_CLIP_MODULE)
if (clip_info)
module_put(atm_clip_ops->owner);
......@@ -378,10 +371,8 @@ static int atm_pvc_info(loff_t pos,char *buf)
static int atm_vc_info(loff_t pos,char *buf)
{
unsigned long flags;
struct atm_dev *dev;
struct list_head *p;
struct atm_vcc *vcc;
struct sock *s;
int left;
if (!pos)
......@@ -389,20 +380,16 @@ static int atm_vc_info(loff_t pos,char *buf)
"Address"," Itf VPI VCI Fam Flags Reply Send buffer"
" Recv buffer\n");
left = pos-1;
spin_lock(&atm_dev_lock);
list_for_each(p, &atm_devs) {
dev = list_entry(p, struct atm_dev, dev_list);
spin_lock_irqsave(&dev->lock, flags);
for (vcc = dev->vccs; vcc; vcc = vcc->next)
read_lock(&vcc_sklist_lock);
for(s = vcc_sklist; s; s = s->sk_next) {
vcc = atm_sk(s);
if (!left--) {
vc_info(vcc,buf);
spin_unlock_irqrestore(&dev->lock, flags);
spin_unlock(&atm_dev_lock);
read_unlock(&vcc_sklist_lock);
return strlen(buf);
}
spin_unlock_irqrestore(&dev->lock, flags);
}
spin_unlock(&atm_dev_lock);
read_unlock(&vcc_sklist_lock);
return 0;
}
......@@ -410,29 +397,23 @@ static int atm_vc_info(loff_t pos,char *buf)
static int atm_svc_info(loff_t pos,char *buf)
{
unsigned long flags;
struct atm_dev *dev;
struct list_head *p;
struct sock *s;
struct atm_vcc *vcc;
int left;
if (!pos)
return sprintf(buf,"Itf VPI VCI State Remote\n");
left = pos-1;
spin_lock(&atm_dev_lock);
list_for_each(p, &atm_devs) {
dev = list_entry(p, struct atm_dev, dev_list);
spin_lock_irqsave(&dev->lock, flags);
for (vcc = dev->vccs; vcc; vcc = vcc->next)
read_lock(&vcc_sklist_lock);
for(s = vcc_sklist; s; s = s->sk_next) {
vcc = atm_sk(s);
if (vcc->sk->sk_family == PF_ATMSVC && !left--) {
svc_info(vcc,buf);
spin_unlock_irqrestore(&dev->lock, flags);
spin_unlock(&atm_dev_lock);
read_unlock(&vcc_sklist_lock);
return strlen(buf);
}
spin_unlock_irqrestore(&dev->lock, flags);
}
spin_unlock(&atm_dev_lock);
read_unlock(&vcc_sklist_lock);
return 0;
}
......
......@@ -17,10 +17,6 @@
#include "resources.h" /* devs and vccs */
#include "common.h" /* common for PVCs and SVCs */
#ifndef NULL
#define NULL 0
#endif
static int pvc_shutdown(struct socket *sock,int how)
{
......@@ -31,20 +27,29 @@ static int pvc_shutdown(struct socket *sock,int how)
static int pvc_bind(struct socket *sock,struct sockaddr *sockaddr,
int sockaddr_len)
{
struct sock *sk = sock->sk;
struct sockaddr_atmpvc *addr;
struct atm_vcc *vcc;
int error;
if (sockaddr_len != sizeof(struct sockaddr_atmpvc)) return -EINVAL;
addr = (struct sockaddr_atmpvc *) sockaddr;
if (addr->sap_family != AF_ATMPVC) return -EAFNOSUPPORT;
lock_sock(sk);
vcc = ATM_SD(sock);
if (!test_bit(ATM_VF_HASQOS,&vcc->flags)) return -EBADFD;
if (!test_bit(ATM_VF_HASQOS, &vcc->flags)) {
error = -EBADFD;
goto out;
}
if (test_bit(ATM_VF_PARTIAL,&vcc->flags)) {
if (vcc->vpi != ATM_VPI_UNSPEC) addr->sap_addr.vpi = vcc->vpi;
if (vcc->vci != ATM_VCI_UNSPEC) addr->sap_addr.vci = vcc->vci;
}
return atm_connect(sock,addr->sap_addr.itf,addr->sap_addr.vpi,
error = vcc_connect(sock, addr->sap_addr.itf, addr->sap_addr.vpi,
addr->sap_addr.vci);
out:
release_sock(sk);
return error;
}
......@@ -54,6 +59,31 @@ static int pvc_connect(struct socket *sock,struct sockaddr *sockaddr,
return pvc_bind(sock,sockaddr,sockaddr_len);
}
static int pvc_setsockopt(struct socket *sock, int level, int optname,
char *optval, int optlen)
{
struct sock *sk = sock->sk;
int error;
lock_sock(sk);
error = vcc_setsockopt(sock, level, optname, optval, optlen);
release_sock(sk);
return error;
}
static int pvc_getsockopt(struct socket *sock, int level, int optname,
char *optval, int *optlen)
{
struct sock *sk = sock->sk;
int error;
lock_sock(sk);
error = vcc_getsockopt(sock, level, optname, optval, optlen);
release_sock(sk);
return error;
}
static int pvc_getname(struct socket *sock,struct sockaddr *sockaddr,
int *sockaddr_len,int peer)
......@@ -72,36 +102,32 @@ static int pvc_getname(struct socket *sock,struct sockaddr *sockaddr,
}
static struct proto_ops SOCKOPS_WRAPPED(pvc_proto_ops) = {
static struct proto_ops pvc_proto_ops = {
.family = PF_ATMPVC,
.release = atm_release,
.release = vcc_release,
.bind = pvc_bind,
.connect = pvc_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = pvc_getname,
.poll = atm_poll,
.ioctl = atm_ioctl,
.ioctl = vcc_ioctl,
.listen = sock_no_listen,
.shutdown = pvc_shutdown,
.setsockopt = atm_setsockopt,
.getsockopt = atm_getsockopt,
.sendmsg = atm_sendmsg,
.recvmsg = atm_recvmsg,
.setsockopt = pvc_setsockopt,
.getsockopt = pvc_getsockopt,
.sendmsg = vcc_sendmsg,
.recvmsg = vcc_recvmsg,
.mmap = sock_no_mmap,
.sendpage = sock_no_sendpage,
};
#include <linux/smp_lock.h>
SOCKOPS_WRAP(pvc_proto, PF_ATMPVC);
static int pvc_create(struct socket *sock,int protocol)
{
sock->ops = &pvc_proto_ops;
return atm_create(sock,protocol,PF_ATMPVC);
return vcc_create(sock, protocol, PF_ATMPVC);
}
......
......@@ -12,6 +12,7 @@
#include <linux/ctype.h>
#include <linux/string.h>
#include <linux/atmdev.h>
#include <linux/sonet.h>
#include <linux/kernel.h> /* for barrier */
#include <linux/module.h>
#include <linux/bitops.h>
......@@ -19,11 +20,7 @@
#include "common.h"
#include "resources.h"
#ifndef NULL
#define NULL 0
#endif
#include "addr.h"
LIST_HEAD(atm_devs);
......@@ -89,7 +86,7 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,
spin_lock(&atm_dev_lock);
if (number != -1) {
if ((inuse = __atm_dev_lookup(number))) {
atm_dev_release(inuse);
atm_dev_put(inuse);
spin_unlock(&atm_dev_lock);
__free_atm_dev(dev);
return NULL;
......@@ -98,7 +95,7 @@ struct atm_dev *atm_dev_register(const char *type, const struct atmdev_ops *ops,
} else {
dev->number = 0;
while ((inuse = __atm_dev_lookup(dev->number))) {
atm_dev_release(inuse);
atm_dev_put(inuse);
dev->number++;
}
}
......@@ -171,73 +168,241 @@ void shutdown_atm_dev(struct atm_dev *dev)
atm_dev_deregister(dev);
}
struct sock *alloc_atm_vcc_sk(int family)
static void copy_aal_stats(struct k_atm_aal_stats *from,
struct atm_aal_stats *to)
{
struct sock *sk;
struct atm_vcc *vcc;
#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
__AAL_STAT_ITEMS
#undef __HANDLE_ITEM
}
sk = sk_alloc(family, GFP_KERNEL, 1, NULL);
if (!sk)
return NULL;
vcc = atm_sk(sk) = kmalloc(sizeof(*vcc), GFP_KERNEL);
if (!vcc) {
sk_free(sk);
return NULL;
}
sock_init_data(NULL, sk);
memset(vcc, 0, sizeof(*vcc));
vcc->sk = sk;
return sk;
static void subtract_aal_stats(struct k_atm_aal_stats *from,
struct atm_aal_stats *to)
{
#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
__AAL_STAT_ITEMS
#undef __HANDLE_ITEM
}
static void unlink_vcc(struct atm_vcc *vcc)
static int fetch_stats(struct atm_dev *dev, struct atm_dev_stats *arg, int zero)
{
unsigned long flags;
if (vcc->dev) {
spin_lock_irqsave(&vcc->dev->lock, flags);
if (vcc->prev)
vcc->prev->next = vcc->next;
else
vcc->dev->vccs = vcc->next;
if (vcc->next)
vcc->next->prev = vcc->prev;
else
vcc->dev->last = vcc->prev;
spin_unlock_irqrestore(&vcc->dev->lock, flags);
struct atm_dev_stats tmp;
int error = 0;
copy_aal_stats(&dev->stats.aal0, &tmp.aal0);
copy_aal_stats(&dev->stats.aal34, &tmp.aal34);
copy_aal_stats(&dev->stats.aal5, &tmp.aal5);
if (arg)
error = copy_to_user(arg, &tmp, sizeof(tmp));
if (zero && !error) {
subtract_aal_stats(&dev->stats.aal0, &tmp.aal0);
subtract_aal_stats(&dev->stats.aal34, &tmp.aal34);
subtract_aal_stats(&dev->stats.aal5, &tmp.aal5);
}
return error ? -EFAULT : 0;
}
void free_atm_vcc_sk(struct sock *sk)
int atm_dev_ioctl(unsigned int cmd, unsigned long arg)
{
unlink_vcc(atm_sk(sk));
sk_free(sk);
}
void *buf;
int error, len, number, size = 0;
struct atm_dev *dev;
struct list_head *p;
int *tmp_buf, *tmp_p;
switch (cmd) {
case ATM_GETNAMES:
if (get_user(buf, &((struct atm_iobuf *) arg)->buffer))
return -EFAULT;
if (get_user(len, &((struct atm_iobuf *) arg)->length))
return -EFAULT;
spin_lock(&atm_dev_lock);
list_for_each(p, &atm_devs)
size += sizeof(int);
if (size > len) {
spin_unlock(&atm_dev_lock);
return -E2BIG;
}
tmp_buf = kmalloc(size, GFP_ATOMIC);
if (!tmp_buf) {
spin_unlock(&atm_dev_lock);
return -ENOMEM;
}
tmp_p = tmp_buf;
list_for_each(p, &atm_devs) {
dev = list_entry(p, struct atm_dev, dev_list);
*tmp_p++ = dev->number;
}
spin_unlock(&atm_dev_lock);
error = ((copy_to_user(buf, tmp_buf, size)) ||
put_user(size, &((struct atm_iobuf *) arg)->length))
? -EFAULT : 0;
kfree(tmp_buf);
return error;
default:
break;
}
void bind_vcc(struct atm_vcc *vcc,struct atm_dev *dev)
{
unsigned long flags;
unlink_vcc(vcc);
vcc->dev = dev;
if (dev) {
spin_lock_irqsave(&dev->lock, flags);
vcc->next = NULL;
vcc->prev = dev->last;
if (dev->vccs)
dev->last->next = vcc;
if (get_user(buf, &((struct atmif_sioc *) arg)->arg))
return -EFAULT;
if (get_user(len, &((struct atmif_sioc *) arg)->length))
return -EFAULT;
if (get_user(number, &((struct atmif_sioc *) arg)->number))
return -EFAULT;
if (!(dev = atm_dev_lookup(number)))
return -ENODEV;
switch (cmd) {
case ATM_GETTYPE:
size = strlen(dev->type) + 1;
if (copy_to_user(buf, dev->type, size)) {
error = -EFAULT;
goto done;
}
break;
case ATM_GETESI:
size = ESI_LEN;
if (copy_to_user(buf, dev->esi, size)) {
error = -EFAULT;
goto done;
}
break;
case ATM_SETESI:
{
int i;
for (i = 0; i < ESI_LEN; i++)
if (dev->esi[i]) {
error = -EEXIST;
goto done;
}
}
/* fall through */
case ATM_SETESIF:
{
unsigned char esi[ESI_LEN];
if (!capable(CAP_NET_ADMIN)) {
error = -EPERM;
goto done;
}
if (copy_from_user(esi, buf, ESI_LEN)) {
error = -EFAULT;
goto done;
}
memcpy(dev->esi, esi, ESI_LEN);
error = ESI_LEN;
goto done;
}
case ATM_GETSTATZ:
if (!capable(CAP_NET_ADMIN)) {
error = -EPERM;
goto done;
}
/* fall through */
case ATM_GETSTAT:
size = sizeof(struct atm_dev_stats);
error = fetch_stats(dev, buf, cmd == ATM_GETSTATZ);
if (error)
goto done;
break;
case ATM_GETCIRANGE:
size = sizeof(struct atm_cirange);
if (copy_to_user(buf, &dev->ci_range, size)) {
error = -EFAULT;
goto done;
}
break;
case ATM_GETLINKRATE:
size = sizeof(int);
if (copy_to_user(buf, &dev->link_rate, size)) {
error = -EFAULT;
goto done;
}
break;
case ATM_RSTADDR:
if (!capable(CAP_NET_ADMIN)) {
error = -EPERM;
goto done;
}
atm_reset_addr(dev);
break;
case ATM_ADDADDR:
case ATM_DELADDR:
if (!capable(CAP_NET_ADMIN)) {
error = -EPERM;
goto done;
}
{
struct sockaddr_atmsvc addr;
if (copy_from_user(&addr, buf, sizeof(addr))) {
error = -EFAULT;
goto done;
}
if (cmd == ATM_ADDADDR)
error = atm_add_addr(dev, &addr);
else
dev->vccs = vcc;
dev->last = vcc;
spin_unlock_irqrestore(&dev->lock, flags);
error = atm_del_addr(dev, &addr);
goto done;
}
case ATM_GETADDR:
error = atm_get_addr(dev, buf, len);
if (error < 0)
goto done;
size = error;
/* may return 0, but later on size == 0 means "don't
write the length" */
error = put_user(size, &((struct atmif_sioc *) arg)->length)
? -EFAULT : 0;
goto done;
case ATM_SETLOOP:
if (__ATM_LM_XTRMT((int) (long) buf) &&
__ATM_LM_XTLOC((int) (long) buf) >
__ATM_LM_XTRMT((int) (long) buf)) {
error = -EINVAL;
goto done;
}
/* fall through */
case ATM_SETCIRANGE:
case SONET_GETSTATZ:
case SONET_SETDIAG:
case SONET_CLRDIAG:
case SONET_SETFRAMING:
if (!capable(CAP_NET_ADMIN)) {
error = -EPERM;
goto done;
}
/* fall through */
default:
if (!dev->ops->ioctl) {
error = -EINVAL;
goto done;
}
size = dev->ops->ioctl(dev, cmd, buf);
if (size < 0) {
error = (size == -ENOIOCTLCMD ? -EINVAL : size);
goto done;
}
}
if (size)
error = put_user(size, &((struct atmif_sioc *) arg)->length)
? -EFAULT : 0;
else
error = 0;
done:
atm_dev_put(dev);
return error;
}
EXPORT_SYMBOL(atm_dev_register);
EXPORT_SYMBOL(atm_dev_deregister);
EXPORT_SYMBOL(atm_dev_lookup);
EXPORT_SYMBOL(shutdown_atm_dev);
EXPORT_SYMBOL(bind_vcc);
......@@ -14,8 +14,7 @@ extern struct list_head atm_devs;
extern spinlock_t atm_dev_lock;
struct sock *alloc_atm_vcc_sk(int family);
void free_atm_vcc_sk(struct sock *sk);
int atm_dev_ioctl(unsigned int cmd, unsigned long arg);
#ifdef CONFIG_PROC_FS
......
......@@ -124,14 +124,16 @@ static int sigd_send(struct atm_vcc *vcc,struct sk_buff *skb)
clear_bit(ATM_VF_REGIS,&vcc->flags);
clear_bit(ATM_VF_READY,&vcc->flags);
vcc->reply = msg->reply;
vcc->sk->sk_err = -msg->reply;
break;
case as_indicate:
vcc = *(struct atm_vcc **) &msg->listen_vcc;
DPRINTK("as_indicate!!!\n");
lock_sock(vcc->sk);
if (vcc->sk->sk_ack_backlog ==
vcc->sk->sk_max_ack_backlog) {
sigd_enq(0,as_reject,vcc,NULL,NULL);
return 0;
goto as_indicate_complete;
}
vcc->sk->sk_ack_backlog++;
skb_queue_tail(&vcc->sk->sk_receive_queue, skb);
......@@ -140,11 +142,14 @@ static int sigd_send(struct atm_vcc *vcc,struct sk_buff *skb)
&vcc->sleep);
vcc->callback(vcc);
}
as_indicate_complete:
release_sock(vcc->sk);
return 0;
case as_close:
set_bit(ATM_VF_RELEASED,&vcc->flags);
clear_bit(ATM_VF_READY,&vcc->flags);
vcc->reply = msg->reply;
vcc->sk->sk_err = -msg->reply;
break;
case as_modify:
modify_qos(vcc,msg);
......@@ -195,25 +200,21 @@ void sigd_enq(struct atm_vcc *vcc,enum atmsvc_msg_type type,
}
static void purge_vccs(struct atm_vcc *vcc)
static void purge_vcc(struct atm_vcc *vcc)
{
while (vcc) {
if (vcc->sk->sk_family == PF_ATMSVC &&
!test_bit(ATM_VF_META,&vcc->flags)) {
set_bit(ATM_VF_RELEASED,&vcc->flags);
vcc->reply = -EUNATCH;
vcc->sk->sk_err = EUNATCH;
wake_up(&vcc->sleep);
}
vcc = vcc->next;
}
}
static void sigd_close(struct atm_vcc *vcc)
{
unsigned long flags;
struct atm_dev *dev;
struct list_head *p;
struct sock *s;
DPRINTK("sigd_close\n");
sigd = NULL;
......@@ -221,14 +222,14 @@ static void sigd_close(struct atm_vcc *vcc)
printk(KERN_ERR "sigd_close: closing with requests pending\n");
skb_queue_purge(&vcc->sk->sk_receive_queue);
spin_lock(&atm_dev_lock);
list_for_each(p, &atm_devs) {
dev = list_entry(p, struct atm_dev, dev_list);
spin_lock_irqsave(&dev->lock, flags);
purge_vccs(dev->vccs);
spin_unlock_irqrestore(&dev->lock, flags);
read_lock(&vcc_sklist_lock);
for(s = vcc_sklist; s; s = s->sk_next) {
struct atm_vcc *vcc = atm_sk(s);
if (vcc->dev)
purge_vcc(vcc);
}
spin_unlock(&atm_dev_lock);
read_unlock(&vcc_sklist_lock);
}
......@@ -251,7 +252,8 @@ int sigd_attach(struct atm_vcc *vcc)
if (sigd) return -EADDRINUSE;
DPRINTK("sigd_attach\n");
sigd = vcc;
bind_vcc(vcc,&sigd_dev);
vcc->dev = &sigd_dev;
vcc_insert_socket(vcc->sk);
set_bit(ATM_VF_META,&vcc->flags);
set_bit(ATM_VF_READY,&vcc->flags);
wake_up(&sigd_sleep);
......
This diff is collapsed.
......@@ -387,8 +387,17 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
if (type == IGMPV3_ALLOW_NEW_SOURCES ||
type == IGMPV3_BLOCK_OLD_SOURCES)
return skb;
if (pmc->crcount || isquery)
if (pmc->crcount || isquery) {
/* make sure we have room for group header and at
* least one source.
*/
if (skb && AVAILABLE(skb) < sizeof(struct igmpv3_grec)+
sizeof(__u32)) {
igmpv3_sendpack(skb);
skb = 0; /* add_grhead will get a new one */
}
skb = add_grhead(skb, pmc, type, &pgr);
}
return skb;
}
pih = skb ? (struct igmpv3_report *)skb->h.igmph : 0;
......
......@@ -1321,8 +1321,17 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ifmcaddr6 *pmc,
if (type == MLD2_ALLOW_NEW_SOURCES ||
type == MLD2_BLOCK_OLD_SOURCES)
return skb;
if (pmc->mca_crcount || isquery)
if (pmc->mca_crcount || isquery) {
/* make sure we have room for group header and at
* least one source.
*/
if (skb && AVAILABLE(skb) < sizeof(struct mld2_grec)+
sizeof(struct in6_addr)) {
mld_sendpack(skb);
skb = 0; /* add_grhead will get a new one */
}
skb = add_grhead(skb, pmc, type, &pgr);
}
return skb;
}
pmr = skb ? (struct mld2_report *)skb->h.raw : 0;
......
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