vswitchd与datapath通过dp_genl_families实现对datapath,vport,flow等结构的增删改查。
如上图而言,就是vswitchd与datapath交互的部分
dp_genl_families
static struct genl_family *dp_genl_families[] = {
&dp_datapath_genl_family,
&dp_vport_genl_family,
&dp_flow_genl_family,
&dp_packet_genl_family,
};
//从内核解除注册
static void dp_unregister_genl(int n_families)
{
int i;
for (i = 0; i < n_families; i++)
genl_unregister_family(dp_genl_families[i]);
}
//向内核注册函数族
static int dp_register_genl(void)
{
int err;
int i;
for (i = 0; i < ARRAY_SIZE(dp_genl_families); i++) {
err = genl_register_family(dp_genl_families[i]);
if (err)
goto error;
}
return 0;
error:
dp_unregister_genl(i);
return err;
}
//init
static int __init dp_init(void)
{
...
err = dp_register_genl();
if (err < 0)
goto error_unreg_notifier;
...
}
static void dp_cleanup(void)
{
dp_unregister_genl(ARRAY_SIZE(dp_genl_families));
...
}
- 下面介绍几个典型交互过程,通过这个图再去看代码就会简单一些。