]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: small simplification for evpn RT commands 10888/head
authoranlan_cs <vic.lan@pica8.com>
Sat, 26 Mar 2022 04:09:27 +0000 (12:09 +0800)
committeranlan_cs <vic.lan@pica8.com>
Sun, 27 Mar 2022 05:02:05 +0000 (13:02 +0800)
Small simplification for evpn RT commands, i.e. both per-VRF
and per-VNI - `bgp_evpn_vrf_rt_cmd` and `bgp_evpn_vni_rt_cmd`.

Just extract the duplicated code as a common code, there are
no functional changes.

Additionally correct one comment for `ecommunity_free()`.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
bgpd/bgp_ecommunity.c
bgpd/bgp_evpn_vty.c

index 5a053a7f34f40cd651b17c0e031ca724319d2556..08caa24a1bbfac6fa92e62871056b16519d49a5b 100644 (file)
@@ -63,7 +63,7 @@ void ecommunity_strfree(char **s)
        XFREE(MTYPE_ECOMMUNITY_STR, *s);
 }
 
-/* Allocate ecommunities.  */
+/* Free ecommunities.  */
 void ecommunity_free(struct ecommunity **ecom)
 {
        if (!(*ecom))
index 4da3fa8f3b2c0542f8a46177d60fd8f678bde0a9..5f519e84ed3f268831e9a8c658dafe8e3d87d43e 100644 (file)
@@ -5858,16 +5858,15 @@ DEFUN (bgp_evpn_vrf_rt,
                return CMD_WARNING;
        }
 
+       ecomadd = ecommunity_str2com(argv[2]->arg, ECOMMUNITY_ROUTE_TARGET, 0);
+       if (!ecomadd) {
+               vty_out(vty, "%% Malformed Route Target list\n");
+               return CMD_WARNING;
+       }
+       ecommunity_str(ecomadd);
+
        /* Add/update the import route-target */
        if (rt_type == RT_TYPE_BOTH || rt_type == RT_TYPE_IMPORT) {
-               ecomadd = ecommunity_str2com(argv[2]->arg,
-                                            ECOMMUNITY_ROUTE_TARGET, 0);
-               if (!ecomadd) {
-                       vty_out(vty, "%% Malformed Route Target list\n");
-                       return CMD_WARNING;
-               }
-               ecommunity_str(ecomadd);
-
                /* Do nothing if we already have this import route-target */
                if (!bgp_evpn_rt_matches_existing(bgp->vrf_import_rtl, ecomadd))
                        bgp_evpn_configure_import_rt_for_vrf(bgp, ecomadd);
@@ -5875,14 +5874,6 @@ DEFUN (bgp_evpn_vrf_rt,
 
        /* Add/update the export route-target */
        if (rt_type == RT_TYPE_BOTH || rt_type == RT_TYPE_EXPORT) {
-               ecomadd = ecommunity_str2com(argv[2]->arg,
-                                            ECOMMUNITY_ROUTE_TARGET, 0);
-               if (!ecomadd) {
-                       vty_out(vty, "%% Malformed Route Target list\n");
-                       return CMD_WARNING;
-               }
-               ecommunity_str(ecomadd);
-
                /* Do nothing if we already have this export route-target */
                if (!bgp_evpn_rt_matches_existing(bgp->vrf_export_rtl, ecomadd))
                        bgp_evpn_configure_export_rt_for_vrf(bgp, ecomadd);
@@ -6107,16 +6098,15 @@ DEFUN (bgp_evpn_vni_rt,
                return CMD_WARNING;
        }
 
+       ecomadd = ecommunity_str2com(argv[2]->arg, ECOMMUNITY_ROUTE_TARGET, 0);
+       if (!ecomadd) {
+               vty_out(vty, "%% Malformed Route Target list\n");
+               return CMD_WARNING;
+       }
+       ecommunity_str(ecomadd);
+
        /* Add/update the import route-target */
        if (rt_type == RT_TYPE_BOTH || rt_type == RT_TYPE_IMPORT) {
-               ecomadd = ecommunity_str2com(argv[2]->arg,
-                                            ECOMMUNITY_ROUTE_TARGET, 0);
-               if (!ecomadd) {
-                       vty_out(vty, "%% Malformed Route Target list\n");
-                       return CMD_WARNING;
-               }
-               ecommunity_str(ecomadd);
-
                /* Do nothing if we already have this import route-target */
                if (!bgp_evpn_rt_matches_existing(vpn->import_rtl, ecomadd))
                        evpn_configure_import_rt(bgp, vpn, ecomadd);
@@ -6124,14 +6114,6 @@ DEFUN (bgp_evpn_vni_rt,
 
        /* Add/update the export route-target */
        if (rt_type == RT_TYPE_BOTH || rt_type == RT_TYPE_EXPORT) {
-               ecomadd = ecommunity_str2com(argv[2]->arg,
-                                            ECOMMUNITY_ROUTE_TARGET, 0);
-               if (!ecomadd) {
-                       vty_out(vty, "%% Malformed Route Target list\n");
-                       return CMD_WARNING;
-               }
-               ecommunity_str(ecomadd);
-
                /* Do nothing if we already have this export route-target */
                if (!bgp_evpn_rt_matches_existing(vpn->export_rtl, ecomadd))
                        evpn_configure_export_rt(bgp, vpn, ecomadd);