diff options
Diffstat (limited to 'net/atm/addr.c')
-rw-r--r-- | net/atm/addr.c | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/net/atm/addr.c b/net/atm/addr.c index a30d0bf48063..3060fd0ba4b9 100644 --- a/net/atm/addr.c +++ b/net/atm/addr.c | |||
@@ -44,31 +44,43 @@ static void notify_sigd(struct atm_dev *dev) | |||
44 | sigd_enq(NULL, as_itf_notify, NULL, &pvc, NULL); | 44 | sigd_enq(NULL, as_itf_notify, NULL, &pvc, NULL); |
45 | } | 45 | } |
46 | 46 | ||
47 | void atm_reset_addr(struct atm_dev *dev) | 47 | void atm_reset_addr(struct atm_dev *dev, enum atm_addr_type_t atype) |
48 | { | 48 | { |
49 | unsigned long flags; | 49 | unsigned long flags; |
50 | struct atm_dev_addr *this, *p; | 50 | struct atm_dev_addr *this, *p; |
51 | struct list_head *head; | ||
51 | 52 | ||
52 | spin_lock_irqsave(&dev->lock, flags); | 53 | spin_lock_irqsave(&dev->lock, flags); |
53 | list_for_each_entry_safe(this, p, &dev->local, entry) { | 54 | if (atype == ATM_ADDR_LECS) |
55 | head = &dev->lecs; | ||
56 | else | ||
57 | head = &dev->local; | ||
58 | list_for_each_entry_safe(this, p, head, entry) { | ||
54 | list_del(&this->entry); | 59 | list_del(&this->entry); |
55 | kfree(this); | 60 | kfree(this); |
56 | } | 61 | } |
57 | spin_unlock_irqrestore(&dev->lock, flags); | 62 | spin_unlock_irqrestore(&dev->lock, flags); |
58 | notify_sigd(dev); | 63 | if (head == &dev->local) |
64 | notify_sigd(dev); | ||
59 | } | 65 | } |
60 | 66 | ||
61 | int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr) | 67 | int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr, |
68 | enum atm_addr_type_t atype) | ||
62 | { | 69 | { |
63 | unsigned long flags; | 70 | unsigned long flags; |
64 | struct atm_dev_addr *this; | 71 | struct atm_dev_addr *this; |
72 | struct list_head *head; | ||
65 | int error; | 73 | int error; |
66 | 74 | ||
67 | error = check_addr(addr); | 75 | error = check_addr(addr); |
68 | if (error) | 76 | if (error) |
69 | return error; | 77 | return error; |
70 | spin_lock_irqsave(&dev->lock, flags); | 78 | spin_lock_irqsave(&dev->lock, flags); |
71 | list_for_each_entry(this, &dev->local, entry) { | 79 | if (atype == ATM_ADDR_LECS) |
80 | head = &dev->lecs; | ||
81 | else | ||
82 | head = &dev->local; | ||
83 | list_for_each_entry(this, head, entry) { | ||
72 | if (identical(&this->addr, addr)) { | 84 | if (identical(&this->addr, addr)) { |
73 | spin_unlock_irqrestore(&dev->lock, flags); | 85 | spin_unlock_irqrestore(&dev->lock, flags); |
74 | return -EEXIST; | 86 | return -EEXIST; |
@@ -80,28 +92,36 @@ int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr) | |||
80 | return -ENOMEM; | 92 | return -ENOMEM; |
81 | } | 93 | } |
82 | this->addr = *addr; | 94 | this->addr = *addr; |
83 | list_add(&this->entry, &dev->local); | 95 | list_add(&this->entry, head); |
84 | spin_unlock_irqrestore(&dev->lock, flags); | 96 | spin_unlock_irqrestore(&dev->lock, flags); |
85 | notify_sigd(dev); | 97 | if (head == &dev->local) |
98 | notify_sigd(dev); | ||
86 | return 0; | 99 | return 0; |
87 | } | 100 | } |
88 | 101 | ||
89 | int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr) | 102 | int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr, |
103 | enum atm_addr_type_t atype) | ||
90 | { | 104 | { |
91 | unsigned long flags; | 105 | unsigned long flags; |
92 | struct atm_dev_addr *this; | 106 | struct atm_dev_addr *this; |
107 | struct list_head *head; | ||
93 | int error; | 108 | int error; |
94 | 109 | ||
95 | error = check_addr(addr); | 110 | error = check_addr(addr); |
96 | if (error) | 111 | if (error) |
97 | return error; | 112 | return error; |
98 | spin_lock_irqsave(&dev->lock, flags); | 113 | spin_lock_irqsave(&dev->lock, flags); |
99 | list_for_each_entry(this, &dev->local, entry) { | 114 | if (atype == ATM_ADDR_LECS) |
115 | head = &dev->lecs; | ||
116 | else | ||
117 | head = &dev->local; | ||
118 | list_for_each_entry(this, head, entry) { | ||
100 | if (identical(&this->addr, addr)) { | 119 | if (identical(&this->addr, addr)) { |
101 | list_del(&this->entry); | 120 | list_del(&this->entry); |
102 | spin_unlock_irqrestore(&dev->lock, flags); | 121 | spin_unlock_irqrestore(&dev->lock, flags); |
103 | kfree(this); | 122 | kfree(this); |
104 | notify_sigd(dev); | 123 | if (head == &dev->local) |
124 | notify_sigd(dev); | ||
105 | return 0; | 125 | return 0; |
106 | } | 126 | } |
107 | } | 127 | } |
@@ -110,22 +130,27 @@ int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr) | |||
110 | } | 130 | } |
111 | 131 | ||
112 | int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user * buf, | 132 | int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user * buf, |
113 | size_t size) | 133 | size_t size, enum atm_addr_type_t atype) |
114 | { | 134 | { |
115 | unsigned long flags; | 135 | unsigned long flags; |
116 | struct atm_dev_addr *this; | 136 | struct atm_dev_addr *this; |
137 | struct list_head *head; | ||
117 | int total = 0, error; | 138 | int total = 0, error; |
118 | struct sockaddr_atmsvc *tmp_buf, *tmp_bufp; | 139 | struct sockaddr_atmsvc *tmp_buf, *tmp_bufp; |
119 | 140 | ||
120 | spin_lock_irqsave(&dev->lock, flags); | 141 | spin_lock_irqsave(&dev->lock, flags); |
121 | list_for_each_entry(this, &dev->local, entry) | 142 | if (atype == ATM_ADDR_LECS) |
143 | head = &dev->lecs; | ||
144 | else | ||
145 | head = &dev->local; | ||
146 | list_for_each_entry(this, head, entry) | ||
122 | total += sizeof(struct sockaddr_atmsvc); | 147 | total += sizeof(struct sockaddr_atmsvc); |
123 | tmp_buf = tmp_bufp = kmalloc(total, GFP_ATOMIC); | 148 | tmp_buf = tmp_bufp = kmalloc(total, GFP_ATOMIC); |
124 | if (!tmp_buf) { | 149 | if (!tmp_buf) { |
125 | spin_unlock_irqrestore(&dev->lock, flags); | 150 | spin_unlock_irqrestore(&dev->lock, flags); |
126 | return -ENOMEM; | 151 | return -ENOMEM; |
127 | } | 152 | } |
128 | list_for_each_entry(this, &dev->local, entry) | 153 | list_for_each_entry(this, head, entry) |
129 | memcpy(tmp_bufp++, &this->addr, sizeof(struct sockaddr_atmsvc)); | 154 | memcpy(tmp_bufp++, &this->addr, sizeof(struct sockaddr_atmsvc)); |
130 | spin_unlock_irqrestore(&dev->lock, flags); | 155 | spin_unlock_irqrestore(&dev->lock, flags); |
131 | error = total > size ? -E2BIG : total; | 156 | error = total > size ? -E2BIG : total; |