]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: display static blackhole routes consistently
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 1 Sep 2017 17:43:24 +0000 (14:43 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Tue, 5 Sep 2017 14:50:34 +0000 (11:50 -0300)
If we configure a static route pointing to null0 and zebra displays
it with the 'blackhole' keyword in the running configuration, the
frr-reload.py script will have issues. Fix this by introducing the
'static_blackhole_type' enum.

Fixes #1091.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
zebra/zebra_static.c
zebra/zebra_static.h
zebra/zebra_vty.c

index ec6d4063255554049cba3e91f31c76a4526cf3ad..658f060fff39d16a241b7cdffa2869341de7bcd3 100644 (file)
@@ -45,6 +45,7 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
        struct route_table *table;
        struct prefix nh_p;
        struct nexthop *nexthop = NULL;
+       enum blackhole_type bh_type = 0;
 
        /* Lookup table.  */
        table = zebra_vrf_table(afi, safi, si->vrf_id);
@@ -52,6 +53,17 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
                return;
 
        memset(&nh_p, 0, sizeof(nh_p));
+       if (si->type == STATIC_BLACKHOLE) {
+               switch (si->bh_type) {
+               case STATIC_BLACKHOLE_DROP:
+               case STATIC_BLACKHOLE_NULL:
+                       bh_type = BLACKHOLE_NULL;
+                       break;
+               case STATIC_BLACKHOLE_REJECT:
+                       bh_type = BLACKHOLE_REJECT;
+                       break;
+               }
+       }
 
        /* Lookup existing route */
        rn = srcdest_rnode_get(table, p, src_p);
@@ -92,7 +104,7 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
                        break;
                case STATIC_BLACKHOLE:
                        nexthop = route_entry_nexthop_blackhole_add(
-                               re, si->bh_type);
+                               re, bh_type);
                        break;
                case STATIC_IPV6_GATEWAY:
                        nexthop = route_entry_nexthop_ipv6_add(re,
@@ -168,7 +180,7 @@ void static_install_route(afi_t afi, safi_t safi, struct prefix *p,
                        break;
                case STATIC_BLACKHOLE:
                        nexthop = route_entry_nexthop_blackhole_add(
-                               re, si->bh_type);
+                               re, bh_type);
                        break;
                case STATIC_IPV6_GATEWAY:
                        nexthop = route_entry_nexthop_ipv6_add(re,
@@ -363,7 +375,7 @@ void static_uninstall_route(afi_t afi, safi_t safi, struct prefix *p,
 
 int static_add_route(afi_t afi, safi_t safi, u_char type, struct prefix *p,
                     struct prefix_ipv6 *src_p, union g_addr *gate,
-                    const char *ifname, enum blackhole_type bh_type,
+                    const char *ifname, enum static_blackhole_type bh_type,
                     route_tag_t tag, u_char distance, struct zebra_vrf *zvrf,
                     struct static_nh_label *snh_label)
 {
index 458594a28951edea3cbae5c8971ee9c8fa7ed995..68fe73b0a348971c377d91f972769f75b0b23b30 100644 (file)
@@ -31,6 +31,12 @@ struct static_nh_label {
        mpls_label_t label[MPLS_MAX_LABELS];
 };
 
+enum static_blackhole_type {
+       STATIC_BLACKHOLE_DROP = 0,
+       STATIC_BLACKHOLE_NULL,
+       STATIC_BLACKHOLE_REJECT
+};
+
 typedef enum {
        STATIC_IFNAME,
        STATIC_IPV4_GATEWAY,
@@ -61,7 +67,7 @@ struct static_route {
        /*
         * Nexthop value.
         */
-       enum blackhole_type bh_type;
+       enum static_blackhole_type bh_type;
        union g_addr addr;
        ifindex_t ifindex;
 
@@ -80,9 +86,9 @@ extern void static_uninstall_route(afi_t afi, safi_t safi, struct prefix *p,
 
 extern int static_add_route(afi_t, safi_t safi, u_char type, struct prefix *p,
                            struct prefix_ipv6 *src_p, union g_addr *gate,
-                           const char *ifname, enum blackhole_type bh_type,
-                           route_tag_t tag, u_char distance,
-                           struct zebra_vrf *zvrf,
+                           const char *ifname,
+                           enum static_blackhole_type bh_type, route_tag_t tag,
+                           u_char distance, struct zebra_vrf *zvrf,
                            struct static_nh_label *snh_label);
 
 extern int static_delete_route(afi_t, safi_t safi, u_char type,
index 95ba19b1f62b535e4fffc46f8c92fafd5bdbb30f..3141782c57e90dc5fa8a34c5c2e352cb28d4b827 100644 (file)
@@ -74,7 +74,7 @@ static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,
        union g_addr gate;
        union g_addr *gatep = NULL;
        struct in_addr mask;
-       enum blackhole_type bh_type = 0;
+       enum static_blackhole_type bh_type = 0;
        route_tag_t tag = 0;
        struct zebra_vrf *zvrf;
        u_char type;
@@ -169,14 +169,13 @@ static int zebra_static_route(struct vty *vty, afi_t afi, safi_t safi,
        if (flag_str) {
                switch (flag_str[0]) {
                case 'r':
-               case 'R': /* XXX */
-                       bh_type = BLACKHOLE_REJECT;
+                       bh_type = STATIC_BLACKHOLE_REJECT;
                        break;
                case 'n':
-               case 'N' /* XXX */:
+                       bh_type = STATIC_BLACKHOLE_NULL;
+                       break;
                case 'b':
-               case 'B': /* XXX */
-                       bh_type = BLACKHOLE_NULL;
+                       bh_type = STATIC_BLACKHOLE_DROP;
                        break;
                default:
                        vty_out(vty, "%% Malformed flag %s \n", flag_str);
@@ -1712,12 +1711,15 @@ static int static_config(struct vty *vty, afi_t afi, safi_t safi,
                                        break;
                                case STATIC_BLACKHOLE:
                                        switch (si->bh_type) {
-                                       case BLACKHOLE_REJECT:
-                                               vty_out(vty, " reject");
-                                               break;
-                                       default:
+                                       case STATIC_BLACKHOLE_DROP:
                                                vty_out(vty, " blackhole");
                                                break;
+                                       case STATIC_BLACKHOLE_NULL:
+                                               vty_out(vty, " null0");
+                                               break;
+                                       case STATIC_BLACKHOLE_REJECT:
+                                               vty_out(vty, " reject");
+                                               break;
                                        }
                                        break;
                                case STATIC_IPV4_GATEWAY_IFNAME: