diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-12-03 15:15:05 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-12-03 15:15:05 +0000 |
commit | b2bd71b81a2ed54b713d9a3c593ca8a7c50c084a (patch) | |
tree | c8263e7472c84aa1f25fe6a048bf22c1becf5ecc /regress/sys/net | |
parent | 0eea5568f73acfd50c7836c0552344f2994d040a (diff) |
Sync to recent changes including SRP protection of rtable_get(), use
of a SRPL for the multipath list and rtable_delete() API change.
Diffstat (limited to 'regress/sys/net')
-rw-r--r-- | regress/sys/net/rtable/delete/main.c | 6 | ||||
-rw-r--r-- | regress/sys/net/rtable/fullfeed/main.c | 4 | ||||
-rw-r--r-- | regress/sys/net/rtable/inet6-fullfeed.txt | 2 | ||||
-rw-r--r-- | regress/sys/net/rtable/kern_compat.h | 4 | ||||
-rw-r--r-- | regress/sys/net/rtable/srp_compat.h | 43 | ||||
-rw-r--r-- | regress/sys/net/rtable/util.c | 10 |
6 files changed, 60 insertions, 9 deletions
diff --git a/regress/sys/net/rtable/delete/main.c b/regress/sys/net/rtable/delete/main.c index 1f0298186ca..b0dfb7b46bd 100644 --- a/regress/sys/net/rtable/delete/main.c +++ b/regress/sys/net/rtable/delete/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.2 2015/11/12 14:32:02 mpi Exp $ */ +/* $OpenBSD: main.c,v 1.3 2015/12/03 15:15:04 mpi Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -16,6 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "srp_compat.h" + #include <sys/socket.h> #include <net/route.h> @@ -32,7 +34,6 @@ #include <assert.h> extern void *rtable_get(unsigned int, sa_family_t); -extern void rtable_put(void *); #endif /* ART */ __dead void @@ -68,7 +69,6 @@ main(int argc, char *argv[]) ar = rtable_get(0, AF_INET6); assert(ar != NULL); assert(ar->ar_root == NULL); - rtable_put(ar); #endif /* ART */ return (0); diff --git a/regress/sys/net/rtable/fullfeed/main.c b/regress/sys/net/rtable/fullfeed/main.c index 4fbcb3b1d44..8f52cde1ad9 100644 --- a/regress/sys/net/rtable/fullfeed/main.c +++ b/regress/sys/net/rtable/fullfeed/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.1 2015/11/04 09:45:52 mpi Exp $ */ +/* $OpenBSD: main.c,v 1.2 2015/12/03 15:15:04 mpi Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -16,6 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "srp_compat.h" + #include <sys/socket.h> #include <net/route.h> diff --git a/regress/sys/net/rtable/inet6-fullfeed.txt b/regress/sys/net/rtable/inet6-fullfeed.txt index 7e9a506ce38..00cdef25c8f 100644 --- a/regress/sys/net/rtable/inet6-fullfeed.txt +++ b/regress/sys/net/rtable/inet6-fullfeed.txt @@ -1,4 +1,3 @@ -0::/0 2a04:980::/29 2a03:d680::/48 2607:4e00::/32 @@ -499,3 +498,4 @@ 2402:6b00::/32 2610:18:e80::/48 2620:0:2f00::/41 +::/0 diff --git a/regress/sys/net/rtable/kern_compat.h b/regress/sys/net/rtable/kern_compat.h index a97f55cd499..2ceb4ceb56b 100644 --- a/regress/sys/net/rtable/kern_compat.h +++ b/regress/sys/net/rtable/kern_compat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_compat.h,v 1.1 2015/11/04 09:45:52 mpi Exp $ */ +/* $OpenBSD: kern_compat.h,v 1.2 2015/12/03 15:15:04 mpi Exp $ */ #ifndef _KERN_COMPAT_H_ #define _KERN_COMPAT_H_ @@ -16,6 +16,8 @@ #include <stdlib.h> #include <string.h> +#include "srp_compat.h" + #define DIAGNOSTIC #define INET #define INET6 diff --git a/regress/sys/net/rtable/srp_compat.h b/regress/sys/net/rtable/srp_compat.h new file mode 100644 index 00000000000..d944aebad78 --- /dev/null +++ b/regress/sys/net/rtable/srp_compat.h @@ -0,0 +1,43 @@ + +#ifndef _SRP_COMPAT_H_ +#define _SRP_COMPAT_H_ + +#include <sys/srp.h> +#include <sys/queue.h> + +/* + * SRPL glue. + */ +#define REFCNT_INITIALIZER() { .refs = 1 } +#define SRP_GC_INITIALIZER(_d, _c) { (_d), (_c), REFCNT_INITIALIZER() } +#define SRPL_RC_INITIALIZER(_r, _u, _c) { _r, SRP_GC_INITIALIZER(_u, _c) } + +#define srp_get_locked(_s) ((_s)->ref) +#define srp_enter(_s) srp_get_locked(_s) +#define srp_leave(_s, _v) /* nothing */ + +#define srp_update_locked(_gc, _s, _v) do { \ + void *ov; \ + \ + ov = (_s)->ref; \ + (_s)->ref = (_v); \ + if (ov != NULL) \ + (*(_gc)->srp_gc_dtor)((_gc)->srp_gc_cookie, ov); \ +} while (0) + +#define SRPL_INIT(_sl) SLIST_INIT(_sl) +#define SRPL_HEAD(name, entry) SLIST_HEAD(name, entry) +#define SRPL_ENTRY(type) SLIST_ENTRY(type) + +#define SRPL_ENTER(_sl, _si) SLIST_FIRST(_sl);(void)_si +#define SRPL_NEXT(_si, _e, _ENTRY) SLIST_NEXT(_e, _ENTRY) +#define SRPL_LEAVE(_si, _c) /* nothing */ + +#define SRPL_FOREACH_SAFE_LOCKED(_c, _sl, _ENTRY, _tc) \ + SLIST_FOREACH_SAFE(_c, _sl, _ENTRY, _tc) +#define SRPL_REMOVE_LOCKED(_rc, _sl, _e, _type, _ENTRY) \ + SLIST_REMOVE(_sl, _e, _type, _ENTRY) +#define SRPL_INSERT_HEAD_LOCKED(_rc, _sl, _e, _ENTRY) \ + SLIST_INSERT_HEAD(_sl, _e, _ENTRY) + +#endif /* _SRP_COMPAT_H_ */ diff --git a/regress/sys/net/rtable/util.c b/regress/sys/net/rtable/util.c index ea31bf1adf2..85fd06d21c7 100644 --- a/regress/sys/net/rtable/util.c +++ b/regress/sys/net/rtable/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.1 2015/11/04 09:45:52 mpi Exp $ */ +/* $OpenBSD: util.c,v 1.2 2015/12/03 15:15:04 mpi Exp $ */ /* * Copyright (c) 2015 Martin Pieuchot @@ -16,9 +16,13 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "srp_compat.h" + #include <sys/socket.h> #include <sys/domain.h> #include <sys/queue.h> +#include <sys/srp.h> + #include <net/rtable.h> #include <net/route.h> @@ -112,7 +116,7 @@ route_delete(unsigned int rid, sa_family_t af, char *string) assert(memcmp(rt_key(rt), dst, dst->sa_len) == 0); assert(maskcmp(af, rt_mask(rt), mask) == 0); - if (rtable_delete(0, dst, mask, 0, rt)) { + if (rtable_delete(0, dst, mask, rt)) { inet_net_satop(af, dst, plen, ip, sizeof(ip)); errx(1, "can't rm route: %s\n", ip); } @@ -202,7 +206,7 @@ rtentry_delete(struct rtentry *rt, void *w, unsigned int rid) plen = sa2plen(af, rt_mask(rt)); - if (rtable_delete(0, rt_key(rt), rt_mask(rt), 0, rt)) { + if (rtable_delete(0, rt_key(rt), rt_mask(rt), rt)) { inet_net_satop(af, rt_key(rt), plen, dest, sizeof(dest)); errx(1, "can't rm route: %s\n", dest); } |