码迷,mamicode.com
首页 > 其他好文 > 详细

OVS 响应 OFPT_SET_CONFIG 过程分析

时间:2014-07-16 12:56:41      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:ovs   ofp_switch_config   max_miss_len   ofptype_set_config   

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

bubuko.com,布布扣


对于这个消息的具体处理:
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);





OVS 响应 OFPT_SET_CONFIG 过程分析,布布扣,bubuko.com

OVS 响应 OFPT_SET_CONFIG 过程分析

标签:ovs   ofp_switch_config   max_miss_len   ofptype_set_config   

原文地址:http://blog.csdn.net/vonzhoufz/article/details/37873295

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!