6.5定位网卡 linux
2017-03-06 16:26:00 weixin_30542079 阅读数 1

启动网卡

  ifup eth0

  eth0:网卡名称

设置网卡开机启动

  vi /etc/sysconfig/network-scripts/ifcfg-eth0

  ONBOOT=yes

转载于:https://www.cnblogs.com/wolil/p/6510551.html

6.5 linux
2015-06-06 04:26:33 sinat_15250185 阅读数 92

Process descriptors handling

process in Kernel Mode access a stack contained in the Kernel data segement.

Kernel control paths make little us  of the stack , only a few thousand bytes of kernel stack are required.

when stack and thread_info are contained in a single page frame ---->the kernel uses a few additional stacks to avoid the overflows caused by deeply nested interrupts and exception.

two data structure are stored in the 2-page (8KB) memory area.

The thread_info resides at the beginning of the memory area. 

The stack grows downward from the end.

The esp register is the CPU stack pointer, which is used to address the stack's top location.

when it was switching from user mode to kernel mode, the kernel stack of a process is always empty.esp register points to the byte immediately followitng the stack.The value of the esp is decreased as soon as date is written into the stack.

The thread_info structure is stored starting at address 0x15fa000 and the stack is stored starting at address 0x15fc000.

the kernel uses the  alloc_thread_info and free_thread_info macros to allocate and release the memory area stroing a thread_info and a kernel stack.

Identifying the current process

If the thread_union structure is 8KB 2^13 bytes long, the kernel masks out the 13 least significant bits of esp to obtain the base address of the thread_info 

if the thread_info structure 4KB long, the kernel masks out he 12 least significant bits of esp .

(his is one by the current _thread_info)

after executing,p contains the thread_info structure pointer of the process running on the CPU that execute the instruction. 

the kernel makes use of the current macro, which is essentially equivalent to current_thread_info()->task.

after executing , pcontains the process descriptor pointer of the process running on the CPU.

the current macro often appears in kernel code as a prefix to fields of the process descriptor.e.g. current->pid returns the process ID of the process currently running.

Doubly linked list 

a set of primitive operations must be implemented: initializing the list, inserting ,deleting,scannning the list and son on.

list_head data structure whose only fields next and prev represent the forward and back pointer of a generic doubly linked list element.

the pointers in a lis_head field  store the addresses of other list_head fields rather than the addresses of the whole data structures in which the list _head fields structure is included.

list_add(n,p)

list_add_tail(n,p)

list_del(p)

list_empty(p)

list_entry(p,t,m)

list_for_each(p,h)

list_for_each_entry(p,h,m)

2017-05-15 17:19:58 qq_30364013 阅读数 199

网卡高级命令
查看网卡状态:mii-tool em2
em2: negotiated 100baseTx-FD flow-control, link ok
查看网卡物理特性:ethtool eth0

[root@mcs-master ~]# ethtool em2
Settings for em2:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: off
        Supports Wake-on: g
        Wake-on: d
        Link detected: yes

查看网卡驱动信息:ethtool -i em2

[root@mcs-master ~]# ethtool -i em2
driver: bnx2
version: 2.2.6
firmware-version: 6.2.15 bc 5.2.3 NCSI 2.0.11
bus-info: 0000:01:00.1
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: no

查看网卡状态:ethtool -S em2

