[firefly] [PATCH 4/6] ofproto/connmgr: notify controllers when their role changes to slave
Alexandru Copot
alex.mihai.c at gmail.com
Tue Oct 8 11:52:32 EEST 2013
Signed-off-by: Alexandru Copot <alex.mihai.c at gmail.com>
---
ofproto/connmgr.c | 15 +++++++++++++++
ofproto/connmgr.h | 2 ++
2 files changed, 17 insertions(+)
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 8a4195d..0a21b3d 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -864,6 +864,20 @@ ofconn_get_role(const struct ofconn *ofconn)
return ofconn->role;
}
+void ofconn_send_role_status(struct ofconn *ofconn, uint32_t role, uint8_t reason)
+{
+ struct ofputil_role_status status;
+ struct ofpbuf *buf;
+
+ status.reason = reason;
+ status.role = role;
+ ofconn_get_master_election_id(ofconn, &status.generation_id);
+
+ buf = ofputil_encode_role_status(&status, ofconn_get_protocol(ofconn));
+
+ ofconn_send(ofconn, buf, NULL);
+}
+
/* Changes 'ofconn''s role to 'role'. If 'role' is OFPCR12_ROLE_MASTER then
* any existing master is demoted to a slave. */
void
@@ -875,6 +889,7 @@ ofconn_set_role(struct ofconn *ofconn, enum ofp12_controller_role role)
HMAP_FOR_EACH (other, hmap_node, &ofconn->connmgr->controllers) {
if (other->role == OFPCR12_ROLE_MASTER) {
other->role = OFPCR12_ROLE_SLAVE;
+ ofconn_send_role_status(other, OFPCR12_ROLE_SLAVE, OFPCRR_MASTER_REQUEST);
}
}
}
diff --git a/ofproto/connmgr.h b/ofproto/connmgr.h
index 55d08a6..202e7fb 100644
--- a/ofproto/connmgr.h
+++ b/ofproto/connmgr.h
@@ -143,6 +143,8 @@ void connmgr_send_flow_removed(struct connmgr *,
void connmgr_send_packet_in(struct connmgr *,
const struct ofputil_packet_in *);
+void ofconn_send_role_status(struct ofconn *ofconn, uint32_t role,
+ uint8_t reason);
/* Fail-open settings. */
enum ofproto_fail_mode connmgr_get_fail_mode(const struct connmgr *);
void connmgr_set_fail_mode(struct connmgr *, enum ofproto_fail_mode);
--
1.8.4
More information about the firefly
mailing list