Skip to content

Commit

Permalink
nanny: rename appply policy func. to factory
Browse files Browse the repository at this point in the history
  • Loading branch information
wipawel committed Jul 9, 2014
1 parent b2bf88c commit bc9c930
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
23 changes: 7 additions & 16 deletions nanny/nanny.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ ni_nanny_recheck(ni_nanny_t *mgr, ni_ifworker_t *w)
ni_managed_device_t *mdev;
ni_managed_policy_t *mpolicy;
unsigned int count;
ni_bool_t virtual = FALSE;
ni_bool_t factory_device = FALSE;

mdev = ni_nanny_get_device(mgr, w);

/* We have an ifworker, but no device yet - follow virtual path */
if (NULL == mdev)
virtual = TRUE;
if (!mdev) {
/* We have an ifworker, but no device yet - follow factory device path */
factory_device = TRUE;
}

/* Note, we also check devices in state FAILED.
* ni_managed_device_apply_policy() will then check if the policy
Expand All @@ -196,24 +196,15 @@ ni_nanny_recheck(ni_nanny_t *mgr, ni_ifworker_t *w)
ni_debug_nanny("%s(%s)", __func__, w->name);
w->use_default_policies = TRUE;
if ((count = ni_fsm_policy_get_applicable_policies(mgr->fsm, w, policies, MAX_POLICIES)) == 0) {
/* Don't try to take down a FAILED device.
* Either we succeed, then we mark it STOPPED (and then try to take it
* up again... and fail), or we fail to take it down (and then we try to
* take it down once more... and fail).
* In either case, we're ending up in a endless loop.
* FIXME: use a ni_managed_device_down_emergency() function, which does a hard
* shutdown of the device. This needs cooperation from the server; which would have
* to kill all leases and destroy all addresses.
*/
ni_debug_nanny("%s: no applicable policies", w->name);
return count;
}

policy = policies[count-1];
mpolicy = ni_nanny_get_policy(mgr, policy);

if (virtual)
ni_virtual_device_apply_policy(mgr->fsm, w, mpolicy);
if (factory_device)
ni_factory_device_apply_policy(mgr->fsm, w, mpolicy);
else
ni_managed_device_apply_policy(mdev, mpolicy);

Expand Down
2 changes: 1 addition & 1 deletion nanny/nanny.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ extern void ni_managed_modem_up(ni_managed_device_t *, unsigned int);

extern ni_managed_device_t * ni_managed_device_new(ni_nanny_t *, ni_ifworker_t *, ni_managed_device_t **list);
extern void ni_managed_device_free(ni_managed_device_t *);
extern void ni_virtual_device_apply_policy(ni_fsm_t *, ni_ifworker_t *, ni_managed_policy_t *);
extern void ni_factory_device_apply_policy(ni_fsm_t *, ni_ifworker_t *, ni_managed_policy_t *);
extern void ni_managed_device_apply_policy(ni_managed_device_t *mdev, ni_managed_policy_t *mpolicy);
extern void ni_managed_device_set_policy(ni_managed_device_t *, ni_managed_policy_t *, xml_node_t *);
extern void ni_managed_device_down(ni_managed_device_t *mdev);
Expand Down

0 comments on commit bc9c930

Please sign in to comment.