+
+/*
+ * Validate version of UST apps and set the compatible bit.
+ */
+int ust_app_validate_version(int sock)
+{
+ int ret;
+ struct ust_app *app;
+
+ rcu_read_lock();
+
+ app = find_app_by_sock(sock);
+ assert(app);
+
+ ret = ustctl_tracer_version(sock, &app->version);
+ if (ret < 0) {
+ goto error;
+ }
+
+ /* Validate version */
+ if (app->version.major > UST_APP_MAJOR_VERSION) {
+ goto error;
+ }
+
+ DBG2("UST app PID %d is compatible with major version %d "
+ "(supporting <= %d)", app->key.pid, app->version.major,
+ UST_APP_MAJOR_VERSION);
+ app->compatible = 1;
+ rcu_read_unlock();
+ return 0;
+
+error:
+ DBG2("UST app PID %d is not compatible with major version %d "
+ "(supporting <= %d)", app->key.pid, app->version.major,
+ UST_APP_MAJOR_VERSION);
+ app->compatible = 0;
+ rcu_read_unlock();
+ return -1;
+}