Ticket #203: imr-renaming-patch-r2.diff
| File imr-renaming-patch-r2.diff, 13.1 kB (added by imr1@waikato.ac.nz, 6 years ago) |
|---|
-
net80211/ieee80211_linux.c
old new 579 579 { 580 580 int i, space; 581 581 582 char *devname = NULL; 582 583 space = 5*sizeof(struct ctl_table) + sizeof(ieee80211_sysctl_template); 583 584 vap->iv_sysctls = kmalloc(space, GFP_KERNEL); 584 585 if (vap->iv_sysctls == NULL) { … … 586 587 return; 587 588 } 588 589 590 /* Reserve space for the device name outside the net_device structure 591 * so that if the name changes we know what it used to be. 592 */ 593 devname = kmalloc((strlen(vap->iv_dev->name) + 1) * sizeof(char), GFP_KERNEL); 594 if(devname == NULL) { 595 printk("%s: no memory for VAP name!\n", __func__); 596 return; 597 } 598 strncpy(devname, vap->iv_dev->name, strlen(vap->iv_dev->name) + 1); 589 599 /* setup the table */ 590 600 memset(vap->iv_sysctls, 0, space); 591 601 vap->iv_sysctls[0].ctl_name = CTL_NET; … … 594 604 vap->iv_sysctls[0].child = &vap->iv_sysctls[2]; 595 605 /* [1] is NULL terminator */ 596 606 vap->iv_sysctls[2].ctl_name = CTL_AUTO; 597 vap->iv_sysctls[2].procname = vap->iv_dev->name;/* XXX bad idea? */607 vap->iv_sysctls[2].procname = devname;//vap->iv_dev->name;/* XXX bad idea? */ 598 608 vap->iv_sysctls[2].mode = 0555; 599 609 vap->iv_sysctls[2].child = &vap->iv_sysctls[4]; 600 610 /* [3] is NULL terminator */ … … 630 640 631 641 if (proc_madwifi) { 632 642 proc_madwifi_count++; 633 vap->iv_proc = proc_mkdir( vap->iv_dev->name, proc_madwifi);643 vap->iv_proc = proc_mkdir(devname, proc_madwifi); 634 644 if (vap->iv_proc) { 635 645 vap->iv_proc_stations = create_proc_entry("associated_sta", 636 646 PROC_IEEE80211_PERM, vap->iv_proc); … … 640 650 } 641 651 642 652 } 653 EXPORT_SYMBOL(ieee80211_sysctl_vattach); 643 654 644 655 void 645 656 ieee80211_sysctl_vdetach(struct ieee80211vap *vap) … … 648 659 unregister_sysctl_table(vap->iv_sysctl_header); 649 660 vap->iv_sysctl_header = NULL; 650 661 } 651 if (vap->iv_sysctls) { 652 kfree(vap->iv_sysctls); 653 vap->iv_sysctls = NULL; 654 } 655 662 656 663 if (vap->iv_proc) { 657 664 remove_proc_entry("associated_sta", vap->iv_proc); 658 remove_proc_entry(vap->iv_ dev->name, proc_madwifi);665 remove_proc_entry(vap->iv_sysctls[2].procname, proc_madwifi); 659 666 if (proc_madwifi_count == 1) { 660 667 remove_proc_entry("madwifi", proc_net); 661 proc_madwifi = NULL;668 proc_madwifi = NULL; 662 669 } 663 proc_madwifi_count--;670 proc_madwifi_count--; 664 671 } 665 672 673 if(vap->iv_sysctls[2].procname) { 674 kfree(vap->iv_sysctls[2].procname); 675 vap->iv_sysctls[2].procname = NULL; 676 } 677 678 if (vap->iv_sysctls) { 679 kfree(vap->iv_sysctls); 680 vap->iv_sysctls = NULL; 681 } 682 666 683 } 684 EXPORT_SYMBOL(ieee80211_sysctl_vdetach); 667 685 #endif /* CONFIG_SYSCTL */ 668 686 669 687 /* -
ath/if_ath_ahb.c
old new 421 421 MODULE_LICENSE("Dual BSD/GPL"); 422 422 #endif 423 423 424 static struct notifier_block ath_dev_notifier = { 425 .notifier_call = ath_rcv_dev_event, 426 }; 427 424 428 static int __init 425 429 init_ath_ahb(void) 426 430 { 427 431 printk(KERN_INFO "%s: %s\n", dev_info, version); 428 432 433 /* Initialise the interface list so we can record 434 * which devices we need to maintain proc entries for. 435 */ 436 ath_initialise_interface_list(); 429 437 if (init_ahb() != 0) { 430 438 printk("ath_ahb: No devices found, driver not installed.\n"); 431 439 return (-ENODEV); … … 433 441 #ifdef CONFIG_SYSCTL 434 442 ath_sysctl_register(); 435 443 #endif 444 445 /* Register for netdevice events so we can maintain 446 * the proc entries when interface names change. 447 */ 448 register_netdevice_notifier(&ath_dev_notifier); 436 449 return (0); 437 450 } 438 451 module_init(init_ath_ahb); … … 440 453 static void __exit 441 454 exit_ath_ahb(void) 442 455 { 456 /* We're unloading, so we need to unregister our interest 457 * in netdevice notifications. 458 */ 459 unregister_netdevice_notifier(&ath_dev_notifier); 443 460 #ifdef CONFIG_SYSCTL 444 461 ath_sysctl_unregister(); 445 462 #endif 446 463 exit_ath_wmac(AR531X_WLAN0_NUM); 447 464 exit_ath_wmac(AR531X_WLAN1_NUM); 448 465 466 /* The list will no longer be being modified, so we 467 * can clean it up and remove any memory that is still 468 * being used by it. 469 */ 470 ath_cleanup_interface_list(); 471 449 472 printk(KERN_INFO "%s: driver unloaded\n", dev_info); 450 473 } 451 474 module_exit(exit_ath_ahb); -
ath/if_ath_pci.c
old new 320 320 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,22) 321 321 /* include the device name so later versions of kudzu DTRT */ 322 322 strncpy(info.bus_info, pci_name((struct pci_dev *)sc->sc_bdev), 323 sizeof(info.bus_info)-1);323 sizeof(info.bus_info)-1); 324 324 #endif 325 325 return copy_to_user(addr, &info, sizeof(info)) ? -EFAULT : 0; 326 326 } … … 332 332 MODULE_LICENSE("Dual BSD/GPL"); 333 333 #endif 334 334 335 static struct notifier_block ath_dev_notifier = { 336 .notifier_call = ath_rcv_dev_event, 337 }; 338 335 339 static int __init 336 340 init_ath_pci(void) 337 341 { 338 342 printk(KERN_INFO "%s: %s\n", dev_info, version); 339 343 344 /* Setup the list of interfaces that interest us 345 * so they can be recorded when they are created. 346 */ 347 ath_initialise_interface_list(); 348 340 349 if (pci_register_driver(&ath_pci_drv_id) < 0) { 341 350 printk("ath_pci: No devices found, driver not installed.\n"); 342 351 pci_unregister_driver(&ath_pci_drv_id); 343 352 return (-ENODEV); 344 353 } 354 355 /* Register for netdevice notifications so we can maintain 356 * the proc entries correctly. 357 */ 358 register_netdevice_notifier(&ath_dev_notifier); 345 359 #ifdef CONFIG_SYSCTL 346 360 ath_sysctl_register(); 347 361 #endif … … 355 369 #ifdef CONFIG_SYSCTL 356 370 ath_sysctl_unregister(); 357 371 #endif 372 /* The module is unloading, so we need to unregister our 373 * interest in netdevice notifications. 374 */ 375 unregister_netdevice_notifier(&ath_dev_notifier); 358 376 pci_unregister_driver(&ath_pci_drv_id); 359 377 378 /* The interfaces list will no longer be modified, so 379 * clean up any memory used by it. 380 */ 381 ath_cleanup_interface_list(); 360 382 printk(KERN_INFO "%s: driver unloaded\n", dev_info); 361 383 } 362 384 module_exit(exit_ath_pci); -
ath/if_athvar.h
old new 664 664 void ath_sysctl_unregister(void); 665 665 #endif /* CONFIG_SYSCTL */ 666 666 667 /* Device Event Notification */ 668 int ath_rcv_dev_event(struct notifier_block *, unsigned long, void *); 669 670 /* Interface List preperatation */ 671 struct ath_interfaces_list { 672 struct list_head list; 673 struct net_device *dev; 674 unsigned char type; 675 }; 676 677 void ath_initialise_interface_list(void); 678 void ath_cleanup_interface_list(void); 679 667 680 /* 668 681 * HAL definitions to comply with local coding convention. 669 682 */ -
ath/if_ath.c
old new 68 68 #include <net80211/ieee80211_var.h> 69 69 #include <net80211/ieee80211_monitor.h> 70 70 71 #include <net80211/ieee80211_linux.h> 72 71 73 #ifdef USE_HEADERLEN_RESV 72 74 #include <net80211/if_llc.h> 73 75 #endif … … 381 383 } \ 382 384 } while(0) 383 385 386 struct ath_interfaces_list interface_list; 387 388 /* 389 * Initialises the list of interfaces to watch for when 390 * we recieve device notifier events. 391 */ 392 393 void ath_initialise_interface_list() 394 { 395 INIT_LIST_HEAD(&interface_list.list); 396 } 397 398 399 /* 400 * Goes through the interface list deleting all entries and 401 * freeing any memory allocated to them. 402 * Done when the module is being unloaded. 403 */ 404 void ath_cleanup_interface_list() 405 { 406 struct list_head *pos, *q; 407 struct ath_interfaces_list *tmp; 408 409 list_for_each_safe(pos, q, &(interface_list.list)) { 410 tmp = list_entry(pos, struct ath_interfaces_list, list); 411 list_del(pos); 412 kfree(tmp); 413 } 414 } 415 416 /* Function to handle the device event notifications. 417 * If the event is a NETDEV_CHANGENAME, and is for an interface 418 * we are taking care of, then we want to remove it's existing 419 * proc entries (which now have the wrong names) and add 420 * new, correct, entries. 421 */ 384 422 int 423 ath_rcv_dev_event(struct notifier_block *this, unsigned long event, 424 void *ptr) 425 { 426 struct net_device *dev = ptr; 427 struct ath_interfaces_list *tmp = NULL; 428 429 #ifdef CONFIG_SYSCTL 430 switch (event) { 431 case NETDEV_CHANGE: 432 break; 433 case NETDEV_CHANGENAME: 434 /* In here, we want to register and deregister 435 * the sysctls, effectively moving 436 * the proc entries to the correct place. 437 */ 438 list_for_each_entry(tmp, &interface_list.list, list) { 439 /* If this is a device in our list of 440 * devices to watch for: 441 */ 442 if(tmp->dev != dev) 443 break; 444 445 /* If the type is 0, then it 446 * a base interface (typically wifi%d) 447 * then we handle it with one 448 * set of functions 449 */ 450 if(tmp->type == 0) { 451 ath_dynamic_sysctl_unregister( 452 dev->priv); 453 ath_dynamic_sysctl_register( 454 dev->priv); 455 } 456 /* If the type is 1 it's a VAP 457 * and so we use a different set. 458 */ 459 else if(tmp->type == 1) { 460 ieee80211_sysctl_vdetach(dev->priv); 461 ieee80211_sysctl_vattach(dev->priv); 462 } 463 } 464 break; 465 } 466 #endif /* CONFIG_SYSCTL */ 467 return NOTIFY_DONE; 468 } 469 470 471 472 int 385 473 ath_attach(u_int16_t devid, struct net_device *dev) 386 474 { 387 475 struct ath_softc *sc = dev->priv; … … 391 479 int error = 0,i; 392 480 u_int8_t csz; 393 481 482 struct ath_interfaces_list *tmp = NULL; 483 394 484 sc->sc_debug = ath_debug; 395 485 DPRINTF(sc, ATH_DEBUG_ANY, "%s: devid 0x%x\n", __func__, devid); 396 486 … … 853 943 printk(KERN_ERR "%s: unable to register device\n", dev->name); 854 944 goto bad3; 855 945 } 946 947 /* interfaces list is definately setup now, so add the new 948 * device to the list. */ 949 950 tmp = (struct ath_interfaces_list *)kmalloc( 951 sizeof(struct ath_interfaces_list), GFP_KERNEL); 952 if(tmp == NULL) { 953 printk(KERN_ERR "%s: unable to allocate space for interface list\n" 954 , dev->name); 955 goto bad3; 956 } 957 tmp->dev = dev; 958 tmp->type = 0; 959 list_add(&(tmp->list), &(interface_list.list)); 856 960 /* 857 961 * Attach dynamic MIB vars and announce support 858 962 * now that we have a device name with unit number. … … 888 992 struct ath_softc *sc = dev->priv; 889 993 struct ath_hal *ah = sc->sc_ah; 890 994 995 891 996 DPRINTF(sc, ATH_DEBUG_ANY, "%s: flags %x\n", __func__, dev->flags); 892 997 ath_stop(dev); 893 998 … … 939 1044 struct ieee80211vap *vap; 940 1045 int ic_opmode; 941 1046 1047 struct ath_interfaces_list *tmp = NULL; 1048 942 1049 /* XXX ic unlocked and race against add */ 943 1050 switch (opmode) { 944 1051 case IEEE80211_M_STA: /* ap+sta for repeater application */ … … 992 1099 } 993 1100 avp = dev->priv; 994 1101 ieee80211_vap_setup(ic, dev, name, unit, opmode, flags); 1102 tmp = (struct ath_interfaces_list *)kmalloc( 1103 sizeof(struct ath_interfaces_list), GFP_KERNEL); 1104 if(tmp == NULL) { 1105 return NULL; 1106 } 1107 tmp->dev = dev; 1108 tmp->type = 1; 1109 list_add(&(tmp->list), &(interface_list.list)); 995 1110 /* override with driver methods */ 996 1111 vap = &avp->av_vap; 997 1112 avp->av_newstate = vap->iv_newstate; … … 1138 1253 struct ath_hal *ah = sc->sc_ah; 1139 1254 struct ath_vap *avp = ATH_VAP(vap); 1140 1255 int decrease = 1; 1256 1257 1258 struct ath_interfaces_list *tmp = NULL; 1259 struct list_head *pos, *q; 1141 1260 KASSERT(vap->iv_state == IEEE80211_S_INIT, ("vap not stopped")); 1142 1261 1143 1262 if (dev->flags & IFF_RUNNING) { … … 1184 1303 decrease = 0; 1185 1304 } 1186 1305 ieee80211_vap_detach(vap); 1306 list_for_each_safe(pos,q,&(interface_list.list)) { 1307 tmp= list_entry(pos, struct ath_interfaces_list, list); 1308 if(tmp->dev == dev) { 1309 list_del(pos); 1310 kfree(tmp); 1311 } 1312 } 1187 1313 /* NB: memory is reclaimed through dev->destructor callback */ 1188 1314 if (decrease) 1189 1315 sc->sc_nvaps--; … … 9218 9344 { 9219 9345 int i, space; 9220 9346 9347 /* Space for the dev->name */ 9348 char *dev_name = NULL; 9221 9349 space = 5*sizeof(struct ctl_table) + sizeof(ath_sysctl_template); 9222 9350 sc->sc_sysctls = kmalloc(space, GFP_KERNEL); 9223 9351 if (sc->sc_sysctls == NULL) { … … 9225 9353 return; 9226 9354 } 9227 9355 9356 /* We want to reserve space for the name of the device seperate 9357 * to the net_device structure, because when the name is changed 9358 * it is changed in the net_device structure and the message given 9359 * out. Thus we won't know what the name used to be if we rely 9360 * on it. 9361 */ 9362 dev_name = kmalloc((strlen(sc->sc_dev->name) + 1) * sizeof(char), GFP_KERNEL); 9363 if (dev_name == NULL) { 9364 printk("%s: no memory for device name storage!\n", __func__); 9365 return; 9366 } 9367 strncpy(dev_name, sc->sc_dev->name, strlen(sc->sc_dev->name) + 1); 9228 9368 /* setup the table */ 9229 9369 memset(sc->sc_sysctls, 0, space); 9230 9370 sc->sc_sysctls[0].ctl_name = CTL_DEV; … … 9233 9373 sc->sc_sysctls[0].child = &sc->sc_sysctls[2]; 9234 9374 /* [1] is NULL terminator */ 9235 9375 sc->sc_sysctls[2].ctl_name = CTL_AUTO; 9236 sc->sc_sysctls[2].procname = sc->sc_dev->name;9376 sc->sc_sysctls[2].procname = dev_name; 9237 9377 sc->sc_sysctls[2].mode = 0555; 9238 9378 sc->sc_sysctls[2].child = &sc->sc_sysctls[4]; 9239 9379 /* [3] is NULL terminator */ … … 9267 9407 unregister_sysctl_table(sc->sc_sysctl_header); 9268 9408 sc->sc_sysctl_header = NULL; 9269 9409 } 9410 if(sc->sc_sysctls[2].procname) { 9411 kfree(sc->sc_sysctls[2].procname); 9412 sc->sc_sysctls[2].procname = NULL; 9413 } 9270 9414 if (sc->sc_sysctls) { 9271 9415 kfree(sc->sc_sysctls); 9272 9416 sc->sc_sysctls = NULL;
