diff --git a/src/agent_ubus.c b/src/agent_ubus.c
index 68bd6c31c3116aa4c9e9a15f9158d13f34cb97db..3b03e52e60eb1ba569e665315386ff62ed873422 100644
--- a/src/agent_ubus.c
+++ b/src/agent_ubus.c
@@ -812,6 +812,7 @@ error:
 	return UBUS_STATUS_UNKNOWN_ERROR;
 }
 
+#if AGENT_SYNC_DYNAMIC_CNTLR_CONFIG
 static int sync_dyn_controller_config(struct ubus_context *ctx, struct ubus_object *obj,
 				      struct ubus_request_data *req, const char *method,
 				      struct blob_attr *msg)
@@ -852,6 +853,7 @@ static int sync_dyn_controller_config(struct ubus_context *ctx, struct ubus_obje
 error:
 	return UBUS_STATUS_UNKNOWN_ERROR;
 }
+#endif
 
 static int cmd(struct ubus_context *ctx, struct ubus_object *obj,
 		      struct ubus_request_data *req, const char *method,
@@ -1175,7 +1177,9 @@ int agent_publish_object(struct agent *a, const char *objname)
 		UBUS_METHOD("assoc_notify", assoc_notify,
 				assoc_notify_params),
 		UBUS_METHOD("pref_channels", pref_channels, pref_channels_params),
+#ifdef AGENT_SYNC_DYNAMIC_CNTLR_CONFIG
 		UBUS_METHOD_NOARG("sync", sync_dyn_controller_config),
+#endif
 	};
 	int num_methods = ARRAY_SIZE(m);
 	struct ubus_object_type *obj_type;