Skip to content

Commit 9a33cd7

Browse files
committed
ovn-controller: Use new ovsdb-idl helpers to make logic more readable.
Also there were lots of 'continue's sprinkled around that didn't seem to be needed given some simple code rearrangement. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Ryan Moats <rmoats@us.ibm.com>
1 parent 6cf888b commit 9a33cd7

4 files changed

Lines changed: 27 additions & 33 deletions

File tree

ovn/controller/binding.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,12 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
266266
process_full_binding = false;
267267
} else {
268268
SBREC_PORT_BINDING_FOR_EACH_TRACKED(binding_rec, ctx->ovnsb_idl) {
269-
bool is_deleted = sbrec_port_binding_row_get_seqno(binding_rec,
270-
OVSDB_IDL_CHANGE_DELETE) > 0;
271-
272-
if (is_deleted) {
269+
if (sbrec_port_binding_is_deleted(binding_rec)) {
273270
remove_local_datapath_by_binding(local_datapaths, binding_rec);
274-
continue;
271+
} else {
272+
consider_local_datapath(ctx, &lports, chassis_rec, binding_rec,
273+
local_datapaths);
275274
}
276-
consider_local_datapath(ctx, &lports, chassis_rec, binding_rec,
277-
local_datapaths);
278275
}
279276
}
280277

ovn/controller/encaps.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2015 Nicira, Inc.
1+
/* Copyright (c) 2015, 2016 Nicira, Inc.
22
*
33
* Licensed under the Apache License, Version 2.0 (the "License");
44
* you may not use this file except in compliance with the License.
@@ -404,12 +404,7 @@ encaps_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
404404
process_full_encaps = false;
405405
} else {
406406
SBREC_CHASSIS_FOR_EACH_TRACKED (chassis_rec, ctx->ovnsb_idl) {
407-
bool is_deleted = sbrec_chassis_row_get_seqno(chassis_rec,
408-
OVSDB_IDL_CHANGE_DELETE) > 0;
409-
bool is_new = sbrec_chassis_row_get_seqno(chassis_rec,
410-
OVSDB_IDL_CHANGE_MODIFY) == 0;
411-
412-
if (is_deleted) {
407+
if (sbrec_chassis_is_deleted(chassis_rec)) {
413408
/* Lookup the tunnel by row uuid and remove it. */
414409
struct port_hash_node *port_hash =
415410
port_lookup_by_uuid(&tc.tunnel_hmap_by_uuid,
@@ -424,14 +419,10 @@ encaps_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
424419
free(port_hash);
425420
binding_reset_processing();
426421
}
427-
continue;
428-
}
429-
if (!is_new) {
430-
check_and_update_tunnel(chassis_rec);
431-
continue;
432-
} else {
422+
} else if (sbrec_chassis_is_new(chassis_rec)) {
433423
check_and_add_tunnel(chassis_rec, chassis_id);
434-
continue;
424+
} else {
425+
check_and_update_tunnel(chassis_rec);
435426
}
436427
}
437428
}

ovn/controller/lport.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,11 @@ lport_index_fill(struct lport_index *lports, struct ovsdb_idl *ovnsb_idl)
107107
full_lport_rebuild = false;
108108
} else {
109109
SBREC_PORT_BINDING_FOR_EACH_TRACKED (pb, ovnsb_idl) {
110-
bool is_delete = sbrec_port_binding_row_get_seqno(pb,
111-
OVSDB_IDL_CHANGE_DELETE) > 0;
112-
113-
if (is_delete) {
110+
if (sbrec_port_binding_is_deleted(pb)) {
114111
lport_index_remove(lports, &pb->header_.uuid);
115-
continue;
112+
} else {
113+
consider_lport_index(lports, pb);
116114
}
117-
consider_lport_index(lports, pb);
118115
}
119116
}
120117
}
@@ -248,14 +245,11 @@ mcgroup_index_fill(struct mcgroup_index *mcgroups, struct ovsdb_idl *ovnsb_idl)
248245
full_mc_rebuild = false;
249246
} else {
250247
SBREC_MULTICAST_GROUP_FOR_EACH_TRACKED (mg, ovnsb_idl) {
251-
bool is_delete = sbrec_multicast_group_row_get_seqno(mg,
252-
OVSDB_IDL_CHANGE_DELETE) > 0;
253-
254-
if (is_delete) {
248+
if (sbrec_multicast_group_is_deleted(mg)) {
255249
mcgroup_index_remove(mcgroups, &mg->header_.uuid);
256-
continue;
250+
} else {
251+
consider_mcgroup_index(mcgroups, mg);
257252
}
258-
consider_mcgroup_index(mcgroups, mg);
259253
}
260254
}
261255
}

ovsdb/ovsdb-idlc.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,18 @@ const struct %(s)s *%(s)s_track_get_next(const struct %(s)s *);
186186
(ROW); \\
187187
(ROW) = %(s)s_track_get_next(ROW))
188188

189+
/* Returns true if 'row' was inserted since the last change tracking reset. */
190+
static inline bool %(s)s_is_new(const struct %(s)s *row)
191+
{
192+
return %(s)s_row_get_seqno(row, OVSDB_IDL_CHANGE_MODIFY) == 0;
193+
}
194+
195+
/* Returns true if 'row' was deleted since the last change tracking reset. */
196+
static inline bool %(s)s_is_deleted(const struct %(s)s *row)
197+
{
198+
return %(s)s_row_get_seqno(row, OVSDB_IDL_CHANGE_DELETE) > 0;
199+
}
200+
189201
void %(s)s_init(struct %(s)s *);
190202
void %(s)s_delete(const struct %(s)s *);
191203
struct %(s)s *%(s)s_insert(struct ovsdb_idl_txn *);

0 commit comments

Comments
 (0)