+ if (target->meta.type != UNIT_TARGET)
+ return 0;
+
+ /* Only add the dependency if boths units are loaded, so that
+ * that loop check below is reliable */
+ if (u->meta.load_state != UNIT_LOADED ||
+ target->meta.load_state != UNIT_LOADED)
+ return 0;
+
+ /* Don't create loops */
+ if (set_get(target->meta.dependencies[UNIT_BEFORE], u))
+ return 0;
+
+ return unit_add_dependency(target, UNIT_AFTER, u, true);
+}
+
+static int unit_add_default_dependencies(Unit *u) {
+ Unit *target;
+ Iterator i;
+ int r;
+
+ assert(u);
+
+ SET_FOREACH(target, u->meta.dependencies[UNIT_REQUIRED_BY], i)
+ if ((r = unit_add_default_target_dependency(u, target)) < 0)
+ return r;
+
+ SET_FOREACH(target, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i)
+ if ((r = unit_add_default_target_dependency(u, target)) < 0)
+ return r;
+
+ SET_FOREACH(target, u->meta.dependencies[UNIT_WANTED_BY], i)
+ if ((r = unit_add_default_target_dependency(u, target)) < 0)
+ return r;