阅读:1525回复:1
网卡驱动的问题,网卡收到包传给另一个设备
在网卡收到包之后,我把sk_buff 用skb_copy 拷贝了一份, 然后传给下面这个函数, 一运行系统就崩溃了.请各位高手给看一下.
int mng_send_from_adapter(struct sk_buff *skb) { struct net_device *dev; struct sk_buff *skb_adapter; dev = dev_get_by_name(mng_ifs[current_if]); if(!dev) { printk(KERN_INFO\"mng_sedn(): could not get management interface %s is down.\\n\", mng_ifs[current_if]); if( 2 == if_count ) { current_if = (0==current_if)?1:0; dev = dev_get_by_name(mng_ifs[current_if]); if(!dev) { printk(KERN_INFO\"mng_sedn(): could not get management interface %s is down.\\n\", mng_ifs[current_if]); return -EOP_NODEV; } } else return -EOP_NODEV; } if(!(dev->flags & IFF_UP)){ printk(KERN_INFO\"mng_send(): management interface %s is down.\\n\", mng_ifs[current_if]); if( 2 == if_count ) { current_if = (0==current_if)?1:0; dev = dev_get_by_name(mng_ifs[current_if]); if(!dev) { printk(KERN_INFO\"mng_sedn(): could not get management interface %s is down.\\n\", mng_ifs[current_if]); return -EOP_NODEV; } if(!(dev->flags & IFF_UP)) { printk(KERN_INFO\"mng_send(): management interface %s is down.\\n\", mng_ifs[current_if]); dev_put(dev); return -EOP_IFFAIL; } } else { dev_put(dev); return -EOP_IFFAIL; } } if(copy_from_user(skb_adapter, skb, sizeof(struct sk_buff))) { printk(KERN_INFO\"mng_send_from_adapter(): couldn\'t read ophir_mng_send_from_adapter.\\n\"); return -EFAULT; } skb_adapter->dev = dev; if (dev->hard_header && dev->hard_header(skb_adapter,dev, ETH_P_OPHIR_MNG, OPAR_MAC, dev->dev_addr,skb_adapter->len) < 0){ dev_put(dev); return -EOP_IFFAIL; } if (skb_adapter) { if(dev_queue_xmit(skb_adapter) != 0) { printk(KERN_INFO\"mng_send_from_adapter(): send failed.\\n\"); dev_put(dev); return -EOP_IFFAIL; } } dev_put(dev); return 1; } |
|
沙发#
发布于:2005-05-25 22:05
信息太少,你给一下错误信息/以及你的这部分代码的运行的级别,interrupt/bh/user context,你的代码只有在user context下 copy_from_user才一定不错。
|
|
|