]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Fix `match peer` when switching between IPv4/IPv6/interface
authorDonatas Abraitis <donatas@opensourcerouting.org>
Thu, 16 May 2024 17:49:56 +0000 (20:49 +0300)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Mon, 20 May 2024 13:58:59 +0000 (13:58 +0000)
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 edfc03614f0c5e14cffde25afae111908cb3bf30)

bgpd/bgp_routemap.c

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