Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: add debugs for interface lib module events #15522

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

libs: add cli for interface lib debugs

0658790
Select commit
Loading
Failed to load commit list.
Open

lib: add debugs for interface lib module events #15522

libs: add cli for interface lib debugs
0658790
Select commit
Loading
Failed to load commit list.
frrbot / frrbot completed Jan 15, 2025 in 11s

Style and/or linter errors found

Style and/or linter errors found

Details

Thanks for your contribution to FRR!

Click for style suggestions

diff --git a/lib/if.c b/lib/if.c
index b5ba8cce5..204652152 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -192,8 +192,7 @@ static struct interface *if_new(struct vrf *vrf)
 void if_new_via_zapi(struct interface *ifp)
 {
 	if (intf_lib_debug)
-		zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name,
-			   ifp->vrf->vrf_id);
+		zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name, ifp->vrf->vrf_id);
 
 	hook_call(if_real, ifp);
 }
@@ -201,8 +200,7 @@ void if_new_via_zapi(struct interface *ifp)
 void if_destroy_via_zapi(struct interface *ifp)
 {
 	if (intf_lib_debug)
-		zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name,
-			   ifp->vrf->vrf_id);
+		zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name, ifp->vrf->vrf_id);
 
 	hook_call(if_unreal, ifp);
 
@@ -216,8 +214,7 @@ void if_destroy_via_zapi(struct interface *ifp)
 void if_up_via_zapi(struct interface *ifp)
 {
 	if (intf_lib_debug)
-		zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name,
-			   ifp->vrf->vrf_id);
+		zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name, ifp->vrf->vrf_id);
 
 	hook_call(if_up, ifp);
 }
@@ -225,8 +222,7 @@ void if_up_via_zapi(struct interface *ifp)
 void if_down_via_zapi(struct interface *ifp)
 {
 	if (intf_lib_debug)
-		zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name,
-			   ifp->vrf->vrf_id);
+		zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name, ifp->vrf->vrf_id);
 
 	hook_call(if_down, ifp);
 }
@@ -338,8 +334,7 @@ static struct interface *if_create_name(const char *name, struct vrf *vrf)
 	if_set_name(ifp, name);
 
 	if (intf_lib_debug)
-		zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name,
-			   ifp->vrf->vrf_id);
+		zlog_debug("%s: ifp %s, vrf %u", __func__, ifp->name, ifp->vrf->vrf_id);
 
 	if (if_notify_oper_changes && ifp->state)
 		if_update_state(ifp);
@@ -358,8 +353,8 @@ void if_update_to_new_vrf(struct interface *ifp, vrf_id_t vrf_id)
 	old_vrf = ifp->vrf;
 
 	if (intf_lib_debug)
-		zlog_debug("%s: ifp %s, old vrf %u -> new vrf %u", __func__,
-			   ifp->name, old_vrf->vrf_id, vrf_id);
+		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);
@@ -406,8 +401,7 @@ void if_delete(struct interface **ifp)
 	struct vrf *vrf = ptr->vrf;
 
 	if (intf_lib_debug)
-		zlog_debug("%s: ifp %s, vrf %u", __func__, ptr->name,
-			   vrf->vrf_id);
+		zlog_debug("%s: ifp %s, vrf %u", __func__, ptr->name, vrf->vrf_id);
 
 	IFNAME_RB_REMOVE(vrf, ptr);
 	if (ptr->ifindex != IFINDEX_INTERNAL)
@@ -736,8 +730,8 @@ struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id,
 		break;
 	case VRF_BACKEND_VRF_LITE:
 		if (intf_lib_debug)
-			zlog_debug("%s: ifname %s, vrf_id %i, vrf_name %s",
-				   __func__, name, vrf_id, vrf_name);
+			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) {
@@ -1534,8 +1528,7 @@ void lib_if_enable_debug(struct vty *vty, bool enable, bool config)
 	if (config) {
 		/* Update northbound */
 		strlcpy(xpath, "/frr-interface:lib/debug-enable", sizeof(xpath));
-		nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY,
-				      enable ? "true" : "false");
+		nb_cli_enqueue_change(vty, xpath, NB_OP_MODIFY, enable ? "true" : "false");
 
 		nb_cli_apply_changes(vty, NULL);
 	}
@@ -1547,8 +1540,7 @@ int lib_if_debug_write_config(struct vty *vty)
 	const struct lyd_node *dnode;
 	bool enabled;
 
