Skip to content

Commit

Permalink
northd: Fix issues for Forwarding_Group.
Browse files Browse the repository at this point in the history
The use of variables from the outer loop in the inner
loop causes the outer loop to terminate prematurely.
eg. LVS are three fwgs, fwg1(p1,p2,p3,p4),fwg2(p11,p22),
fwg3(p31,p32),only fwg1 in logical_flows.

Submitted-at: ovn-org#250
Signed-off-by: zhangqiang45 <zhangqiang45@lenovo.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
(cherry picked from commit b64c564)
  • Loading branch information
zhangqiang45 authored and numansiddique committed Jul 22, 2024
1 parent aa4cd0c commit 3cbd4d8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ xushengping shengping.xu@huawei.com
yinpeijun yinpeijun@huawei.com
zangchuanqiang zangchuanqiang@huawei.com
zhang yanxian zhangyanxian@pmlabs.com.cn
zhangqiang45 zhangqiang45@lenovo.com
zhaojingjing zhao.jingjing1@zte.com.cn
zhongbaisong zhongbaisong@huawei.com
zhaozhanxu zhaozhanxu@163.com
Expand Down
9 changes: 6 additions & 3 deletions northd/northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -8930,13 +8930,16 @@ build_fwd_group_lflows(struct ovn_datapath *od, struct hmap *lflows)
struct ds actions = DS_EMPTY_INITIALIZER;
struct ds group_ports = DS_EMPTY_INITIALIZER;

for (int i = 0; i < od->nbs->n_forwarding_groups; ++i) {
for (size_t i = 0; i < od->nbs->n_forwarding_groups; ++i) {
const struct nbrec_forwarding_group *fwd_group = NULL;
fwd_group = od->nbs->forwarding_groups[i];
if (!fwd_group->n_child_port) {
continue;
}

ds_clear(&match);
ds_clear(&actions);

/* ARP responder for the forwarding group's virtual IP */
ds_put_format(&match, "arp.tpa == %s && arp.op == 1",
fwd_group->vip);
Expand Down Expand Up @@ -8967,9 +8970,9 @@ build_fwd_group_lflows(struct ovn_datapath *od, struct hmap *lflows)
ds_put_cstr(&group_ports, "liveness=\"true\",");
}
ds_put_cstr(&group_ports, "childports=");
for (i = 0; i < (fwd_group->n_child_port - 1); ++i) {
for (size_t j = 0; j < (fwd_group->n_child_port - 1); ++j) {
ds_put_format(&group_ports, "\"%s\",",
fwd_group->child_port[i]);
fwd_group->child_port[j]);
}
ds_put_format(&group_ports, "\"%s\"",
fwd_group->child_port[fwd_group->n_child_port - 1]);
Expand Down
7 changes: 7 additions & 0 deletions tests/ovn.at
Original file line number Diff line number Diff line change
Expand Up @@ -27421,7 +27421,14 @@ check ovs-vsctl add-port br-int vif3 -- set Interface vif3 external-ids:iface-id
# Add a forwarding group on ls2 with lsp21 and lsp22 as child ports
# virtual IP - 172.16.1.11, virtual MAC - 00:11:de:ad:be:ef
check ovn-nbctl --wait=hv fwd-group-add fwd_grp1 ls2 172.16.1.11 00:11:de:ad:be:ef lsp21 lsp22
check ovn-nbctl --wait=hv fwd-group-add fwd_grp2 ls2 172.16.2.11 00:22:de:ad:be:ef lsp21 lsp22

# Check logical flow
AT_CAPTURE_FILE([sbflows])
ovn-sbctl dump-flows > sbflows
AT_CHECK([grep ls_in_l2_lkup sbflows | grep fwd_group | wc -l], [0], [2
])
check ovn-nbctl --wait=hv fwd-group-del fwd_grp2
# Check logical flow
AT_CAPTURE_FILE([sbflows])
ovn-sbctl dump-flows > sbflows
Expand Down

0 comments on commit 3cbd4d8

Please sign in to comment.