backport 2.6 changes to 2.4
Subsystems (3)
PATCH 4/6 backport 2.6 changes to 2.4
Don't dynamically allocate a net_device_stats structure for each bond, instead allocate it with the bonding structure.
Since they are always allocated together anyway, we might as well put the stats struct within the bond.
drivers/net/bonding/bond_main.c +3 -14
@@ -3322,10 +3322,10 @@ static int bond_xmit_activebackup(structstatic struct net_device_stats *bond_get_stats (struct net_device *dev) {bonding_t *bond = dev->priv; -struct net_device_stats *stats = bond->stats, *sstats; +struct net_device_stats *stats = &(bond->stats), *sstats;slave_t *slave; -memset (bond->stats,0 ,sizeof (struct net_device_stats )); +memset (stats,0 ,sizeof (struct net_device_stats ));read_lock_bh (&bond->lock);
@@ -3563,13 +3563,6 @@ static int __init bond_init(struct net_d/* initialize rwlocks */ rwlock_init (&bond->lock);rwlock_init (&bond->ptrlock); - - bond->stats =kmalloc (sizeof (struct net_device_stats ),GFP_KERNEL ); -if (bond->stats ==NULL ) { -kfree (bond); -return -ENOMEM ; - } -memset (bond->stats,0 ,sizeof (struct net_device_stats )); bond->next = bond->prev = (slave_t *)bond; bond->current_slave =NULL ;
@@ -3600,7 +3593,6 @@ static int __init bond_init(struct net_dbreak ;default :printk (KERN_ERR "Unknown bonding mode %d\n" , bond_mode); -kfree (bond->stats);kfree (bond);return -EINVAL ; }
@@ -3651,7 +3643,6 @@ static int __init bond_init(struct net_dif (bond->bond_proc_dir ==NULL ) {printk (KERN_ERR "%s: Cannot init /proc/net/%s/\n" , dev->name, dev->name); -kfree (bond->stats);kfree (bond);return -ENOMEM ; }
@@ -3664,7 +3655,6 @@ static int __init bond_init(struct net_dprintk (KERN_ERR "%s: Cannot init /proc/net/%s/info\n" , dev->name, dev->name);remove_proc_entry (dev->name, proc_net); -kfree (bond->stats);kfree (bond);return -ENOMEM ; }
@@ -4007,9 +3997,8 @@ static void __exit bonding_exit(void)remove_proc_entry (dev_bond->name, proc_net);#endif unregister_netdev (dev_bond); -kfree (bond->stats);kfree (dev_bond->priv); - + dev_bond->priv =NULL ; dev_bond++; }
drivers/net/bonding/bonding.h +1 -1
@@ -99,7 +99,7 @@ typedef struct bonding {rwlock_t ptrlock;struct timer_list mii_timer;struct timer_list arp_timer; -struct net_device_stats *stats; +struct net_device_stats stats;#ifdef CONFIG_PROC_FS struct proc_dir_entry *bond_proc_dir;struct proc_dir_entry *bond_proc_info_file;
Signature · 4 lines
| Shmulik Hen Advanced Network Services | | Israel Design Center, Jerusalem | | LAN Access Division, Platform Networking | | Intel Communications Group, Intel corp. |