From: Ben Pfaff Date: Thu, 26 May 2011 23:41:52 +0000 (-0700) Subject: connmgr: New function ofconn_send_error(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1be5ff7596ab018eb0491176af493d8c51cf1cc8;p=openvswitch connmgr: New function ofconn_send_error(). An upcoming commit will sometimes make connmgr responsible for sending error replies, so it's reasonable for it to have a function to do that. --- diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c index 403a1403..bdebd3bf 100644 --- a/ofproto/connmgr.c +++ b/ofproto/connmgr.c @@ -778,6 +778,19 @@ ofconn_send_replies(const struct ofconn *ofconn, struct list *replies) } } +/* Sends 'error', which should be an OpenFlow error created with + * e.g. ofp_mkerr(), on 'ofconn', as a reply to 'request'. Only at most the + * first 64 bytes of 'request' are used. */ +void +ofconn_send_error(const struct ofconn *ofconn, + const struct ofp_header *request, int error) +{ + struct ofpbuf *msg = ofputil_encode_error_msg(error, request); + if (msg) { + ofconn_send_reply(ofconn, msg); + } +} + /* Same as pktbuf_retrieve(), using the pktbuf owned by 'ofconn'. */ int ofconn_pktbuf_retrieve(struct ofconn *ofconn, uint32_t id, diff --git a/ofproto/connmgr.h b/ofproto/connmgr.h index 9b2e9c56..4ac564cc 100644 --- a/ofproto/connmgr.h +++ b/ofproto/connmgr.h @@ -88,6 +88,8 @@ void ofconn_set_miss_send_len(struct ofconn *, int miss_send_len); void ofconn_send_reply(const struct ofconn *, struct ofpbuf *); void ofconn_send_replies(const struct ofconn *, struct list *); +void ofconn_send_error(const struct ofconn *, const struct ofp_header *request, + int error); int ofconn_pktbuf_retrieve(struct ofconn *, uint32_t id, struct ofpbuf **bufferp, uint16_t *in_port); diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index de212ee4..f259905c 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1359,17 +1359,6 @@ rule_is_hidden(const struct rule *rule) return rule->cr.priority > UINT16_MAX; } -static void -send_error_oh(const struct ofconn *ofconn, const struct ofp_header *oh, - int error) -{ - struct ofpbuf *buf = ofputil_encode_error_msg(error, oh); - if (buf) { - COVERAGE_INC(ofproto_error); - ofconn_send_reply(ofconn, buf); - } -} - static int handle_echo_request(struct ofconn *ofconn, const struct ofp_header *oh) { @@ -2513,7 +2502,7 @@ handle_openflow(struct ofconn *ofconn, struct ofpbuf *ofp_msg) { int error = handle_openflow__(ofconn, ofp_msg); if (error) { - send_error_oh(ofconn, ofp_msg->data, error); + ofconn_send_error(ofconn, ofp_msg->data, error); } COVERAGE_INC(ofproto_recv_openflow); }