- if (controller_ip) {
- /* Allow ARP replies to the controller's IP. */
- memset(&flow, 0, sizeof flow);
- flow.dl_type = htons(ETH_TYPE_ARP);
- flow.nw_proto = ARP_OP_REPLY;
- flow.nw_dst = controller_ip;
- set_up_flow(in_band, IBR_TO_CTL_ARP, &flow,
- (OFPFW_DL_TYPE | OFPFW_NW_PROTO | OFPFW_NW_DST_MASK),
- OFPP_NORMAL);
-
- /* Allow ARP requests from the controller's IP. */
- memset(&flow, 0, sizeof flow);
- flow.dl_type = htons(ETH_TYPE_ARP);
- flow.nw_proto = ARP_OP_REQUEST;
- flow.nw_src = controller_ip;
- set_up_flow(in_band, IBR_FROM_CTL_ARP, &flow,
- (OFPFW_DL_TYPE | OFPFW_NW_PROTO | OFPFW_NW_SRC_MASK),
- OFPP_NORMAL);
-
- /* OpenFlow traffic to or from the controller.
- *
- * (A given field's value is completely ignored if it is wildcarded,
- * which is why we can get away with using a single 'flow' in each
- * case here.) */
- memset(&flow, 0, sizeof flow);
- flow.dl_type = htons(ETH_TYPE_IP);
- flow.nw_proto = IP_TYPE_TCP;
- flow.nw_src = controller_ip;
- flow.nw_dst = controller_ip;
- flow.tp_src = htons(OFP_TCP_PORT);
- flow.tp_dst = htons(OFP_TCP_PORT);
- set_up_flow(in_band, IBR_TO_CTL_OFP, &flow,
- (OFPFW_DL_TYPE | OFPFW_NW_PROTO | OFPFW_NW_DST_MASK
- | OFPFW_TP_DST), OFPP_NORMAL);
- set_up_flow(in_band, IBR_FROM_CTL_OFP, &flow,
- (OFPFW_DL_TYPE | OFPFW_NW_PROTO | OFPFW_NW_SRC_MASK
- | OFPFW_TP_SRC), OFPP_NORMAL);
- } else {
- drop_flow(in_band, IBR_TO_CTL_ARP);
- drop_flow(in_band, IBR_FROM_CTL_ARP);
- drop_flow(in_band, IBR_TO_CTL_OFP);
- drop_flow(in_band, IBR_FROM_CTL_OFP);
+/* Inserts flows into the flow table for the current state of 'ib'. */
+static void
+add_rules(struct in_band *ib)
+{
+ make_rules(ib, add_rule);
+}
+
+static int
+compare_addrs(const void *a_, const void *b_)
+{
+ const struct sockaddr_in *a = a_;
+ const struct sockaddr_in *b = b_;
+ int cmp;
+
+ cmp = memcmp(&a->sin_addr.s_addr,
+ &b->sin_addr.s_addr,
+ sizeof a->sin_addr.s_addr);
+ if (cmp) {
+ return cmp;
+ }
+ return memcmp(&a->sin_port, &b->sin_port, sizeof a->sin_port);
+}
+
+static int
+compare_macs(const void *a, const void *b)
+{
+ return memcmp(a, b, ETH_ADDR_LEN);
+}
+
+void
+in_band_run(struct in_band *ib)
+{
+ bool local_change, remote_change, queue_id_change;
+ struct in_band_remote *r;
+
+ local_change = refresh_local(ib);
+ remote_change = refresh_remotes(ib);
+ queue_id_change = ib->queue_id != ib->prev_queue_id;
+ if (!local_change && !remote_change && !queue_id_change) {
+ /* Nothing changed, nothing to do. */
+ return;