root@mcs-master ~]# ethtool -S em2
NIC statistics:
     rx_bytes: 1081851677
     rx_error_bytes: 0
     tx_bytes: 1637827045
     tx_error_bytes: 0
     rx_ucast_packets: 8321677
     rx_mcast_packets: 422726
     rx_bcast_packets: 1863810
     tx_ucast_packets: 6088067
     tx_mcast_packets: 129
     tx_bcast_packets: 11
     tx_mac_errors: 0
     tx_carrier_errors: 0
     rx_crc_errors: 0
     rx_align_errors: 0
     tx_single_collisions: 0
     tx_multi_collisions: 0
     tx_deferred: 0
     tx_excess_collisions: 0
     tx_late_collisions: 0
     tx_total_collisions: 0
     rx_fragments: 0
     rx_jabbers: 0
     rx_undersize_packets: 0
     rx_oversize_packets: 0
     rx_64_byte_packets: 2060553
     rx_65_to_127_byte_packets: 7215302
     rx_128_to_255_byte_packets: 922836
     rx_256_to_511_byte_packets: 358439
     rx_512_to_1023_byte_packets: 21717
     rx_1024_to_1522_byte_packets: 29366
     rx_1523_to_9022_byte_packets: 0
     tx_64_byte_packets: 674490
     tx_65_to_127_byte_packets: 2750766
     tx_128_to_255_byte_packets: 971918
     tx_256_to_511_byte_packets: 790864
     tx_512_to_1023_byte_packets: 726193
     tx_1024_to_1522_byte_packets: 173976
     tx_1523_to_9022_byte_packets: 0
     rx_xon_frames: 0
     rx_xoff_frames: 0
     tx_xon_frames: 0
     tx_xoff_frames: 0
     rx_mac_ctrl_frames: 0
     rx_filtered_packets: 412784
     rx_ftq_discards: 0
     rx_discards: 0
     rx_fw_discards: 0

IP别名:支持在一个物理网卡上配置多个IP地址,用来实现类似子接口之类的功能。
CentOS/RHEL系统默认会启动NetworkManager对网卡管理,以方便用户使用,但是如果使用子接口需要禁用NetworkManager。
service NetworkManager stop
chkconfig NetworkManager off
之后使用ip命令临时创建一个IP别名
ip addr add 10.1.1.1/24 dev em2 label em2:0
永久添加IP别名:在/etc/sysconfig/network-scripts/下添加ifcfg-em2:0
DEVICE=em2:0
IPADDR=10.1.1.1
PREFIX=24
ONPARENT=yes

多网卡绑定:支持多块网卡绑定为一个逻辑网卡。
绑定模式:0【平衡轮询】、1【主动备份】、3【广播】
在/etc/sysconfig/network-scripts/下添加ifcfg-bond0
DEVICE=bond0
IPADDR=10.1.1.1
PREFIX=24
ONPARENT=yes
BOOTPROTO=none
USERCTL=no
BONDING_OPTS=”mode=1 mii”

修改/etc/sysconfig/network-scripts/ifcfg-em2
DEVICE=em2
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
修改/etc/sysconfig/network-scripts/ifcfg-em3
DEVICE=em3
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no

bond网卡添加驱动支持:
/etc/modprobe.d/bonding.conf
alias bond0 bonding

网卡操作:ifdown【关闭】、ifup【开启】

service network restart

2017-09-06 13:41:00 weixin_33725239 阅读数 4
ethtool eth0 # 查看网卡eth0信息


# ethtool eth0  
Settings for eth0:  
    Supported ports: [ TP MII ]  
    Supported link modes:   10baseT/Half 10baseT/Full   
                            100baseT/Half 100baseT/Full   
                            1000baseT/Half 1000baseT/Full #支持千兆半双工,全双工模式  
    Supported pause frame use: No   
    Supports auto-negotiation: Yes #支持自适应模式,一般都支持  
    Advertised link modes:  10baseT/Half 10baseT/Full   
                            100baseT/Half 100baseT/Full   
                            1000baseT/Half 1000baseT/Full  
    Advertised pause frame use: Symmetric Receive-only  
    Advertised auto-negotiation: Yes #默认使用自适应模式  
    Link partner advertised link modes:  10baseT/Half 10baseT/Full   
                                         100baseT/Half 100baseT/Full   
    .....  
    Speed: 100Mb/s #现在网卡的速度是100Mb,网卡使用自适应模式,所以推测路由是100Mb,导致网卡从支持千兆,变成要支持百兆  
    Duplex: Full   #全双工  
    .....  
    Link detected: yes    #表示有网线连接,和路由是通的  

例如:将网卡eth1设置为100M全双工、自动协商关闭
# ethtool -s eth1 autoneg off speed 100 duplex full


