@@ -409,6 +409,44 @@ put_load(const uint8_t *data, size_t len,
bitwise_one(&sf->mask, sf->field->n_bytes, ofs, n_bits);
}
+static void
+consider_neighbor_flow(const struct lport_index *lports,
+ const struct sbrec_mac_binding *b,
+ struct ofpbuf *ofpacts_p,
+ struct match *match_p,
+ bool is_new)
+{
+ const struct sbrec_port_binding *pb
+ = lport_lookup_by_name(lports, b->logical_port);
+ if (!pb) {
+ return;
+ }
+
+ struct eth_addr mac;
+ if (!eth_addr_from_string(b->mac, &mac)) {
+ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
+ VLOG_WARN_RL(&rl, "bad 'mac' %s", b->mac);
+ return;
+ }
+
+ ovs_be32 ip;
+ if (!ip_parse(b->ip, &ip)) {
+ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
+ VLOG_WARN_RL(&rl, "bad 'ip' %s", b->ip);
+ return;
+ }
+
+ match_set_metadata(match_p, htonll(pb->datapath->tunnel_key));
+ match_set_reg(match_p, MFF_LOG_OUTPORT - MFF_REG0, pb->tunnel_key);
+ match_set_reg(match_p, 0, ntohl(ip));
+
+ ofpbuf_clear(ofpacts_p);
+ put_load(mac.ea, sizeof mac.ea, MFF_ETH_DST, 0, 48, ofpacts_p);
+
+ ofctrl_add_flow(OFTABLE_MAC_BINDING, 100, match_p, ofpacts_p,
+ &b->header_.uuid, is_new);
+}
+
/* Adds an OpenFlow flow to flow tables for each MAC binding in the OVN
* southbound database, using 'lports' to resolve logical port names to
* numbers. */
@@ -423,35 +461,7 @@ add_neighbor_flows(struct controller_ctx *ctx,
const struct sbrec_mac_binding *b;
SBREC_MAC_BINDING_FOR_EACH (b, ctx->ovnsb_idl) {
- const struct sbrec_port_binding *pb
- = lport_lookup_by_name(lports, b->logical_port);
- if (!pb) {
- continue;
- }
-
- struct eth_addr mac;
- if (!eth_addr_from_string(b->mac, &mac)) {
- static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
- VLOG_WARN_RL(&rl, "bad 'mac' %s", b->mac);
- continue;
- }
-
- ovs_be32 ip;
- if (!ip_parse(b->ip, &ip)) {
- static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
- VLOG_WARN_RL(&rl, "bad 'ip' %s", b->ip);
- continue;
- }
-
- match_set_metadata(&match, htonll(pb->datapath->tunnel_key));
- match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, pb->tunnel_key);
- match_set_reg(&match, 0, ntohl(ip));
-
- ofpbuf_clear(&ofpacts);
- put_load(mac.ea, sizeof mac.ea, MFF_ETH_DST, 0, 48, &ofpacts);
-
- ofctrl_add_flow(OFTABLE_MAC_BINDING, 100, &match, &ofpacts,
- &b->header_.uuid, true);
+ consider_neighbor_flow(lports, b, &ofpacts, &match, true);
}
ofpbuf_uninit(&ofpacts);
}
Extract block within SBREC_MAC_BINDING_FOR_EACH loop within add_neighbor_flows to helper method so it can be reused when doing incremental processing. This is_new parameter is added for use in a later patch set. Signed-off-by: Ryan Moats <rmoats@us.ibm.com> --- ovn/controller/lflow.c | 68 +++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 29 deletions(-)