summaryrefslogtreecommitdiff
path: root/zebra/rt_netlink.c
diff options
context:
space:
mode:
authorNaveen Naidu <naveennaidu479@gmail.com>2020-03-11 23:50:41 +0530
committerNaveen Naidu <naveennaidu479@gmail.com>2020-03-12 00:37:21 +0530
commit6a6d11a33bf6cadc00d394557f4d289129c64daa (patch)
treebb5dba6ff16393d476bfe4db1059750dbfef47b2 /zebra/rt_netlink.c
parent2ff6f38eaa6ec6bbc3c94950370ceee04023a318 (diff)
zebra/rt_netlink.c: Clean is_selfroute function
The return type of is_selfroute function is changed from int to bool. Also remove the redundant invoking of the is_selfroute function in the calling function netlink_route_change_read_unicast Fixes: https://github.com/FRRouting/frr/issues/5984 Signed-off-by: Naveen Naidu <naveennaidu479@gmail.com>
Diffstat (limited to 'zebra/rt_netlink.c')
-rw-r--r--zebra/rt_netlink.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 7011342ab4..5a0c1599c9 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -142,7 +142,7 @@ static uint16_t neigh_state_to_netlink(uint16_t dplane_state)
}
-static inline int is_selfroute(int proto)
+static inline bool is_selfroute(int proto)
{
if ((proto == RTPROT_BGP) || (proto == RTPROT_OSPF)
|| (proto == RTPROT_ZSTATIC) || (proto == RTPROT_ZEBRA)
@@ -151,10 +151,10 @@ static inline int is_selfroute(int proto)
|| (proto == RTPROT_LDP) || (proto == RTPROT_BABEL)
|| (proto == RTPROT_RIP) || (proto == RTPROT_SHARP)
|| (proto == RTPROT_PBR) || (proto == RTPROT_OPENFABRIC)) {
- return 1;
+ return true;
}
- return 0;
+ return false;
}
static inline int zebra2proto(int proto)
@@ -513,6 +513,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
struct prefix p;
struct prefix_ipv6 src_p = {};
vrf_id_t vrf_id;
+ bool selfroute;
char anyaddr[16] = {0};
@@ -574,8 +575,9 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
if (rtm->rtm_protocol == RTPROT_KERNEL)
return 0;
- if (!startup && is_selfroute(rtm->rtm_protocol)
- && h->nlmsg_type == RTM_NEWROUTE) {
+ selfroute = is_selfroute(rtm->rtm_protocol);
+
+ if (!startup && selfroute && h->nlmsg_type == RTM_NEWROUTE) {
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("Route type: %d Received that we think we have originated, ignoring",
rtm->rtm_protocol);
@@ -602,7 +604,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id,
}
/* Route which inserted by Zebra. */
- if (is_selfroute(rtm->rtm_protocol)) {
+ if (selfroute) {
flags |= ZEBRA_FLAG_SELFROUTE;
proto = proto2zebra(rtm->rtm_protocol, rtm->rtm_family, false);
}