@@ -205,6 +205,15 @@ static int route_notify_owner(ZAPI_CALLBACK_ARGS)
205205static void zebra_connected (struct zclient * zclient )
206206{
207207 zclient_send_reg_requests (zclient , VRF_DEFAULT );
208+
209+ /*
210+ * Do not actually turn this on yet
211+ * This is just the start of the infrastructure needed here
212+ * This can be fixed at a later time.
213+ *
214+ * zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
215+ * ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT);
216+ */
208217}
209218
210219void vrf_label_add (vrf_id_t vrf_id , afi_t afi , mpls_label_t label )
@@ -300,28 +309,13 @@ void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import,
300309 __PRETTY_FUNCTION__ );
301310}
302311
303- static int sharp_nexthop_update ( ZAPI_CALLBACK_ARGS )
312+ static int sharp_debug_nexthops ( struct zapi_route * api )
304313{
305- struct sharp_nh_tracker * nht ;
306- struct zapi_route nhr ;
307- char buf [PREFIX_STRLEN ];
308314 int i ;
315+ char buf [PREFIX_STRLEN ];
309316
310- if (!zapi_nexthop_update_decode (zclient -> ibuf , & nhr )) {
311- zlog_warn ("%s: Decode of update failed" , __PRETTY_FUNCTION__ );
312-
313- return 0 ;
314- }
315-
316- zlog_debug ("Received update for %s" ,
317- prefix2str (& nhr .prefix , buf , sizeof (buf )));
318-
319- nht = sharp_nh_tracker_get (& nhr .prefix );
320- nht -> nhop_num = nhr .nexthop_num ;
321- nht -> updates ++ ;
322-
323- for (i = 0 ; i < nhr .nexthop_num ; i ++ ) {
324- struct zapi_nexthop * znh = & nhr .nexthops [i ];
317+ for (i = 0 ; i < api -> nexthop_num ; i ++ ) {
318+ struct zapi_nexthop * znh = & api -> nexthops [i ];
325319
326320 switch (znh -> type ) {
327321 case NEXTHOP_TYPE_IPV4_IFINDEX :
@@ -351,6 +345,45 @@ static int sharp_nexthop_update(ZAPI_CALLBACK_ARGS)
351345 break ;
352346 }
353347 }
348+
349+ return i ;
350+ }
351+ static int sharp_nexthop_update (ZAPI_CALLBACK_ARGS )
352+ {
353+ struct sharp_nh_tracker * nht ;
354+ struct zapi_route nhr ;
355+
356+ if (!zapi_nexthop_update_decode (zclient -> ibuf , & nhr )) {
357+ zlog_warn ("%s: Decode of update failed" , __PRETTY_FUNCTION__ );
358+
359+ return 0 ;
360+ }
361+
362+ zlog_debug ("Received update for %pFX" , & nhr .prefix );
363+
364+ nht = sharp_nh_tracker_get (& nhr .prefix );
365+ nht -> nhop_num = nhr .nexthop_num ;
366+ nht -> updates ++ ;
367+
368+ sharp_debug_nexthops (& nhr );
369+
370+ return 0 ;
371+ }
372+
373+ static int sharp_redistribute_route (ZAPI_CALLBACK_ARGS )
374+ {
375+ struct zapi_route api ;
376+
377+ if (zapi_route_decode (zclient -> ibuf , & api ) < 0 )
378+ zlog_warn ("%s: Decode of redistribute failed: %d" ,
379+ __PRETTY_FUNCTION__ ,
380+ ZEBRA_REDISTRIBUTE_ROUTE_ADD );
381+
382+ zlog_debug ("%s: %pFX (%s)" , zserv_command_string (cmd ),
383+ & api .prefix , zebra_route_string (api .type ));
384+
385+ sharp_debug_nexthops (& api );
386+
354387 return 0 ;
355388}
356389
@@ -372,4 +405,7 @@ void sharp_zebra_init(void)
372405 zclient -> route_notify_owner = route_notify_owner ;
373406 zclient -> nexthop_update = sharp_nexthop_update ;
374407 zclient -> import_check_update = sharp_nexthop_update ;
408+
409+ zclient -> redistribute_route_add = sharp_redistribute_route ;
410+ zclient -> redistribute_route_del = sharp_redistribute_route ;
375411}
0 commit comments