return (struct sock *)vcc;
}
-struct atm_dev_addr {
- struct sockaddr_atmsvc addr; /* ATM address */
- struct list_head entry; /* next address */
-};
-
-enum atm_addr_type_t { ATM_ADDR_LOCAL, ATM_ADDR_LECS };
-
struct atm_dev {
const struct atmdev_ops *ops; /* device operations; NULL if unused */
const struct atmphy_ops *phy; /* PHY operations, may be undefined */
void *dev_data; /* per-device data */
void *phy_data; /* private PHY data */
unsigned long flags; /* device flags (ATM_DF_*) */
- struct list_head local; /* local ATM addresses */
- struct list_head lecs; /* LECS ATM addresses learned via ILMI */
unsigned char esi[ESI_LEN]; /* ESI ("MAC" addr) */
struct atm_cirange ci_range; /* VPI/VCI range */
struct k_atm_dev_stats stats; /* statistics */
# Makefile for the ATM Protocol Families.
#
-atm-y := addr.o pvc.o signaling.o svc.o ioctl.o common.o atm_misc.o raw.o resources.o atm_sysfs.o
+atm-y := pvc.o signaling.o svc.o ioctl.o common.o atm_misc.o raw.o resources.o atm_sysfs.o
obj-$(CONFIG_ATM) += atm.o
obj-$(CONFIG_ATM_BR2684) += br2684.o
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0
-/* net/atm/addr.c - Local ATM address registry */
-
-/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
-
-#include <linux/atm.h>
-#include <linux/atmdev.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-
-#include "signaling.h"
-#include "addr.h"
-
-static int check_addr(const struct sockaddr_atmsvc *addr)
-{
- int i;
-
- if (addr->sas_family != AF_ATMSVC)
- return -EAFNOSUPPORT;
- if (!*addr->sas_addr.pub)
- return *addr->sas_addr.prv ? 0 : -EINVAL;
- for (i = 1; i < ATM_E164_LEN + 1; i++) /* make sure it's \0-terminated */
- if (!addr->sas_addr.pub[i])
- return 0;
- return -EINVAL;
-}
-
-static int identical(const struct sockaddr_atmsvc *a, const struct sockaddr_atmsvc *b)
-{
- if (*a->sas_addr.prv)
- if (memcmp(a->sas_addr.prv, b->sas_addr.prv, ATM_ESA_LEN))
- return 0;
- if (!*a->sas_addr.pub)
- return !*b->sas_addr.pub;
- if (!*b->sas_addr.pub)
- return 0;
- return !strcmp(a->sas_addr.pub, b->sas_addr.pub);
-}
-
-static void notify_sigd(const struct atm_dev *dev)
-{
- struct sockaddr_atmpvc pvc;
-
- pvc.sap_addr.itf = dev->number;
- sigd_enq(NULL, as_itf_notify, NULL, &pvc, NULL);
-}
-
-void atm_reset_addr(struct atm_dev *dev, enum atm_addr_type_t atype)
-{
- unsigned long flags;
- struct atm_dev_addr *this, *p;
- struct list_head *head;
-
- spin_lock_irqsave(&dev->lock, flags);
- if (atype == ATM_ADDR_LECS)
- head = &dev->lecs;
- else
- head = &dev->local;
- list_for_each_entry_safe(this, p, head, entry) {
- list_del(&this->entry);
- kfree(this);
- }
- spin_unlock_irqrestore(&dev->lock, flags);
- if (head == &dev->local)
- notify_sigd(dev);
-}
-
-int atm_add_addr(struct atm_dev *dev, const struct sockaddr_atmsvc *addr,
- enum atm_addr_type_t atype)
-{
- unsigned long flags;
- struct atm_dev_addr *this;
- struct list_head *head;
- int error;
-
- error = check_addr(addr);
- if (error)
- return error;
- spin_lock_irqsave(&dev->lock, flags);
- if (atype == ATM_ADDR_LECS)
- head = &dev->lecs;
- else
- head = &dev->local;
- list_for_each_entry(this, head, entry) {
- if (identical(&this->addr, addr)) {
- spin_unlock_irqrestore(&dev->lock, flags);
- return -EEXIST;
- }
- }
- this = kmalloc_obj(struct atm_dev_addr, GFP_ATOMIC);
- if (!this) {
- spin_unlock_irqrestore(&dev->lock, flags);
- return -ENOMEM;
- }
- this->addr = *addr;
- list_add(&this->entry, head);
- spin_unlock_irqrestore(&dev->lock, flags);
- if (head == &dev->local)
- notify_sigd(dev);
- return 0;
-}
-
-int atm_del_addr(struct atm_dev *dev, const struct sockaddr_atmsvc *addr,
- enum atm_addr_type_t atype)
-{
- unsigned long flags;
- struct atm_dev_addr *this;
- struct list_head *head;
- int error;
-
- error = check_addr(addr);
- if (error)
- return error;
- spin_lock_irqsave(&dev->lock, flags);
- if (atype == ATM_ADDR_LECS)
- head = &dev->lecs;
- else
- head = &dev->local;
- list_for_each_entry(this, head, entry) {
- if (identical(&this->addr, addr)) {
- list_del(&this->entry);
- spin_unlock_irqrestore(&dev->lock, flags);
- kfree(this);
- if (head == &dev->local)
- notify_sigd(dev);
- return 0;
- }
- }
- spin_unlock_irqrestore(&dev->lock, flags);
- return -ENOENT;
-}
-
-int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user * buf,
- size_t size, enum atm_addr_type_t atype)
-{
- unsigned long flags;
- struct atm_dev_addr *this;
- struct list_head *head;
- int total = 0, error;
- struct sockaddr_atmsvc *tmp_buf, *tmp_bufp;
-
- spin_lock_irqsave(&dev->lock, flags);
- if (atype == ATM_ADDR_LECS)
- head = &dev->lecs;
- else
- head = &dev->local;
- list_for_each_entry(this, head, entry)
- total += sizeof(struct sockaddr_atmsvc);
- tmp_buf = tmp_bufp = kmalloc(total, GFP_ATOMIC);
- if (!tmp_buf) {
- spin_unlock_irqrestore(&dev->lock, flags);
- return -ENOMEM;
- }
- list_for_each_entry(this, head, entry)
- memcpy(tmp_bufp++, &this->addr, sizeof(struct sockaddr_atmsvc));
- spin_unlock_irqrestore(&dev->lock, flags);
- error = total > size ? -E2BIG : total;
- if (copy_to_user(buf, tmp_buf, total < size ? total : size))
- error = -EFAULT;
- kfree(tmp_buf);
- return error;
-}
+++ /dev/null
-/* SPDX-License-Identifier: GPL-2.0 */
-/* net/atm/addr.h - Local ATM address registry */
-
-/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
-
-
-#ifndef NET_ATM_ADDR_H
-#define NET_ATM_ADDR_H
-
-#include <linux/atm.h>
-#include <linux/atmdev.h>
-
-void atm_reset_addr(struct atm_dev *dev, enum atm_addr_type_t type);
-int atm_add_addr(struct atm_dev *dev, const struct sockaddr_atmsvc *addr,
- enum atm_addr_type_t type);
-int atm_del_addr(struct atm_dev *dev, const struct sockaddr_atmsvc *addr,
- enum atm_addr_type_t type);
-int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user *buf,
- size_t size, enum atm_addr_type_t type);
-
-#endif
return scnprintf(buf, PAGE_SIZE, "%pM\n", adev->esi);
}
-static ssize_t atmaddress_show(struct device *cdev,
- struct device_attribute *attr, char *buf)
-{
- unsigned long flags;
- struct atm_dev *adev = to_atm_dev(cdev);
- struct atm_dev_addr *aaddr;
- int count = 0;
-
- spin_lock_irqsave(&adev->lock, flags);
- list_for_each_entry(aaddr, &adev->local, entry) {
- count += scnprintf(buf + count, PAGE_SIZE - count,
- "%1phN.%2phN.%10phN.%6phN.%1phN\n",
- &aaddr->addr.sas_addr.prv[0],
- &aaddr->addr.sas_addr.prv[1],
- &aaddr->addr.sas_addr.prv[3],
- &aaddr->addr.sas_addr.prv[13],
- &aaddr->addr.sas_addr.prv[19]);
- }
- spin_unlock_irqrestore(&adev->lock, flags);
-
- return count;
-}
-
static ssize_t atmindex_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
}
static DEVICE_ATTR_RO(address);
-static DEVICE_ATTR_RO(atmaddress);
static DEVICE_ATTR_RO(atmindex);
static DEVICE_ATTR_RO(carrier);
static DEVICE_ATTR_RO(type);
static DEVICE_ATTR_RO(link_rate);
static struct device_attribute *atm_attrs[] = {
- &dev_attr_atmaddress,
&dev_attr_address,
&dev_attr_atmindex,
&dev_attr_carrier,
#include "resources.h" /* atm_find_dev */
#include "common.h" /* prototypes */
#include "protocols.h" /* atm_init_<transport> */
-#include "addr.h" /* address registry */
#include "signaling.h" /* for WAITING and sigd_attach */
struct hlist_head vcc_hash[VCC_HTABLE_SIZE];
#define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct compat_atm_iobuf)
#define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct compat_atmif_sioc)
#define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct compat_atmif_sioc)
-#define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct compat_atmif_sioc)
-#define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct compat_atmif_sioc)
-#define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct compat_atmif_sioc)
-#define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct compat_atmif_sioc)
#define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct compat_atmif_sioc)
#define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct compat_atmif_sioc)
#define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct compat_atmif_sioc)
{ ATM_GETNAMES32, ATM_GETNAMES },
{ ATM_GETTYPE32, ATM_GETTYPE },
{ ATM_GETESI32, ATM_GETESI },
- { ATM_GETADDR32, ATM_GETADDR },
- { ATM_RSTADDR32, ATM_RSTADDR },
- { ATM_ADDADDR32, ATM_ADDADDR },
- { ATM_DELADDR32, ATM_DELADDR },
{ ATM_GETCIRANGE32, ATM_GETCIRANGE },
{ ATM_SETCIRANGE32, ATM_SETCIRANGE },
{ ATM_SETESI32, ATM_SETESI },
case ATM_GETLINKRATE:
case ATM_GETTYPE:
case ATM_GETESI:
- case ATM_GETADDR:
- case ATM_RSTADDR:
- case ATM_ADDADDR:
- case ATM_DELADDR:
case ATM_GETCIRANGE:
case ATM_SETCIRANGE:
case ATM_SETESI:
#include "common.h"
#include "resources.h"
-#include "addr.h"
LIST_HEAD(atm_devs);
dev->signal = ATM_PHY_SIG_UNKNOWN;
dev->link_rate = ATM_OC3_PCR;
spin_lock_init(&dev->lock);
- INIT_LIST_HEAD(&dev->local);
- INIT_LIST_HEAD(&dev->lecs);
return dev;
}
int atm_dev_ioctl(unsigned int cmd, void __user *buf, int __user *sioc_len,
int number, int compat)
{
- int error, len, size = 0;
struct atm_dev *dev;
-
- if (get_user(len, sioc_len))
- return -EFAULT;
+ int error, size = 0;
dev = try_then_request_module(atm_dev_lookup(number), "atm-device-%d",
number);
goto done;
}
break;
- case ATM_RSTADDR:
- if (!capable(CAP_NET_ADMIN)) {
- error = -EPERM;
- goto done;
- }
- atm_reset_addr(dev, ATM_ADDR_LOCAL);
- break;
- case ATM_ADDADDR:
- case ATM_DELADDR:
- case ATM_ADDLECSADDR:
- case ATM_DELLECSADDR:
- {
- struct sockaddr_atmsvc addr;
-
- if (!capable(CAP_NET_ADMIN)) {
- error = -EPERM;
- goto done;
- }
-
- if (copy_from_user(&addr, buf, sizeof(addr))) {
- error = -EFAULT;
- goto done;
- }
- if (cmd == ATM_ADDADDR || cmd == ATM_ADDLECSADDR)
- error = atm_add_addr(dev, &addr,
- (cmd == ATM_ADDADDR ?
- ATM_ADDR_LOCAL : ATM_ADDR_LECS));
- else
- error = atm_del_addr(dev, &addr,
- (cmd == ATM_DELADDR ?
- ATM_ADDR_LOCAL : ATM_ADDR_LECS));
- goto done;
- }
- case ATM_GETADDR:
- case ATM_GETLECSADDR:
- error = atm_get_addr(dev, buf, len,
- (cmd == ATM_GETADDR ?
- ATM_ADDR_LOCAL : ATM_ADDR_LECS));
- 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, sioc_len) ? -EFAULT : 0;
- goto done;
case ATM_SETLOOP:
if (__ATM_LM_XTRMT((int) (unsigned long) buf) &&
__ATM_LM_XTLOC((int) (unsigned long) buf) >
#include "resources.h"
#include "common.h" /* common for PVCs and SVCs */
#include "signaling.h"
-#include "addr.h"
#ifdef CONFIG_COMPAT
/* It actually takes struct sockaddr_atmsvc, not struct atm_iobuf */