@@ -5,27 +5,21 @@ Subject: [PATCH] add support for conditionally skipping conntrack
55
66Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
77---
8- controller/lflow.c | 11 +++++++++++
9- controller/ovn-controller.c | 26 +++++++++++++++++++++++++-
10- controller/ovn-controller.h | 3 +++
11- lib/ovn-util.h | 2 ++
12- northd/lflow-mgr.c | 29 +++++++++++++++++++++--------
13- northd/lflow-mgr.h | 26 +++++++++++++++++---------
14- 6 files changed, 79 insertions(+), 18 deletions(-)
8+ 6 files changed, 82 insertions(+), 15 deletions(-)
159
1610diff --git a/controller/lflow.c b/controller/lflow.c
17- index a782ec740c..6ef64fa897 100644
11+ index 14d61cfd1..0fe23af69 100644
1812--- a/controller/lflow.c
1913+++ b/controller/lflow.c
20- @@ -33 ,6 +33 ,7 @@
14+ @@ -34 ,6 +34 ,7 @@
2115 #include "lib/lb.h"
2216 #include "lib/ovn-l7.h"
2317 #include "lib/ovn-sb-idl.h"
2418+ #include "lib/ovn-util.h"
2519 #include "lib/extend-table.h"
2620 #include "lib/uuidset.h"
2721 #include "packets.h"
28- @@ -1056 ,6 +1057 ,16 @@ consider_logical_flow__(const struct sbrec_logical_flow *lflow,
22+ @@ -1074 ,6 +1075 ,16 @@ consider_logical_flow__(const struct sbrec_logical_flow *lflow,
2923 return;
3024 }
3125
@@ -43,7 +37,7 @@ index a782ec740c..6ef64fa897 100644
4337 if (io_port) {
4438 objdep_mgr_add(l_ctx_out->lflow_deps_mgr, OBJDEP_TYPE_PORTBINDING,
4539diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
46- index 9a21069e7c..261d6772ad 100644
40+ index e7a00f6f3..201e48df0 100644
4741--- a/controller/ovn-controller.c
4842+++ b/controller/ovn-controller.c
4943@@ -23,6 +23,7 @@
@@ -63,7 +57,7 @@ index 9a21069e7c..261d6772ad 100644
6357 static unixctl_cb_func ct_zone_list;
6458 static unixctl_cb_func extend_table_list;
6559 static unixctl_cb_func inject_pkt;
66- @@ -5513 ,6 +5516 ,25 @@ main(int argc, char *argv[])
60+ @@ -5563 ,6 +5566 ,25 @@ main(int argc, char *argv[])
6761 char *ovs_remote = parse_options(argc, argv);
6862 fatal_ignore_sigpipe();
6963
@@ -89,7 +83,7 @@ index 9a21069e7c..261d6772ad 100644
8983 daemonize_start(true, false);
9084
9185 char *abs_unixctl_path = get_abs_unix_ctl_path(unixctl_path);
92- @@ -5526 ,6 +5548 ,9 @@ main(int argc, char *argv[])
86+ @@ -5576 ,6 +5598 ,9 @@ main(int argc, char *argv[])
9387
9488 daemonize_complete();
9589
@@ -99,7 +93,7 @@ index 9a21069e7c..261d6772ad 100644
9993 /* Register ofctrl seqno types. */
10094 ofctrl_seq_type_nb_cfg = ofctrl_seqno_add_type();
10195
102- @@ -5651 ,7 +5676 ,6 @@ main(int argc, char *argv[])
96+ @@ -5704 ,7 +5729 ,6 @@ main(int argc, char *argv[])
10397 * */
10498
10599 ovsdb_idl_omit(ovnsb_idl_loop.idl, &sbrec_sb_global_col_external_ids);
@@ -108,7 +102,7 @@ index 9a21069e7c..261d6772ad 100644
108102 ovsdb_idl_omit(ovnsb_idl_loop.idl, &sbrec_ssl_col_external_ids);
109103 ovsdb_idl_omit(ovnsb_idl_loop.idl,
110104diff --git a/controller/ovn-controller.h b/controller/ovn-controller.h
111- index fafd704df7..99e1c8b36f 100644
105+ index fafd704df..99e1c8b36 100644
112106--- a/controller/ovn-controller.h
113107+++ b/controller/ovn-controller.h
114108@@ -18,6 +18,7 @@
@@ -127,7 +121,7 @@ index fafd704df7..99e1c8b36f 100644
127121+
128122 #endif /* controller/ovn-controller.h */
129123diff --git a/lib/ovn-util.h b/lib/ovn-util.h
130- index 6e559118a0..50ab622410 100644
124+ index 1d4f853e0..f6f4d8ec5 100644
131125--- a/lib/ovn-util.h
132126+++ b/lib/ovn-util.h
133127@@ -31,6 +31,8 @@
@@ -140,100 +134,99 @@ index 6e559118a0..50ab622410 100644
140134 #define ETHERNET_OVERHEAD (ETH_HEADER_LEN + ETH_CRC_LENGTH)
141135
142136diff --git a/northd/lflow-mgr.c b/northd/lflow-mgr.c
143- index 88ce7ce56d..5de34f387c 100644
137+ index eb795180c..da66f6b70 100644
144138--- a/northd/lflow-mgr.c
145139+++ b/northd/lflow-mgr.c
146- @@ -37,6 +37,7 @@ static void ovn_lflow_init(struct ovn_lflow *, struct ovn_datapath *od,
147- uint16_t priority, char *match,
140+ @@ -38,6 +38,7 @@ static void ovn_lflow_init(struct ovn_lflow *, struct ovn_datapath *od,
148141 char *actions, char *io_port,
149142 char *ctrl_meter, char *stage_hint,
143+ bool acl_ct_translation,
150144+ const char *kube_ovn_hint,
151145 const char *where, const char *flow_desc);
152146 static struct ovn_lflow *ovn_lflow_find(const struct hmap *lflows,
153147 enum ovn_stage stage,
154- @@ -53,9 +54,9 @@ static struct ovn_lflow *do_ovn_lflow_add(
155- const char *actions, const char *io_port,
148+ @@ -57,7 +58,8 @@ static struct ovn_lflow *do_ovn_lflow_add(
156149 const char *ctrl_meter,
157150 const struct ovsdb_idl_row *stage_hint,
158- + const char* kube_ovn_hint,
159- const char *where, const char *flow_desc);
151+ const char *where, const char *flow_desc,
152+ - bool acl_ct_translation);
153+ + bool acl_ct_translation,
154+ + const char *kube_ovn_hint);
155+
160156
161- -
162157 static struct ovs_mutex *lflow_hash_lock(const struct hmap *lflow_table,
163- uint32_t hash);
164- static void lflow_hash_unlock(struct ovs_mutex *hash_lock);
165- @@ -169,6 +170,7 @@ struct ovn_lflow {
158+ @@ -173,6 +175,7 @@ struct ovn_lflow {
166159 char *actions;
167160 char *io_port;
168161 char *stage_hint;
169162+ const char *kube_ovn_hint;
170163 char *ctrl_meter;
171164 size_t n_ods; /* Number of datapaths referenced by 'od' and
172165 * 'dpg_bitmap'. */
173- @@ -661,6 +663,7 @@ lflow_table_add_lflow(struct lflow_table *lflow_table,
174- const char *match, const char *actions,
166+ @@ -669,6 +672,7 @@ lflow_table_add_lflow(struct lflow_table *lflow_table,
175167 const char *io_port, const char *ctrl_meter,
168+ bool acl_ct_translation,
176169 const struct ovsdb_idl_row *stage_hint,
177170+ const char *kube_ovn_hint,
178171 const char *where, const char *flow_desc,
179172 struct lflow_ref *lflow_ref)
180173 OVS_EXCLUDED(fake_hash_mutex)
181- @@ -681,8 +684,7 @@ lflow_table_add_lflow(struct lflow_table *lflow_table,
182- do_ovn_lflow_add(lflow_table,
174+ @@ -690,7 +694,7 @@ lflow_table_add_lflow(struct lflow_table *lflow_table,
183175 od ? ods_size(od->datapaths) : dp_bitmap_len,
184176 hash, stage, priority, match, actions,
185- - io_port, ctrl_meter, stage_hint, where, flow_desc);
186- -
187- + io_port, ctrl_meter, stage_hint, kube_ovn_hint, where, flow_desc);
177+ io_port, ctrl_meter, stage_hint, where, flow_desc,
178+ - acl_ct_translation);
179+ + acl_ct_translation, kube_ovn_hint);
180+
188181 if (lflow_ref) {
189182 struct lflow_ref_node *lrn =
190- lflow_ref_node_find(&lflow_ref->lflow_ref_nodes, lflow, hash);
191- @@ -734,7 +736,7 @@ lflow_table_add_lflow_default_drop(struct lflow_table *lflow_table,
183+ @@ -743,7 +747,7 @@ lflow_table_add_lflow_default_drop(struct lflow_table *lflow_table,
192184 struct lflow_ref *lflow_ref)
193185 {
194186 lflow_table_add_lflow(lflow_table, od, NULL, 0, stage, 0, "1",
195- - debug_drop_action(), NULL, NULL, NULL,
196- + debug_drop_action(), NULL, NULL, NULL, NULL,
187+ - debug_drop_action(), NULL, NULL, false, NULL,
188+ + debug_drop_action(), NULL, NULL, false, NULL, NULL,
197189 where, NULL, lflow_ref);
198190 }
199191
200- @@ -858,8 +860,7 @@ static void
192+ @@ -867,7 +871,8 @@ static void
201193 ovn_lflow_init(struct ovn_lflow *lflow, struct ovn_datapath *od,
202194 size_t dp_bitmap_len, enum ovn_stage stage, uint16_t priority,
203195 char *match, char *actions, char *io_port, char *ctrl_meter,
204- - char *stage_hint, const char *where,
205- - const char *flow_desc)
206- + char *stage_hint, const char *kube_ovn_hint, const char *where, const char *flow_desc)
196+ - char *stage_hint, bool acl_ct_translation, const char *where,
197+ + char *stage_hint, bool acl_ct_translation,
198+ + const char *kube_ovn_hint, const char *where,
199+ const char *flow_desc)
207200 {
208201 lflow->dpg_bitmap = bitmap_allocate(dp_bitmap_len);
209- lflow->od = od;
210- @@ -869,6 +870,7 @@ ovn_lflow_init(struct ovn_lflow *lflow, struct ovn_datapath *od,
202+ @@ -878,6 +883,7 @@ ovn_lflow_init(struct ovn_lflow *lflow, struct ovn_datapath *od,
211203 lflow->actions = actions;
212204 lflow->io_port = io_port;
213205 lflow->stage_hint = stage_hint;
214206+ lflow->kube_ovn_hint = kube_ovn_hint;
215207 lflow->ctrl_meter = ctrl_meter;
216208 lflow->flow_desc = flow_desc;
217209 lflow->dpg = NULL;
218- @@ -964,6 +966,7 @@ do_ovn_lflow_add(struct lflow_table *lflow_table, size_t dp_bitmap_len,
219- const char *match, const char *actions,
210+ @@ -978,7 +984,8 @@ do_ovn_lflow_add(struct lflow_table *lflow_table, size_t dp_bitmap_len,
220211 const char *io_port, const char *ctrl_meter,
221212 const struct ovsdb_idl_row *stage_hint,
222- + const char* kube_ovn_hint,
223- const char *where, const char *flow_desc)
213+ const char *where, const char *flow_desc,
214+ - bool acl_ct_translation)
215+ + bool acl_ct_translation,
216+ + const char *kube_ovn_hint)
224217 OVS_REQUIRES(fake_hash_mutex)
225218 {
226- @@ -986,8 +989,7 @@ do_ovn_lflow_add( struct lflow_table *lflow_table, size_t dp_bitmap_len,
227- xstrdup(match), xstrdup(actions) ,
219+ struct ovn_lflow *old_lflow;
220+ @@ -1002,7 +1009,7 @@ do_ovn_lflow_add(struct lflow_table *lflow_table, size_t dp_bitmap_len ,
228221 io_port ? xstrdup(io_port) : NULL,
229222 nullable_xstrdup(ctrl_meter),
230- - ovn_lflow_hint(stage_hint), where ,
231- - flow_desc);
232- + ovn_lflow_hint(stage_hint), kube_ovn_hint, where, flow_desc);
223+ ovn_lflow_hint(stage_hint), acl_ct_translation ,
224+ - where, flow_desc);
225+ + kube_ovn_hint, where, flow_desc);
233226
234227 if (parallelization_state != STATE_USE_PARALLELIZATION) {
235228 hmap_insert(&lflow_table->entries, &lflow->hmap_node, hash);
236- @@ -1082 ,6 +1084 ,9 @@ sync_lflow_to_sb(struct ovn_lflow *lflow,
229+ @@ -1107 ,6 +1114 ,9 @@ sync_lflow_to_sb(struct ovn_lflow *lflow,
237230 if (lflow->stage_hint) {
238231 smap_add(&ids, "stage-hint", lflow->stage_hint);
239232 }
@@ -243,7 +236,7 @@ index 88ce7ce56d..5de34f387c 100644
243236 sbrec_logical_flow_set_external_ids(sbflow, &ids);
244237 smap_destroy(&ids);
245238
246- @@ -1094 ,6 +1099 ,8 @@ sync_lflow_to_sb(struct ovn_lflow *lflow,
239+ @@ -1119 ,6 +1129 ,8 @@ sync_lflow_to_sb(struct ovn_lflow *lflow,
247240 "stage-name", "");
248241 const char *stage_hint = smap_get_def(&sbflow->external_ids,
249242 "stage-hint", "");
@@ -252,7 +245,7 @@ index 88ce7ce56d..5de34f387c 100644
252245 const char *source = smap_get_def(&sbflow->external_ids,
253246 "source", "");
254247
255- @@ -1107 ,6 +1114 ,12 @@ sync_lflow_to_sb(struct ovn_lflow *lflow,
248+ @@ -1132 ,6 +1144 ,12 @@ sync_lflow_to_sb(struct ovn_lflow *lflow,
256249 sbflow, "stage-hint", lflow->stage_hint);
257250 }
258251 }
@@ -266,82 +259,87 @@ index 88ce7ce56d..5de34f387c 100644
266259
267260 /* Trim the source locator lflow->where, which looks something
268261diff --git a/northd/lflow-mgr.h b/northd/lflow-mgr.h
269- index 2c05b352dc..3f3cb639d7 100644
262+ index 7efc61caf..702303703 100644
270263--- a/northd/lflow-mgr.h
271264+++ b/northd/lflow-mgr.h
272- @@ -78,8 +78,8 @@ void lflow_table_add_lflow(struct lflow_table *, const struct ovn_datapath *,
265+ @@ -79,6 +79,7 @@ void lflow_table_add_lflow(struct lflow_table *, const struct ovn_datapath *,
273266 const char *actions, const char *io_port,
274- const char *ctrl_meter,
267+ const char *ctrl_meter, bool acl_ct_translation,
275268 const struct ovsdb_idl_row *stage_hint,
276- - const char *where, const char *flow_desc,
277- - struct lflow_ref *);
278269+ const char *kube_ovn_hint,
279- + const char *where, const char *flow_desc, struct lflow_ref *);
270+ const char *where, const char *flow_desc,
271+ struct lflow_ref *);
280272 void lflow_table_add_lflow_default_drop(struct lflow_table *,
281- const struct ovn_datapath *,
282- enum ovn_stage stage,
283- @@ -91,13 +91,21 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,
284- ACTIONS, IN_OUT_PORT, CTRL_METER, \
273+ @@ -93,12 +94,20 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,
285274 STAGE_HINT, LFLOW_REF) \
286275 lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
287- - ACTIONS, IN_OUT_PORT, CTRL_METER, STAGE_HINT , \
288- + ACTIONS, IN_OUT_PORT, CTRL_METER, STAGE_HINT, NULL, \
289- OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
276+ ACTIONS, IN_OUT_PORT, CTRL_METER, false , \
277+ - STAGE_HINT, OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
278+ + STAGE_HINT, NULL, OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
290279
291280 #define ovn_lflow_add_with_hint(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, \
292281 ACTIONS, STAGE_HINT, LFLOW_REF) \
293282 lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
294- - ACTIONS, NULL, NULL, STAGE_HINT, \
295- + ACTIONS, NULL, NULL, STAGE_HINT, NULL, \
283+ - ACTIONS, NULL, NULL, false, STAGE_HINT, \
284+ + ACTIONS, NULL, NULL, false, STAGE_HINT, NULL, \
296285+ OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
297286+
298287+ #define ovn_lflow_add_with_kube_ovn_hint(LFLOW_TABLE, OD, STAGE, PRIORITY, \
299288+ MATCH, ACTIONS, STAGE_HINT, \
300289+ LFLOW_REF) \
301290+ lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
302- + ACTIONS, NULL, NULL, STAGE_HINT, \
291+ + ACTIONS, NULL, NULL, false, STAGE_HINT, \
303292+ OVN_LFLOW_HINT_KUBE_OVN_SKIP_CT, \
304293 OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
305294
306295 #define ovn_lflow_add_with_dp_group(LFLOW_TABLE, DP_BITMAP, DP_BITMAP_LEN, \
307- @@ -105 ,7 +113 ,7 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,
296+ @@ -106 ,7 +115 ,7 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,
308297 STAGE_HINT, LFLOW_REF) \
309298 lflow_table_add_lflow(LFLOW_TABLE, NULL, DP_BITMAP, DP_BITMAP_LEN, STAGE, \
310- PRIORITY, MATCH, ACTIONS, NULL, NULL, STAGE_HINT , \
311- - OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
312- + NULL, OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
299+ PRIORITY, MATCH, ACTIONS, NULL, NULL, false , \
300+ - STAGE_HINT, OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
301+ + STAGE_HINT, NULL, OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
313302
314303 #define ovn_lflow_add_default_drop(LFLOW_TABLE, OD, STAGE, LFLOW_REF) \
315304 lflow_table_add_lflow_default_drop(LFLOW_TABLE, OD, STAGE, \
316- @@ -126,19 +134,19 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,
305+ @@ -118,7 +127,7 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,
306+ STAGE_HINT, LFLOW_REF) \
307+ lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
308+ ACTIONS, NULL, NULL, ACL_CT_TRANSLATION, \
309+ - STAGE_HINT, OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
310+ + STAGE_HINT, NULL, OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
311+
312+ /* This macro is similar to ovn_lflow_add_with_hint, except that it requires
313+ * the IN_OUT_PORT argument, which tells the lport name that appears in the
314+ @@ -134,19 +143,19 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,
317315 MATCH, ACTIONS, IN_OUT_PORT, \
318316 STAGE_HINT, LFLOW_REF) \
319317 lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
320- - ACTIONS, IN_OUT_PORT, NULL, STAGE_HINT, \
321- + ACTIONS, IN_OUT_PORT, NULL, STAGE_HINT, NULL, \
318+ - ACTIONS, IN_OUT_PORT, NULL, false, STAGE_HINT, \
319+ + ACTIONS, IN_OUT_PORT, NULL, false, STAGE_HINT, NULL, \
322320 OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
323321
324322 #define ovn_lflow_add(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, ACTIONS, \
325323 LFLOW_REF) \
326324 lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
327- - ACTIONS, NULL, NULL, NULL, OVS_SOURCE_LOCATOR , \
328- + ACTIONS, NULL, NULL, NULL , NULL,OVS_SOURCE_LOCATOR , \
329- NULL, LFLOW_REF)
325+ - ACTIONS, NULL, NULL, false, NULL , \
326+ + ACTIONS, NULL, NULL, false , NULL, NULL , \
327+ OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
330328
331329 #define ovn_lflow_add_drop_with_desc(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, \
332330 DESCRIPTION, LFLOW_REF) \
333331 lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
334- - debug_drop_action(), NULL, NULL, NULL, \
335- + debug_drop_action(), NULL, NULL, NULL, NULL, \
332+ - debug_drop_action(), NULL, NULL, false, NULL, \
333+ + debug_drop_action(), NULL, NULL, false, NULL, NULL, \
336334 OVS_SOURCE_LOCATOR, DESCRIPTION, LFLOW_REF)
337335
338336 #define ovn_lflow_add_drop_with_lport_hint_and_desc(LFLOW_TABLE, OD, STAGE, \
339- @@ -146,7 +154,7 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,
340- IN_OUT_PORT, STAGE_HINT, \
337+ @@ -155,7 +164,7 @@ void lflow_table_add_lflow_default_drop(struct lflow_table *,
341338 DESCRIPTION, LFLOW_REF) \
342339 lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
343- - debug_drop_action(), IN_OUT_PORT, NULL, STAGE_HINT, \
344- + debug_drop_action(), IN_OUT_PORT, NULL, STAGE_HINT, NULL, \
345- OVS_SOURCE_LOCATOR, DESCRIPTION, LFLOW_REF)
340+ debug_drop_action(), IN_OUT_PORT, NULL, false, \
341+ - STAGE_HINT, OVS_SOURCE_LOCATOR, DESCRIPTION, \
342+ + STAGE_HINT, NULL, OVS_SOURCE_LOCATOR, DESCRIPTION, \
343+ LFLOW_REF)
346344
347345 #define ovn_lflow_metered(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, ACTIONS, \
0 commit comments