• 大小: 0.82M
    文件类型: .pdf
    金币: 1
    下载: 0 次
    发布日期: 2021-03-27
  • 语言: 其他
  • 标签: 其他  

资源简介


Open vSwitch源代码详细的分析与指导,非常值得一看!
COPYING 许可说明 DESIGN 设计原则,处理 openflow协议相关细节和考虑 FAQ NEWS NOTICE README README-gCOV REPORTING-BUGS WHY-OVS 注:1.8.90版本,所有C源码行数为189964,其中 datapath模块28131, vswitchd模 块5888, ovsdb模块10549,ib为101592, ofproto为18571。 find openvswitch -name"*[ch]"I xargs cat Wc - 15.其他文件 debian/ Integration Guide 集成到其他 hypervisor PORTING 移植说明 python/ Submitting Patches 补丁提交 tests 测试代码 third-party/ 支持第三方的插件,包括让 tcpdump支持解析of协议的补丁。 utilities/ 小工具,包括用户操作命令,例如ovs-dpct、ovs- ofctl、 OVS-controller、 oVS-vsctl等 等。其中 ovs-vsctl是主要的对配置数据库进行交互的接口。 xenserver/ xenserver集成信息 1.6.整体功能逻辑 ovid pace ovS-dpctl controller + ovs-vswitchd etc Kerne datapath data path datapath pace 2. datapath模块 2.1.整体分析 datapath模块的代码主要包括如下几个关键子模块:主文件 datapath.hc, vport的实 现 vport( generIc/gre/ capwap/ netdev/ internal/ρatch),gen子模块。 2.1.1 tion模块 action.c中定义了对网包执行操仵的各个接口。 包括对van头的处理,对skb执行一系列给定的操作,发出网包,发skb给用户态 ovsd),采样,设置包头各个域的属性等。 2.1.2.flow模块 包括fowh和 flow. c。 定义维护交换机本地流表相关的数据结构和操作,包括流表结构的创建、更新、删除, 对每条流的管理等。 21.3.genl模块 gen|- exec. h中定义了对gen的相关操作,包括 typedef int genl exec func t)void*data) int genl exec(genl exec func t func, void*data); int genl exec init(void; void genl exec exit(void) genl_ exec_ family的定义为 static struct genl family genl exec family =i id= GENL ID GENERATE, / channel number: will be assigned by the controller name=ovs genl exec version =1 genl exec ops的定义为 static struct genl ops genl exec opsl cmd= GENL EXEC RUN, // reference the operation doit= genl exec cmd, //the callback function flags =CAP NET ADMIN, 2.14. vport和 vport ops 关键的逻辑实现在 vport子模块中。在 vport. h/c中定义了抽象的 vport结构。对外的 对 vport进行操作的接山如下 int ovs vport init(void); void ovs vport exit/void) struct vport ovs vport add(const struct vport parms*): void ovs vport del(struct vport*); struct vport ovs vport locate(struct net*net, const char *name) int ovs vport set addr struct vport * const unsigned char void ovs vport set stats(struct vport struct ovs vport stats ) void ovs vport get stats struct vport struct ovs vport stats " int ovs _vport set options(struct vport *, struct nlattr *options) int ovs vport_ _ get options(const struct vport*, struct sk buff *) int ovs vport send(struct vport * struct sk buff 这些接口对外提供统一的用户操作界面。部分并没有立刻定义,即使定义的接口中, 大部分依次或者单独调用某种类型的 vport上绑定的 vport_ops中提供的接口,对所有支 持的 vport进行操作。例如,初始化过程中,实际上是初始化了一个 vport_ ops list,依 次初始化不同类型的 vport,并放到该ist中。再比如 ovs vport add接山实际上先进行查 找,找到给定的类型之后,进行对应的操作 而具体到某个 vport,其能进行操作的接口在 vport ops结构体中声眀,为 struct vport ops i enum ovs vport type type 32 fla / Called at module in it and exit respectively int (init)(void); (exit)(void); / Called with RTNL lock * port**create)(const struct vport_ parms *) yoid(destroy (struct vport * ) int set options)(struct vport*, struct nlattr * int( get options)(const stru 0● t sk buff ) int set addr (struct sports, const unsigned char * / Called with rcu read lock or rtL lock const char *get name)const struct vport*) const unsigned char *(get _addr(const struct vport void get_config(const struct vport * void*); struct kobject*( get kobe(const struct vport ) unsigned get dev flags)(const struct vport ) int ( *is running)(const struct vport unsigned char get operstate)(const struct vport *) int *get ifindex (const struct vport*) int (get mtu)(const struct vport*) int(send)(struct vport struct sk buff * 日前, vport ops支持5种类型,分别为 static const struct vport ops *base vport ops list[=i &ovs netdev vport ops &ovs internal vport ops, &ovs patch vport ops, &ovs gre vport ops #if LINUX VERSION CODE >=KERNEL VERSION(2, 6, 26) &ovs capwap vport ops, fendi 以 ovs netdev vport ops为例,定义了一系列的函数指针。 const struct vport ops ovs netdev vport ops =t tvpe E OVS VPORT TYPE NETDEV flags VPORT F REQUIRED netdev init exit netdev exit create netdev create, destroy netdev destroy set addr ovs netdev set addr, get name =ovs netdev_get name, et addr =ovs_ netdev _get_ addr get kob ovs netdev get obj get dev flags =ovs netdev get dev flags, is running =ovs netdev is running get operstate ovs netdev get operstate, get_ifindex =ovs_ netdev_get ifindex, get_ mtu ovs netdev get mtu sen netdev send 2.1.5. netdev vport 绑定到具体网终设备上的vpot的结构 该结构的定义十分简单,封装了一个 net device结构,定义如下。 struct netdev vport struct net device dev 2.2 datapath. c 模块的主文件。实现了一个简单的交换机。 2.2.1.注册和回收 module_ init(dp init); call when this module is loaded into kernel module exit(dp cleanup); //call when the module is removed from kernel 注册后,调用dρ_init来完成各项初始化工作,dpρ_init也是模块的主函数。 当模垬被卸载时,调用dp_ cleanup完成清理工作,凹收各项数据结构 dp init主要过程为 genl exec inito ovs workqueues init( ovs flow inito ovs vport init() register_pernet device(&ovs_ _net ops) register netdevice notifier(&ovs dp device notifier) dp register geno schedule delayed work &rehash flow wa, REHASH FLOW INTERVAL 22.2. GENL EXEC RUN初始化 genl exec_init(,完成 genl exec run的相关注册,仅在 KERNEL VERSION<2.635时生 效。主要代码为 err= genl register family with ops(&genl exec family genl_ exec ops, ARRAY SIZE(genl_ exec ops) 注册的 generic netlink family:gen|_ exec family。 static struct genl family genl exec family = i id=GENL ID GENERATE, / new family will be assigned by the controller ame=ovs_genl exec version =1 对应操作的结构为 static struct genl ops genl exec ops[=i cmd= gENL EXEC RUN doit genl exec cmd, flags= CAP NET_ ADMIN 22.3.工作队列初始化 ovs workqueues init( 创建 worker thread,初始化 more work工作队列,轮询检测执行队列中的任务 主要代码为 work_ thread = kthread create worker thread, NULL, "ovs work ) ;//just create wake up_ process work thread); //run the created thread 224. port_ table初始化 ovs_tnl_init),初始化 port_ table数据结构 主要代码为 port table kmalloc(PORT TABLE_ SIZE *sizeof(struct hist head*), GFP KERNEL) fori=0; i< PORT TABLE SIZE; i++) INIT HLIST HEAD (&port table[il) 22.5. flow cache初始化 ovs flow init(),申请 flow cache,主要代码为

资源截图

代码片段和文件信息

评论

共有 条评论