#include <linux/inetdevice.h> #define LIMIT_PRINTK(fmt, arg...) / { / if(net_ratelimit()) / printk(fmt, ##arg); / } static __inline__ int is_dev_ip(struct net_device* dev) { struct in_device *in_dev = (struct in_device*)(dev->ip_ptr); /* has any ip address in this dev? */ if(in_dev == NULL || in_dev->ifa_list == NULL || in_dev->ifa_list->ifa_address == 0) { LIMIT_PRINTK("No IP in this dev./n"); return 0; } LIMIT_PRINTK("has IP in dev named %s/n", in_dev->ifa_list->ifa_label); return 1; } 支持一个接口上有多个IP的情况。