X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ofproto%2Fin-band.c;h=f9dd21823ae6198a578facd3ee6f8b29289851e8;hb=0f2bbc23998430276a2f530ede1de40e45098441;hp=14cfa040aba23cbbe9977d26fd15d014a19a3433;hpb=7ee20df120d4d56df894abc00a60fe1bc43a058d;p=openvswitch diff --git a/ofproto/in-band.c b/ofproto/in-band.c index 14cfa040..f9dd2182 100644 --- a/ofproto/in-band.c +++ b/ofproto/in-band.c @@ -32,10 +32,10 @@ #include "odp-util.h" #include "ofproto.h" #include "ofpbuf.h" +#include "ofproto-provider.h" #include "openflow/openflow.h" #include "packets.h" #include "poll-loop.h" -#include "private.h" #include "timeval.h" #include "vlog.h" @@ -131,7 +131,7 @@ refresh_remote(struct in_band *ib, struct in_band_remote *r) { netdev_close(r->remote_netdev); - retval = netdev_open_default(next_hop_dev, &r->remote_netdev); + retval = netdev_open(next_hop_dev, "system", &r->remote_netdev); if (retval) { VLOG_WARN_RL(&rl, "cannot open netdev %s (next hop " "to controller "IP_FMT"): %s", @@ -310,7 +310,7 @@ update_rules(struct in_band *ib) ib_rule->op = DELETE; } - if (!eth_addr_is_zero(ib->local_mac)) { + if (ib->n_remotes && !eth_addr_is_zero(ib->local_mac)) { /* (a) Allow DHCP requests sent from the local port. */ cls_rule_init_catchall(&rule, IBR_FROM_LOCAL_DHCP); cls_rule_set_in_port(&rule, ODPP_LOCAL); @@ -395,7 +395,12 @@ update_rules(struct in_band *ib) } } -void +/* Updates the OpenFlow flow table for the current state of in-band control. + * Returns true ordinarily. Returns false if no remotes are configured on 'ib' + * and 'ib' doesn't have any rules left to remove from the OpenFlow flow + * table. Thus, a false return value means that the caller can destroy 'ib' + * without leaving extra flows hanging around in the flow table. */ +bool in_band_run(struct in_band *ib) { struct { @@ -446,6 +451,8 @@ in_band_run(struct in_band *ib) break; } } + + return ib->n_remotes || !hmap_is_empty(&ib->rules); } void @@ -465,7 +472,7 @@ in_band_create(struct ofproto *ofproto, const char *local_name, int error; *in_bandp = NULL; - error = netdev_open_default(local_name, &local_netdev); + error = netdev_open(local_name, "system", &local_netdev); if (error) { VLOG_ERR("failed to initialize in-band control: cannot open " "datapath local port %s (%s)", local_name, strerror(error));