下面的命令会把eth0设置成全双工非自动协商工作模式,并且速度为100M
ethtool -s eth0 duplex full autoneg off speed 100
设置网卡工作模式开机为全双工的方法:
一:
在/etc/sysconfig/network-script/ifcfg-ethX加入下面这句:
ETHTOOL_OPTS="speed 100 duplex full autoneg off"

二:
将上面的命令写入到/etc/rc.local里面。
ethtool -s eth0 duplex full autoneg off speed 100

转载于:https://my.oschina.net/corleone/blog/1529878

2014-01-05 00:20:50 u012995513 阅读数 2160

Network Interface Card(NIC)

默认网卡名称为eth0,以此类推

一般的linux发行版大多数支持我们所使用的网卡,但是假若开发商没有公布源代码或者是网卡型号比较新,那么我们就需要自己重新编译内核和网卡内核模块了。

这里主要说明网卡配置方面,具体网卡编译细节就不说了,除了要使用make工具外,还需要先移除加载到内存中的网卡模块 使用

rmmod 模块名 

即可

然后再使用 modprobe 模块名

1、modprobe 命令是根据depmod -a的输出/lib/modules/version/modules.dep来加载全部的所需要模块。
2、删除模块的命令是:modprobe -r filename。
3、系统启动后,正常工作的模块都在/proc/modules文件中列出。使用lsmod命令也可显示相同内容。
4、在内核中有一个“Automatic kernel module loading"功能被编译到了内核中。当用户尝试打开某类型的文件时,内核会根据需要尝试加载相应的模块。/etc/modules.conf或 /etc/modprobe.conf文件是一个自动处理内核模块的控制文件。

更新内核后网卡模块要重新编译


如果要查看内核捕捉到的网卡信息,可以使用dmesg命令

开机信息保存在/var/log目录中,名称为dmesg的文件里.

这里我用管道查看dmesg的关于eth的信息

命令如下 dmesg | grep -in eth

836:[   10.624151] r8169 Gigabit Ethernet driver 2.3LK-NAPI loaded
839:[   10.624634] r8169 0000:04:00.0 eth0: RTL8168e/8111e at 0xffffc900047c6000, 30:85:a9:2a:4c:7a, XID 0c200000 IRQ 43
840:[   10.624638] r8169 0000:04:00.0 eth0: jumbo features [frames: 9200 bytes, tx checksumming: ko]
920:[   10.942117] systemd-udevd[358]: renamed network interface eth0 to enp4s0
943:[   22.808343] Bluetooth: BNEP (Ethernet Emulation) ver 1.3

命令结果如上所示

或者使用如下命令

lspci | grep -i ethernet

@linux-5cxs:~> /sbin/lspci | grep -i ethernet
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)

lsmod | grep 网卡可以查看是否加载到内核中了。

至于modinfo可以查看模块的相关信息

比如

filename:       /lib/modules/3.11.6-4-desktop/kernel/drivers/net/ethernet/realtek/r8169.ko
firmware:       rtl_nic/rtl8168g-3.fw
firmware:       rtl_nic/rtl8168g-2.fw
firmware:       rtl_nic/rtl8106e-2.fw
firmware:       rtl_nic/rtl8106e-1.fw
firmware:       rtl_nic/rtl8411-2.fw
firmware:       rtl_nic/rtl8411-1.fw
firmware:       rtl_nic/rtl8402-1.fw
firmware:       rtl_nic/rtl8168f-2.fw
firmware:       rtl_nic/rtl8168f-1.fw
firmware:       rtl_nic/rtl8105e-1.fw
firmware:       rtl_nic/rtl8168e-3.fw
firmware:       rtl_nic/rtl8168e-2.fw
firmware:       rtl_nic/rtl8168e-1.fw
firmware:       rtl_nic/rtl8168d-2.fw
firmware:       rtl_nic/rtl8168d-1.fw
version:        2.3LK-NAPI
...
... 
文件名就是网卡驱动所在的文件

linux网卡

阅读数 480

linux 网卡

阅读数 24

Linux网卡

阅读数 193

linux网卡

阅读数 1

linux网卡

阅读数 174

没有更多推荐了,返回首页