上两篇分析了ofservice的建立,请求处理的过程,本篇分析ovs-ofctl命令行是如何和 ofservice交互的。
1、mian函数
int
main(int argc, char *argv[])
{
struct ovs_cmdl_context ctx = { .argc = 0, };
set_program_name(argv[0]);
service_start(&argc, &argv);
parse_options(argc, argv);
fatal_ignore_sigpipe();
ctx.argc = argc - optind;
ctx.argv = argv + optind;
daemon_become_new_user(false);
ovs_cmdl_run_command(&ctx, get_all_commands()); //处理ovs-ofctl命令行
return 0;
}
2、ovs_cmdl_run_command函数
void
ovs_cmdl_run_command(struct ovs_cmdl_context *ctx, const struct ovs_cmdl_command commands[])
{
const struct ovs_cmdl_command *p;
if (ctx->argc < 1) {
ovs_fatal(0, "missing command name; use --help for help");
}
for (p = commands; p->name != NULL; p++) {
if (!strcmp(p->name, ctx->argv[0])) {
int n_arg = ctx->argc - 1;
if (n_arg < p->min_args) {
VLOG_FATAL( "'%s' command requires at least %d arguments",
p->name, p->min_args);
} else if (n_arg > p->max_args) {
VLOG_FATAL("'%s' command takes at most %d arguments",
p->name, p->max_args);
} else {
p->handler(ctx); //OVS注册多个command处理,以添加流表为例,实际会掉用ofctl_add_flow函数
if (ferror(stdout)) {
VLOG_FATAL("write to stdout failed");
}
if (ferror(stderr)) {
OVS2.5.0:ovs - ofctl与ofservice交互分析

本文深入解析OVS2.5.0中openflow连接的实现,继上两篇对ofservice建立和请求处理的分析,本节关注ovs-ofctl命令行如何与ofservice进行交互。
最低0.47元/天 解锁文章
&spm=1001.2101.3001.5002&articleId=52346527&d=1&t=3&u=04eab558db3f4548909acbb34ecef347)
647

被折叠的 条评论
为什么被折叠?



