static void ofconn_destroy(struct ofconn *);
static void ofconn_run(struct ofconn *);
static void ofconn_wait(struct ofconn *);
+
static bool ofconn_receives_async_msgs(const struct ofconn *);
static char *ofconn_make_name(const struct ofproto *, const char *target);
static void ofconn_set_rate_limit(struct ofconn *, int rate, int burst);
+static struct ofproto *ofconn_get_ofproto(struct ofconn *);
+
static void queue_tx(struct ofpbuf *msg, const struct ofconn *ofconn,
struct rconn_packet_counter *counter);
static void
ofconn_destroy(struct ofconn *ofconn)
{
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
+
if (ofconn->type == OFCONN_PRIMARY) {
- hmap_remove(&ofconn->ofproto->controllers, &ofconn->hmap_node);
+ hmap_remove(&ofproto->controllers, &ofconn->hmap_node);
}
list_remove(&ofconn->node);
static void
ofconn_run(struct ofconn *ofconn)
{
- struct ofproto *p = ofconn->ofproto;
+ struct ofproto *p = ofconn_get_ofproto(ofconn);
int iteration;
size_t i;
}
}
}
+
+static struct ofproto *
+ofconn_get_ofproto(struct ofconn *ofconn)
+{
+ return ofconn->ofproto;
+}
\f
static void
ofservice_reconfigure(struct ofservice *ofservice,
static int
handle_features_request(struct ofconn *ofconn, const struct ofp_header *oh)
{
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
struct ofp_switch_features *osf;
struct ofpbuf *buf;
struct ofport *port;
osf = make_openflow_xid(sizeof *osf, OFPT_FEATURES_REPLY, oh->xid, &buf);
- osf->datapath_id = htonll(ofconn->ofproto->datapath_id);
+ osf->datapath_id = htonll(ofproto->datapath_id);
osf->n_buffers = htonl(pktbuf_capacity());
osf->n_tables = 2;
osf->capabilities = htonl(OFPC_FLOW_STATS | OFPC_TABLE_STATS |
(1u << OFPAT_SET_TP_DST) |
(1u << OFPAT_ENQUEUE));
- HMAP_FOR_EACH (port, hmap_node, &ofconn->ofproto->ports) {
+ HMAP_FOR_EACH (port, hmap_node, &ofproto->ports) {
hton_ofp_phy_port(ofpbuf_put(buf, &port->opp, sizeof port->opp));
}
static int
handle_get_config_request(struct ofconn *ofconn, const struct ofp_header *oh)
{
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
struct ofpbuf *buf;
struct ofp_switch_config *osc;
uint16_t flags;
bool drop_frags;
/* Figure out flags. */
- dpif_get_drop_frags(ofconn->ofproto->dpif, &drop_frags);
+ dpif_get_drop_frags(ofproto->dpif, &drop_frags);
flags = drop_frags ? OFPC_FRAG_DROP : OFPC_FRAG_NORMAL;
/* Send reply. */
static int
handle_set_config(struct ofconn *ofconn, const struct ofp_switch_config *osc)
{
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
uint16_t flags = ntohs(osc->flags);
if (ofconn->type == OFCONN_PRIMARY && ofconn->role != NX_ROLE_SLAVE) {
switch (flags & OFPC_FRAG_MASK) {
case OFPC_FRAG_NORMAL:
- dpif_set_drop_frags(ofconn->ofproto->dpif, false);
+ dpif_set_drop_frags(ofproto->dpif, false);
break;
case OFPC_FRAG_DROP:
- dpif_set_drop_frags(ofconn->ofproto->dpif, true);
+ dpif_set_drop_frags(ofproto->dpif, true);
break;
default:
VLOG_WARN_RL(&rl, "requested bad fragment mode (flags=%"PRIx16")",
static int
handle_packet_out(struct ofconn *ofconn, const struct ofp_header *oh)
{
- struct ofproto *p = ofconn->ofproto;
+ struct ofproto *p = ofconn_get_ofproto(ofconn);
struct ofp_packet_out *opo;
struct ofpbuf payload, *buffer;
union ofp_action *ofp_actions;
static int
handle_port_mod(struct ofconn *ofconn, const struct ofp_header *oh)
{
- struct ofproto *p = ofconn->ofproto;
+ struct ofproto *p = ofconn_get_ofproto(ofconn);
const struct ofp_port_mod *opm = (const struct ofp_port_mod *) oh;
struct ofport *port;
int error;
handle_desc_stats_request(struct ofconn *ofconn,
const struct ofp_header *request)
{
- struct ofproto *p = ofconn->ofproto;
+ struct ofproto *p = ofconn_get_ofproto(ofconn);
struct ofp_desc_stats *ods;
struct ofpbuf *msg;
handle_table_stats_request(struct ofconn *ofconn,
const struct ofp_header *request)
{
- struct ofproto *p = ofconn->ofproto;
+ struct ofproto *p = ofconn_get_ofproto(ofconn);
struct ofp_table_stats *ots;
struct ofpbuf *msg;
static int
handle_port_stats_request(struct ofconn *ofconn, const struct ofp_header *oh)
{
- struct ofproto *p = ofconn->ofproto;
+ struct ofproto *p = ofconn_get_ofproto(ofconn);
const struct ofp_port_stats_request *psr = ofputil_stats_body(oh);
struct ofp_port_stats *ops;
struct ofpbuf *msg;
handle_flow_stats_request(struct ofconn *ofconn, const struct ofp_header *oh)
{
const struct ofp_flow_stats_request *fsr = ofputil_stats_body(oh);
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
struct ofpbuf *reply;
COVERAGE_INC(ofproto_flows_req);
ofputil_cls_rule_from_match(&fsr->match, 0, NXFF_OPENFLOW10, 0,
&target);
- cls_cursor_init(&cursor, &ofconn->ofproto->cls, &target);
+ cls_cursor_init(&cursor, &ofproto->cls, &target);
CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
put_ofp_flow_stats(ofconn, rule, fsr->out_port, &reply);
}
static int
handle_nxst_flow(struct ofconn *ofconn, const struct ofp_header *oh)
{
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
struct nx_flow_stats_request *nfsr;
struct cls_rule target;
struct ofpbuf *reply;
struct cls_cursor cursor;
struct rule *rule;
- cls_cursor_init(&cursor, &ofconn->ofproto->cls, &target);
+ cls_cursor_init(&cursor, &ofproto->cls, &target);
CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
put_nx_flow_stats(ofconn, rule, nfsr->out_port, &reply);
}
const struct ofp_header *oh)
{
const struct ofp_aggregate_stats_request *request = ofputil_stats_body(oh);
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
struct ofp_aggregate_stats_reply *reply;
struct cls_rule target;
struct ofpbuf *msg;
msg = start_ofp_stats_reply(oh, sizeof *reply);
reply = append_ofp_stats_reply(sizeof *reply, ofconn, &msg);
- query_aggregate_stats(ofconn->ofproto, &target, request->out_port,
+ query_aggregate_stats(ofproto, &target, request->out_port,
request->table_id, reply);
queue_tx(msg, ofconn, ofconn->reply_counter);
return 0;
static int
handle_nxst_aggregate(struct ofconn *ofconn, const struct ofp_header *oh)
{
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
struct nx_aggregate_stats_request *request;
struct ofp_aggregate_stats_reply *reply;
struct cls_rule target;
COVERAGE_INC(ofproto_flows_req);
buf = start_nxstats_reply(&request->nsm, sizeof *reply);
reply = ofpbuf_put_uninit(buf, sizeof *reply);
- query_aggregate_stats(ofconn->ofproto, &target, request->out_port,
+ query_aggregate_stats(ofproto, &target, request->out_port,
request->table_id, reply);
queue_tx(buf, ofconn, ofconn->reply_counter);
static int
handle_queue_stats_request(struct ofconn *ofconn, const struct ofp_header *oh)
{
- struct ofproto *ofproto = ofconn->ofproto;
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
const struct ofp_queue_stats_request *qsr;
struct queue_stats_cbdata cbdata;
struct ofport *port;
* in which no matching flow already exists in the flow table.
*
* Adds the flow specified by 'ofm', which is followed by 'n_actions'
- * ofp_actions, to ofconn->ofproto's flow table. Returns 0 on success or an
+ * ofp_actions, to the ofproto's flow table. Returns 0 on success or an
* OpenFlow error code as encoded by ofp_mkerr() on failure.
*
* 'ofconn' is used to retrieve the packet buffer specified in ofm->buffer_id,
static int
add_flow(struct ofconn *ofconn, struct flow_mod *fm)
{
- struct ofproto *p = ofconn->ofproto;
+ struct ofproto *p = ofconn_get_ofproto(ofconn);
struct ofpbuf *packet;
struct rule *rule;
uint16_t in_port;
send_buffered_packet(struct ofconn *ofconn,
struct rule *rule, uint32_t buffer_id)
{
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
struct ofpbuf *packet;
uint16_t in_port;
int error;
return error;
}
- rule_execute(ofconn->ofproto, rule, in_port, packet);
+ rule_execute(ofproto, rule, in_port, packet);
return 0;
}
static int
modify_flows_loose(struct ofconn *ofconn, struct flow_mod *fm)
{
- struct ofproto *p = ofconn->ofproto;
+ struct ofproto *p = ofconn_get_ofproto(ofconn);
struct rule *match = NULL;
struct cls_cursor cursor;
struct rule *rule;
static int
modify_flow_strict(struct ofconn *ofconn, struct flow_mod *fm)
{
- struct ofproto *p = ofconn->ofproto;
+ struct ofproto *p = ofconn_get_ofproto(ofconn);
struct rule *rule = find_flow_strict(p, fm);
if (rule && !rule_is_hidden(rule)) {
modify_flow(p, fm, rule);
static int
handle_flow_mod(struct ofconn *ofconn, const struct ofp_header *oh)
{
- struct ofproto *p = ofconn->ofproto;
+ struct ofproto *p = ofconn_get_ofproto(ofconn);
struct flow_mod fm;
int error;
}
if (role == NX_ROLE_MASTER) {
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
struct ofconn *other;
- HMAP_FOR_EACH (other, hmap_node, &ofconn->ofproto->controllers) {
+ HMAP_FOR_EACH (other, hmap_node, &ofproto->controllers) {
if (other->role == NX_ROLE_MASTER) {
other->role = NX_ROLE_SLAVE;
}
schedule_packet_in(struct ofconn *ofconn, struct dpif_upcall *upcall,
const struct flow *flow, bool clone)
{
- struct ofproto *ofproto = ofconn->ofproto;
+ struct ofproto *ofproto = ofconn_get_ofproto(ofconn);
struct ofputil_packet_in pin;
struct ofpbuf *msg;