@@ -441,16 +441,16 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr,
441441 char * buff )
442442{
443443 struct net_device * net_dev = kobj_to_netdev (kobj );
444- struct batman_if * batman_if = get_batman_if_by_netdev (net_dev );
444+ struct hard_iface * hard_iface = hardif_get_by_netdev (net_dev );
445445 ssize_t length ;
446446
447- if (!batman_if )
447+ if (!hard_iface )
448448 return 0 ;
449449
450- length = sprintf (buff , "%s\n" , batman_if -> if_status == IF_NOT_IN_USE ?
451- "none" : batman_if -> soft_iface -> name );
450+ length = sprintf (buff , "%s\n" , hard_iface -> if_status == IF_NOT_IN_USE ?
451+ "none" : hard_iface -> soft_iface -> name );
452452
453- kref_put ( & batman_if -> refcount , hardif_free_ref );
453+ hardif_free_ref ( hard_iface );
454454
455455 return length ;
456456}
@@ -459,11 +459,11 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
459459 char * buff , size_t count )
460460{
461461 struct net_device * net_dev = kobj_to_netdev (kobj );
462- struct batman_if * batman_if = get_batman_if_by_netdev (net_dev );
462+ struct hard_iface * hard_iface = hardif_get_by_netdev (net_dev );
463463 int status_tmp = -1 ;
464- int ret ;
464+ int ret = count ;
465465
466- if (!batman_if )
466+ if (!hard_iface )
467467 return count ;
468468
469469 if (buff [count - 1 ] == '\n' )
@@ -472,7 +472,7 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
472472 if (strlen (buff ) >= IFNAMSIZ ) {
473473 pr_err ("Invalid parameter for 'mesh_iface' setting received: "
474474 "interface name too long '%s'\n" , buff );
475- kref_put ( & batman_if -> refcount , hardif_free_ref );
475+ hardif_free_ref ( hard_iface );
476476 return - EINVAL ;
477477 }
478478
@@ -481,44 +481,45 @@ static ssize_t store_mesh_iface(struct kobject *kobj, struct attribute *attr,
481481 else
482482 status_tmp = IF_I_WANT_YOU ;
483483
484- if ((batman_if -> if_status == status_tmp ) || ((batman_if -> soft_iface ) &&
485- (strncmp (batman_if -> soft_iface -> name , buff , IFNAMSIZ ) == 0 ))) {
486- kref_put (& batman_if -> refcount , hardif_free_ref );
487- return count ;
488- }
484+ if (hard_iface -> if_status == status_tmp )
485+ goto out ;
486+
487+ if ((hard_iface -> soft_iface ) &&
488+ (strncmp (hard_iface -> soft_iface -> name , buff , IFNAMSIZ ) == 0 ))
489+ goto out ;
489490
490491 if (status_tmp == IF_NOT_IN_USE ) {
491492 rtnl_lock ();
492- hardif_disable_interface (batman_if );
493+ hardif_disable_interface (hard_iface );
493494 rtnl_unlock ();
494- kref_put (& batman_if -> refcount , hardif_free_ref );
495- return count ;
495+ goto out ;
496496 }
497497
498498 /* if the interface already is in use */
499- if (batman_if -> if_status != IF_NOT_IN_USE ) {
499+ if (hard_iface -> if_status != IF_NOT_IN_USE ) {
500500 rtnl_lock ();
501- hardif_disable_interface (batman_if );
501+ hardif_disable_interface (hard_iface );
502502 rtnl_unlock ();
503503 }
504504
505- ret = hardif_enable_interface (batman_if , buff );
506- kref_put (& batman_if -> refcount , hardif_free_ref );
505+ ret = hardif_enable_interface (hard_iface , buff );
507506
507+ out :
508+ hardif_free_ref (hard_iface );
508509 return ret ;
509510}
510511
511512static ssize_t show_iface_status (struct kobject * kobj , struct attribute * attr ,
512513 char * buff )
513514{
514515 struct net_device * net_dev = kobj_to_netdev (kobj );
515- struct batman_if * batman_if = get_batman_if_by_netdev (net_dev );
516+ struct hard_iface * hard_iface = hardif_get_by_netdev (net_dev );
516517 ssize_t length ;
517518
518- if (!batman_if )
519+ if (!hard_iface )
519520 return 0 ;
520521
521- switch (batman_if -> if_status ) {
522+ switch (hard_iface -> if_status ) {
522523 case IF_TO_BE_REMOVED :
523524 length = sprintf (buff , "disabling\n" );
524525 break ;
@@ -537,7 +538,7 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr,
537538 break ;
538539 }
539540
540- kref_put ( & batman_if -> refcount , hardif_free_ref );
541+ hardif_free_ref ( hard_iface );
541542
542543 return length ;
543544}
0 commit comments