diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2015-02-21 11:39:45 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2015-02-21 11:39:45 +0100 |
commit | 7730553b7eeb33d21e5597f110334ca584ad532d (patch) | |
tree | c80bf6d48fc91bafd7f0aefc859a033d3b472c89 /nest | |
parent | 0da562a7cb25ed2b8724248ad6f841b1831a09c3 (diff) | |
parent | ec2194fa7a20a2768ca0027b5f3c024f0a251866 (diff) |
Merge remote-tracking branch 'origin/soft-int'
Diffstat (limited to 'nest')
-rw-r--r-- | nest/iface.c | 31 | ||||
-rw-r--r-- | nest/locks.c | 10 | ||||
-rw-r--r-- | nest/locks.h | 5 | ||||
-rw-r--r-- | nest/password.c | 15 | ||||
-rw-r--r-- | nest/password.h | 9 |
5 files changed, 47 insertions, 23 deletions
diff --git a/nest/iface.c b/nest/iface.c index 298698a7..4d73c2a4 100644 --- a/nest/iface.c +++ b/nest/iface.c @@ -150,7 +150,7 @@ ifa_send_notify(struct proto *p, unsigned c, struct ifa *a) } static void -ifa_notify_change_dep(unsigned c, struct ifa *a) +ifa_notify_change_(unsigned c, struct ifa *a) { struct proto *p; @@ -163,8 +163,13 @@ ifa_notify_change_dep(unsigned c, struct ifa *a) static inline void ifa_notify_change(unsigned c, struct ifa *a) { - neigh_ifa_update(a); - ifa_notify_change_dep(c, a); + if (c & IF_CHANGE_DOWN) + neigh_ifa_update(a); + + ifa_notify_change_(c, a); + + if (c & IF_CHANGE_UP) + neigh_ifa_update(a); } static inline void @@ -201,14 +206,14 @@ if_notify_change(unsigned c, struct iface *i) if_dump(i); #endif - if (c & IF_CHANGE_UP) - neigh_if_up(i); + if (c & IF_CHANGE_DOWN) + neigh_if_down(i); if (c & IF_CHANGE_DOWN) WALK_LIST(a, i->addrs) { a->flags = (i->flags & ~IA_FLAGS) | (a->flags & IA_FLAGS); - ifa_notify_change_dep(IF_CHANGE_DOWN, a); + ifa_notify_change_(IF_CHANGE_DOWN, a); } WALK_LIST(p, active_proto_list) @@ -218,14 +223,14 @@ if_notify_change(unsigned c, struct iface *i) WALK_LIST(a, i->addrs) { a->flags = (i->flags & ~IA_FLAGS) | (a->flags & IA_FLAGS); - ifa_notify_change_dep(IF_CHANGE_UP, a); + ifa_notify_change_(IF_CHANGE_UP, a); } + if (c & IF_CHANGE_UP) + neigh_if_up(i); + if ((c & (IF_CHANGE_UP | IF_CHANGE_DOWN | IF_CHANGE_LINK)) == IF_CHANGE_LINK) neigh_if_link(i); - - if (c & IF_CHANGE_DOWN) - neigh_if_down(i); } static unsigned @@ -251,8 +256,8 @@ if_change_flags(struct iface *i, unsigned flags) } /** - * if_delete - remove interface - * @old: interface + * if_delete - remove interface + * @old: interface * * This function is called by the low-level platform dependent code * whenever it notices an interface disappears. It is just a shorthand @@ -676,7 +681,7 @@ iface_patt_match(struct iface_patt *ifp, struct iface *i, struct ifa *a) if ((a->flags & IA_PEER) && ipa_in_net(a->opposite, p->prefix, p->pxlen)) return pos; - + continue; } diff --git a/nest/locks.c b/nest/locks.c index 7044d6a9..c74f2f45 100644 --- a/nest/locks.c +++ b/nest/locks.c @@ -22,10 +22,11 @@ * or some other non-shareable resource, it asks the core to lock it and it doesn't * use the resource until it's notified that it has acquired the lock. * - * Object locks are represented by &object_lock structures which are in turn a kind of - * resource. Lockable resources are uniquely determined by resource type + * Object locks are represented by &object_lock structures which are in turn a + * kind of resource. Lockable resources are uniquely determined by resource type * (%OBJLOCK_UDP for a UDP port etc.), IP address (usually a broadcast or - * multicast address the port is bound to), port number and interface. + * multicast address the port is bound to), port number, interface and optional + * instance ID. */ #undef LOCAL_DEBUG @@ -45,6 +46,7 @@ olock_same(struct object_lock *x, struct object_lock *y) x->type == y->type && x->iface == y->iface && x->port == y->port && + x->inst == y->inst && ipa_equal(x->addr, y->addr); } @@ -88,7 +90,7 @@ olock_dump(resource *r) struct object_lock *l = (struct object_lock *) r; static char *olock_states[] = { "free", "locked", "waiting", "event" }; - debug("(%d:%s:%I:%d) [%s]\n", l->type, (l->iface ? l->iface->name : "?"), l->addr, l->port, olock_states[l->state]); + debug("(%d:%s:%I:%d:%d) [%s]\n", l->type, (l->iface ? l->iface->name : "?"), l->addr, l->port, l->inst, olock_states[l->state]); if (!EMPTY_LIST(l->waiters)) debug(" [wanted]\n"); } diff --git a/nest/locks.h b/nest/locks.h index 892d3c6b..3d58c8ed 100644 --- a/nest/locks.h +++ b/nest/locks.h @@ -26,9 +26,10 @@ struct object_lock { resource r; ip_addr addr; /* Identification of a object: IP address */ - unsigned int type; /* ... object type (OBJLOCK_xxx) */ + uint type; /* ... object type (OBJLOCK_xxx) */ + uint port; /* ... port number */ + uint inst; /* ... instance ID */ struct iface *iface; /* ... interface */ - unsigned int port; /* ... port number */ void (*hook)(struct object_lock *); /* Called when the lock succeeds */ void *data; /* User data */ /* ... internal to lock manager, don't touch ... */ diff --git a/nest/password.c b/nest/password.c index 179939e2..21e42e0e 100644 --- a/nest/password.c +++ b/nest/password.c @@ -36,9 +36,18 @@ password_find(list *l, int first_fit) return pf; } -void password_cpy(char *dst, char *src, int size) +struct password_item * +password_find_by_id(list *l, int id) { - bzero(dst, size); - memcpy(dst, src, (strlen(src) < (unsigned) size ? strlen(src) : (unsigned) size)); + struct password_item *pi; + + if (!l) + return NULL; + + WALK_LIST(pi, *l) + if ((pi->id == id) && (pi->accfrom <= now_real) && (now_real < pi->accto)) + return pi; + + return NULL; } diff --git a/nest/password.h b/nest/password.h index 726af733..cd120d70 100644 --- a/nest/password.h +++ b/nest/password.h @@ -23,6 +23,13 @@ struct password_item { extern struct password_item *last_password_item; struct password_item *password_find(list *l, int first_fit); -void password_cpy(char *dst, char *src, int size); +struct password_item *password_find_by_id(list *l, int id); + +static inline int password_verify(struct password_item *p1, char *p2, uint size) +{ + char buf[size]; + strncpy(buf, p1->password, size); + return !memcmp(buf, p2, size); +} #endif |