diff --git a/lib/if.c b/lib/if.c index a344c2b8657e..d73009e76616 100644 --- a/lib/if.c +++ b/lib/if.c @@ -51,6 +51,9 @@ DEFINE_KOOH(if_unreal, (struct interface *ifp), (ifp)); DEFINE_HOOK(if_up, (struct interface *ifp), (ifp)); DEFINE_KOOH(if_down, (struct interface *ifp), (ifp)); +/* Control debug output for the lib module */ +static bool ifp_debug; + /* Compare interface names, returning an integer greater than, equal to, or * less than 0, (following the strcmp convention), according to the * relationship between ifp1 and ifp2. Interface names consist of an @@ -178,11 +181,19 @@ static struct interface *if_new(struct vrf *vrf) void if_new_via_zapi(struct interface *ifp) { + if (ifp_debug) + zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name, + ifp->vrf->vrf_id); + hook_call(if_real, ifp); } void if_destroy_via_zapi(struct interface *ifp) { + if (ifp_debug) + zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name, + ifp->vrf->vrf_id); + hook_call(if_unreal, ifp); ifp->oldifindex = ifp->ifindex; @@ -194,11 +205,19 @@ void if_destroy_via_zapi(struct interface *ifp) void if_up_via_zapi(struct interface *ifp) { + if (ifp_debug) + zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name, + ifp->vrf->vrf_id); + hook_call(if_up, ifp); } void if_down_via_zapi(struct interface *ifp) { + if (ifp_debug) + zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name, + ifp->vrf->vrf_id); + hook_call(if_down, ifp); } @@ -210,6 +229,10 @@ static struct interface *if_create_name(const char *name, struct vrf *vrf) if_set_name(ifp, name); + if (ifp_debug) + zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name, + ifp->vrf->vrf_id); + hook_call(if_add, ifp); return ifp; } @@ -222,6 +245,10 @@ void if_update_to_new_vrf(struct interface *ifp, vrf_id_t vrf_id) /* remove interface from old master vrf list */ old_vrf = ifp->vrf; + if (ifp_debug) + zlog_debug("%s: ifp %s, old vrf %u -> new vrf %u", __func__, + ifp->name, old_vrf->vrf_id, vrf_id); + if (ifp->name[0] != '\0') IFNAME_RB_REMOVE(old_vrf, ifp); @@ -261,6 +288,10 @@ void if_delete(struct interface **ifp) struct interface *ptr = *ifp; struct vrf *vrf = ptr->vrf; + if (ifp_debug) + zlog_debug("%s: ifp %s, vrf %u", __func__, ptr->name, + vrf->vrf_id); + IFNAME_RB_REMOVE(vrf, ptr); if (ptr->ifindex != IFINDEX_INTERNAL) IFINDEX_RB_REMOVE(vrf, ptr); @@ -585,6 +616,10 @@ struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id, break; case VRF_BACKEND_VRF_LITE: + if (ifp_debug) + zlog_debug("%s: ifname %s, vrf_id %i, vrf_name %s", + __func__, name, vrf_id, vrf_name); + ifp = if_lookup_by_name_all_vrf(name); if (ifp) { /* If it came from the kernel or by way of zclient, diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 76cabd1bf09b..6bc31c3f1ed5 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -175,6 +175,10 @@ int zsend_interface_add(struct zserv *client, struct interface *ifp) { struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ); + if (IS_ZEBRA_DEBUG_EVENT) + zlog_debug("MESSAGE: %s %s vrf %s(%u)", __func__, ifp->name, + ifp->vrf->name, ifp->vrf->vrf_id); + zclient_create_header(s, ZEBRA_INTERFACE_ADD, ifp->vrf->vrf_id); zserv_encode_interface(s, ifp); @@ -187,6 +191,10 @@ int zsend_interface_delete(struct zserv *client, struct interface *ifp) { struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ); + if (IS_ZEBRA_DEBUG_EVENT) + zlog_debug("MESSAGE: %s %s vrf %s(%u)", __func__, ifp->name, + ifp->vrf->name, ifp->vrf->vrf_id); + zclient_create_header(s, ZEBRA_INTERFACE_DELETE, ifp->vrf->vrf_id); zserv_encode_interface(s, ifp); @@ -198,6 +206,10 @@ int zsend_vrf_add(struct zserv *client, struct zebra_vrf *zvrf) { struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ); + if (IS_ZEBRA_DEBUG_EVENT) + zlog_debug("MESSAGE: %s vrf %s(%u)", __func__, zvrf->vrf->name, + zvrf_id(zvrf)); + zclient_create_header(s, ZEBRA_VRF_ADD, zvrf_id(zvrf)); zserv_encode_vrf(s, zvrf); @@ -211,6 +223,10 @@ int zsend_vrf_delete(struct zserv *client, struct zebra_vrf *zvrf) { struct stream *s = stream_new(ZEBRA_MAX_PACKET_SIZ); + if (IS_ZEBRA_DEBUG_EVENT) + zlog_debug("MESSAGE: %s vrf %s(%u)", __func__, zvrf->vrf->name, + zvrf_id(zvrf)); + zclient_create_header(s, ZEBRA_VRF_DELETE, zvrf_id(zvrf)); zserv_encode_vrf(s, zvrf);