diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2013-05-31 13:15:54 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2013-05-31 13:15:54 +0000 |
commit | 956076bda4f834be239075d492595bf4cfd779a0 (patch) | |
tree | 684c0cf0167beea3d7e0a4f316a679c26bef726f /sys | |
parent | d8793a1eb2f35729775ed62e6b1bfb59400984f2 (diff) |
The function rip6_ctlinput() claims that sa6_src is constant to
allow the assingment of &sa6_any. But rip6_ctlinput() could not
guarantee that as it casted away the const attribute when it passes
the pointer to in6_pcbnotify(). Replace sockaddr with const
sockaddr_in6 in the in6_pcbnotify() parameters. This reduces the
number of casts. Also adjust in6_pcbhashlookup() to handle the
const attribute correctly.
Input and OK claudio@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/in_pcb.c | 6 | ||||
-rw-r--r-- | sys/netinet/in_pcb.h | 10 | ||||
-rw-r--r-- | sys/netinet/tcp_subr.c | 12 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 11 | ||||
-rw-r--r-- | sys/netinet6/in6_pcb.c | 23 | ||||
-rw-r--r-- | sys/netinet6/raw_ip6.c | 10 |
6 files changed, 35 insertions, 37 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index f608fd47ea2..7924049db77 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.137 2013/04/09 08:35:38 mpi Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.138 2013/05/31 13:15:53 bluhm Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -946,8 +946,8 @@ in_pcbhashlookup(struct inpcbtable *table, struct in_addr faddr, #ifdef INET6 struct inpcb * -in6_pcbhashlookup(struct inpcbtable *table, struct in6_addr *faddr, - u_int fport_arg, struct in6_addr *laddr, u_int lport_arg) +in6_pcbhashlookup(struct inpcbtable *table, const struct in6_addr *faddr, + u_int fport_arg, const struct in6_addr *laddr, u_int lport_arg) { struct inpcbhead *head; struct inpcb *inp; diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 0831cfbd6a1..9c06a41c7b9 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.h,v 1.78 2013/05/17 09:04:30 mpi Exp $ */ +/* $OpenBSD: in_pcb.h,v 1.79 2013/05/31 13:15:53 bluhm Exp $ */ /* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */ /* @@ -266,8 +266,8 @@ struct inpcb * struct mbuf *, u_int); #ifdef INET6 struct inpcb * - in6_pcbhashlookup(struct inpcbtable *, struct in6_addr *, - u_int, struct in6_addr *, u_int); + in6_pcbhashlookup(struct inpcbtable *, const struct in6_addr *, + u_int, const struct in6_addr *, u_int); struct inpcb * in6_pcblookup_listen(struct inpcbtable *, struct in6_addr *, u_int, int, struct mbuf *); @@ -293,8 +293,8 @@ struct rtentry * in_pcbrtentry(struct inpcb *); /* INET6 stuff */ -int in6_pcbnotify(struct inpcbtable *, struct sockaddr *, - u_int, struct sockaddr *, u_int, int, void *, +int in6_pcbnotify(struct inpcbtable *, struct sockaddr_in6 *, + u_int, const struct sockaddr_in6 *, u_int, int, void *, void (*)(struct inpcb *, int)); int in6_selecthlim(struct inpcb *, struct ifnet *); int in6_pcbsetport(struct in6_addr *, struct inpcb *, struct proc *); diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 1038cfb61ad..508a57ee1b3 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_subr.c,v 1.118 2013/04/10 08:50:59 mpi Exp $ */ +/* $OpenBSD: tcp_subr.c,v 1.119 2013/05/31 13:15:53 bluhm Exp $ */ /* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */ /* @@ -663,7 +663,7 @@ tcp6_ctlinput(cmd, sa, d) void (*notify)(struct inpcb *, int) = tcp_notify; struct ip6_hdr *ip6; const struct sockaddr_in6 *sa6_src = NULL; - struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa; + struct sockaddr_in6 *sa6 = satosin6(sa); struct inpcb *inp; struct mbuf *m; tcp_seq seq; @@ -760,8 +760,8 @@ tcp6_ctlinput(cmd, sa, d) syn_cache_unreach((struct sockaddr *)sa6_src, sa, &th, /* XXX */ 0); } else { - (void) in6_pcbnotify(&tcbtable, sa, 0, - (struct sockaddr *)sa6_src, 0, cmd, NULL, notify); + (void) in6_pcbnotify(&tcbtable, sa6, 0, + sa6_src, 0, cmd, NULL, notify); } } #endif @@ -906,8 +906,8 @@ tcp6_mtudisc_callback(faddr) sin6.sin6_family = AF_INET6; sin6.sin6_len = sizeof(struct sockaddr_in6); sin6.sin6_addr = *faddr; - (void) in6_pcbnotify(&tcbtable, (struct sockaddr *)&sin6, 0, - (struct sockaddr *)&sa6_any, 0, PRC_MSGSIZE, NULL, tcp_mtudisc); + (void) in6_pcbnotify(&tcbtable, &sin6, 0, + &sa6_any, 0, PRC_MSGSIZE, NULL, tcp_mtudisc); } #endif /* INET6 */ diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 1231135e191..a4863ebea6b 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.161 2013/05/17 09:04:30 mpi Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.162 2013/05/31 13:15:53 bluhm Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -884,12 +884,11 @@ udp6_ctlinput(int cmd, struct sockaddr *sa, void *d) */ } - (void) in6_pcbnotify(&udbtable, (struct sockaddr *)&sa6, - uh.uh_dport, (struct sockaddr *)&sa6_src, - uh.uh_sport, cmd, cmdarg, notify); + (void) in6_pcbnotify(&udbtable, &sa6, uh.uh_dport, + &sa6_src, uh.uh_sport, cmd, cmdarg, notify); } else { - (void) in6_pcbnotify(&udbtable, (struct sockaddr *)&sa6, 0, - (struct sockaddr *)&sa6_any, 0, cmd, cmdarg, notify); + (void) in6_pcbnotify(&udbtable, &sa6, 0, + &sa6_any, 0, cmd, cmdarg, notify); } } #endif diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index acb628945a3..7d283bc92ff 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_pcb.c,v 1.54 2013/04/10 08:50:59 mpi Exp $ */ +/* $OpenBSD: in6_pcb.c,v 1.55 2013/05/31 13:15:53 bluhm Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -478,23 +478,22 @@ in6_pcbconnect(struct inpcb *inp, struct mbuf *nam) * Must be called at splnet. */ int -in6_pcbnotify(struct inpcbtable *head, struct sockaddr *dst, - uint fport_arg, struct sockaddr *src, uint lport_arg, int cmd, - void *cmdarg, void (*notify)(struct inpcb *, int)) +in6_pcbnotify(struct inpcbtable *head, struct sockaddr_in6 *dst, + uint fport_arg, const struct sockaddr_in6 *src, uint lport_arg, int cmd, + void *cmdarg, void (*notify)(struct inpcb *, int)) { struct inpcb *inp, *ninp; u_short fport = fport_arg, lport = lport_arg; - struct sockaddr_in6 sa6_src, *sa6_dst; + struct sockaddr_in6 sa6_src; int errno, nmatch = 0; u_int32_t flowinfo; - if ((unsigned)cmd >= PRC_NCMDS || dst->sa_family != AF_INET6) + if ((unsigned)cmd >= PRC_NCMDS) return (0); - sa6_dst = (struct sockaddr_in6 *)dst; - if (IN6_IS_ADDR_UNSPECIFIED(&sa6_dst->sin6_addr)) + if (IN6_IS_ADDR_UNSPECIFIED(&dst->sin6_addr)) return (0); - if (IN6_IS_ADDR_V4MAPPED(&sa6_dst->sin6_addr)) { + if (IN6_IS_ADDR_V4MAPPED(&dst->sin6_addr)) { #ifdef DIAGNOSTIC printf("Huh? Thought in6_pcbnotify() never got " "called with mapped!\n"); @@ -505,7 +504,7 @@ in6_pcbnotify(struct inpcbtable *head, struct sockaddr *dst, /* * note that src can be NULL when we get notify by local fragmentation. */ - sa6_src = (src == NULL) ? sa6_any : *(struct sockaddr_in6 *)src; + sa6_src = (src == NULL) ? sa6_any : *src; flowinfo = sa6_src.sin6_flowinfo; /* @@ -572,7 +571,7 @@ in6_pcbnotify(struct inpcbtable *head, struct sockaddr *dst, dst6 = (struct sockaddr_in6 *)&inp->inp_route.ro_dst; if (IN6_ARE_ADDR_EQUAL(&dst6->sin6_addr, - &sa6_dst->sin6_addr)) + &dst->sin6_addr)) goto do_notify; } @@ -590,7 +589,7 @@ in6_pcbnotify(struct inpcbtable *head, struct sockaddr *dst, IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, &sa6_src.sin6_addr)) goto do_notify; else if (!IN6_ARE_ADDR_EQUAL(&inp->inp_faddr6, - &sa6_dst->sin6_addr) || + &dst->sin6_addr) || inp->inp_socket == 0 || (lport && inp->inp_lport != lport) || (!IN6_IS_ADDR_UNSPECIFIED(&sa6_src.sin6_addr) && diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 21560676817..9b4936184cb 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.54 2013/05/02 11:54:10 mpi Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.55 2013/05/31 13:15:53 bluhm Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -240,6 +240,7 @@ rip6_ctlinput(int cmd, struct sockaddr *sa, void *d) { struct ip6_hdr *ip6; struct ip6ctlparam *ip6cp = NULL; + struct sockaddr_in6 *sa6 = satosin6(sa); const struct sockaddr_in6 *sa6_src = NULL; void *cmdarg; void (*notify)(struct in6pcb *, int) = in6_rtchange; @@ -275,7 +276,6 @@ rip6_ctlinput(int cmd, struct sockaddr *sa, void *d) } if (ip6 && cmd == PRC_MSGSIZE) { - struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa; int valid = 0; struct in6pcb *in6p; @@ -288,7 +288,7 @@ rip6_ctlinput(int cmd, struct sockaddr *sa, void *d) */ in6p = NULL; in6p = in6_pcbhashlookup(&rawin6pcbtable, &sa6->sin6_addr, 0, - (struct in6_addr *)&sa6_src->sin6_addr, 0); + &sa6_src->sin6_addr, 0); #if 0 if (!in6p) { /* @@ -326,8 +326,8 @@ rip6_ctlinput(int cmd, struct sockaddr *sa, void *d) */ } - (void) in6_pcbnotify(&rawin6pcbtable, sa, 0, - (struct sockaddr *)sa6_src, 0, cmd, cmdarg, notify); + (void) in6_pcbnotify(&rawin6pcbtable, sa6, 0, + sa6_src, 0, cmd, cmdarg, notify); } /* |