static struct ofproto *ofconn_get_ofproto(struct ofconn *);
+static enum nx_flow_format ofconn_get_flow_format(struct ofconn *);
+static void ofconn_set_flow_format(struct ofconn *, enum nx_flow_format);
+
+static int ofconn_get_miss_send_len(const struct ofconn *);
+static void ofconn_set_miss_send_len(struct ofconn *, int miss_send_len);
+
+static enum ofconn_type ofconn_get_type(const struct ofconn *);
+
+static enum nx_role ofconn_get_role(const struct ofconn *);
+static void ofconn_set_role(struct ofconn *, enum nx_role);
+
static void queue_tx(struct ofpbuf *msg, const struct ofconn *ofconn,
struct rconn_packet_counter *counter);
static int
snoop_preference(const struct ofconn *ofconn)
{
- switch (ofconn->role) {
+ switch (ofconn_get_role(ofconn)) {
case NX_ROLE_MASTER:
return 3;
case NX_ROLE_OTHER:
/* Pick a controller for monitoring. */
best = NULL;
LIST_FOR_EACH (ofconn, node, &ofproto->all_conns) {
- if (ofconn->type == OFCONN_PRIMARY
+ if (ofconn_get_type(ofconn) == OFCONN_PRIMARY
&& (!best || snoop_preference(ofconn) > snoop_preference(best))) {
best = ofconn;
}
shash_add(info, rconn_get_target(rconn), cinfo);
cinfo->is_connected = rconn_is_connected(rconn);
- cinfo->role = ofconn->role;
+ cinfo->role = ofconn_get_role(ofconn);
cinfo->pairs.n = 0;
/* Primary controllers, even slaves, should always get port status
updates. Otherwise obey ofconn_receives_async_msgs(). */
- if (ofconn->type != OFCONN_PRIMARY
+ if (ofconn_get_type(ofconn) != OFCONN_PRIMARY
&& !ofconn_receives_async_msgs(ofconn)) {
continue;
}
{
struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
- if (ofconn->type == OFCONN_PRIMARY) {
+ if (ofconn_get_type(ofconn) == OFCONN_PRIMARY) {
hmap_remove(&ofproto->controllers, &ofconn->hmap_node);
}
static bool
ofconn_receives_async_msgs(const struct ofconn *ofconn)
{
- if (ofconn->type == OFCONN_PRIMARY) {
+ if (ofconn_get_type(ofconn) == OFCONN_PRIMARY) {
/* Primary controllers always get asynchronous messages unless they
* have configured themselves as "slaves". */
- return ofconn->role != NX_ROLE_SLAVE;
+ return ofconn_get_role(ofconn) != NX_ROLE_SLAVE;
} else {
/* Service connections don't get asynchronous messages unless they have
* explicitly asked for them by setting a nonzero miss send length. */
{
return ofconn->ofproto;
}
+
+static enum nx_flow_format
+ofconn_get_flow_format(struct ofconn *ofconn)
+{
+ return ofconn->flow_format;
+}
+
+static void
+ofconn_set_flow_format(struct ofconn *ofconn, enum nx_flow_format flow_format)
+{
+ ofconn->flow_format = flow_format;
+}
+
+static int
+ofconn_get_miss_send_len(const struct ofconn *ofconn)
+{
+ return ofconn->miss_send_len;
+}
+
+static void
+ofconn_set_miss_send_len(struct ofconn *ofconn, int miss_send_len)
+{
+ ofconn->miss_send_len = miss_send_len;
+}
+
+static enum ofconn_type
+ofconn_get_type(const struct ofconn *ofconn)
+{
+ return ofconn->type;
+}
+
+static enum nx_role
+ofconn_get_role(const struct ofconn *ofconn)
+{
+ return ofconn->role;
+}
+
+static void
+ofconn_set_role(struct ofconn *ofconn, enum nx_role role)
+{
+ ofconn->role = role;
+}
\f
static void
ofservice_reconfigure(struct ofservice *ofservice,
/* Send reply. */
osc = make_openflow_xid(sizeof *osc, OFPT_GET_CONFIG_REPLY, oh->xid, &buf);
osc->flags = htons(flags);
- osc->miss_send_len = htons(ofconn->miss_send_len);
+ osc->miss_send_len = htons(ofconn_get_miss_send_len(ofconn));
ofconn_send_reply(ofconn, buf);
return 0;
struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
uint16_t flags = ntohs(osc->flags);
- if (ofconn->type == OFCONN_PRIMARY && ofconn->role != NX_ROLE_SLAVE) {
+ if (ofconn_get_type(ofconn) == OFCONN_PRIMARY
+ && ofconn_get_role(ofconn) != NX_ROLE_SLAVE) {
switch (flags & OFPC_FRAG_MASK) {
case OFPC_FRAG_NORMAL:
dpif_set_drop_frags(ofproto->dpif, false);
}
}
- ofconn->miss_send_len = ntohs(osc->miss_send_len);
+ ofconn_set_miss_send_len(ofconn, ntohs(osc->miss_send_len));
return 0;
}
static int
reject_slave_controller(struct ofconn *ofconn, const const char *msg_type)
{
- if (ofconn->type == OFCONN_PRIMARY && ofconn->role == NX_ROLE_SLAVE) {
+ if (ofconn_get_type(ofconn) == OFCONN_PRIMARY
+ && ofconn_get_role(ofconn) == NX_ROLE_SLAVE) {
static struct vlog_rate_limit perm_rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_WARN_RL(&perm_rl, "rejecting %s message from slave controller",
msg_type);
ots = append_ofp_stats_reply(sizeof *ots, ofconn, &msg);
memset(ots, 0, sizeof *ots);
strcpy(ots->name, "classifier");
- ots->wildcards = (ofconn->flow_format == NXFF_OPENFLOW10
+ ots->wildcards = (ofconn_get_flow_format(ofconn) == NXFF_OPENFLOW10
? htonl(OFPFW_ALL) : htonl(OVSFW_ALL));
ots->max_entries = htonl(1024 * 1024); /* An arbitrary big number. */
ots->active_count = htonl(classifier_count(&p->cls));
ofs->length = htons(len);
ofs->table_id = 0;
ofs->pad = 0;
- ofputil_cls_rule_to_match(&rule->cr, ofconn->flow_format, &ofs->match,
- rule->flow_cookie, &cookie);
+ ofputil_cls_rule_to_match(&rule->cr, ofconn_get_flow_format(ofconn),
+ &ofs->match, rule->flow_cookie, &cookie);
put_32aligned_be64(&ofs->cookie, cookie);
calc_flow_duration(rule->created, &ofs->duration_sec, &ofs->duration_nsec);
ofs->priority = htons(rule->cr.priority);
return error;
}
- error = ofputil_decode_flow_mod(&fm, oh, ofconn->flow_format);
+ error = ofputil_decode_flow_mod(&fm, oh, ofconn_get_flow_format(ofconn));
if (error) {
return error;
}
{
const struct nxt_tun_id_cookie *msg
= (const struct nxt_tun_id_cookie *) oh;
+ enum nx_flow_format flow_format;
+
+ flow_format = msg->set ? NXFF_TUN_ID_FROM_COOKIE : NXFF_OPENFLOW10;
+ ofconn_set_flow_format(ofconn, flow_format);
- ofconn->flow_format = msg->set ? NXFF_TUN_ID_FROM_COOKIE : NXFF_OPENFLOW10;
return 0;
}
struct ofpbuf *buf;
uint32_t role;
- if (ofconn->type != OFCONN_PRIMARY) {
+ if (ofconn_get_type(ofconn) != OFCONN_PRIMARY) {
VLOG_WARN_RL(&rl, "ignoring role request on non-controller "
"connection");
return ofp_mkerr(OFPET_BAD_REQUEST, OFPBRC_EPERM);
struct ofconn *other;
HMAP_FOR_EACH (other, hmap_node, &ofproto->controllers) {
- if (other->role == NX_ROLE_MASTER) {
- other->role = NX_ROLE_SLAVE;
+ if (ofconn_get_role(other) == NX_ROLE_MASTER) {
+ ofconn_set_role(other, NX_ROLE_SLAVE);
}
}
}
- ofconn->role = role;
+ ofconn_set_role(ofconn, role);
reply = make_nxmsg_xid(sizeof *reply, NXT_ROLE_REPLY, oh->xid, &buf);
reply->role = htonl(role);
if (format == NXFF_OPENFLOW10
|| format == NXFF_TUN_ID_FROM_COOKIE
|| format == NXFF_NXM) {
- ofconn->flow_format = format;
+ ofconn_set_flow_format(ofconn, format);
return 0;
} else {
return ofp_mkerr(OFPET_BAD_REQUEST, OFPBRC_EPERM);
* being processed also prevents new flows from being added (and
* expiring). (It also prevents processing OpenFlow requests that
* would not add new flows, so it is imperfect.) */
- msg = ofputil_encode_flow_removed(&fr, ofconn->flow_format);
+ msg = ofputil_encode_flow_removed(&fr, ofconn_get_flow_format(ofconn));
ofconn_send_reply(ofconn, msg);
}
}