From: kn Date: Mon, 8 Aug 2022 17:47:59 +0000 (+0000) Subject: Constify in6_addr pointer arguments in nd6_*() functions X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b76075053f08f635bc5c36e7adb684520ef3420e;p=openbsd Constify in6_addr pointer arguments in nd6_*() functions All of them are passed to inspect/copy out fields, none of the functions writes to the struct. This makes it easier to argue about code (in MP context). OK bluhm --- diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 35162ce597f..c06ee2924ff 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.244 2022/08/08 15:56:35 kn Exp $ */ +/* $OpenBSD: nd6.c,v 1.245 2022/08/08 17:47:59 kn Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -301,7 +301,7 @@ skip1: * ND6 timer routine to handle ND6 entries */ void -nd6_llinfo_settimer(struct llinfo_nd6 *ln, unsigned int secs) +nd6_llinfo_settimer(const struct llinfo_nd6 *ln, unsigned int secs) { time_t expire = getuptime() + secs; @@ -547,7 +547,7 @@ nd6_purge(struct ifnet *ifp) } struct rtentry * -nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp, +nd6_lookup(const struct in6_addr *addr6, int create, struct ifnet *ifp, u_int rtableid) { struct rtentry *rt; @@ -641,7 +641,7 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp, * XXX: should take care of the destination of a p2p link? */ int -nd6_is_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp) +nd6_is_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp) { struct in6_ifaddr *ia6; struct ifaddr *ifa; @@ -1079,7 +1079,7 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) * code - type dependent information */ void -nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, +nd6_cache_lladdr(struct ifnet *ifp, const struct in6_addr *from, char *lladdr, int lladdrlen, int type, int code) { struct rtentry *rt = NULL; diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h index 8ea60eb9c5f..980524f16ea 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.h,v 1.78 2022/07/28 13:11:44 kn Exp $ */ +/* $OpenBSD: nd6.h,v 1.79 2022/08/08 17:47:59 kn Exp $ */ /* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */ /* @@ -157,27 +157,29 @@ union nd_opts { void nd6_init(void); struct nd_ifinfo *nd6_ifattach(struct ifnet *); void nd6_ifdetach(struct nd_ifinfo *); -int nd6_is_addr_neighbor(struct sockaddr_in6 *, struct ifnet *); +int nd6_is_addr_neighbor(const struct sockaddr_in6 *, struct ifnet *); void nd6_option_init(void *, int, union nd_opts *); struct nd_opt_hdr *nd6_option(union nd_opts *); int nd6_options(union nd_opts *); -struct rtentry *nd6_lookup(struct in6_addr *, int, struct ifnet *, u_int); -void nd6_llinfo_settimer(struct llinfo_nd6 *, unsigned int); +struct rtentry *nd6_lookup(const struct in6_addr *, int, struct ifnet *, + u_int); +void nd6_llinfo_settimer(const struct llinfo_nd6 *, unsigned int); void nd6_purge(struct ifnet *); void nd6_nud_hint(struct rtentry *); void nd6_rtrequest(struct ifnet *, int, struct rtentry *); int nd6_ioctl(u_long, caddr_t, struct ifnet *); -void nd6_cache_lladdr(struct ifnet *, struct in6_addr *, char *, int, int, int); +void nd6_cache_lladdr(struct ifnet *, const struct in6_addr *, char *, + int, int, int); int nd6_resolve(struct ifnet *, struct rtentry *, struct mbuf *, struct sockaddr *, u_char *); int nd6_need_cache(struct ifnet *); void nd6_na_input(struct mbuf *, int, int); -void nd6_na_output(struct ifnet *, struct in6_addr *, - struct in6_addr *, u_long, int, struct sockaddr *); +void nd6_na_output(struct ifnet *, const struct in6_addr *, + const struct in6_addr *, u_long, int, struct sockaddr *); void nd6_ns_input(struct mbuf *, int, int); -void nd6_ns_output(struct ifnet *, struct in6_addr *, - struct in6_addr *, struct llinfo_nd6 *, int); +void nd6_ns_output(struct ifnet *, const struct in6_addr *, + const struct in6_addr *, const struct llinfo_nd6 *, int); caddr_t nd6_ifptomac(struct ifnet *); void nd6_dad_start(struct ifaddr *); void nd6_dad_stop(struct ifaddr *); diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index 5061a325f55..57433b47d41 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_nbr.c,v 1.131 2022/02/07 15:23:43 bluhm Exp $ */ +/* $OpenBSD: nd6_nbr.c,v 1.132 2022/08/08 17:47:59 kn Exp $ */ /* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */ /* @@ -357,8 +357,8 @@ nd6_ns_input(struct mbuf *m, int off, int icmp6len) * dad - duplicated address detection */ void -nd6_ns_output(struct ifnet *ifp, struct in6_addr *daddr6, - struct in6_addr *taddr6, struct llinfo_nd6 *ln, int dad) +nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6, + const struct in6_addr *taddr6, const struct llinfo_nd6 *ln, int dad) { struct mbuf *m; struct ip6_hdr *ip6; @@ -871,8 +871,8 @@ nd6_na_input(struct mbuf *m, int off, int icmp6len) * sdl0 - sockaddr_dl (= proxy NA) or NULL */ void -nd6_na_output(struct ifnet *ifp, struct in6_addr *daddr6, - struct in6_addr *taddr6, u_long flags, int tlladdr, +nd6_na_output(struct ifnet *ifp, const struct in6_addr *daddr6, + const struct in6_addr *taddr6, u_long flags, int tlladdr, struct sockaddr *sdl0) { struct mbuf *m;