私はカーネルモジュールを学んでおり、それに慣れていません。eth0 の MTU サイズを変更したい。これが私が書いたモジュールプログラムです。
意図は 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);