summaryrefslogtreecommitdiff
path: root/zebra/zserv.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2016-10-06 09:18:41 -0300
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-10-18 08:51:23 -0400
commit9c6060d47a78c709db94bf975e8abcaa96daae1c (patch)
tree46c0692e5bcaa6addce32e785fd52da8d5a6e448 /zebra/zserv.c
parent83c6557494a13fb549079eb290f81d4994e28f3f (diff)
zebra: cleanup redistribution code
Remove code duplication and reduce excessive indentation levels whenever possible. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'zebra/zserv.c')
-rw-r--r--zebra/zserv.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/zebra/zserv.c b/zebra/zserv.c
index da52f93a28..18076fb62d 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -599,9 +599,11 @@ zsend_interface_update (int cmd, struct zserv *client, struct interface *ifp)
* all the nexthops.
*/
int
-zsend_redistribute_route (int cmd, struct zserv *client, struct prefix *p,
+zsend_redistribute_route (int add, struct zserv *client, struct prefix *p,
struct rib *rib)
{
+ afi_t afi;
+ int cmd;
int psize;
struct stream *s;
struct nexthop *nexthop;
@@ -610,6 +612,40 @@ zsend_redistribute_route (int cmd, struct zserv *client, struct prefix *p,
u_char zapi_flags = 0;
struct nexthop dummy_nh;
+ afi = family2afi (p->family);
+ if (add)
+ {
+ switch (afi)
+ {
+ case AFI_IP:
+ cmd = ZEBRA_REDISTRIBUTE_IPV4_ADD;
+ client->redist_v4_add_cnt++;
+ break;
+ case AFI_IP6:
+ cmd = ZEBRA_REDISTRIBUTE_IPV6_ADD;
+ client->redist_v6_add_cnt++;
+ break;
+ default:
+ return -1;
+ }
+ }
+ else
+ {
+ switch (afi)
+ {
+ case AFI_IP:
+ cmd = ZEBRA_REDISTRIBUTE_IPV4_DEL;
+ client->redist_v4_del_cnt++;
+ break;
+ case AFI_IP6:
+ cmd = ZEBRA_REDISTRIBUTE_IPV6_DEL;
+ client->redist_v6_del_cnt++;
+ break;
+ default:
+ return -1;
+ }
+ }
+
/* Came from VRF lib patch, is this really needed? callers of this routine
do check for redist.., so may be its not needed.
Check this client need this route.