X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=ofproto%2Fofproto.c;h=050b4df1a961be4b6865bde485a3ec4a0008c647;hb=4f484bb2245f077b195da1c560d75f0993491bab;hp=d8215a85d5bb83375a066559c85faa57fe280cb7;hpb=487ec65f157060b83ee050dc516ddd792574543b;p=openvswitch diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index d8215a85..050b4df1 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -225,6 +225,7 @@ static void ofconn_destroy(struct ofconn *); static void ofconn_run(struct ofconn *, struct ofproto *); 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 queue_tx(struct ofpbuf *msg, const struct ofconn *ofconn, struct rconn_packet_counter *counter); @@ -459,7 +460,9 @@ add_controller(struct ofproto *ofproto, const struct ofproto_controller *c) if (discovery) { ofconn->discovery = discovery; } else { - rconn_connect(ofconn->rconn, c->target); + char *name = ofconn_make_name(ofproto, c->target); + rconn_connect(ofconn->rconn, c->target, name); + free(name); } hmap_insert(&ofproto->controllers, &ofconn->hmap_node, hash_string(c->target, 0)); @@ -510,7 +513,7 @@ update_controller(struct ofconn *ofconn, const struct ofproto_controller *c) static const char * ofconn_get_target(const struct ofconn *ofconn) { - return ofconn->discovery ? "discover" : rconn_get_name(ofconn->rconn); + return ofconn->discovery ? "discover" : rconn_get_target(ofconn->rconn); } static struct ofconn * @@ -573,7 +576,9 @@ update_in_band_remotes(struct ofproto *ofproto) in_band_create(ofproto, ofproto->dpif, ofproto->switch_status, &ofproto->in_band); } - in_band_set_remotes(ofproto->in_band, addrs, n_addrs); + if (ofproto->in_band) { + in_band_set_remotes(ofproto->in_band, addrs, n_addrs); + } ofproto->next_in_band_update = time_msec() + 1000; } else { in_band_destroy(ofproto->in_band); @@ -1076,8 +1081,15 @@ ofproto_run1(struct ofproto *p) retval = pvconn_accept(p->listeners[i], OFP_VERSION, &vconn); if (!retval) { - ofconn_create(p, rconn_new_from_vconn("passive", vconn), - OFCONN_TRANSIENT); + struct rconn *rconn; + char *name; + + rconn = rconn_create(60, 0); + name = ofconn_make_name(p, vconn_get_name(vconn)); + rconn_connect_unreliably(rconn, vconn, name); + free(name); + + ofconn_create(p, rconn, OFCONN_TRANSIENT); } else if (retval != EAGAIN) { VLOG_WARN_RL(&rl, "accept failed (%s)", strerror(retval)); } @@ -1356,7 +1368,6 @@ make_ofport(const struct odp_port *odp_port) memset(&netdev_options, 0, sizeof netdev_options); netdev_options.name = odp_port->devname; netdev_options.ethertype = NETDEV_ETH_TYPE_NONE; - netdev_options.may_open = true; error = netdev_open(&netdev_options, &netdev); if (error) { @@ -1628,7 +1639,9 @@ ofconn_run(struct ofconn *ofconn, struct ofproto *p) } if (discovery_run(ofconn->discovery, &controller_name)) { if (controller_name) { - rconn_connect(ofconn->rconn, controller_name); + char *ofconn_name = ofconn_make_name(p, controller_name); + rconn_connect(ofconn->rconn, controller_name, ofconn_name); + free(ofconn_name); } else { rconn_disconnect(ofconn->rconn); } @@ -1696,6 +1709,18 @@ ofconn_receives_async_msgs(const struct ofconn *ofconn) return ofconn->miss_send_len > 0; } } + +/* Returns a human-readable name for an OpenFlow connection between 'ofproto' + * and 'target', suitable for use in log messages for identifying the + * connection. + * + * The name is dynamically allocated. The caller should free it (with free()) + * when it is no longer needed. */ +static char * +ofconn_make_name(const struct ofproto *ofproto, const char *target) +{ + return xasprintf("%s<->%s", dpif_base_name(ofproto->dpif), target); +} /* Caller is responsible for initializing the 'cr' member of the returned * rule. */ @@ -4229,7 +4254,8 @@ default_normal_ofhook_cb(const flow_t *flow, const struct ofpbuf *packet, /* Learn source MAC (but don't try to learn from revalidation). */ if (packet != NULL) { tag_type rev_tag = mac_learning_learn(ofproto->ml, flow->dl_src, - 0, flow->in_port); + 0, flow->in_port, + GRAT_ARP_LOCK_NONE); if (rev_tag) { /* The log messages here could actually be useful in debugging, * so keep the rate limit relatively high. */ @@ -4241,7 +4267,8 @@ default_normal_ofhook_cb(const flow_t *flow, const struct ofpbuf *packet, } /* Determine output port. */ - out_port = mac_learning_lookup_tag(ofproto->ml, flow->dl_dst, 0, tags); + out_port = mac_learning_lookup_tag(ofproto->ml, flow->dl_dst, 0, tags, + NULL); if (out_port < 0) { add_output_group_action(actions, DP_GROUP_FLOOD, nf_output_iface); } else if (out_port != flow->in_port) {