diff options
author | 2001-06-23 04:39:33 +0000 | |
---|---|---|
committer | 2001-06-23 04:39:33 +0000 | |
commit | 4b98e3077fa88d274af28a308c054d950fa04e73 (patch) | |
tree | f8b8ec96aec63cd69c350cb5934778120835b1ad | |
parent | print names in reference (.%A) as below (diff) | |
download | wireguard-openbsd-4b98e3077fa88d274af28a308c054d950fa04e73.tar.xz wireguard-openbsd-4b98e3077fa88d274af28a308c054d950fa04e73.zip |
Having to update queue(3) for DLIST_* is a major PITA; thus, just use
SLIST and be done with it.
-rw-r--r-- | sys/kern/uipc_mbuf2.c | 28 | ||||
-rw-r--r-- | sys/netinet/ip_ipsp.c | 24 | ||||
-rw-r--r-- | sys/sys/mbuf.h | 10 | ||||
-rw-r--r-- | sys/sys/queue.h | 66 |
4 files changed, 32 insertions, 96 deletions
diff --git a/sys/kern/uipc_mbuf2.c b/sys/kern/uipc_mbuf2.c index b644d255034..eef4191ebd6 100644 --- a/sys/kern/uipc_mbuf2.c +++ b/sys/kern/uipc_mbuf2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf2.c,v 1.14 2001/06/23 03:57:48 angelos Exp $ */ +/* $OpenBSD: uipc_mbuf2.c,v 1.15 2001/06/23 04:39:33 angelos Exp $ */ /* $KAME: uipc_mbuf2.c,v 1.29 2001/02/14 13:42:10 itojun Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.40 1999/04/01 00:23:25 thorpej Exp $ */ @@ -300,7 +300,7 @@ m_tag_prepend(m, t) struct mbuf *m; struct m_tag *t; { - DLIST_INSERT_HEAD(&m->m_pkthdr.tags, t, m_tag_link); + SLIST_INSERT_HEAD(&m->m_pkthdr.tags, t, m_tag_link); } /* Unlink a packet tag. */ @@ -309,7 +309,7 @@ m_tag_unlink(m, t) struct mbuf *m; struct m_tag *t; { - DLIST_REMOVE(&m->m_pkthdr.tags, t, m_tag_link); + SLIST_REMOVE(&m->m_pkthdr.tags, t, m_tag, m_tag_link); } /* Unlink and free a packet tag. */ @@ -333,10 +333,10 @@ m_tag_delete_chain(m, t) if (t != NULL) p = t; else - p = DLIST_FIRST(&m->m_pkthdr.tags); + p = SLIST_FIRST(&m->m_pkthdr.tags); if (p == NULL) return; - while ((q = DLIST_NEXT(p, m_tag_link)) != NULL) + while ((q = SLIST_NEXT(p, m_tag_link)) != NULL) m_tag_delete(m, q); m_tag_delete(m, p); } @@ -351,13 +351,13 @@ m_tag_find(m, type, t) struct m_tag *p; if (t == NULL) - p = DLIST_FIRST(&m->m_pkthdr.tags); + p = SLIST_FIRST(&m->m_pkthdr.tags); else - p = DLIST_NEXT(t, m_tag_link); + p = SLIST_NEXT(t, m_tag_link); while (p != NULL) { if (p->m_tag_id == type) return (p); - p = DLIST_NEXT(p, m_tag_link); + p = SLIST_NEXT(p, m_tag_link); } return (NULL); } @@ -390,16 +390,16 @@ m_tag_copy_chain(to, from) struct m_tag *p, *t, *tprev = NULL; m_tag_delete_chain(to, NULL); - DLIST_FOREACH(p, &from->m_pkthdr.tags, m_tag_link) { + SLIST_FOREACH(p, &from->m_pkthdr.tags, m_tag_link) { t = m_tag_copy(p); if (t == NULL) { m_tag_delete_chain(to, NULL); return (0); } if (tprev == NULL) - DLIST_INSERT_HEAD(&to->m_pkthdr.tags, t, m_tag_link); + SLIST_INSERT_HEAD(&to->m_pkthdr.tags, t, m_tag_link); else { - DLIST_INSERT_AFTER(tprev, t, m_tag_link); + SLIST_INSERT_AFTER(tprev, t, m_tag_link); tprev = t; } } @@ -411,7 +411,7 @@ void m_tag_init(m) struct mbuf *m; { - DLIST_INIT(&m->m_pkthdr.tags); + SLIST_INIT(&m->m_pkthdr.tags); } /* Get first tag in chain. */ @@ -419,7 +419,7 @@ struct m_tag * m_tag_first(m) struct mbuf *m; { - return (DLIST_FIRST(&m->m_pkthdr.tags)); + return (SLIST_FIRST(&m->m_pkthdr.tags)); } /* Get next tag in chain. */ @@ -428,5 +428,5 @@ m_tag_next(m, t) struct mbuf *m; struct m_tag *t; { - return (DLIST_NEXT(t, m_tag_link)); + return (SLIST_NEXT(t, m_tag_link)); } diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c index 5dceabf1ba8..54725672003 100644 --- a/sys/netinet/ip_ipsp.c +++ b/sys/netinet/ip_ipsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipsp.c,v 1.131 2001/06/23 04:01:57 angelos Exp $ */ +/* $OpenBSD: ip_ipsp.c,v 1.132 2001/06/23 04:39:34 angelos Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), @@ -1263,7 +1263,7 @@ struct m_tag * ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) { int ipv4sa = 0, s, esphlen = 0, trail = 0, i; - DLIST_HEAD(packet_tags, m_tag) tags; + SLIST_HEAD(packet_tags, m_tag) tags; unsigned char lasteight[8]; struct tdb_ident *tdbi; struct m_tag *mtag; @@ -1281,7 +1281,7 @@ ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) if (proto != IPPROTO_IPV4 && proto != IPPROTO_IPV6) return NULL; - DLIST_INIT(&tags); + SLIST_INIT(&tags); while (1) { @@ -1325,7 +1325,7 @@ ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) mtag = m_tag_get(PACKET_TAG_IPSEC_IN_CRYPTO_DONE, sizeof(struct tdb_ident), M_NOWAIT); if (mtag == NULL) - return tags.dh_first; + return tags.slh_first; tdbi = (struct tdb_ident *) (mtag + 1); bzero(tdbi, sizeof(struct tdb_ident)); @@ -1335,7 +1335,7 @@ ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) tdbi->dst.sin6.sin6_family = AF_INET6; tdbi->dst.sin6.sin6_len = sizeof(struct sockaddr_in6); tdbi->dst.sin6.sin6_addr = ip6_dst; - DLIST_INSERT_HEAD(&tags, mtag, m_tag_link); + SLIST_INSERT_HEAD(&tags, mtag, m_tag_link); } else if (nxtp == IPPROTO_IPV6) @@ -1379,7 +1379,7 @@ ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) if (tdb == NULL) { splx(s); - return tags.dh_first; + return tags.slh_first; } /* How large is the ESP header ? We use this later */ @@ -1396,7 +1396,7 @@ ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) if (tdb->tdb_flags & TDBF_RANDOMPADDING) { splx(s); - return tags.dh_first; + return tags.slh_first; } /* Update the length of trailing ESP authenticators */ @@ -1412,11 +1412,11 @@ ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) if (lasteight[6] != 0) { if (lasteight[6] != lasteight[5]) - return tags.dh_first; + return tags.slh_first; for (i = 4; lasteight[i + 1] != 1 && i >= 0; i--) if (lasteight[i + 1] != lasteight[i] + 1) - return tags.dh_first; + return tags.slh_first; } } /* Fall through */ @@ -1424,7 +1424,7 @@ ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) mtag = m_tag_get(PACKET_TAG_IPSEC_IN_CRYPTO_DONE, sizeof(struct tdb_ident), M_NOWAIT); if (mtag == NULL) - return tags.dh_first; + return tags.slh_first; tdbi = (struct tdb_ident *) (mtag + 1); bzero(tdbi, sizeof(struct tdb_ident)); @@ -1458,7 +1458,7 @@ ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) } #endif /* INET6 */ - DLIST_INSERT_HEAD(&tags, mtag, m_tag_link); + SLIST_INSERT_HEAD(&tags, mtag, m_tag_link); /* Update next protocol/header and header offset */ if (proto == IPPROTO_AH) @@ -1478,7 +1478,7 @@ ipsp_parse_headers(struct mbuf *m, int off, u_int8_t proto) break; default: - return tags.dh_first; /* done */ + return tags.slh_first; /* done */ } } } diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 981905066e9..518e96a0cb8 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.h,v 1.41 2001/06/23 03:57:25 angelos Exp $ */ +/* $OpenBSD: mbuf.h,v 1.42 2001/06/23 04:39:35 angelos Exp $ */ /* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */ /* @@ -58,7 +58,7 @@ /* Packet tags structure */ struct m_tag { - DLIST_ENTRY(m_tag) m_tag_link; /* List of packet tags */ + SLIST_ENTRY(m_tag) m_tag_link; /* List of packet tags */ u_int16_t m_tag_id; /* Tag ID */ u_int16_t m_tag_len; /* Length of data */ }; @@ -82,7 +82,7 @@ struct m_hdr { /* record/packet header in first mbuf of chain; valid if M_PKTHDR set */ struct pkthdr { struct ifnet *rcvif; /* rcv interface */ - DLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ + SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ int len; /* total packet length */ int csum; /* Hardware checksum info */ }; @@ -237,7 +237,7 @@ struct mbuf *_sk_mget(int, int); (m)->m_nextpkt = (struct mbuf *)NULL; \ (m)->m_data = (m)->m_pktdat; \ (m)->m_flags = M_PKTHDR; \ - DLIST_INIT(&(m)->m_pkthdr.tags); \ + SLIST_INIT(&(m)->m_pkthdr.tags); \ (m)->m_pkthdr.csum = 0; \ } else \ (m) = m_retryhdr((how), (type)); \ @@ -421,7 +421,7 @@ void _sk_mclget(struct mbuf *, int); */ #define M_DUP_HDR(to, from) { \ M_COPY_HDR((to), (from)); \ - DLIST_INIT(&(to)->m_pkthdr.tags); \ + SLIST_INIT(&(to)->m_pkthdr.tags); \ m_tag_copy_chain((to), (from)); \ } diff --git a/sys/sys/queue.h b/sys/sys/queue.h index 8595e768f4b..c85bb240c53 100644 --- a/sys/sys/queue.h +++ b/sys/sys/queue.h @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.h,v 1.21 2001/06/23 04:23:05 angelos Exp $ */ +/* $OpenBSD: queue.h,v 1.22 2001/06/23 04:39:35 angelos Exp $ */ /* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ /* @@ -224,70 +224,6 @@ struct { \ } while (0) /* - * Doubly-linked list with a single head pointer. This is - * the same as the LIST_* type, except that le_prev of the - * first element does not point to the list head. - */ -#define DLIST_HEAD(name, type) \ -struct name { \ - struct type *dh_first; /* first element */ \ -} - -#define DLIST_HEAD_INITIALIZER(head) \ - { NULL } - -#define DLIST_ENTRY(type) \ -struct { \ - struct type *de_next; /* next element */ \ - struct type **de_prev; /* address of previous next element */ \ -} - -/* - * List access methods - */ -#define DLIST_FIRST(head) ((head)->dh_first) -#define DLIST_END(head) NULL -#define DLIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head)) -#define DLIST_NEXT(elm, field) ((elm)->field.de_next) - -#define DLIST_FOREACH(var, head, field) \ - for((var) = DLIST_FIRST(head); \ - (var)!= DLIST_END(head); \ - (var) = DLIST_NEXT(var, field)) - -/* - * List functions. - */ -#define DLIST_INIT(head) do { \ - DLIST_FIRST(head) = DLIST_END(head); \ -} while (0) - -#define DLIST_INSERT_AFTER(listelm, elm, field) do { \ - if (((elm)->field.de_next = (listelm)->field.de_next) != NULL) \ - (listelm)->field.de_next->field.de_prev = \ - &(elm)->field.de_next; \ - (listelm)->field.de_next = (elm); \ - (elm)->field.de_prev = &(listelm)->field.de_next; \ -} while (0) - -#define DLIST_INSERT_HEAD(head, elm, field) do { \ - if (((elm)->field.de_next = (head)->dh_first) != NULL) \ - (head)->dh_first->field.de_prev = &(elm)->field.de_next;\ - (head)->dh_first = (elm); \ - (elm)->field.de_prev = NULL; \ -} while (0) - -#define DLIST_REMOVE(head, elm, field) do { \ - if ((elm)->field.de_next != NULL) \ - (elm)->field.de_next->field.de_prev = \ - (elm)->field.de_prev; \ - if ((elm)->field.de_prev != NULL) \ - *(elm)->field.de_prev = (elm)->field.de_next; \ - else \ - (head)->dh_first = DLIST_END(head); \ -} while (0) - -/* * Simple queue definitions. */ #define SIMPLEQ_HEAD(name, type) \ |