#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"
*
* 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>";
*
* 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) {
*/
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;
/*
* 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:
rib_dest_t *dest, struct route_entry *re)
{
struct nexthop *nexthop;
- int discard;
memset(ri, 0, sizeof(*ri));
}
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