在網絡卡裝置的驅動中首先會呼叫
ndev = alloc_etherdev_mq(sizeof(struct hns_nic_priv), nic_max_q_per_vf);
if (!ndev)
return -enomem;
來申請乙個struct net_device *ndev;
#define alloc_etherdev_mq(sizeof_priv, count) alloc_etherdev_mqs(sizeof_priv, count, count)
struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
unsigned int rxqs)
注意這裡的網絡卡驅動賦值的name是eth%d。在alloc_etherdev_mqs 完成後這個網絡卡裝置驅動的name就是eth%d。在最後呼叫register_netdevice的時候才會改名為eth0/eth1等
register_netdevice->dev_get_valid_name
static int dev_get_valid_name(struct net *net,
struct net_device *dev,
const char *name)
因為申請的名字是eth%d,因此strchr(name, '%')成立呼叫dev_alloc_name_ns->__dev_alloc_name
static int __dev_alloc_name(struct net *net, const char *name, char *buf)
i = find_first_zero_bit(inuse, max_netdevices);
free_page((unsigned long) inuse);}}
RHEL7 CentOS7中更改網絡卡預設名稱
一台centos 7.2虛擬機器 操作步驟 方法一 1.更改網絡卡配置檔案的名字 cd etc sysconfig network scripts network scripts mv ifcfg eno33559296ifcfg eth0 2.編輯網絡卡ifcfg eth0資訊 3.修改 etc ...
Linux 設定網絡卡預設啟動
最近使用rhel server 6.4 i386,發現系統啟動後每次都要手動啟動網絡卡,系統網絡卡預設是不啟動的。為了使用方便,需要設定網絡卡預設啟動,可以依據以下操作進行,首先說幾個配置檔案 網絡卡配置檔案 etc sysconfig network script ifcfg eth0 dns配置...
linux系統中,多網絡卡場景下設定永久預設閘道器
在需要配置成預設閘道器的網絡卡中設定閘道器 vim etc sysconfig network scripts ifcfg 新增如下引數gateway 該網絡卡的閘道器ip 其他的網絡卡一定不要配置gateway引數 systemctl restart network vim etc rc.d rc...