--- zzzz-none-000/linux-2.6.28.10/include/linux/inetdevice.h 2009-05-02 18:54:43.000000000 +0000 +++ fusiv-7390-686/linux-2.6.28.10/include/linux/inetdevice.h 2012-02-14 14:37:49.000000000 +0000 @@ -128,6 +128,9 @@ extern int unregister_inetaddr_notifier(struct notifier_block *nb); extern struct net_device *ip_dev_find(struct net *net, __be32 addr); +#if defined(CONFIG_MACH_FUSIV) +extern struct net_device *ipv6_dev_find(struct net *net, struct in6_addr *addr); +#endif extern int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b); extern int devinet_ioctl(struct net *net, unsigned int cmd, void __user *); extern void devinet_init(void); @@ -173,6 +176,84 @@ return in_dev; } +#ifdef CONFIG_DEV_REFCNT_DEBUG + +#include "linux/kallsyms.h" + +static inline void in_show_here(char *func, struct net_device *dev, + int refcnt, char *fn, int ln, + unsigned long ip) +{ + printk(KERN_DEBUG "%s: in %d dev %d %s() %s:%d", + dev->name, refcnt, atomic_read(&dev->refcnt), + func, fn, ln); + print_ip_sym(ip); +} + +#define in_dev_get(dev) ____in_dev_get(dev, __FILE__, __LINE__) + +static inline struct in_device * +____in_dev_get(struct net_device *dev, char *fn, int ln) +{ + struct in_device *idev = NULL; + rcu_read_lock(); + idev = __in_dev_get_rcu(dev); + if (idev) { + atomic_inc(&idev->refcnt); + in_show_here("in_dev_get", idev->dev, atomic_read(&idev->refcnt), + fn, ln, + (unsigned long)__builtin_return_address(0)); + } + rcu_read_unlock(); + return idev; +} + +static __inline__ struct in_device * +__in_dev_get_rtnl(const struct net_device *dev) +{ + return (struct in_device*)dev->ip_ptr; +} + +extern void in_dev_finish_destroy(struct in_device *idev); + +#define in_dev_put(idev) ____in_dev_put(idev, __FILE__, __LINE__) + +static inline void +____in_dev_put(struct in_device *idev, char *fn, int ln) +{ + int tmp = atomic_dec_and_test(&idev->refcnt); + + in_show_here("in_dev_put", idev->dev, atomic_read(&idev->refcnt), + fn, ln, + (unsigned long)__builtin_return_address(0)); + if (tmp) + in_dev_finish_destroy(idev); +} + +#define __in_dev_put(idev) ______in_dev_put(idev, __FILE__, __LINE__) + +static inline void +______in_dev_put(struct in_device *idev, char *fn, int ln) +{ + atomic_dec(&(idev)->refcnt); + in_show_here("__in_dev_put", idev->dev, atomic_read(&idev->refcnt), + fn, ln, + (unsigned long)__builtin_return_address(0)); +} + +#define in_dev_hold(idev) ____in_dev_hold(idev, __FILE__, __LINE__) + +static inline void +____in_dev_hold(struct in_device *idev, char *fn, int ln) +{ + atomic_inc(&(idev)->refcnt); + in_show_here("__in_dev_put", idev->dev, atomic_read(&idev->refcnt), + fn, ln, + (unsigned long)__builtin_return_address(0)); +} + +#else + static __inline__ struct in_device * in_dev_get(const struct net_device *dev) { @@ -202,6 +283,7 @@ #define __in_dev_put(idev) atomic_dec(&(idev)->refcnt) #define in_dev_hold(idev) atomic_inc(&(idev)->refcnt) +#endif #endif /* __KERNEL__ */