]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_fpm_netlink.c
Merge pull request #3384 from donaldsharp/topotests
[mirror_frr.git] / zebra / zebra_fpm_netlink.c
index 28f795663939aa4250cba15bb3174be33c294266..207cbc0992221a9c2de839ff69a7cf9c23467813 100644 (file)
@@ -32,6 +32,7 @@
 #include "prefix.h"
 
 #include "zebra/zserv.h"
+#include "zebra/zebra_dplane.h"
 #include "zebra/zebra_ns.h"
 #include "zebra/zebra_vrf.h"
 #include "zebra/kernel_netlink.h"
@@ -45,7 +46,7 @@
  *
  * Returns string representation of an address of the given AF.
  */
-static inline const char *addr_to_a(u_char af, void *addr)
+static inline const char *addr_to_a(uint8_t af, void *addr)
 {
        if (!addr)
                return "<No address>";
@@ -83,7 +84,7 @@ static const char *prefix_addr_to_a(struct prefix *prefix)
  *
  * The size of an address in a given address family.
  */
-static size_t af_addr_size(u_char af)
+static size_t af_addr_size(uint8_t af)
 {
        switch (af) {
 
@@ -125,10 +126,10 @@ typedef struct netlink_nh_info_t_ {
  */
 typedef struct netlink_route_info_t_ {
        uint16_t nlmsg_type;
-       u_char rtm_type;
+       uint8_t rtm_type;
        uint32_t rtm_table;
-       u_char rtm_protocol;
-       u_char af;
+       uint8_t rtm_protocol;
+       uint8_t af;
        struct prefix *prefix;
        uint32_t *metric;
        unsigned int num_nhs;
@@ -199,7 +200,7 @@ static int netlink_route_info_add_nh(netlink_route_info_t *ri,
 /*
  * netlink_proto_from_route_type
  */
-static u_char netlink_proto_from_route_type(int type)
+static uint8_t netlink_proto_from_route_type(int type)
 {
        switch (type) {
        case ZEBRA_ROUTE_KERNEL:
@@ -222,7 +223,6 @@ static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd,
                                   rib_dest_t *dest, struct route_entry *re)
 {
        struct nexthop *nexthop;
-       int discard;
 
        memset(ri, 0, sizeof(*ri));
 
@@ -247,37 +247,32 @@ static int netlink_route_info_fill(netlink_route_info_t *ri, int cmd,
        }
 
        ri->rtm_protocol = netlink_proto_from_route_type(re->type);
-
-       if ((re->flags & ZEBRA_FLAG_BLACKHOLE)
-           || (re->flags & ZEBRA_FLAG_REJECT))
-               discard = 1;
-       else
-               discard = 0;
-
-       if (cmd == RTM_NEWROUTE) {
-               if (discard) {
-                       if (re->flags & ZEBRA_FLAG_BLACKHOLE)
-                               ri->rtm_type = RTN_BLACKHOLE;
-                       else if (re->flags & ZEBRA_FLAG_REJECT)
-                               ri->rtm_type = RTN_UNREACHABLE;
-                       else
-                               assert(0);
-               } else
-                       ri->rtm_type = RTN_UNICAST;
-       }
-
+       ri->rtm_type = RTN_UNICAST;
        ri->metric = &re->metric;
 
-       if (discard)
-               return 1;
-
-       for (ALL_NEXTHOPS(re->nexthop, nexthop)) {
+       for (ALL_NEXTHOPS(re->ng, nexthop)) {
                if (ri->num_nhs >= multipath_num)
                        break;
 
                if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_RECURSIVE))
                        continue;
 
+               if (nexthop->type == NEXTHOP_TYPE_BLACKHOLE) {
+                       switch (nexthop->bh_type) {
+                       case BLACKHOLE_ADMINPROHIB:
+                               ri->rtm_type = RTN_PROHIBIT;
+                               break;
+                       case BLACKHOLE_REJECT:
+                               ri->rtm_type = RTN_UNREACHABLE;
+                               break;
+                       case BLACKHOLE_NULL:
+                       default:
+                               ri->rtm_type = RTN_BLACKHOLE;
+                               break;
+                       }
+                       return 1;
+               }
+
                if ((cmd == RTM_NEWROUTE
                     && CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
                    || (cmd == RTM_DELROUTE