-	dnode = yang_dnode_get(running_config->dnode,
-			       "/frr-interface:lib/debug-enable");
+	dnode = yang_dnode_get(running_config->dnode, "/frr-interface:lib/debug-enable");
 	if (dnode) {
 		enabled = yang_dnode_get_bool(dnode, NULL);
 		if (enabled) {
@@ -1924,8 +1916,7 @@ static int lib_debug_enable_modify(struct nb_cb_modify_args *args)
 	return NB_OK;
 }
 
-static void lib_debug_enable_cli_write(struct vty *vty,
-				       const struct lyd_node *dnode,
+static void lib_debug_enable_cli_write(struct vty *vty, const struct lyd_node *dnode,
 				       bool show_defaults)
 {
 	lib_if_debug_write_config(vty);
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index 11918768f..48db892c3 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -453,8 +453,7 @@ void vtysh_config_parse_line(void *arg, const char *line)
 			config = config_get(FORWARDING_NODE, line);
 		else if (strncmp(line, "debug vrf", strlen("debug vrf")) == 0)
 			config = config_get(VRF_DEBUG_NODE, line);
-		else if (strncmp(line, "debug interface",
-				 strlen("debug interface")) == 0)
+		else if (strncmp(line, "debug interface", strlen("debug interface")) == 0)
 			config = config_get(INTF_DEBUG_NODE, line);
 		else if (strncmp(line, "debug route-map",
 				 strlen("debug route-map"))
@@ -523,16 +522,13 @@ void vtysh_config_parse_line(void *arg, const char *line)
 
 /* Macro to check delimiter is needed between each configuration line
  * or not. */
-#define NO_DELIMITER(I)                                                        \
-	((I) == AFFMAP_NODE || (I) == ACCESS_NODE || (I) == PREFIX_NODE ||     \
-	 (I) == IP_NODE || (I) == AS_LIST_NODE ||                              \
-	 (I) == COMMUNITY_LIST_NODE || (I) == COMMUNITY_ALIAS_NODE ||          \
-	 (I) == ACCESS_IPV6_NODE || (I) == ACCESS_MAC_NODE ||                  \
-	 (I) == PREFIX_IPV6_NODE || (I) == FORWARDING_NODE ||                  \
-	 (I) == DEBUG_NODE || (I) == AAA_NODE || (I) == VRF_DEBUG_NODE ||      \
-	 (I) == RMAP_DEBUG_NODE || (I) == RESOLVER_DEBUG_NODE ||               \
-	 (I) == MPLS_NODE || (I) == KEYCHAIN_KEY_NODE ||                       \
-	 (I) == INTF_DEBUG_NODE)
+#define NO_DELIMITER(I)                                                                            \
+	((I) == AFFMAP_NODE || (I) == ACCESS_NODE || (I) == PREFIX_NODE || (I) == IP_NODE ||       \
+	 (I) == AS_LIST_NODE || (I) == COMMUNITY_LIST_NODE || (I) == COMMUNITY_ALIAS_NODE ||       \
+	 (I) == ACCESS_IPV6_NODE || (I) == ACCESS_MAC_NODE || (I) == PREFIX_IPV6_NODE ||           \
+	 (I) == FORWARDING_NODE || (I) == DEBUG_NODE || (I) == AAA_NODE ||                         \
+	 (I) == VRF_DEBUG_NODE || (I) == RMAP_DEBUG_NODE || (I) == RESOLVER_DEBUG_NODE ||          \
+	 (I) == MPLS_NODE || (I) == KEYCHAIN_KEY_NODE || (I) == INTF_DEBUG_NODE)
 
 static void configvec_dump(vector vec, bool nested)
 {
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index d44605674..e91e69d34 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -176,8 +176,8 @@ 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);
+		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);
@@ -192,8 +192,8 @@ 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);
+		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);
@@ -207,8 +207,7 @@ 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));
+		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);
@@ -224,8 +223,7 @@ 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));
+		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);

To apply the style suggestions:

curl https://gist.githubusercontent.com/polychaeta/f597d809cd679c4eb36278ce1602b86b/raw/e1e5e827183251e46eec7de711d3be8f374066c1/style.diff | git apply -

If you are a new contributor to FRR, please see our contributing guidelines.

After making changes, you do not need to create a new PR. You should perform an amend or interactive rebase followed by a force push.