2

[Linux Kernel 源码分析] 通过vconfig配置vlan的系统调用/驱动流程分析 - 蓝天上的云℡

 1 year ago
source link: https://www.cnblogs.com/yucloud/p/kdriver_vlan.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

By YuCloud (蓝天上的云℡ - 博客园 https://www.cnblogs.com/yucloud/)
转载请注明出处


vconfig源码分析

vlan/vconfig.c at master · Distrotech/vlan (github.com)
https://github.com/Distrotech/vlan/blob/master/vconfig.c#L185-L199

vconfig简单使用

sh
#为网卡eth0添加vlan10
vconfig add eth0 10
#为网卡eth0删除vlan10
vconfig rem eth0.10

以下是本人对整个流程的源码分析

配置vlan的驱动流程

  1. vconfig 通过 ioctl 系统调用接口陷入内核态执行驱动里的net/socket.c:sock_ioctl,里面调用了钩子函数
  2. 钩子是在net/8021q/vlan.c:vlan_proto_init里面配置好的
  3. 钩子处理函数本体位于 net/8021q/vlan.c:vlan_ioctl_handler,里面就是配置vlan的地方了。

源码分析片段

1072169-20221222173516217-195911708.png

OneNote写的,懒得转了,右击打开图片即可

  • 成功:分析了kernel里配置vlan的流程
  • 不足:对于网络包收发过程中内核如何对 vlan 包的处理还没分析。

__EOF__

本文作者: YuCloud 本文链接: https://www.cnblogs.com/yucloud/p/kdriver_vlan.html 关于博主: love to create 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处! 声援博主: Click【推荐】if the article helpful, and Welcome to discuss

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK