Blame view
net/atm/mpc.c
38.2 KB
09c434b8a treewide: Add SPD... |
1 |
// SPDX-License-Identifier: GPL-2.0-only |
99824461e net/atm: Convert ... |
2 |
#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ |
1da177e4c Linux-2.6.12-rc2 |
3 4 |
#include <linux/kernel.h> #include <linux/string.h> |
5a0e3ad6a include cleanup: ... |
5 |
#include <linux/slab.h> |
1da177e4c Linux-2.6.12-rc2 |
6 7 8 |
#include <linux/timer.h> #include <linux/init.h> #include <linux/bitops.h> |
4fc268d24 [PATCH] capable/c... |
9 |
#include <linux/capability.h> |
1da177e4c Linux-2.6.12-rc2 |
10 11 12 13 14 15 16 17 18 |
#include <linux/seq_file.h> /* We are an ethernet device */ #include <linux/if_ether.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <net/sock.h> #include <linux/skbuff.h> #include <linux/ip.h> |
571004407 net/atm/mpc.c: ch... |
19 |
#include <linux/uaccess.h> |
1da177e4c Linux-2.6.12-rc2 |
20 |
#include <asm/byteorder.h> |
1da177e4c Linux-2.6.12-rc2 |
21 22 23 24 25 26 27 28 29 30 |
#include <net/checksum.h> /* for ip_fast_csum() */ #include <net/arp.h> #include <net/dst.h> #include <linux/proc_fs.h> /* And atm device */ #include <linux/atmdev.h> #include <linux/atmlec.h> #include <linux/atmmpc.h> /* Modular too */ |
1da177e4c Linux-2.6.12-rc2 |
31 32 33 34 35 36 37 |
#include <linux/module.h> #include "lec.h" #include "mpc.h" #include "resources.h" /* |
f7d57453d [NET] ATM: Fix wh... |
38 |
* mpc.c: Implementation of MPOA client kernel part |
1da177e4c Linux-2.6.12-rc2 |
39 40 41 |
*/ #if 0 |
b50c2ea72 net/atm: Cleanup ... |
42 43 44 |
#define dprintk(format, args...) \ printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args) #define dprintk_cont(format, args...) printk(KERN_CONT format, ##args) |
1da177e4c Linux-2.6.12-rc2 |
45 |
#else |
b50c2ea72 net/atm: Cleanup ... |
46 47 48 49 50 51 |
#define dprintk(format, args...) \ do { if (0) \ printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args);\ } while (0) #define dprintk_cont(format, args...) \ do { if (0) printk(KERN_CONT format, ##args); } while (0) |
1da177e4c Linux-2.6.12-rc2 |
52 53 54 |
#endif #if 0 |
b50c2ea72 net/atm: Cleanup ... |
55 56 57 |
#define ddprintk(format, args...) \ printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args) #define ddprintk_cont(format, args...) printk(KERN_CONT format, ##args) |
1da177e4c Linux-2.6.12-rc2 |
58 |
#else |
b50c2ea72 net/atm: Cleanup ... |
59 60 61 62 63 64 |
#define ddprintk(format, args...) \ do { if (0) \ printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args);\ } while (0) #define ddprintk_cont(format, args...) \ do { if (0) printk(KERN_CONT format, ##args); } while (0) |
1da177e4c Linux-2.6.12-rc2 |
65 |
#endif |
1da177e4c Linux-2.6.12-rc2 |
66 |
/* mpc_daemon -> kernel */ |
571004407 net/atm/mpc.c: ch... |
67 |
static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc); |
1da177e4c Linux-2.6.12-rc2 |
68 69 70 71 |
static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc); static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc); static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc); static void mps_death(struct k_message *msg, struct mpoa_client *mpc); |
571004407 net/atm/mpc.c: ch... |
72 73 74 75 76 77 78 79 |
static void clean_up(struct k_message *msg, struct mpoa_client *mpc, int action); static void MPOA_cache_impos_rcvd(struct k_message *msg, struct mpoa_client *mpc); static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg, struct mpoa_client *mpc); static void set_mps_mac_addr_rcvd(struct k_message *mesg, struct mpoa_client *mpc); |
1da177e4c Linux-2.6.12-rc2 |
80 |
|
cba5cbd15 atm: fix const as... |
81 82 83 84 |
static const uint8_t *copy_macs(struct mpoa_client *mpc, const uint8_t *router_mac, const uint8_t *tlvs, uint8_t mps_macs, uint8_t device_type); |
1da177e4c Linux-2.6.12-rc2 |
85 |
static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry); |
cba5cbd15 atm: fix const as... |
86 |
static void send_set_mps_ctrl_addr(const char *addr, struct mpoa_client *mpc); |
1da177e4c Linux-2.6.12-rc2 |
87 88 89 90 |
static void mpoad_close(struct atm_vcc *vcc); static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb); static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb); |
3c805a22a convert ATM drive... |
91 |
static netdev_tx_t mpc_send_packet(struct sk_buff *skb, |
571004407 net/atm/mpc.c: ch... |
92 93 94 |
struct net_device *dev); static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned long event, void *dev); |
1da177e4c Linux-2.6.12-rc2 |
95 |
static void mpc_timer_refresh(void); |
5c658e19a net: atm/mpc: Sto... |
96 |
static void mpc_cache_check(struct timer_list *unused); |
1da177e4c Linux-2.6.12-rc2 |
97 98 99 100 101 |
static struct llc_snap_hdr llc_snap_mpoa_ctrl = { 0xaa, 0xaa, 0x03, {0x00, 0x00, 0x5e}, {0x00, 0x03} /* For MPOA control PDUs */ |
f7d57453d [NET] ATM: Fix wh... |
102 |
}; |
1da177e4c Linux-2.6.12-rc2 |
103 104 105 106 |
static struct llc_snap_hdr llc_snap_mpoa_data = { 0xaa, 0xaa, 0x03, {0x00, 0x00, 0x00}, {0x08, 0x00} /* This is for IP PDUs only */ |
f7d57453d [NET] ATM: Fix wh... |
107 |
}; |
1da177e4c Linux-2.6.12-rc2 |
108 109 110 111 |
static struct llc_snap_hdr llc_snap_mpoa_data_tagged = { 0xaa, 0xaa, 0x03, {0x00, 0x00, 0x00}, {0x88, 0x4c} /* This is for tagged data PDUs */ |
f7d57453d [NET] ATM: Fix wh... |
112 |
}; |
1da177e4c Linux-2.6.12-rc2 |
113 114 115 116 117 118 |
static struct notifier_block mpoa_notifier = { mpoa_event_listener, NULL, 0 }; |
1da177e4c Linux-2.6.12-rc2 |
119 120 |
struct mpoa_client *mpcs = NULL; /* FIXME */ static struct atm_mpoa_qos *qos_head = NULL; |
1e9aa74ec net/atm/mpc: Avoi... |
121 |
static DEFINE_TIMER(mpc_timer, mpc_cache_check); |
1da177e4c Linux-2.6.12-rc2 |
122 123 124 125 126 |
static struct mpoa_client *find_mpc_by_itfnum(int itf) { struct mpoa_client *mpc; |
f7d57453d [NET] ATM: Fix wh... |
127 |
|
1da177e4c Linux-2.6.12-rc2 |
128 129 130 131 |
mpc = mpcs; /* our global linked list */ while (mpc != NULL) { if (mpc->dev_num == itf) return mpc; |
f7d57453d [NET] ATM: Fix wh... |
132 |
mpc = mpc->next; |
1da177e4c Linux-2.6.12-rc2 |
133 134 135 136 137 138 139 140 |
} return NULL; /* not found */ } static struct mpoa_client *find_mpc_by_vcc(struct atm_vcc *vcc) { struct mpoa_client *mpc; |
f7d57453d [NET] ATM: Fix wh... |
141 |
|
1da177e4c Linux-2.6.12-rc2 |
142 143 144 145 146 147 148 149 150 151 152 153 154 |
mpc = mpcs; /* our global linked list */ while (mpc != NULL) { if (mpc->mpoad_vcc == vcc) return mpc; mpc = mpc->next; } return NULL; /* not found */ } static struct mpoa_client *find_mpc_by_lec(struct net_device *dev) { struct mpoa_client *mpc; |
f7d57453d [NET] ATM: Fix wh... |
155 |
|
1da177e4c Linux-2.6.12-rc2 |
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
mpc = mpcs; /* our global linked list */ while (mpc != NULL) { if (mpc->dev == dev) return mpc; mpc = mpc->next; } return NULL; /* not found */ } /* * Functions for managing QoS list */ /* * Overwrites the old entry or makes a new one. */ |
30d492da7 [ATM]: Annotations. |
173 |
struct atm_mpoa_qos *atm_mpoa_add_qos(__be32 dst_ip, struct atm_qos *qos) |
1da177e4c Linux-2.6.12-rc2 |
174 175 176 177 178 179 180 181 182 183 184 |
{ struct atm_mpoa_qos *entry; entry = atm_mpoa_search_qos(dst_ip); if (entry != NULL) { entry->qos = *qos; return entry; } entry = kmalloc(sizeof(struct atm_mpoa_qos), GFP_KERNEL); if (entry == NULL) { |
571004407 net/atm/mpc.c: ch... |
185 186 |
pr_info("mpoa: out of memory "); |
1da177e4c Linux-2.6.12-rc2 |
187 188 189 190 191 192 193 194 195 196 197 |
return entry; } entry->ipaddr = dst_ip; entry->qos = *qos; entry->next = qos_head; qos_head = entry; return entry; } |
30d492da7 [ATM]: Annotations. |
198 |
struct atm_mpoa_qos *atm_mpoa_search_qos(__be32 dst_ip) |
1da177e4c Linux-2.6.12-rc2 |
199 200 201 202 |
{ struct atm_mpoa_qos *qos; qos = qos_head; |
571004407 net/atm/mpc.c: ch... |
203 204 |
while (qos) { if (qos->ipaddr == dst_ip) |
1da177e4c Linux-2.6.12-rc2 |
205 |
break; |
1da177e4c Linux-2.6.12-rc2 |
206 207 208 209 |
qos = qos->next; } return qos; |
f7d57453d [NET] ATM: Fix wh... |
210 |
} |
1da177e4c Linux-2.6.12-rc2 |
211 212 213 214 215 216 |
/* * Returns 0 for failure */ int atm_mpoa_delete_qos(struct atm_mpoa_qos *entry) { |
1da177e4c Linux-2.6.12-rc2 |
217 |
struct atm_mpoa_qos *curr; |
571004407 net/atm/mpc.c: ch... |
218 219 |
if (entry == NULL) return 0; |
1da177e4c Linux-2.6.12-rc2 |
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
if (entry == qos_head) { qos_head = qos_head->next; kfree(entry); return 1; } curr = qos_head; while (curr != NULL) { if (curr->next == entry) { curr->next = entry->next; kfree(entry); return 1; } curr = curr->next; } return 0; } /* this is buggered - we need locking for qos_head */ void atm_mpoa_disp_qos(struct seq_file *m) { |
1da177e4c Linux-2.6.12-rc2 |
242 243 244 245 246 247 248 249 250 |
struct atm_mpoa_qos *qos; qos = qos_head; seq_printf(m, "QoS entries for shortcuts: "); seq_printf(m, "IP address TX:max_pcr pcr min_pcr max_cdv max_sdu RX:max_pcr pcr min_pcr max_cdv max_sdu "); |
1da177e4c Linux-2.6.12-rc2 |
251 |
while (qos != NULL) { |
21454aaad net: replace NIPQ... |
252 253 254 255 |
seq_printf(m, "%pI4 %-7d %-7d %-7d %-7d %-7d %-7d %-7d %-7d %-7d %-7d ", |
571004407 net/atm/mpc.c: ch... |
256 257 258 259 260 261 262 263 264 265 266 |
&qos->ipaddr, qos->qos.txtp.max_pcr, qos->qos.txtp.pcr, qos->qos.txtp.min_pcr, qos->qos.txtp.max_cdv, qos->qos.txtp.max_sdu, qos->qos.rxtp.max_pcr, qos->qos.rxtp.pcr, qos->qos.rxtp.min_pcr, qos->qos.rxtp.max_cdv, qos->qos.rxtp.max_sdu); |
1da177e4c Linux-2.6.12-rc2 |
267 268 269 270 271 272 273 274 275 276 |
qos = qos->next; } } static struct net_device *find_lec_by_itfnum(int itf) { struct net_device *dev; char name[IFNAMSIZ]; sprintf(name, "lec%d", itf); |
881d966b4 [NET]: Make the d... |
277 |
dev = dev_get_by_name(&init_net, name); |
f7d57453d [NET] ATM: Fix wh... |
278 |
|
1da177e4c Linux-2.6.12-rc2 |
279 280 281 282 283 284 |
return dev; } static struct mpoa_client *alloc_mpc(void) { struct mpoa_client *mpc; |
571004407 net/atm/mpc.c: ch... |
285 |
mpc = kzalloc(sizeof(struct mpoa_client), GFP_KERNEL); |
1da177e4c Linux-2.6.12-rc2 |
286 287 |
if (mpc == NULL) return NULL; |
1da177e4c Linux-2.6.12-rc2 |
288 289 290 291 292 293 294 |
rwlock_init(&mpc->ingress_lock); rwlock_init(&mpc->egress_lock); mpc->next = mpcs; atm_mpoa_init_cache(mpc); mpc->parameters.mpc_p1 = MPC_P1; mpc->parameters.mpc_p2 = MPC_P2; |
571004407 net/atm/mpc.c: ch... |
295 |
memset(mpc->parameters.mpc_p3, 0, sizeof(mpc->parameters.mpc_p3)); |
1da177e4c Linux-2.6.12-rc2 |
296 |
mpc->parameters.mpc_p4 = MPC_P4; |
f7d57453d [NET] ATM: Fix wh... |
297 |
mpc->parameters.mpc_p5 = MPC_P5; |
1da177e4c Linux-2.6.12-rc2 |
298 |
mpc->parameters.mpc_p6 = MPC_P6; |
f7d57453d [NET] ATM: Fix wh... |
299 |
|
1da177e4c Linux-2.6.12-rc2 |
300 |
mpcs = mpc; |
f7d57453d [NET] ATM: Fix wh... |
301 |
|
1da177e4c Linux-2.6.12-rc2 |
302 303 304 305 306 307 |
return mpc; } /* * * start_mpc() puts the MPC on line. All the packets destined |
f7d57453d [NET] ATM: Fix wh... |
308 |
* to the lec underneath us are now being monitored and |
1da177e4c Linux-2.6.12-rc2 |
309 310 311 312 313 |
* shortcuts will be established. * */ static void start_mpc(struct mpoa_client *mpc, struct net_device *dev) { |
f7d57453d [NET] ATM: Fix wh... |
314 |
|
b50c2ea72 net/atm: Cleanup ... |
315 316 |
dprintk("(%s) ", mpc->dev->name); |
788dee0a9 atm: convert mpc ... |
317 |
if (!dev->netdev_ops) |
571004407 net/atm/mpc.c: ch... |
318 319 |
pr_info("(%s) not starting ", dev->name); |
788dee0a9 atm: convert mpc ... |
320 321 322 323 324 |
else { mpc->old_ops = dev->netdev_ops; mpc->new_ops = *mpc->old_ops; mpc->new_ops.ndo_start_xmit = mpc_send_packet; dev->netdev_ops = &mpc->new_ops; |
1da177e4c Linux-2.6.12-rc2 |
325 |
} |
1da177e4c Linux-2.6.12-rc2 |
326 327 328 329 |
} static void stop_mpc(struct mpoa_client *mpc) { |
788dee0a9 atm: convert mpc ... |
330 |
struct net_device *dev = mpc->dev; |
b50c2ea72 net/atm: Cleanup ... |
331 |
dprintk("(%s)", mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
332 333 |
/* Lets not nullify lec device's dev->hard_start_xmit */ |
788dee0a9 atm: convert mpc ... |
334 |
if (dev->netdev_ops != &mpc->new_ops) { |
b50c2ea72 net/atm: Cleanup ... |
335 336 |
dprintk_cont(" mpc already stopped, not fatal "); |
1da177e4c Linux-2.6.12-rc2 |
337 338 |
return; } |
b50c2ea72 net/atm: Cleanup ... |
339 340 |
dprintk_cont(" "); |
f7d57453d [NET] ATM: Fix wh... |
341 |
|
788dee0a9 atm: convert mpc ... |
342 343 344 345 |
dev->netdev_ops = mpc->old_ops; mpc->old_ops = NULL; /* close_shortcuts(mpc); ??? FIXME */ |
1da177e4c Linux-2.6.12-rc2 |
346 347 348 349 350 351 |
} static const char *mpoa_device_type_string(char type) __attribute__ ((unused)); static const char *mpoa_device_type_string(char type) { |
571004407 net/atm/mpc.c: ch... |
352 |
switch (type) { |
1da177e4c Linux-2.6.12-rc2 |
353 354 |
case NON_MPOA: return "non-MPOA device"; |
1da177e4c Linux-2.6.12-rc2 |
355 356 |
case MPS: return "MPS"; |
1da177e4c Linux-2.6.12-rc2 |
357 358 |
case MPC: return "MPC"; |
1da177e4c Linux-2.6.12-rc2 |
359 360 |
case MPS_AND_MPC: return "both MPS and MPC"; |
1da177e4c Linux-2.6.12-rc2 |
361 |
} |
571004407 net/atm/mpc.c: ch... |
362 |
return "unspecified (non-MPOA) device"; |
1da177e4c Linux-2.6.12-rc2 |
363 364 365 |
} /* |
b74ca3a89 netdevice: Kill n... |
366 367 |
* lec device calls this via its netdev_priv(dev)->lane2_ops * ->associate_indicator() when it sees a TLV in LE_ARP packet. |
1da177e4c Linux-2.6.12-rc2 |
368 369 370 371 372 373 374 375 376 377 |
* We fill in the pointer above when we see a LANE2 lec initializing * See LANE2 spec 3.1.5 * * Quite a big and ugly function but when you look at it * all it does is to try to locate and parse MPOA Device * Type TLV. * We give our lec a pointer to this function and when the * lec sees a TLV it uses the pointer to call this function. * */ |
cba5cbd15 atm: fix const as... |
378 379 |
static void lane2_assoc_ind(struct net_device *dev, const u8 *mac_addr, const u8 *tlvs, u32 sizeoftlvs) |
1da177e4c Linux-2.6.12-rc2 |
380 381 382 |
{ uint32_t type; uint8_t length, mpoa_device_type, number_of_mps_macs; |
cba5cbd15 atm: fix const as... |
383 |
const uint8_t *end_of_tlvs; |
1da177e4c Linux-2.6.12-rc2 |
384 |
struct mpoa_client *mpc; |
f7d57453d [NET] ATM: Fix wh... |
385 |
|
1da177e4c Linux-2.6.12-rc2 |
386 |
mpoa_device_type = number_of_mps_macs = 0; /* silence gcc */ |
b50c2ea72 net/atm: Cleanup ... |
387 |
dprintk("(%s) received TLV(s), ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
388 389 390 391 |
dprintk("total length of all TLVs %d ", sizeoftlvs); mpc = find_mpc_by_lec(dev); /* Sampo-Fix: moved here from below */ if (mpc == NULL) { |
571004407 net/atm/mpc.c: ch... |
392 393 |
pr_info("(%s) no mpc ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
394 395 396 397 |
return; } end_of_tlvs = tlvs + sizeoftlvs; while (end_of_tlvs - tlvs >= 5) { |
571004407 net/atm/mpc.c: ch... |
398 399 |
type = ((tlvs[0] << 24) | (tlvs[1] << 16) | (tlvs[2] << 8) | tlvs[3]); |
1da177e4c Linux-2.6.12-rc2 |
400 401 402 403 404 |
length = tlvs[4]; tlvs += 5; dprintk(" type 0x%x length %02x ", type, length); if (tlvs + length > end_of_tlvs) { |
571004407 net/atm/mpc.c: ch... |
405 406 |
pr_info("TLV value extends past its buffer, aborting parse "); |
1da177e4c Linux-2.6.12-rc2 |
407 408 |
return; } |
f7d57453d [NET] ATM: Fix wh... |
409 |
|
1da177e4c Linux-2.6.12-rc2 |
410 |
if (type == 0) { |
571004407 net/atm/mpc.c: ch... |
411 412 413 |
pr_info("mpoa: (%s) TLV type was 0, returning ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
414 415 416 417 418 419 420 421 422 |
return; } if (type != TLV_MPOA_DEVICE_TYPE) { tlvs += length; continue; /* skip other TLVs */ } mpoa_device_type = *tlvs++; number_of_mps_macs = *tlvs++; |
b50c2ea72 net/atm: Cleanup ... |
423 |
dprintk("(%s) MPOA device type '%s', ", |
571004407 net/atm/mpc.c: ch... |
424 |
dev->name, mpoa_device_type_string(mpoa_device_type)); |
1da177e4c Linux-2.6.12-rc2 |
425 426 |
if (mpoa_device_type == MPS_AND_MPC && length < (42 + number_of_mps_macs*ETH_ALEN)) { /* :) */ |
571004407 net/atm/mpc.c: ch... |
427 428 429 |
pr_info("(%s) short MPOA Device Type TLV ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
430 431 |
continue; } |
571004407 net/atm/mpc.c: ch... |
432 433 434 435 |
if ((mpoa_device_type == MPS || mpoa_device_type == MPC) && length < 22 + number_of_mps_macs*ETH_ALEN) { pr_info("(%s) short MPOA Device Type TLV ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
436 437 |
continue; } |
571004407 net/atm/mpc.c: ch... |
438 439 |
if (mpoa_device_type != MPS && mpoa_device_type != MPS_AND_MPC) { |
b50c2ea72 net/atm: Cleanup ... |
440 |
dprintk("ignoring non-MPS device "); |
571004407 net/atm/mpc.c: ch... |
441 442 |
if (mpoa_device_type == MPC) tlvs += 20; |
1da177e4c Linux-2.6.12-rc2 |
443 444 |
continue; /* we are only interested in MPSs */ } |
571004407 net/atm/mpc.c: ch... |
445 446 447 448 |
if (number_of_mps_macs == 0 && mpoa_device_type == MPS_AND_MPC) { pr_info("(%s) MPS_AND_MPC has zero MACs ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
449 450 |
continue; /* someone should read the spec */ } |
b50c2ea72 net/atm: Cleanup ... |
451 452 453 |
dprintk_cont("this MPS has %d MAC addresses ", number_of_mps_macs); |
f7d57453d [NET] ATM: Fix wh... |
454 |
|
571004407 net/atm/mpc.c: ch... |
455 456 457 458 |
/* * ok, now we can go and tell our daemon * the control address of MPS */ |
1da177e4c Linux-2.6.12-rc2 |
459 |
send_set_mps_ctrl_addr(tlvs, mpc); |
f7d57453d [NET] ATM: Fix wh... |
460 |
|
571004407 net/atm/mpc.c: ch... |
461 462 463 464 |
tlvs = copy_macs(mpc, mac_addr, tlvs, number_of_mps_macs, mpoa_device_type); if (tlvs == NULL) return; |
1da177e4c Linux-2.6.12-rc2 |
465 466 |
} if (end_of_tlvs - tlvs != 0) |
5b5e0928f lib/vsprintf.c: r... |
467 468 |
pr_info("(%s) ignoring %zd bytes of trailing TLV garbage ", |
571004407 net/atm/mpc.c: ch... |
469 |
dev->name, end_of_tlvs - tlvs); |
1da177e4c Linux-2.6.12-rc2 |
470 471 472 473 474 475 476 |
} /* * Store at least advertizing router's MAC address * plus the possible MAC address(es) to mpc->mps_macs. * For a freshly allocated MPOA client mpc->mps_macs == 0. */ |
cba5cbd15 atm: fix const as... |
477 478 479 480 |
static const uint8_t *copy_macs(struct mpoa_client *mpc, const uint8_t *router_mac, const uint8_t *tlvs, uint8_t mps_macs, uint8_t device_type) |
1da177e4c Linux-2.6.12-rc2 |
481 482 483 484 485 |
{ int num_macs; num_macs = (mps_macs > 1) ? mps_macs : 1; if (mpc->number_of_mps_macs != num_macs) { /* need to reallocate? */ |
571004407 net/atm/mpc.c: ch... |
486 487 |
if (mpc->number_of_mps_macs != 0) kfree(mpc->mps_macs); |
1da177e4c Linux-2.6.12-rc2 |
488 |
mpc->number_of_mps_macs = 0; |
6da2ec560 treewide: kmalloc... |
489 |
mpc->mps_macs = kmalloc_array(ETH_ALEN, num_macs, GFP_KERNEL); |
1da177e4c Linux-2.6.12-rc2 |
490 |
if (mpc->mps_macs == NULL) { |
571004407 net/atm/mpc.c: ch... |
491 492 |
pr_info("(%s) out of mem ", mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
493 494 495 |
return NULL; } } |
116e853f7 atm: Use ether_ad... |
496 |
ether_addr_copy(mpc->mps_macs, router_mac); |
1da177e4c Linux-2.6.12-rc2 |
497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
tlvs += 20; if (device_type == MPS_AND_MPC) tlvs += 20; if (mps_macs > 0) memcpy(mpc->mps_macs, tlvs, mps_macs*ETH_ALEN); tlvs += mps_macs*ETH_ALEN; mpc->number_of_mps_macs = num_macs; return tlvs; } static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc) { in_cache_entry *entry; struct iphdr *iph; char *buff; |
30d492da7 [ATM]: Annotations. |
511 |
__be32 ipaddr = 0; |
1da177e4c Linux-2.6.12-rc2 |
512 513 514 |
static struct { struct llc_snap_hdr hdr; |
30d492da7 [ATM]: Annotations. |
515 |
__be32 tag; |
1da177e4c Linux-2.6.12-rc2 |
516 517 518 519 520 521 522 523 |
} tagged_llc_snap_hdr = { {0xaa, 0xaa, 0x03, {0x00, 0x00, 0x00}, {0x88, 0x4c}}, 0 }; buff = skb->data + mpc->dev->hard_header_len; iph = (struct iphdr *)buff; ipaddr = iph->daddr; |
b50c2ea72 net/atm: Cleanup ... |
524 525 |
ddprintk("(%s) ipaddr 0x%x ", |
571004407 net/atm/mpc.c: ch... |
526 |
mpc->dev->name, ipaddr); |
1da177e4c Linux-2.6.12-rc2 |
527 528 529 530 |
entry = mpc->in_ops->get(ipaddr, mpc); if (entry == NULL) { entry = mpc->in_ops->add_entry(ipaddr, mpc); |
571004407 net/atm/mpc.c: ch... |
531 532 |
if (entry != NULL) mpc->in_ops->put(entry); |
1da177e4c Linux-2.6.12-rc2 |
533 534 |
return 1; } |
571004407 net/atm/mpc.c: ch... |
535 536 |
/* threshold not exceeded or VCC not ready */ if (mpc->in_ops->cache_hit(entry, mpc) != OPEN) { |
b50c2ea72 net/atm: Cleanup ... |
537 538 |
ddprintk("(%s) cache_hit: returns != OPEN ", |
571004407 net/atm/mpc.c: ch... |
539 |
mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
540 541 542 |
mpc->in_ops->put(entry); return 1; } |
b50c2ea72 net/atm: Cleanup ... |
543 544 |
ddprintk("(%s) using shortcut ", |
571004407 net/atm/mpc.c: ch... |
545 |
mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
546 547 |
/* MPOA spec A.1.4, MPOA client must decrement IP ttl at least by one */ if (iph->ttl <= 1) { |
b50c2ea72 net/atm: Cleanup ... |
548 549 |
ddprintk("(%s) IP ttl = %u, using LANE ", |
571004407 net/atm/mpc.c: ch... |
550 |
mpc->dev->name, iph->ttl); |
1da177e4c Linux-2.6.12-rc2 |
551 552 553 554 555 556 557 558 |
mpc->in_ops->put(entry); return 1; } iph->ttl--; iph->check = 0; iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); if (entry->ctrl_info.tag != 0) { |
b50c2ea72 net/atm: Cleanup ... |
559 560 |
ddprintk("(%s) adding tag 0x%x ", |
571004407 net/atm/mpc.c: ch... |
561 |
mpc->dev->name, entry->ctrl_info.tag); |
1da177e4c Linux-2.6.12-rc2 |
562 |
tagged_llc_snap_hdr.tag = entry->ctrl_info.tag; |
571004407 net/atm/mpc.c: ch... |
563 564 565 |
skb_pull(skb, ETH_HLEN); /* get rid of Eth header */ skb_push(skb, sizeof(tagged_llc_snap_hdr)); /* add LLC/SNAP header */ |
27d7ff46a [SK_BUFF]: Introd... |
566 567 |
skb_copy_to_linear_data(skb, &tagged_llc_snap_hdr, sizeof(tagged_llc_snap_hdr)); |
1da177e4c Linux-2.6.12-rc2 |
568 |
} else { |
571004407 net/atm/mpc.c: ch... |
569 570 571 |
skb_pull(skb, ETH_HLEN); /* get rid of Eth header */ skb_push(skb, sizeof(struct llc_snap_hdr)); /* add LLC/SNAP header + tag */ |
27d7ff46a [SK_BUFF]: Introd... |
572 573 |
skb_copy_to_linear_data(skb, &llc_snap_mpoa_data, sizeof(struct llc_snap_hdr)); |
1da177e4c Linux-2.6.12-rc2 |
574 |
} |
9bbe60a67 atm: Preserve val... |
575 |
atm_account_tx(entry->shortcut, skb); |
1da177e4c Linux-2.6.12-rc2 |
576 577 578 579 580 581 582 583 584 585 |
entry->shortcut->send(entry->shortcut, skb); entry->packets_fwded++; mpc->in_ops->put(entry); return 0; } /* * Probably needs some error checks and locking, not sure... */ |
3c805a22a convert ATM drive... |
586 587 |
static netdev_tx_t mpc_send_packet(struct sk_buff *skb, struct net_device *dev) |
1da177e4c Linux-2.6.12-rc2 |
588 |
{ |
1da177e4c Linux-2.6.12-rc2 |
589 590 591 |
struct mpoa_client *mpc; struct ethhdr *eth; int i = 0; |
f7d57453d [NET] ATM: Fix wh... |
592 |
|
1da177e4c Linux-2.6.12-rc2 |
593 |
mpc = find_mpc_by_lec(dev); /* this should NEVER fail */ |
571004407 net/atm/mpc.c: ch... |
594 595 596 |
if (mpc == NULL) { pr_info("(%s) no MPC found ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
597 598 599 600 601 602 |
goto non_ip; } eth = (struct ethhdr *)skb->data; if (eth->h_proto != htons(ETH_P_IP)) goto non_ip; /* Multi-Protocol Over ATM :-) */ |
1c9b7aa1e [ATM]: Check IP h... |
603 604 605 606 607 608 |
/* Weed out funny packets (e.g., AF_PACKET or raw). */ if (skb->len < ETH_HLEN + sizeof(struct iphdr)) goto non_ip; skb_set_network_header(skb, ETH_HLEN); if (skb->len < ETH_HLEN + ip_hdr(skb)->ihl * 4 || ip_hdr(skb)->ihl < 5) goto non_ip; |
1da177e4c Linux-2.6.12-rc2 |
609 |
while (i < mpc->number_of_mps_macs) { |
150238ebb atm: Convert comp... |
610 |
if (ether_addr_equal(eth->h_dest, mpc->mps_macs + i * ETH_ALEN)) |
571004407 net/atm/mpc.c: ch... |
611 612 |
if (send_via_shortcut(skb, mpc) == 0) /* try shortcut */ return NETDEV_TX_OK; |
1da177e4c Linux-2.6.12-rc2 |
613 614 |
i++; } |
571004407 net/atm/mpc.c: ch... |
615 |
non_ip: |
fa2dbdc25 net: Pass a "more... |
616 |
return __netdev_start_xmit(mpc->old_ops, skb, dev, false); |
1da177e4c Linux-2.6.12-rc2 |
617 618 619 620 621 622 623 624 |
} static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg) { int bytes_left; struct mpoa_client *mpc; struct atmmpc_ioc ioc_data; in_cache_entry *in_entry; |
30d492da7 [ATM]: Annotations. |
625 |
__be32 ipaddr; |
1da177e4c Linux-2.6.12-rc2 |
626 627 628 |
bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmmpc_ioc)); if (bytes_left != 0) { |
571004407 net/atm/mpc.c: ch... |
629 630 631 |
pr_info("mpoa:Short read (missed %d bytes) from userland ", bytes_left); |
1da177e4c Linux-2.6.12-rc2 |
632 633 634 635 636 |
return -EFAULT; } ipaddr = ioc_data.ipaddr; if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF) return -EINVAL; |
f7d57453d [NET] ATM: Fix wh... |
637 |
|
1da177e4c Linux-2.6.12-rc2 |
638 639 640 |
mpc = find_mpc_by_itfnum(ioc_data.dev_num); if (mpc == NULL) return -EINVAL; |
f7d57453d [NET] ATM: Fix wh... |
641 |
|
1da177e4c Linux-2.6.12-rc2 |
642 643 |
if (ioc_data.type == MPC_SOCKET_INGRESS) { in_entry = mpc->in_ops->get(ipaddr, mpc); |
571004407 net/atm/mpc.c: ch... |
644 645 646 647 |
if (in_entry == NULL || in_entry->entry_state < INGRESS_RESOLVED) { pr_info("(%s) did not find RESOLVED entry from ingress cache ", |
1da177e4c Linux-2.6.12-rc2 |
648 |
mpc->dev->name); |
571004407 net/atm/mpc.c: ch... |
649 650 |
if (in_entry != NULL) mpc->in_ops->put(in_entry); |
1da177e4c Linux-2.6.12-rc2 |
651 652 |
return -EINVAL; } |
571004407 net/atm/mpc.c: ch... |
653 654 655 |
pr_info("(%s) attaching ingress SVC, entry = %pI4 ", mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); |
1da177e4c Linux-2.6.12-rc2 |
656 657 658 |
in_entry->shortcut = vcc; mpc->in_ops->put(in_entry); } else { |
571004407 net/atm/mpc.c: ch... |
659 660 |
pr_info("(%s) attaching egress SVC ", mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
} vcc->proto_data = mpc->dev; vcc->push = mpc_push; return 0; } /* * */ static void mpc_vcc_close(struct atm_vcc *vcc, struct net_device *dev) { struct mpoa_client *mpc; in_cache_entry *in_entry; eg_cache_entry *eg_entry; |
f7d57453d [NET] ATM: Fix wh... |
677 |
|
1da177e4c Linux-2.6.12-rc2 |
678 679 |
mpc = find_mpc_by_lec(dev); if (mpc == NULL) { |
571004407 net/atm/mpc.c: ch... |
680 681 |
pr_info("(%s) close for unknown MPC ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
682 683 |
return; } |
b50c2ea72 net/atm: Cleanup ... |
684 685 |
dprintk("(%s) ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
686 687 |
in_entry = mpc->in_ops->get_by_vcc(vcc, mpc); if (in_entry) { |
b50c2ea72 net/atm: Cleanup ... |
688 689 |
dprintk("(%s) ingress SVC closed ip = %pI4 ", |
571004407 net/atm/mpc.c: ch... |
690 |
mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); |
1da177e4c Linux-2.6.12-rc2 |
691 692 693 694 695 |
in_entry->shortcut = NULL; mpc->in_ops->put(in_entry); } eg_entry = mpc->eg_ops->get_by_vcc(vcc, mpc); if (eg_entry) { |
b50c2ea72 net/atm: Cleanup ... |
696 697 |
dprintk("(%s) egress SVC closed ", mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
698 699 700 701 702 |
eg_entry->shortcut = NULL; mpc->eg_ops->put(eg_entry); } if (in_entry == NULL && eg_entry == NULL) |
b50c2ea72 net/atm: Cleanup ... |
703 704 |
dprintk("(%s) unused vcc closed ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
705 706 707 708 709 710 711 712 |
} static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb) { struct net_device *dev = (struct net_device *)vcc->proto_data; struct sk_buff *new_skb; eg_cache_entry *eg; struct mpoa_client *mpc; |
30d492da7 [ATM]: Annotations. |
713 |
__be32 tag; |
1da177e4c Linux-2.6.12-rc2 |
714 |
char *tmp; |
f7d57453d [NET] ATM: Fix wh... |
715 |
|
b50c2ea72 net/atm: Cleanup ... |
716 717 |
ddprintk("(%s) ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
718 |
if (skb == NULL) { |
b50c2ea72 net/atm: Cleanup ... |
719 720 |
dprintk("(%s) null skb, closing VCC ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
721 722 723 |
mpc_vcc_close(vcc, dev); return; } |
f7d57453d [NET] ATM: Fix wh... |
724 |
|
1da177e4c Linux-2.6.12-rc2 |
725 |
skb->dev = dev; |
571004407 net/atm/mpc.c: ch... |
726 727 |
if (memcmp(skb->data, &llc_snap_mpoa_ctrl, sizeof(struct llc_snap_hdr)) == 0) { |
1da177e4c Linux-2.6.12-rc2 |
728 |
struct sock *sk = sk_atm(vcc); |
b50c2ea72 net/atm: Cleanup ... |
729 730 |
dprintk("(%s) control packet arrived ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
731 732 |
/* Pass control packets to daemon */ skb_queue_tail(&sk->sk_receive_queue, skb); |
676d23690 net: Fix use afte... |
733 |
sk->sk_data_ready(sk); |
1da177e4c Linux-2.6.12-rc2 |
734 735 736 737 738 739 740 741 |
return; } /* data coming over the shortcut */ atm_return(vcc, skb->truesize); mpc = find_mpc_by_lec(dev); if (mpc == NULL) { |
571004407 net/atm/mpc.c: ch... |
742 743 |
pr_info("(%s) unknown MPC ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
744 745 |
return; } |
571004407 net/atm/mpc.c: ch... |
746 747 |
if (memcmp(skb->data, &llc_snap_mpoa_data_tagged, sizeof(struct llc_snap_hdr)) == 0) { /* MPOA tagged data */ |
b50c2ea72 net/atm: Cleanup ... |
748 749 |
ddprintk("(%s) tagged data packet arrived ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
750 |
|
571004407 net/atm/mpc.c: ch... |
751 752 753 754 755 |
} else if (memcmp(skb->data, &llc_snap_mpoa_data, sizeof(struct llc_snap_hdr)) == 0) { /* MPOA data */ pr_info("(%s) Unsupported non-tagged data packet arrived. Purging ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
756 757 758 |
dev_kfree_skb_any(skb); return; } else { |
571004407 net/atm/mpc.c: ch... |
759 760 |
pr_info("(%s) garbage arrived, purging ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
761 762 763 764 765 |
dev_kfree_skb_any(skb); return; } tmp = skb->data + sizeof(struct llc_snap_hdr); |
30d492da7 [ATM]: Annotations. |
766 |
tag = *(__be32 *)tmp; |
1da177e4c Linux-2.6.12-rc2 |
767 768 769 |
eg = mpc->eg_ops->get_by_tag(tag, mpc); if (eg == NULL) { |
571004407 net/atm/mpc.c: ch... |
770 771 772 |
pr_info("mpoa: (%s) Didn't find egress cache entry, tag = %u ", dev->name, tag); |
1da177e4c Linux-2.6.12-rc2 |
773 774 775 776 |
purge_egress_shortcut(vcc, NULL); dev_kfree_skb_any(skb); return; } |
f7d57453d [NET] ATM: Fix wh... |
777 |
|
1da177e4c Linux-2.6.12-rc2 |
778 779 780 |
/* * See if ingress MPC is using shortcut we opened as a return channel. * This means we have a bi-directional vcc opened by us. |
f7d57453d [NET] ATM: Fix wh... |
781 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
782 783 |
if (eg->shortcut == NULL) { eg->shortcut = vcc; |
571004407 net/atm/mpc.c: ch... |
784 785 |
pr_info("(%s) egress SVC in use ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
786 |
} |
571004407 net/atm/mpc.c: ch... |
787 788 789 790 |
skb_pull(skb, sizeof(struct llc_snap_hdr) + sizeof(tag)); /* get rid of LLC/SNAP header */ new_skb = skb_realloc_headroom(skb, eg->ctrl_info.DH_length); /* LLC/SNAP is shorter than MAC header :( */ |
1da177e4c Linux-2.6.12-rc2 |
791 |
dev_kfree_skb_any(skb); |
571004407 net/atm/mpc.c: ch... |
792 |
if (new_skb == NULL) { |
1da177e4c Linux-2.6.12-rc2 |
793 794 795 796 |
mpc->eg_ops->put(eg); return; } skb_push(new_skb, eg->ctrl_info.DH_length); /* add MAC header */ |
27d7ff46a [SK_BUFF]: Introd... |
797 798 |
skb_copy_to_linear_data(new_skb, eg->ctrl_info.DLL_header, eg->ctrl_info.DH_length); |
1da177e4c Linux-2.6.12-rc2 |
799 |
new_skb->protocol = eth_type_trans(new_skb, dev); |
c1d2bbe1c [SK_BUFF]: Introd... |
800 |
skb_reset_network_header(new_skb); |
1da177e4c Linux-2.6.12-rc2 |
801 |
|
eddc9ec53 [SK_BUFF]: Introd... |
802 |
eg->latest_ip_addr = ip_hdr(new_skb)->saddr; |
1da177e4c Linux-2.6.12-rc2 |
803 804 |
eg->packets_rcvd++; mpc->eg_ops->put(eg); |
5518b29f2 ATM: mpc, fix use... |
805 |
memset(ATM_SKB(new_skb), 0, sizeof(struct atm_skb_data)); |
1da177e4c Linux-2.6.12-rc2 |
806 |
netif_rx(new_skb); |
1da177e4c Linux-2.6.12-rc2 |
807 |
} |
800bb47e7 net: atm: make at... |
808 |
static const struct atmdev_ops mpc_ops = { /* only send is required */ |
1da177e4c Linux-2.6.12-rc2 |
809 810 811 812 813 814 815 816 |
.close = mpoad_close, .send = msg_from_mpoad }; static struct atm_dev mpc_dev = { .ops = &mpc_ops, .type = "mpc", .number = 42, |
4ef8d0aea [NET]: SPIN_LOCK_... |
817 |
.lock = __SPIN_LOCK_UNLOCKED(mpc_dev.lock) |
1da177e4c Linux-2.6.12-rc2 |
818 819 |
/* members not explicitly initialised will be 0 */ }; |
571004407 net/atm/mpc.c: ch... |
820 |
static int atm_mpoa_mpoad_attach(struct atm_vcc *vcc, int arg) |
1da177e4c Linux-2.6.12-rc2 |
821 822 823 824 |
{ struct mpoa_client *mpc; struct lec_priv *priv; int err; |
f7d57453d [NET] ATM: Fix wh... |
825 |
|
1da177e4c Linux-2.6.12-rc2 |
826 |
if (mpcs == NULL) { |
1da177e4c Linux-2.6.12-rc2 |
827 828 829 830 831 832 833 834 835 |
mpc_timer_refresh(); /* This lets us now how our LECs are doing */ err = register_netdevice_notifier(&mpoa_notifier); if (err < 0) { del_timer(&mpc_timer); return err; } } |
f7d57453d [NET] ATM: Fix wh... |
836 |
|
1da177e4c Linux-2.6.12-rc2 |
837 838 |
mpc = find_mpc_by_itfnum(arg); if (mpc == NULL) { |
b50c2ea72 net/atm: Cleanup ... |
839 840 |
dprintk("allocating new mpc for itf %d ", arg); |
1da177e4c Linux-2.6.12-rc2 |
841 842 843 844 |
mpc = alloc_mpc(); if (mpc == NULL) return -ENOMEM; mpc->dev_num = arg; |
571004407 net/atm/mpc.c: ch... |
845 846 |
mpc->dev = find_lec_by_itfnum(arg); /* NULL if there was no lec */ |
1da177e4c Linux-2.6.12-rc2 |
847 848 |
} if (mpc->mpoad_vcc) { |
571004407 net/atm/mpc.c: ch... |
849 850 |
pr_info("mpoad is already present for itf %d ", arg); |
1da177e4c Linux-2.6.12-rc2 |
851 852 853 854 |
return -EADDRINUSE; } if (mpc->dev) { /* check if the lec is LANE2 capable */ |
524ad0a79 netdevice: safe c... |
855 |
priv = netdev_priv(mpc->dev); |
1da177e4c Linux-2.6.12-rc2 |
856 857 858 859 |
if (priv->lane_version < 2) { dev_put(mpc->dev); mpc->dev = NULL; } else |
f7d57453d [NET] ATM: Fix wh... |
860 |
priv->lane2_ops->associate_indicator = lane2_assoc_ind; |
1da177e4c Linux-2.6.12-rc2 |
861 862 863 864 865 |
} mpc->mpoad_vcc = vcc; vcc->dev = &mpc_dev; vcc_insert_socket(sk_atm(vcc)); |
571004407 net/atm/mpc.c: ch... |
866 867 |
set_bit(ATM_VF_META, &vcc->flags); set_bit(ATM_VF_READY, &vcc->flags); |
1da177e4c Linux-2.6.12-rc2 |
868 869 870 871 |
if (mpc->dev) { char empty[ATM_ESA_LEN]; memset(empty, 0, ATM_ESA_LEN); |
f7d57453d [NET] ATM: Fix wh... |
872 |
|
1da177e4c Linux-2.6.12-rc2 |
873 874 875 876 |
start_mpc(mpc, mpc->dev); /* set address if mpcd e.g. gets killed and restarted. * If we do not do it now we have to wait for the next LE_ARP */ |
571004407 net/atm/mpc.c: ch... |
877 |
if (memcmp(mpc->mps_ctrl_addr, empty, ATM_ESA_LEN) != 0) |
1da177e4c Linux-2.6.12-rc2 |
878 879 880 881 882 883 |
send_set_mps_ctrl_addr(mpc->mps_ctrl_addr, mpc); } __module_get(THIS_MODULE); return arg; } |
cba5cbd15 atm: fix const as... |
884 |
static void send_set_mps_ctrl_addr(const char *addr, struct mpoa_client *mpc) |
1da177e4c Linux-2.6.12-rc2 |
885 886 |
{ struct k_message mesg; |
571004407 net/atm/mpc.c: ch... |
887 |
memcpy(mpc->mps_ctrl_addr, addr, ATM_ESA_LEN); |
f7d57453d [NET] ATM: Fix wh... |
888 |
|
1da177e4c Linux-2.6.12-rc2 |
889 890 891 |
mesg.type = SET_MPS_CTRL_ADDR; memcpy(mesg.MPS_ctrl, addr, ATM_ESA_LEN); msg_to_mpoad(&mesg, mpc); |
1da177e4c Linux-2.6.12-rc2 |
892 893 894 895 896 897 898 899 900 |
} static void mpoad_close(struct atm_vcc *vcc) { struct mpoa_client *mpc; struct sk_buff *skb; mpc = find_mpc_by_vcc(vcc); if (mpc == NULL) { |
571004407 net/atm/mpc.c: ch... |
901 902 |
pr_info("did not find MPC "); |
1da177e4c Linux-2.6.12-rc2 |
903 904 905 |
return; } if (!mpc->mpoad_vcc) { |
571004407 net/atm/mpc.c: ch... |
906 907 |
pr_info("close for non-present mpoad "); |
1da177e4c Linux-2.6.12-rc2 |
908 909 |
return; } |
f7d57453d [NET] ATM: Fix wh... |
910 |
|
1da177e4c Linux-2.6.12-rc2 |
911 912 |
mpc->mpoad_vcc = NULL; if (mpc->dev) { |
524ad0a79 netdevice: safe c... |
913 |
struct lec_priv *priv = netdev_priv(mpc->dev); |
1da177e4c Linux-2.6.12-rc2 |
914 915 916 917 918 919 920 921 922 923 924 925 |
priv->lane2_ops->associate_indicator = NULL; stop_mpc(mpc); dev_put(mpc->dev); } mpc->in_ops->destroy_cache(mpc); mpc->eg_ops->destroy_cache(mpc); while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue))) { atm_return(vcc, skb->truesize); kfree_skb(skb); } |
f7d57453d [NET] ATM: Fix wh... |
926 |
|
571004407 net/atm/mpc.c: ch... |
927 928 |
pr_info("(%s) going down ", |
1da177e4c Linux-2.6.12-rc2 |
929 930 |
(mpc->dev) ? mpc->dev->name : "<unknown>"); module_put(THIS_MODULE); |
1da177e4c Linux-2.6.12-rc2 |
931 932 933 934 935 936 937 |
} /* * */ static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb) { |
f7d57453d [NET] ATM: Fix wh... |
938 |
|
1da177e4c Linux-2.6.12-rc2 |
939 |
struct mpoa_client *mpc = find_mpc_by_vcc(vcc); |
571004407 net/atm/mpc.c: ch... |
940 |
struct k_message *mesg = (struct k_message *)skb->data; |
14afee4b6 net: convert sock... |
941 |
WARN_ON(refcount_sub_and_test(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc)); |
f7d57453d [NET] ATM: Fix wh... |
942 |
|
1da177e4c Linux-2.6.12-rc2 |
943 |
if (mpc == NULL) { |
571004407 net/atm/mpc.c: ch... |
944 945 |
pr_info("no mpc found "); |
1da177e4c Linux-2.6.12-rc2 |
946 947 |
return 0; } |
b50c2ea72 net/atm: Cleanup ... |
948 |
dprintk("(%s)", mpc->dev ? mpc->dev->name : "<unknown>"); |
571004407 net/atm/mpc.c: ch... |
949 |
switch (mesg->type) { |
1da177e4c Linux-2.6.12-rc2 |
950 |
case MPOA_RES_REPLY_RCVD: |
b50c2ea72 net/atm: Cleanup ... |
951 952 |
dprintk_cont("mpoa_res_reply_rcvd "); |
1da177e4c Linux-2.6.12-rc2 |
953 954 955 |
MPOA_res_reply_rcvd(mesg, mpc); break; case MPOA_TRIGGER_RCVD: |
b50c2ea72 net/atm: Cleanup ... |
956 957 |
dprintk_cont("mpoa_trigger_rcvd "); |
1da177e4c Linux-2.6.12-rc2 |
958 959 960 |
MPOA_trigger_rcvd(mesg, mpc); break; case INGRESS_PURGE_RCVD: |
b50c2ea72 net/atm: Cleanup ... |
961 962 |
dprintk_cont("nhrp_purge_rcvd "); |
1da177e4c Linux-2.6.12-rc2 |
963 964 965 |
ingress_purge_rcvd(mesg, mpc); break; case EGRESS_PURGE_RCVD: |
b50c2ea72 net/atm: Cleanup ... |
966 967 |
dprintk_cont("egress_purge_reply_rcvd "); |
1da177e4c Linux-2.6.12-rc2 |
968 969 970 |
egress_purge_rcvd(mesg, mpc); break; case MPS_DEATH: |
b50c2ea72 net/atm: Cleanup ... |
971 972 |
dprintk_cont("mps_death "); |
1da177e4c Linux-2.6.12-rc2 |
973 974 975 |
mps_death(mesg, mpc); break; case CACHE_IMPOS_RCVD: |
b50c2ea72 net/atm: Cleanup ... |
976 977 |
dprintk_cont("cache_impos_rcvd "); |
1da177e4c Linux-2.6.12-rc2 |
978 979 980 |
MPOA_cache_impos_rcvd(mesg, mpc); break; case SET_MPC_CTRL_ADDR: |
b50c2ea72 net/atm: Cleanup ... |
981 982 |
dprintk_cont("set_mpc_ctrl_addr "); |
1da177e4c Linux-2.6.12-rc2 |
983 984 985 |
set_mpc_ctrl_addr_rcvd(mesg, mpc); break; case SET_MPS_MAC_ADDR: |
b50c2ea72 net/atm: Cleanup ... |
986 987 |
dprintk_cont("set_mps_mac_addr "); |
1da177e4c Linux-2.6.12-rc2 |
988 989 990 |
set_mps_mac_addr_rcvd(mesg, mpc); break; case CLEAN_UP_AND_EXIT: |
b50c2ea72 net/atm: Cleanup ... |
991 992 |
dprintk_cont("clean_up_and_exit "); |
1da177e4c Linux-2.6.12-rc2 |
993 994 995 |
clean_up(mesg, mpc, DIE); break; case RELOAD: |
b50c2ea72 net/atm: Cleanup ... |
996 997 |
dprintk_cont("reload "); |
1da177e4c Linux-2.6.12-rc2 |
998 999 1000 |
clean_up(mesg, mpc, RELOAD); break; case SET_MPC_PARAMS: |
b50c2ea72 net/atm: Cleanup ... |
1001 1002 |
dprintk_cont("set_mpc_params "); |
1da177e4c Linux-2.6.12-rc2 |
1003 1004 1005 |
mpc->parameters = mesg->content.params; break; default: |
b50c2ea72 net/atm: Cleanup ... |
1006 1007 |
dprintk_cont("unknown message %d ", mesg->type); |
1da177e4c Linux-2.6.12-rc2 |
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 |
break; } kfree_skb(skb); return 0; } /* Remember that this function may not do things that sleep */ int msg_to_mpoad(struct k_message *mesg, struct mpoa_client *mpc) { struct sk_buff *skb; struct sock *sk; if (mpc == NULL || !mpc->mpoad_vcc) { |
571004407 net/atm/mpc.c: ch... |
1022 1023 |
pr_info("mesg %d to a non-existent mpoad ", mesg->type); |
1da177e4c Linux-2.6.12-rc2 |
1024 1025 1026 1027 1028 1029 1030 |
return -ENXIO; } skb = alloc_skb(sizeof(struct k_message), GFP_ATOMIC); if (skb == NULL) return -ENOMEM; skb_put(skb, sizeof(struct k_message)); |
27d7ff46a [SK_BUFF]: Introd... |
1031 |
skb_copy_to_linear_data(skb, mesg, sizeof(*mesg)); |
1da177e4c Linux-2.6.12-rc2 |
1032 |
atm_force_charge(mpc->mpoad_vcc, skb->truesize); |
f7d57453d [NET] ATM: Fix wh... |
1033 |
|
1da177e4c Linux-2.6.12-rc2 |
1034 1035 |
sk = sk_atm(mpc->mpoad_vcc); skb_queue_tail(&sk->sk_receive_queue, skb); |
676d23690 net: Fix use afte... |
1036 |
sk->sk_data_ready(sk); |
1da177e4c Linux-2.6.12-rc2 |
1037 1038 1039 |
return 0; } |
571004407 net/atm/mpc.c: ch... |
1040 |
static int mpoa_event_listener(struct notifier_block *mpoa_notifier, |
351638e7d net: pass info st... |
1041 |
unsigned long event, void *ptr) |
1da177e4c Linux-2.6.12-rc2 |
1042 |
{ |
351638e7d net: pass info st... |
1043 |
struct net_device *dev = netdev_notifier_info_to_dev(ptr); |
1da177e4c Linux-2.6.12-rc2 |
1044 1045 |
struct mpoa_client *mpc; struct lec_priv *priv; |
721499e89 netns: Use net_eq... |
1046 |
if (!net_eq(dev_net(dev), &init_net)) |
e9dc86534 [NET]: Make devic... |
1047 |
return NOTIFY_DONE; |
0d135e4f2 net: atm: remove ... |
1048 |
if (strncmp(dev->name, "lec", 3)) |
1da177e4c Linux-2.6.12-rc2 |
1049 |
return NOTIFY_DONE; /* we are only interested in lec:s */ |
f7d57453d [NET] ATM: Fix wh... |
1050 |
|
1da177e4c Linux-2.6.12-rc2 |
1051 1052 |
switch (event) { case NETDEV_REGISTER: /* a new lec device was allocated */ |
524ad0a79 netdevice: safe c... |
1053 |
priv = netdev_priv(dev); |
1da177e4c Linux-2.6.12-rc2 |
1054 1055 1056 1057 1058 |
if (priv->lane_version < 2) break; priv->lane2_ops->associate_indicator = lane2_assoc_ind; mpc = find_mpc_by_itfnum(priv->itfnum); if (mpc == NULL) { |
b50c2ea72 net/atm: Cleanup ... |
1059 1060 |
dprintk("allocating new mpc for %s ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
1061 1062 |
mpc = alloc_mpc(); if (mpc == NULL) { |
571004407 net/atm/mpc.c: ch... |
1063 |
pr_info("no new mpc"); |
1da177e4c Linux-2.6.12-rc2 |
1064 1065 1066 1067 1068 1069 |
break; } } mpc->dev_num = priv->itfnum; mpc->dev = dev; dev_hold(dev); |
b50c2ea72 net/atm: Cleanup ... |
1070 1071 |
dprintk("(%s) was initialized ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
1072 1073 1074 1075 1076 1077 |
break; case NETDEV_UNREGISTER: /* the lec device was deallocated */ mpc = find_mpc_by_lec(dev); if (mpc == NULL) break; |
b50c2ea72 net/atm: Cleanup ... |
1078 1079 |
dprintk("device (%s) was deallocated ", dev->name); |
1da177e4c Linux-2.6.12-rc2 |
1080 1081 1082 1083 1084 1085 1086 1087 1088 |
stop_mpc(mpc); dev_put(mpc->dev); mpc->dev = NULL; break; case NETDEV_UP: /* the dev was ifconfig'ed up */ mpc = find_mpc_by_lec(dev); if (mpc == NULL) break; |
571004407 net/atm/mpc.c: ch... |
1089 |
if (mpc->mpoad_vcc != NULL) |
1da177e4c Linux-2.6.12-rc2 |
1090 |
start_mpc(mpc, dev); |
1da177e4c Linux-2.6.12-rc2 |
1091 1092 1093 1094 1095 1096 1097 1098 1099 |
break; case NETDEV_DOWN: /* the dev was ifconfig'ed down */ /* this means that the flow of packets from the * upper layer stops */ mpc = find_mpc_by_lec(dev); if (mpc == NULL) break; |
571004407 net/atm/mpc.c: ch... |
1100 |
if (mpc->mpoad_vcc != NULL) |
1da177e4c Linux-2.6.12-rc2 |
1101 |
stop_mpc(mpc); |
1da177e4c Linux-2.6.12-rc2 |
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 |
break; case NETDEV_REBOOT: case NETDEV_CHANGE: case NETDEV_CHANGEMTU: case NETDEV_CHANGEADDR: case NETDEV_GOING_DOWN: break; default: break; } return NOTIFY_DONE; } /* * Functions which are called after a message is received from mpcd. * Msg is reused on purpose. */ static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc) { |
30d492da7 [ATM]: Annotations. |
1124 |
__be32 dst_ip = msg->content.in_info.in_dst_ip; |
1da177e4c Linux-2.6.12-rc2 |
1125 1126 1127 |
in_cache_entry *entry; entry = mpc->in_ops->get(dst_ip, mpc); |
571004407 net/atm/mpc.c: ch... |
1128 |
if (entry == NULL) { |
1da177e4c Linux-2.6.12-rc2 |
1129 1130 1131 1132 1133 |
entry = mpc->in_ops->add_entry(dst_ip, mpc); entry->entry_state = INGRESS_RESOLVING; msg->type = SND_MPOA_RES_RQST; msg->content.in_info = entry->ctrl_info; msg_to_mpoad(msg, mpc); |
d750dbdc0 atm: mpoa: remove... |
1134 |
entry->reply_wait = ktime_get_seconds(); |
1da177e4c Linux-2.6.12-rc2 |
1135 1136 1137 |
mpc->in_ops->put(entry); return; } |
f7d57453d [NET] ATM: Fix wh... |
1138 |
|
571004407 net/atm/mpc.c: ch... |
1139 |
if (entry->entry_state == INGRESS_INVALID) { |
1da177e4c Linux-2.6.12-rc2 |
1140 1141 1142 1143 |
entry->entry_state = INGRESS_RESOLVING; msg->type = SND_MPOA_RES_RQST; msg->content.in_info = entry->ctrl_info; msg_to_mpoad(msg, mpc); |
d750dbdc0 atm: mpoa: remove... |
1144 |
entry->reply_wait = ktime_get_seconds(); |
1da177e4c Linux-2.6.12-rc2 |
1145 1146 1147 |
mpc->in_ops->put(entry); return; } |
f7d57453d [NET] ATM: Fix wh... |
1148 |
|
571004407 net/atm/mpc.c: ch... |
1149 1150 |
pr_info("(%s) entry already in resolving state ", |
1da177e4c Linux-2.6.12-rc2 |
1151 1152 |
(mpc->dev) ? mpc->dev->name : "<unknown>"); mpc->in_ops->put(entry); |
1da177e4c Linux-2.6.12-rc2 |
1153 1154 1155 1156 |
} /* * Things get complicated because we have to check if there's an egress |
f7d57453d [NET] ATM: Fix wh... |
1157 |
* shortcut with suitable traffic parameters we could use. |
1da177e4c Linux-2.6.12-rc2 |
1158 |
*/ |
571004407 net/atm/mpc.c: ch... |
1159 1160 1161 |
static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_client *client, in_cache_entry *entry) |
1da177e4c Linux-2.6.12-rc2 |
1162 |
{ |
30d492da7 [ATM]: Annotations. |
1163 |
__be32 dst_ip = msg->content.in_info.in_dst_ip; |
1da177e4c Linux-2.6.12-rc2 |
1164 1165 |
struct atm_mpoa_qos *qos = atm_mpoa_search_qos(dst_ip); eg_cache_entry *eg_entry = client->eg_ops->get_by_src_ip(dst_ip, client); |
571004407 net/atm/mpc.c: ch... |
1166 1167 1168 1169 1170 1171 1172 1173 |
if (eg_entry && eg_entry->shortcut) { if (eg_entry->shortcut->qos.txtp.traffic_class & msg->qos.txtp.traffic_class & (qos ? qos->qos.txtp.traffic_class : ATM_UBR | ATM_CBR)) { if (eg_entry->shortcut->qos.txtp.traffic_class == ATM_UBR) entry->shortcut = eg_entry->shortcut; else if (eg_entry->shortcut->qos.txtp.max_pcr > 0) entry->shortcut = eg_entry->shortcut; |
1da177e4c Linux-2.6.12-rc2 |
1174 |
} |
571004407 net/atm/mpc.c: ch... |
1175 |
if (entry->shortcut) { |
b50c2ea72 net/atm: Cleanup ... |
1176 1177 |
dprintk("(%s) using egress SVC to reach %pI4 ", |
21454aaad net: replace NIPQ... |
1178 |
client->dev->name, &dst_ip); |
1da177e4c Linux-2.6.12-rc2 |
1179 1180 1181 1182 1183 1184 1185 1186 1187 |
client->eg_ops->put(eg_entry); return; } } if (eg_entry != NULL) client->eg_ops->put(eg_entry); /* No luck in the egress cache we must open an ingress SVC */ msg->type = OPEN_INGRESS_SVC; |
571004407 net/atm/mpc.c: ch... |
1188 1189 |
if (qos && (qos->qos.txtp.traffic_class == msg->qos.txtp.traffic_class)) { |
1da177e4c Linux-2.6.12-rc2 |
1190 |
msg->qos = qos->qos; |
571004407 net/atm/mpc.c: ch... |
1191 1192 1193 1194 1195 |
pr_info("(%s) trying to get a CBR shortcut ", client->dev->name); } else memset(&msg->qos, 0, sizeof(struct atm_qos)); |
1da177e4c Linux-2.6.12-rc2 |
1196 |
msg_to_mpoad(msg, client); |
1da177e4c Linux-2.6.12-rc2 |
1197 1198 1199 1200 |
} static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc) { |
30d492da7 [ATM]: Annotations. |
1201 |
__be32 dst_ip = msg->content.in_info.in_dst_ip; |
1da177e4c Linux-2.6.12-rc2 |
1202 |
in_cache_entry *entry = mpc->in_ops->get(dst_ip, mpc); |
1e4fd51e2 [ATM]: atm/mpc.c ... |
1203 |
|
b50c2ea72 net/atm: Cleanup ... |
1204 1205 |
dprintk("(%s) ip %pI4 ", |
21454aaad net: replace NIPQ... |
1206 |
mpc->dev->name, &dst_ip); |
b50c2ea72 net/atm: Cleanup ... |
1207 |
ddprintk("(%s) entry = %p", |
571004407 net/atm/mpc.c: ch... |
1208 1209 1210 1211 1212 |
mpc->dev->name, entry); if (entry == NULL) { pr_info("(%s) ARGH, received res. reply for an entry that doesn't exist. ", mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
1213 1214 |
return; } |
b50c2ea72 net/atm: Cleanup ... |
1215 |
ddprintk_cont(" entry_state = %d ", entry->entry_state); |
1da177e4c Linux-2.6.12-rc2 |
1216 1217 |
if (entry->entry_state == INGRESS_RESOLVED) { |
571004407 net/atm/mpc.c: ch... |
1218 1219 |
pr_info("(%s) RESOLVED entry! ", mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
1220 1221 1222 1223 1224 |
mpc->in_ops->put(entry); return; } entry->ctrl_info = msg->content.in_info; |
d750dbdc0 atm: mpoa: remove... |
1225 1226 1227 |
entry->time = ktime_get_seconds(); /* Used in refreshing func from now on */ entry->reply_wait = ktime_get_seconds(); |
1da177e4c Linux-2.6.12-rc2 |
1228 |
entry->refresh_time = 0; |
b50c2ea72 net/atm: Cleanup ... |
1229 1230 |
ddprintk_cont("entry->shortcut = %p ", entry->shortcut); |
1da177e4c Linux-2.6.12-rc2 |
1231 |
|
571004407 net/atm/mpc.c: ch... |
1232 1233 |
if (entry->entry_state == INGRESS_RESOLVING && entry->shortcut != NULL) { |
f7d57453d [NET] ATM: Fix wh... |
1234 |
entry->entry_state = INGRESS_RESOLVED; |
1da177e4c Linux-2.6.12-rc2 |
1235 1236 1237 1238 1239 |
mpc->in_ops->put(entry); return; /* Shortcut already open... */ } if (entry->shortcut != NULL) { |
571004407 net/atm/mpc.c: ch... |
1240 1241 1242 |
pr_info("(%s) entry->shortcut != NULL, impossible! ", mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
1243 1244 1245 |
mpc->in_ops->put(entry); return; } |
f7d57453d [NET] ATM: Fix wh... |
1246 |
|
1da177e4c Linux-2.6.12-rc2 |
1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 |
check_qos_and_open_shortcut(msg, mpc, entry); entry->entry_state = INGRESS_RESOLVED; mpc->in_ops->put(entry); return; } static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc) { |
30d492da7 [ATM]: Annotations. |
1257 1258 |
__be32 dst_ip = msg->content.in_info.in_dst_ip; __be32 mask = msg->ip_mask; |
1da177e4c Linux-2.6.12-rc2 |
1259 |
in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask); |
571004407 net/atm/mpc.c: ch... |
1260 1261 1262 1263 |
if (entry == NULL) { pr_info("(%s) purge for a non-existing entry, ip = %pI4 ", mpc->dev->name, &dst_ip); |
1da177e4c Linux-2.6.12-rc2 |
1264 1265 1266 1267 |
return; } do { |
b50c2ea72 net/atm: Cleanup ... |
1268 1269 |
dprintk("(%s) removing an ingress entry, ip = %pI4 ", |
21454aaad net: replace NIPQ... |
1270 |
mpc->dev->name, &dst_ip); |
1da177e4c Linux-2.6.12-rc2 |
1271 1272 1273 1274 1275 1276 |
write_lock_bh(&mpc->ingress_lock); mpc->in_ops->remove_entry(entry, mpc); write_unlock_bh(&mpc->ingress_lock); mpc->in_ops->put(entry); entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask); } while (entry != NULL); |
f7d57453d [NET] ATM: Fix wh... |
1277 |
} |
1da177e4c Linux-2.6.12-rc2 |
1278 1279 1280 |
static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc) { |
30d492da7 [ATM]: Annotations. |
1281 |
__be32 cache_id = msg->content.eg_info.cache_id; |
1da177e4c Linux-2.6.12-rc2 |
1282 |
eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id(cache_id, mpc); |
f7d57453d [NET] ATM: Fix wh... |
1283 |
|
1da177e4c Linux-2.6.12-rc2 |
1284 |
if (entry == NULL) { |
b50c2ea72 net/atm: Cleanup ... |
1285 1286 |
dprintk("(%s) purge for a non-existing entry ", |
571004407 net/atm/mpc.c: ch... |
1287 |
mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
1288 1289 1290 1291 1292 1293 1294 1295 |
return; } write_lock_irq(&mpc->egress_lock); mpc->eg_ops->remove_entry(entry, mpc); write_unlock_irq(&mpc->egress_lock); mpc->eg_ops->put(entry); |
f7d57453d [NET] ATM: Fix wh... |
1296 |
} |
1da177e4c Linux-2.6.12-rc2 |
1297 1298 1299 1300 1301 1302 |
static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry) { struct sock *sk; struct k_message *purge_msg; struct sk_buff *skb; |
b50c2ea72 net/atm: Cleanup ... |
1303 1304 |
dprintk("entering "); |
1da177e4c Linux-2.6.12-rc2 |
1305 |
if (vcc == NULL) { |
571004407 net/atm/mpc.c: ch... |
1306 1307 |
pr_info("vcc == NULL "); |
1da177e4c Linux-2.6.12-rc2 |
1308 1309 1310 1311 1312 |
return; } skb = alloc_skb(sizeof(struct k_message), GFP_ATOMIC); if (skb == NULL) { |
571004407 net/atm/mpc.c: ch... |
1313 1314 |
pr_info("out of memory "); |
1da177e4c Linux-2.6.12-rc2 |
1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 |
return; } skb_put(skb, sizeof(struct k_message)); memset(skb->data, 0, sizeof(struct k_message)); purge_msg = (struct k_message *)skb->data; purge_msg->type = DATA_PLANE_PURGE; if (entry != NULL) purge_msg->content.eg_info = entry->ctrl_info; atm_force_charge(vcc, skb->truesize); sk = sk_atm(vcc); skb_queue_tail(&sk->sk_receive_queue, skb); |
676d23690 net: Fix use afte... |
1329 |
sk->sk_data_ready(sk); |
b50c2ea72 net/atm: Cleanup ... |
1330 1331 |
dprintk("exiting "); |
1da177e4c Linux-2.6.12-rc2 |
1332 1333 1334 1335 1336 1337 |
} /* * Our MPS died. Tell our daemon to send NHRP data plane purge to each * of the egress shortcuts we have. */ |
571004407 net/atm/mpc.c: ch... |
1338 |
static void mps_death(struct k_message *msg, struct mpoa_client *mpc) |
1da177e4c Linux-2.6.12-rc2 |
1339 1340 |
{ eg_cache_entry *entry; |
b50c2ea72 net/atm: Cleanup ... |
1341 1342 |
dprintk("(%s) ", mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
1343 |
|
571004407 net/atm/mpc.c: ch... |
1344 1345 1346 |
if (memcmp(msg->MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN)) { pr_info("(%s) wrong MPS ", mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 |
return; } /* FIXME: This knows too much of the cache structure */ read_lock_irq(&mpc->egress_lock); entry = mpc->eg_cache; while (entry != NULL) { purge_egress_shortcut(entry->shortcut, entry); entry = entry->next; } read_unlock_irq(&mpc->egress_lock); mpc->in_ops->destroy_cache(mpc); mpc->eg_ops->destroy_cache(mpc); |
1da177e4c Linux-2.6.12-rc2 |
1361 |
} |
571004407 net/atm/mpc.c: ch... |
1362 1363 |
static void MPOA_cache_impos_rcvd(struct k_message *msg, struct mpoa_client *mpc) |
1da177e4c Linux-2.6.12-rc2 |
1364 1365 1366 |
{ uint16_t holding_time; eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id(msg->content.eg_info.cache_id, mpc); |
f7d57453d [NET] ATM: Fix wh... |
1367 |
|
1da177e4c Linux-2.6.12-rc2 |
1368 |
holding_time = msg->content.eg_info.holding_time; |
b50c2ea72 net/atm: Cleanup ... |
1369 1370 |
dprintk("(%s) entry = %p, holding_time = %u ", |
571004407 net/atm/mpc.c: ch... |
1371 1372 |
mpc->dev->name, entry, holding_time); if (entry == NULL && holding_time) { |
1da177e4c Linux-2.6.12-rc2 |
1373 1374 1375 1376 |
entry = mpc->eg_ops->add_entry(msg, mpc); mpc->eg_ops->put(entry); return; } |
571004407 net/atm/mpc.c: ch... |
1377 |
if (holding_time) { |
1da177e4c Linux-2.6.12-rc2 |
1378 1379 1380 |
mpc->eg_ops->update(entry, holding_time); return; } |
f7d57453d [NET] ATM: Fix wh... |
1381 |
|
1da177e4c Linux-2.6.12-rc2 |
1382 1383 1384 1385 1386 |
write_lock_irq(&mpc->egress_lock); mpc->eg_ops->remove_entry(entry, mpc); write_unlock_irq(&mpc->egress_lock); mpc->eg_ops->put(entry); |
1da177e4c Linux-2.6.12-rc2 |
1387 |
} |
571004407 net/atm/mpc.c: ch... |
1388 1389 |
static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg, struct mpoa_client *mpc) |
1da177e4c Linux-2.6.12-rc2 |
1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 |
{ struct lec_priv *priv; int i, retval ; uint8_t tlv[4 + 1 + 1 + 1 + ATM_ESA_LEN]; tlv[0] = 00; tlv[1] = 0xa0; tlv[2] = 0x3e; tlv[3] = 0x2a; /* type */ tlv[4] = 1 + 1 + ATM_ESA_LEN; /* length */ tlv[5] = 0x02; /* MPOA client */ tlv[6] = 0x00; /* number of MPS MAC addresses */ memcpy(&tlv[7], mesg->MPS_ctrl, ATM_ESA_LEN); /* MPC ctrl ATM addr */ memcpy(mpc->our_ctrl_addr, mesg->MPS_ctrl, ATM_ESA_LEN); |
b50c2ea72 net/atm: Cleanup ... |
1403 1404 |
dprintk("(%s) setting MPC ctrl ATM address to", mpc->dev ? mpc->dev->name : "<unknown>"); |
1da177e4c Linux-2.6.12-rc2 |
1405 |
for (i = 7; i < sizeof(tlv); i++) |
b50c2ea72 net/atm: Cleanup ... |
1406 1407 1408 |
dprintk_cont(" %02x", tlv[i]); dprintk_cont(" "); |
1da177e4c Linux-2.6.12-rc2 |
1409 1410 |
if (mpc->dev) { |
524ad0a79 netdevice: safe c... |
1411 |
priv = netdev_priv(mpc->dev); |
571004407 net/atm/mpc.c: ch... |
1412 1413 1414 |
retval = priv->lane2_ops->associate_req(mpc->dev, mpc->dev->dev_addr, tlv, sizeof(tlv)); |
1da177e4c Linux-2.6.12-rc2 |
1415 |
if (retval == 0) |
571004407 net/atm/mpc.c: ch... |
1416 1417 1418 |
pr_info("(%s) MPOA device type TLV association failed ", mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
1419 1420 |
retval = priv->lane2_ops->resolve(mpc->dev, NULL, 1, NULL, NULL); if (retval < 0) |
571004407 net/atm/mpc.c: ch... |
1421 1422 1423 |
pr_info("(%s) targetless LE_ARP request failed ", mpc->dev->name); |
1da177e4c Linux-2.6.12-rc2 |
1424 |
} |
1da177e4c Linux-2.6.12-rc2 |
1425 |
} |
571004407 net/atm/mpc.c: ch... |
1426 1427 |
static void set_mps_mac_addr_rcvd(struct k_message *msg, struct mpoa_client *client) |
1da177e4c Linux-2.6.12-rc2 |
1428 |
{ |
571004407 net/atm/mpc.c: ch... |
1429 |
if (client->number_of_mps_macs) |
1da177e4c Linux-2.6.12-rc2 |
1430 1431 |
kfree(client->mps_macs); client->number_of_mps_macs = 0; |
2afe37cdf [ATM]: Use kmemdu... |
1432 |
client->mps_macs = kmemdup(msg->MPS_ctrl, ETH_ALEN, GFP_KERNEL); |
1da177e4c Linux-2.6.12-rc2 |
1433 |
if (client->mps_macs == NULL) { |
571004407 net/atm/mpc.c: ch... |
1434 1435 |
pr_info("out of memory "); |
1da177e4c Linux-2.6.12-rc2 |
1436 1437 1438 |
return; } client->number_of_mps_macs = 1; |
1da177e4c Linux-2.6.12-rc2 |
1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 |
} /* * purge egress cache and tell daemon to 'action' (DIE, RELOAD) */ static void clean_up(struct k_message *msg, struct mpoa_client *mpc, int action) { eg_cache_entry *entry; msg->type = SND_EGRESS_PURGE; /* FIXME: This knows too much of the cache structure */ read_lock_irq(&mpc->egress_lock); entry = mpc->eg_cache; |
571004407 net/atm/mpc.c: ch... |
1454 1455 |
while (entry != NULL) { msg->content.eg_info = entry->ctrl_info; |
b50c2ea72 net/atm: Cleanup ... |
1456 1457 |
dprintk("cache_id %u ", entry->ctrl_info.cache_id); |
571004407 net/atm/mpc.c: ch... |
1458 1459 |
msg_to_mpoad(msg, mpc); entry = entry->next; |
1da177e4c Linux-2.6.12-rc2 |
1460 1461 1462 1463 1464 |
} read_unlock_irq(&mpc->egress_lock); msg->type = action; msg_to_mpoad(msg, mpc); |
1da177e4c Linux-2.6.12-rc2 |
1465 |
} |
5c658e19a net: atm/mpc: Sto... |
1466 |
static unsigned long checking_time; |
1da177e4c Linux-2.6.12-rc2 |
1467 1468 1469 |
static void mpc_timer_refresh(void) { mpc_timer.expires = jiffies + (MPC_P2 * HZ); |
5c658e19a net: atm/mpc: Sto... |
1470 |
checking_time = mpc_timer.expires; |
1da177e4c Linux-2.6.12-rc2 |
1471 |
add_timer(&mpc_timer); |
1da177e4c Linux-2.6.12-rc2 |
1472 |
} |
5c658e19a net: atm/mpc: Sto... |
1473 |
static void mpc_cache_check(struct timer_list *unused) |
1da177e4c Linux-2.6.12-rc2 |
1474 1475 1476 1477 |
{ struct mpoa_client *mpc = mpcs; static unsigned long previous_resolving_check_time; static unsigned long previous_refresh_time; |
f7d57453d [NET] ATM: Fix wh... |
1478 |
|
571004407 net/atm/mpc.c: ch... |
1479 |
while (mpc != NULL) { |
1da177e4c Linux-2.6.12-rc2 |
1480 1481 |
mpc->in_ops->clear_count(mpc); mpc->eg_ops->clear_expired(mpc); |
571004407 net/atm/mpc.c: ch... |
1482 1483 |
if (checking_time - previous_resolving_check_time > mpc->parameters.mpc_p4 * HZ) { |
1da177e4c Linux-2.6.12-rc2 |
1484 1485 1486 |
mpc->in_ops->check_resolving(mpc); previous_resolving_check_time = checking_time; } |
571004407 net/atm/mpc.c: ch... |
1487 1488 |
if (checking_time - previous_refresh_time > mpc->parameters.mpc_p5 * HZ) { |
1da177e4c Linux-2.6.12-rc2 |
1489 1490 1491 1492 1493 1494 |
mpc->in_ops->refresh(mpc); previous_refresh_time = checking_time; } mpc = mpc->next; } mpc_timer_refresh(); |
1da177e4c Linux-2.6.12-rc2 |
1495 |
} |
571004407 net/atm/mpc.c: ch... |
1496 1497 |
static int atm_mpoa_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
1da177e4c Linux-2.6.12-rc2 |
1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 |
{ int err = 0; struct atm_vcc *vcc = ATM_SD(sock); if (cmd != ATMMPC_CTRL && cmd != ATMMPC_DATA) return -ENOIOCTLCMD; if (!capable(CAP_NET_ADMIN)) return -EPERM; switch (cmd) { |
571004407 net/atm/mpc.c: ch... |
1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 |
case ATMMPC_CTRL: err = atm_mpoa_mpoad_attach(vcc, (int)arg); if (err >= 0) sock->state = SS_CONNECTED; break; case ATMMPC_DATA: err = atm_mpoa_vcc_attach(vcc, (void __user *)arg); break; default: break; |
1da177e4c Linux-2.6.12-rc2 |
1519 1520 1521 |
} return err; } |
1da177e4c Linux-2.6.12-rc2 |
1522 1523 1524 1525 1526 1527 1528 1529 |
static struct atm_ioctl atm_ioctl_ops = { .owner = THIS_MODULE, .ioctl = atm_mpoa_ioctl, }; static __init int atm_mpoa_init(void) { register_atm_ioctl(&atm_ioctl_ops); |
1da177e4c Linux-2.6.12-rc2 |
1530 |
if (mpc_proc_init() != 0) |
99824461e net/atm: Convert ... |
1531 1532 |
pr_info("failed to initialize /proc/mpoa "); |
1da177e4c Linux-2.6.12-rc2 |
1533 |
|
36a9f77e5 atm: Drop __TIME_... |
1534 1535 |
pr_info("mpc.c: initialized "); |
1da177e4c Linux-2.6.12-rc2 |
1536 1537 1538 1539 1540 1541 1542 1543 1544 |
return 0; } static void __exit atm_mpoa_cleanup(void) { struct mpoa_client *mpc, *tmp; struct atm_mpoa_qos *qos, *nextqos; struct lec_priv *priv; |
1da177e4c Linux-2.6.12-rc2 |
1545 |
mpc_proc_clean(); |
1da177e4c Linux-2.6.12-rc2 |
1546 |
|
84275593a atm: replace del_... |
1547 |
del_timer_sync(&mpc_timer); |
1da177e4c Linux-2.6.12-rc2 |
1548 1549 1550 1551 1552 1553 1554 1555 1556 |
unregister_netdevice_notifier(&mpoa_notifier); deregister_atm_ioctl(&atm_ioctl_ops); mpc = mpcs; mpcs = NULL; while (mpc != NULL) { tmp = mpc->next; if (mpc->dev != NULL) { stop_mpc(mpc); |
524ad0a79 netdevice: safe c... |
1557 |
priv = netdev_priv(mpc->dev); |
1da177e4c Linux-2.6.12-rc2 |
1558 1559 1560 |
if (priv->lane2_ops != NULL) priv->lane2_ops->associate_indicator = NULL; } |
b50c2ea72 net/atm: Cleanup ... |
1561 1562 |
ddprintk("about to clear caches "); |
1da177e4c Linux-2.6.12-rc2 |
1563 1564 |
mpc->in_ops->destroy_cache(mpc); mpc->eg_ops->destroy_cache(mpc); |
b50c2ea72 net/atm: Cleanup ... |
1565 1566 |
ddprintk("caches cleared "); |
1da177e4c Linux-2.6.12-rc2 |
1567 1568 |
kfree(mpc->mps_macs); memset(mpc, 0, sizeof(struct mpoa_client)); |
b50c2ea72 net/atm: Cleanup ... |
1569 1570 |
ddprintk("about to kfree %p ", mpc); |
1da177e4c Linux-2.6.12-rc2 |
1571 |
kfree(mpc); |
b50c2ea72 net/atm: Cleanup ... |
1572 1573 |
ddprintk("next mpc is at %p ", tmp); |
1da177e4c Linux-2.6.12-rc2 |
1574 1575 1576 1577 1578 1579 1580 |
mpc = tmp; } qos = qos_head; qos_head = NULL; while (qos != NULL) { nextqos = qos->next; |
b50c2ea72 net/atm: Cleanup ... |
1581 1582 |
dprintk("freeing qos entry %p ", qos); |
1da177e4c Linux-2.6.12-rc2 |
1583 1584 1585 |
kfree(qos); qos = nextqos; } |
1da177e4c Linux-2.6.12-rc2 |
1586 1587 1588 1589 1590 1591 |
} module_init(atm_mpoa_init); module_exit(atm_mpoa_cleanup); MODULE_LICENSE("GPL"); |