传统交换机的端口可以按照vlan可以划分为access、trunk和hybrid三类接口。 首先,我们先看OVS的VLAN实现原理,最后对比OVS与传统交换机的差异。
OVS中,数据面的转发流表都是从用户态下发的,所以流表生成的入口是upcall_actions函数(该函数不是upcall的总入口,由于层次比较多,以该函数作为分析的入口是合适的)。
1、xlate_actions函数
mirror_ingress_packet(&ctx);
do_xlate_actions(ofpacts, ofpacts_len, &ctx); //openflow流表转化为精确流表
if (ctx.error) {
goto exit;
}
2、do_xlate_actons函数
case OFPACT_OUTPUT:
xlate_output_action(ctx, ofpact_get_OUTPUT(a)->port, //normal规则也是output的一种
ofpact_get_OUTPUT(a)->max_len, true);
break;
3、xlate_output_action函数
static void
xlate_output_action(struct xlate_ctx *ctx,
ofp_port_t port, uint16_t max_len, bool may_packet_in)
{
ofp_port_t prev_nf_output_iface = ctx->nf_output_iface;
ctx->nf_output_iface = NF_OUT_DROP;
switch (port) {
case OFPP_IN_PORT:
compose_output_action(ctx, ctx->xin->flow.in_port.ofp_port, NULL);
break;
case OFPP_TABLE:
xlate_table_action(ctx, ctx->xin->flow.in_port.ofp_port,
0, may_packet_in, true);
break;
case OFPP_NORMAL:
xlate_normal(ctx); //normal规则流表转化为精确流表
break;
case OFPP_FLOOD:
flood_packets(ctx, false);
break;
case OFPP_ALL:
flood_packets(ctx, true);
break;
case OFPP_CONTROLLER:
execute_controller_action(ctx, max_len,
(ctx->in_group ? OFPR_GRO

本文深入分析OVS2.5.0中VLAN和trunk的实现原理,探讨OVS如何处理数据面的转发流表,并通过upcall_actions和xlate_actions函数来理解其与传统交换机的区别。
最低0.47元/天 解锁文章
&spm=1001.2101.3001.5002&articleId=52206911&d=1&t=3&u=9e7d8c4da0274aad91161a87c2a23d4c)
3194

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



