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/netinet6 | |
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/netinet6')
-rw-r--r-- | sys/netinet6/in6_pcb.c | 23 | ||||
-rw-r--r-- | sys/netinet6/raw_ip6.c | 10 |
2 files changed, 16 insertions, 17 deletions
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); } /* |