summaryrefslogtreecommitdiff
path: root/zebra/rt_netlink.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-05-02 11:38:06 -0400
committerGitHub <noreply@github.com>2017-05-02 11:38:06 -0400
commitb46be72b4aff1d413e89bc26a70a29934afe9d85 (patch)
treecd556a135211559b7e636db619dbf5257f874e86 /zebra/rt_netlink.c
parent2a23cf9503bf2ff36d3c34308de78618b3196f35 (diff)
parentb2ab6b282ce1569ed348aebe17432094adfe7d24 (diff)
Merge branch 'master' into EIGRP
Diffstat (limited to 'zebra/rt_netlink.c')
-rw-r--r--zebra/rt_netlink.c47
1 files changed, 44 insertions, 3 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index a544593dd6..77f03a2c67 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -103,6 +103,47 @@ struct gw_family_t
union g_addr gate;
};
+static inline int is_selfroute(int proto)
+{
+ if ((proto == RTPROT_BGP) || (proto == RTPROT_OSPF) ||
+ (proto == RTPROT_STATIC) || (proto == RTPROT_ZEBRA) ||
+ (proto == RTPROT_ISIS) || (proto == RTPROT_RIPNG)) {
+ return 1;
+ }
+
+ return 0;
+}
+
+static inline int get_rt_proto(int proto)
+{
+ switch (proto) {
+ case ZEBRA_ROUTE_BGP:
+ proto = RTPROT_BGP;
+ break;
+ case ZEBRA_ROUTE_OSPF:
+ case ZEBRA_ROUTE_OSPF6:
+ proto = RTPROT_OSPF;
+ break;
+ case ZEBRA_ROUTE_STATIC:
+ proto = RTPROT_STATIC;
+ break;
+ case ZEBRA_ROUTE_ISIS:
+ proto = RTPROT_ISIS;
+ break;
+ case ZEBRA_ROUTE_RIP:
+ proto = RTPROT_RIP;
+ break;
+ case ZEBRA_ROUTE_RIPNG:
+ proto = RTPROT_RIPNG;
+ break;
+ default:
+ proto = RTPROT_ZEBRA;
+ break;
+ }
+
+ return proto;
+}
+
/*
Pending: create an efficient table_id (in a tree/hash) based lookup)
*/
@@ -171,7 +212,7 @@ netlink_route_change_read_unicast (struct sockaddr_nl *snl, struct nlmsghdr *h,
return 0;
if (!startup &&
- rtm->rtm_protocol == RTPROT_ZEBRA &&
+ is_selfroute (rtm->rtm_protocol) &&
h->nlmsg_type == RTM_NEWROUTE)
return 0;
@@ -196,7 +237,7 @@ netlink_route_change_read_unicast (struct sockaddr_nl *snl, struct nlmsghdr *h,
}
/* Route which inserted by Zebra. */
- if (rtm->rtm_protocol == RTPROT_ZEBRA)
+ if (is_selfroute(rtm->rtm_protocol))
flags |= ZEBRA_FLAG_SELFROUTE;
if (tb[RTA_OIF])
@@ -1137,7 +1178,7 @@ netlink_route_multipath (int cmd, struct prefix *p, struct prefix *src_p,
req.r.rtm_family = family;
req.r.rtm_dst_len = p->prefixlen;
req.r.rtm_src_len = src_p ? src_p->prefixlen : 0;
- req.r.rtm_protocol = RTPROT_ZEBRA;
+ req.r.rtm_protocol = get_rt_proto(rib->type);
req.r.rtm_scope = RT_SCOPE_UNIVERSE;
if ((rib->flags & ZEBRA_FLAG_BLACKHOLE) || (rib->flags & ZEBRA_FLAG_REJECT))