OVS 响应 OFPT_SET_CONFIG 过程分析

ovs 对于 OFPT_SET_CONFIG消息的处理过程非常简单,其实就是通过TCP协议(或其它)交换了几个整型值,而且交换机不需要对此消息进行回复;只需要解析出消息体(struct ofp_switch_config)然后设置max miss  len 即可。通过分析Floodlight发送它的过程 和 OVS 处理它的过程,我们可以对openflow协议有更好的理解。下面是代码流程:
 



对于这个消息的具体处理:
static enum ofperr
handle_set_config(struct ofconn *ofconn, const struct ofp_header *oh)
{
    const struct ofp_switch_config *osc = ofpmsg_body(oh);
     /* ignore the ofp_header to get the config struct */
    struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
     /*get the OF SW abstraction, later will config it */
    uint16_t flags = ntohs(osc->flags);
     /*openflow use bigendian mode*/

    if (ofconn_get_type(ofconn) != OFCONN_PRIMARY
        || ofconn_get_role(ofconn) != NX_ROLE_SLAVE) {
        enum ofp_config_flags cur = ofproto->frag_handling;
        enum ofp_config_flags next = flags & OFPC_FRAG_MASK;

        assert((cur & OFPC_FRAG_MASK) == cur);
        if (cur != next) {
            if (ofproto->ofproto_class->set_frag_handling(ofproto, next)) {
                ofproto->frag_handling = next;
            } else {
                VLOG_WARN_RL(&rl, "%s: unsupported fragment handling mode %s",
                             ofproto->name,
                             ofputil_frag_handling_to_string(next));
            }
        }
    }
    ofconn_set_invalid_ttl_to_controller(ofconn,
             (flags & OFPC_INVALID_TTL_TO_CONTROLLER));
     /* set the max miss length of the SW XXX*/
     ofconn_set_miss_send_len(ofconn, ntohs(osc->miss_send_len));

    return 0;
}

下面的这个结构体代表的是 OFPT_SET_CONFIG 消息的消息体。
/* Switch configuration. */
struct ofp_switch_config {
    ovs_be16 flags;             /* OFPC_* flags. */
    ovs_be16 miss_send_len;     /* Max bytes of new flow that datapath should
                                   send to the controller. */
};
OFP_ASSERT(sizeof(struct ofp_switch_config) == 4);


Floodlight 是如何发送这个消息的呢? 比如 设置在出现packetin时候把全部的包发送到 Controller
OFSetConfig config = (OFSetConfig) factory
                    .getMessage(OFType.SET_CONFIG);
            config.setMissSendLength((short) 0xffff)
            .setLengthU(OFSwitchConfig.MINIMUM_LENGTH);
            sw.write(config, null);





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值