Skip to content

Commit

Permalink
support dedicated bfd lrp
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian committed Nov 1, 2024
1 parent df87e13 commit e49bd4b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
5 changes: 3 additions & 2 deletions controller/pinctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1392,14 +1392,15 @@ prepare_ipv6_prefixd(struct ovsdb_idl_txn *ovnsb_idl_txn,
continue;
}

bool bfd_only = smap_get_bool(&pb->options, "bfd_only", false);
const char *peer_s = smap_get(&pb->options, "peer");
if (!peer_s) {
if (!peer_s && !bfd_only) {
continue;
}

const struct sbrec_port_binding *peer
= lport_lookup_by_name(sbrec_port_binding_by_name, peer_s);
if (!peer) {
if (!peer && !bfd_only) {
continue;
}

Expand Down
30 changes: 26 additions & 4 deletions northd/northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2996,6 +2996,17 @@ ovn_port_update_sbrec(struct ovsdb_idl_txn *ovnsb_txn,
/* Delete the legacy gateway_chassis from the pb. */
sbrec_port_binding_set_gateway_chassis(op->sb, NULL, 0);
}
} else {
struct smap options;
smap_clone(&options, &op->sb->options);
const char *bfd_only = smap_get(&op->nbrp->options, "bfd-only");
if (bfd_only) {
smap_replace(&options, "bfd-only", bfd_only);
} else {
smap_remove(&options, "bfd-only");
}
sbrec_port_binding_set_options(op->sb, &options);
smap_destroy(&options);
}

sbrec_port_binding_set_parent_port(op->sb, NULL);
Expand Down Expand Up @@ -3885,6 +3896,11 @@ sync_pb_for_lrp(struct ovn_port *op,
smap_add(&new, "always-redirect", "true");
}
} else {
const char *bfd_only = smap_get(&op->nbrp->options, "bfd_only");
if (bfd_only) {
smap_add(&new, "bfd_only", bfd_only);
}

if (op->peer) {
smap_add(&new, "peer", op->peer->key);
if (op->nbrp->ha_chassis_group ||
Expand Down Expand Up @@ -10259,6 +10275,7 @@ static struct ovs_mutex bfd_lock = OVS_MUTEX_INITIALIZER;

static bool check_bfd_state(
const struct nbrec_logical_router_policy *rule,
const struct hmap *lr_ports,
const struct hmap *bfd_connections,
struct ovn_port *out_port,
const char *nexthop)
Expand All @@ -10284,7 +10301,11 @@ static bool check_bfd_state(
}

if (strcmp(nb_bt->logical_port, out_port->key)) {
continue;
struct ovn_port *op = ovn_port_find(lr_ports, nb_bt->logical_port);
if (!op || !op->nbrp ||
!smap_get_bool(&op->nbrp->options, "bfd_only", false)) {
continue;
}
}

struct bfd_entry *bfd_e = bfd_port_lookup(bfd_connections,
Expand Down Expand Up @@ -10338,7 +10359,8 @@ build_routing_policy_flow(struct lflow_table *lflows, struct ovn_datapath *od,
return;
}

if (!check_bfd_state(rule, bfd_connections, out_port, nexthop)) {
if (!check_bfd_state(rule, lr_ports, bfd_connections,
out_port, nexthop)) {
return;
}

Expand Down Expand Up @@ -10435,8 +10457,8 @@ build_ecmp_routing_policy_flows(struct lflow_table *lflows,
goto cleanup;
}

if (!check_bfd_state(rule, bfd_connections, out_port,
rule->nexthops[i])) {
if (!check_bfd_state(rule, lr_ports, bfd_connections,
out_port, rule->nexthops[i])) {
continue;
}

Expand Down

0 comments on commit e49bd4b

Please sign in to comment.