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.
---
ofproto/connmgr.c | 13 +++++++++++++
ofproto/connmgr.h | 2 ++
ofproto/ofproto.c | 13 +------------
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 403a140..bdebd3b 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 9b2e9c5..4ac564c 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 1e5e4ec..3cfb6f4 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -1350,17 +1350,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)
{
@@ -2510,7 +2499,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);
}
--
1.7.4.4
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev