diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2021-05-25 22:45:11 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2021-05-25 22:45:11 +0000 |
commit | 879df70c3f9d6dfd798576c79b2dc21ef470c9c2 (patch) | |
tree | dfc82cd179c0e9818eca5ee087da3739ff422777 /sys/net | |
parent | 389d274508daed57afbbdf7a04db903700e1f7a0 (diff) |
As network features are not added dynamically, the domain structures
are constant. Having more const makes MP review easier. More
pointers are mapped read-only in the kernel image.
OK deraadt@ mvs@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.c | 6 | ||||
-rw-r--r-- | sys/net/pfkeyv2.c | 6 | ||||
-rw-r--r-- | sys/net/route.c | 4 | ||||
-rw-r--r-- | sys/net/rtable.c | 44 | ||||
-rw-r--r-- | sys/net/rtsock.c | 6 |
5 files changed, 32 insertions, 34 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index c11710b75fc..e375f5211db 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.640 2021/03/26 22:41:06 mvs Exp $ */ +/* $OpenBSD: if.c,v 1.641 2021/05/25 22:45:09 bluhm Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -501,7 +501,7 @@ if_free_sadl(struct ifnet *ifp) void if_attachdomain(struct ifnet *ifp) { - struct domain *dp; + const struct domain *dp; int i, s; s = splnet(); @@ -1010,7 +1010,7 @@ if_detach(struct ifnet *ifp) { struct ifaddr *ifa; struct ifg_list *ifg; - struct domain *dp; + const struct domain *dp; int i, s; /* Undo pseudo-driver changes. */ diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c index 23f4d00a3b0..fa6917352b5 100644 --- a/sys/net/pfkeyv2.c +++ b/sys/net/pfkeyv2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkeyv2.c,v 1.212 2021/05/25 09:55:22 bluhm Exp $ */ +/* $OpenBSD: pfkeyv2.c,v 1.213 2021/05/25 22:45:09 bluhm Exp $ */ /* * @(#)COPYRIGHT 1.1 (NRL) 17 January 1995 @@ -125,7 +125,7 @@ static const struct sadb_alg calgs[] = { struct pool pkpcb_pool; #define PFKEY_MSG_MAXSZ 4096 const struct sockaddr pfkey_addr = { 2, PF_KEY, }; -struct domain pfkeydomain; +const struct domain pfkeydomain; /* * pfkey PCB @@ -214,7 +214,7 @@ static struct protosw pfkeysw[] = { } }; -struct domain pfkeydomain = { +const struct domain pfkeydomain = { .dom_family = PF_KEY, .dom_name = "PF_KEY", .dom_init = pfkey_init, diff --git a/sys/net/route.c b/sys/net/route.c index 3e3c32617df..73bd6f53639 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.398 2021/03/10 10:21:48 jsg Exp $ */ +/* $OpenBSD: route.c,v 1.399 2021/05/25 22:45:09 bluhm Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -1061,7 +1061,7 @@ rt_copysa(struct sockaddr *src, struct sockaddr *mask, struct sockaddr **dst) static const u_char maskarray[] = { 0x0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe }; struct sockaddr *ndst; - struct domain *dp; + const struct domain *dp; u_char *csrc, *cdst; int i, plen; diff --git a/sys/net/rtable.c b/sys/net/rtable.c index 4d00cd101f7..4cdd303200a 100644 --- a/sys/net/rtable.c +++ b/sys/net/rtable.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtable.c,v 1.74 2021/03/26 22:41:06 mvs Exp $ */ +/* $OpenBSD: rtable.c,v 1.75 2021/05/25 22:45:09 bluhm Exp $ */ /* * Copyright (c) 2014-2016 Martin Pieuchot @@ -90,8 +90,8 @@ void *rtable_get(unsigned int, sa_family_t); void rtmap_init(void) { - struct domain *dp; - int i; + const struct domain *dp; + int i; /* Start with a single table for every domain that requires it. */ for (i = 0; (dp = domains[i]) != NULL; i++) { @@ -152,8 +152,8 @@ rtmap_dtor(void *null, void *xmap) void rtable_init(void) { - struct domain *dp; - int i; + const struct domain *dp; + int i; KASSERT(sizeof(struct rtmap) == sizeof(struct dommp)); @@ -189,13 +189,13 @@ rtable_init(void) int rtable_add(unsigned int id) { - struct domain *dp; - void *tbl; - struct rtmap *map; - struct dommp *dmm; - sa_family_t af; - unsigned int off, alen; - int i, error = 0; + const struct domain *dp; + void *tbl; + struct rtmap *map; + struct dommp *dmm; + sa_family_t af; + unsigned int off, alen; + int i, error = 0; if (id > RT_TABLEID_MAX) return (EINVAL); @@ -262,9 +262,9 @@ rtable_get(unsigned int rtableid, sa_family_t af) int rtable_exists(unsigned int rtableid) { - struct domain *dp; - void *tbl; - int i; + const struct domain *dp; + void *tbl; + int i; for (i = 0; (dp = domains[i]) != NULL; i++) { if (dp->dom_rtoffset == 0) @@ -281,9 +281,9 @@ rtable_exists(unsigned int rtableid) int rtable_empty(unsigned int rtableid) { - struct domain *dp; - int i; - struct art_root *tbl; + const struct domain *dp; + int i; + struct art_root *tbl; for (i = 0; (dp = domains[i]) != NULL; i++) { if (dp->dom_rtoffset == 0) @@ -902,10 +902,10 @@ satoaddr(struct art_root *at, struct sockaddr *sa) int rtable_satoplen(sa_family_t af, struct sockaddr *mask) { - struct domain *dp; - uint8_t *ap, *ep; - int mlen, plen = 0; - int i; + const struct domain *dp; + uint8_t *ap, *ep; + int mlen, plen = 0; + int i; for (i = 0; (dp = domains[i]) != NULL; i++) { if (dp->dom_rtoffset == 0) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 36c52549528..cd7c3490964 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.315 2021/05/17 17:58:35 claudio Exp $ */ +/* $OpenBSD: rtsock.c,v 1.316 2021/05/25 22:45:09 bluhm Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -2356,8 +2356,6 @@ rt_setsource(unsigned int rtableid, struct sockaddr *src) * Definitions of protocols supported in the ROUTE domain. */ -struct domain routedomain; - struct protosw routesw[] = { { .pr_type = SOCK_RAW, @@ -2373,7 +2371,7 @@ struct protosw routesw[] = { } }; -struct domain routedomain = { +const struct domain routedomain = { .dom_family = PF_ROUTE, .dom_name = "route", .dom_init = route_init, |