Skip to content

Commit

Permalink
northd: Fix missig "); " from LB flows
Browse files Browse the repository at this point in the history
Fix missing enclose for LB lflows when both
"ct-no-masked-label" and "ovn-ct-lb-related"
features are set false and the LB is configured
with either "skip_snat" or "force_snat".
Add missing test case for those.

Fixes: cd600de ("northd: Add flag for CT related.")
Signed-off-by: Ales Musil <amusil@redhat.com>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Mark Michelson <mmichels@redhat.com>
  • Loading branch information
almusil authored and putnopvut committed Mar 13, 2023
1 parent c3d8797 commit 002a392
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
8 changes: 4 additions & 4 deletions northd/northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -9965,9 +9965,9 @@ build_lrouter_nat_flows_for_lb(struct ovn_lb_vip *lb_vip,
if (smap_get_bool(&lb->nlb->options, "skip_snat", false)) {
snat_type = SKIP_SNAT;
const char *skip_snat = features->ct_lb_related && !drop
? "; skip_snat);"
? "; skip_snat"
: "";
skip_snat_new_action = xasprintf("flags.skip_snat_for_lb = 1; %s%s",
skip_snat_new_action = xasprintf("flags.skip_snat_for_lb = 1; %s%s);",
ds_cstr(action), skip_snat);
skip_snat_est_action = xasprintf("flags.skip_snat_for_lb = 1; "
"next;");
Expand Down Expand Up @@ -10029,9 +10029,9 @@ build_lrouter_nat_flows_for_lb(struct ovn_lb_vip *lb_vip,
}

const char *force_snat = features->ct_lb_related && !drop
? "; force_snat);"
? "; force_snat"
: "";
force_snat_new_action = xasprintf("flags.force_snat_for_lb = 1; %s%s",
force_snat_new_action = xasprintf("flags.force_snat_for_lb = 1; %s%s);",
ds_cstr(action), force_snat);
if (!drop) {
ds_put_cstr(action, ");");
Expand Down
32 changes: 32 additions & 0 deletions tests/ovn-northd.at
Original file line number Diff line number Diff line change
Expand Up @@ -6554,6 +6554,22 @@ AT_CHECK([ovn-sbctl lflow-list | grep -e natted -e ct_lb], [0], [dnl
table=2 (ls_out_pre_stateful), priority=110 , match=(reg0[[2]] == 1), action=(ct_lb;)
])

check ovn-nbctl --wait=sb set logical_router lr options:lb_force_snat_ip="42.42.42.1"
AT_CHECK([ovn-sbctl lflow-list | grep lr_in_dnat], [0], [dnl
table=6 (lr_in_dnat ), priority=110 , match=(ct.est && !ct.rel && ip4 && reg0 == 66.66.66.66 && ct_label.natted == 1), action=(flags.force_snat_for_lb = 1; next;)
table=6 (lr_in_dnat ), priority=110 , match=(ct.new && !ct.rel && ip4 && reg0 == 66.66.66.66), action=(flags.force_snat_for_lb = 1; ct_lb(backends=42.42.42.2);)
table=6 (lr_in_dnat ), priority=0 , match=(1), action=(next;)
])
check ovn-nbctl remove logical_router lr options lb_force_snat_ip

check ovn-nbctl --wait=sb set load_balancer lb-test options:skip_snat="true"
AT_CHECK([ovn-sbctl lflow-list | grep lr_in_dnat], [0], [dnl
table=6 (lr_in_dnat ), priority=110 , match=(ct.est && !ct.rel && ip4 && reg0 == 66.66.66.66 && ct_label.natted == 1), action=(flags.skip_snat_for_lb = 1; next;)
table=6 (lr_in_dnat ), priority=110 , match=(ct.new && !ct.rel && ip4 && reg0 == 66.66.66.66), action=(flags.skip_snat_for_lb = 1; ct_lb(backends=42.42.42.2);)
table=6 (lr_in_dnat ), priority=0 , match=(1), action=(next;)
])
check ovn-nbctl remove load_balancer lb-test options skip_snat

AS_BOX([Chassis upgrades and supports ct_lb_mark - use ct_lb_mark and ct_mark.natted])
check ovn-sbctl set chassis hv other_config:ct-no-masked-label=true
check ovn-nbctl --wait=sb sync
Expand Down Expand Up @@ -6703,6 +6719,22 @@ AT_CHECK([grep -e "lr_in_defrag" -e "lr_in_dnat" lflows1], [0], [dnl
table=? (lr_in_dnat ), priority=110 , match=(ct.new && !ct.rel && ip4 && reg0 == 192.168.0.1), action=(ct_lb(backends=192.168.1.10);)
])

check ovn-nbctl --wait=sb set logical_router lr options:lb_force_snat_ip="192.168.1.1"
AT_CHECK([ovn-sbctl lflow-list | grep lr_in_dnat], [0], [dnl
table=7 (lr_in_dnat ), priority=110 , match=(ct.est && !ct.rel && ip4 && reg0 == 192.168.0.1 && ct_label.natted == 1), action=(flags.force_snat_for_lb = 1; next;)
table=7 (lr_in_dnat ), priority=110 , match=(ct.new && !ct.rel && ip4 && reg0 == 192.168.0.1), action=(flags.force_snat_for_lb = 1; ct_lb(backends=192.168.1.10);)
table=7 (lr_in_dnat ), priority=0 , match=(1), action=(next;)
])
check ovn-nbctl remove logical_router lr options lb_force_snat_ip

check ovn-nbctl --wait=sb set load_balancer lb-test options:skip_snat="true"
AT_CHECK([ovn-sbctl lflow-list | grep lr_in_dnat], [0], [dnl
table=7 (lr_in_dnat ), priority=110 , match=(ct.est && !ct.rel && ip4 && reg0 == 192.168.0.1 && ct_label.natted == 1), action=(flags.skip_snat_for_lb = 1; next;)
table=7 (lr_in_dnat ), priority=110 , match=(ct.new && !ct.rel && ip4 && reg0 == 192.168.0.1), action=(flags.skip_snat_for_lb = 1; ct_lb(backends=192.168.1.10);)
table=7 (lr_in_dnat ), priority=0 , match=(1), action=(next;)
])
check ovn-nbctl remove load_balancer lb-test options skip_snat

AT_CHECK([grep -e "ls_in_acl" -e "ls_out_acl" lflows1 | grep "priority=65532"], [0], [dnl
table=? (ls_in_acl ), priority=65532, match=(!ct.est && ct.rel && !ct.new && !ct.inv && ct_label.blocked == 0), action=(next;)
table=? (ls_in_acl ), priority=65532, match=(ct.est && !ct.rel && !ct.new && !ct.inv && ct.rpl && ct_label.blocked == 0), action=(reg0[[9]] = 0; reg0[[10]] = 0; next;)
Expand Down

0 comments on commit 002a392

Please sign in to comment.