1
저는 커널 모듈을 배우고 있으며 새로 도입했습니다. eth0의 MTU 크기를 변경하고 싶습니다. 여기 제가 작성한 모듈 프로그램이 있습니다.MTU 크기를 변경하는 Linux 커널 모듈이 작동하지 않습니다.
의도는 eth0의 MTU 크기를 1000으로 변경하는 것입니다. 그러나 변경되지 않습니다. 누구나 내가 누락 된 내용을 말해 줄 수 있습니까? 접근 자체가 잘못된 경우 올바른 방향으로 나를 가리킬 수 있습니까?
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/etherdevice.h>
#include <linux/netdevice.h>
static int __init hello_2_init(void)
{
printk(KERN_INFO "Hello, world 2\n");
struct net_device dev;
eth_change_mtu(&dev,1000); //calling eth_change_mtu
return 0;
}
static void __exit hello_2_exit(void)
{
printk(KERN_INFO "Goodbye, world 2\n");
}
int eth_change_mtu(struct net_device *dev, int new_mtu)
{
dev->mtu = new_mtu;
printk(KERN_INFO "New MTU is %d",new_mtu);
return 0;
}
module_init(hello_2_init);
module_exit(hello_2_exit);
이렇게하려면 커널 모듈이 필요하지 않습니다.이 명령을 터미널'ifconfig eth0 mtu 1000 up'에 입력하십시오. –