bgpd: Fix match peer when switching between IPv4/IPv6/interface

Without this patch we MUST follow this sequence:

```
no match peer 10.0.0.1
match peer 2a01::1
```

Otherwise, both IPv4/IPv6 values are set/compiled, thus when printing the
configuration in show running, we see the first one (IPv4).

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit edfc03614f)
This commit is contained in:
Donatas Abraitis 2024-05-16 20:49:56 +03:00 committed by Mergify
parent 90165b9dae
commit 8b6ba46120

View File

@ -5219,27 +5219,23 @@ DEFPY_YANG (match_peer,
nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL); nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
if (addrv4_str) { snprintf(xpath_value, sizeof(xpath_value),
snprintf( "%s/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address",
xpath_value, sizeof(xpath_value), xpath);
"%s/rmap-match-condition/frr-bgp-route-map:peer-ipv4-address", nb_cli_enqueue_change(vty, xpath_value,
xpath); addrv4_str ? NB_OP_MODIFY : NB_OP_DESTROY,
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, addrv4_str);
addrv4_str); snprintf(xpath_value, sizeof(xpath_value),
} else if (addrv6_str) { "%s/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address",
snprintf( xpath);
xpath_value, sizeof(xpath_value), nb_cli_enqueue_change(vty, xpath_value,
"%s/rmap-match-condition/frr-bgp-route-map:peer-ipv6-address", addrv6_str ? NB_OP_MODIFY : NB_OP_DESTROY,
xpath); addrv6_str);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, snprintf(xpath_value, sizeof(xpath_value),
addrv6_str); "%s/rmap-match-condition/frr-bgp-route-map:peer-interface",
} else { xpath);
snprintf( nb_cli_enqueue_change(vty, xpath_value,
xpath_value, sizeof(xpath_value), intf ? NB_OP_MODIFY : NB_OP_DESTROY, intf);
"%s/rmap-match-condition/frr-bgp-route-map:peer-interface",
xpath);
nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, intf);
}
return nb_cli_apply_changes(vty, NULL); return nb_cli_apply_changes(vty, NULL);
} }