diff --git a/sys/net/if.c b/sys/net/if.c index 39dc941..1ce07df 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1593,7 +1593,7 @@ done: */ /*ARGSUSED*/ struct ifaddr * -ifa_ifwithdstaddr(struct sockaddr *addr) +ifa_ifwithdstaddr(const struct sockaddr *addr) { struct ifnet *ifp; struct ifaddr *ifa; diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 41ac056..80b5be6 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -935,7 +935,7 @@ int ifa_del_loopback_route(struct ifaddr *, struct sockaddr *); struct ifaddr *ifa_ifwithaddr(struct sockaddr *); int ifa_ifwithaddr_check(struct sockaddr *); struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *); -struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *); +struct ifaddr *ifa_ifwithdstaddr(const struct sockaddr *); struct ifaddr *ifa_ifwithnet(struct sockaddr *, int); struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *); struct ifaddr *ifa_ifwithroute_fib(int, struct sockaddr *, struct sockaddr *, u_int); diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 12abd0d..e7e96e3 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -237,6 +237,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, struct route_in6 ip6route; struct rtentry *rt = NULL; struct sockaddr_in6 *dst, src_sa, dst_sa; + const struct sockaddr_in6 *gw; struct in6_addr odst; int error = 0; struct in6_ifaddr *ia = NULL; @@ -519,7 +520,7 @@ skip_ipsec2:; ro_pmtu = ro; if (opt && opt->ip6po_rthdr) ro = &opt->ip6po_route; - dst = (struct sockaddr_in6 *)&ro->ro_dst; + gw = dst = (struct sockaddr_in6 *)&ro->ro_dst; #ifdef FLOWTABLE if (ro->ro_rt == NULL) { struct flentry *fle; @@ -589,7 +590,7 @@ again: m = state.m; ro = (struct route_in6 *)state.ro; - dst = (struct sockaddr_in6 *)state.dst; + gw = (struct sockaddr_in6 *)state.dst; if (error == EJUSTRETURN) { /* * We had a SP with a level of 'use' and no SA. We @@ -636,7 +637,7 @@ again: /* adjust pointer */ ip6 = mtod(m, struct ip6_hdr *); - if (ro->ro_rt && fwd_tag == NULL) { + if (ro->ro_rt != NULL && fwd_tag == NULL) { rt = ro->ro_rt; ifp = ro->ro_rt->rt_ifp; } else { @@ -653,13 +654,13 @@ again: in6_ifstat_inc(ifp, ifs6_out_discard); goto bad; } - } - if (rt == NULL) { - /* - * If in6_selectroute() does not return a route entry, - * dst may not have been updated. - */ - *dst = dst_sa; /* XXX */ + if (rt == NULL) { + /* + * If in6_selectroute() does not return a route entry, + * dst may not have been updated. + */ + *dst = dst_sa; /* XXX */ + } } /* @@ -727,10 +728,9 @@ again: * application. We assume the next hop is an IPv6 * address. */ - dst = (struct sockaddr_in6 *)opt->ip6po_nexthop; - } - else if ((rt->rt_flags & RTF_GATEWAY)) - dst = (struct sockaddr_in6 *)rt->rt_gateway; + gw = (const struct sockaddr_in6 *)opt->ip6po_nexthop; + } else if ((rt->rt_flags & RTF_GATEWAY)) + gw = (const struct sockaddr_in6 *)rt->rt_gateway; } if (!IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst)) { @@ -927,7 +927,6 @@ again: /* Or forward to some other address? */ if ((m->m_flags & M_IP6_NEXTHOP) && (fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL)) != NULL) { - dst = (struct sockaddr_in6 *)&ro->ro_dst; bcopy((fwd_tag+1), &dst_sa, sizeof(struct sockaddr_in6)); m->m_flags |= M_SKIP_FIREWALL; m->m_flags &= ~M_IP6_NEXTHOP; @@ -1025,7 +1024,7 @@ passout: ia6->ia_ifa.if_obytes += m->m_pkthdr.len; ifa_free(&ia6->ia_ifa); } - error = nd6_output(ifp, origifp, m, dst, ro->ro_rt); + error = nd6_output(ifp, origifp, m, gw, ro->ro_rt); goto done; } @@ -1179,7 +1178,7 @@ sendorfree: ia->ia_ifa.if_opackets++; ia->ia_ifa.if_obytes += m->m_pkthdr.len; } - error = nd6_output(ifp, origifp, m, dst, ro->ro_rt); + error = nd6_output(ifp, origifp, m, gw, ro->ro_rt); } else m_freem(m); } diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 0e30825..bc3d115 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -122,7 +122,7 @@ VNET_DEFINE(int, nd6_recalc_reachtm_interval) = ND6_RECALC_REACHTM_INTERVAL; int (*send_sendso_input_hook)(struct mbuf *, struct ifnet *, int, int); -static int nd6_is_new_addr_neighbor(struct sockaddr_in6 *, +static int nd6_is_new_addr_neighbor(const struct sockaddr_in6 *, struct ifnet *); static void nd6_setmtu0(struct ifnet *, struct nd_ifinfo *); static void nd6_slowtimo(void *); @@ -824,7 +824,7 @@ nd6_purge(struct ifnet *ifp) * Returns the llentry locked */ struct llentry * -nd6_lookup(struct in6_addr *addr6, int flags, struct ifnet *ifp) +nd6_lookup(const struct in6_addr *addr6, int flags, struct ifnet *ifp) { struct sockaddr_in6 sin6; struct llentry *ln; @@ -856,7 +856,7 @@ nd6_lookup(struct in6_addr *addr6, int flags, struct ifnet *ifp) * to not reenter the routing code from within itself. */ static int -nd6_is_new_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp) +nd6_is_new_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp) { struct nd_prefix *pr; struct ifaddr *dstaddr; @@ -929,7 +929,7 @@ nd6_is_new_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp) * If the address is assigned on the node of the other side of * a p2p interface, the address should be a neighbor. */ - dstaddr = ifa_ifwithdstaddr((struct sockaddr *)addr); + dstaddr = ifa_ifwithdstaddr((const struct sockaddr *)addr); if (dstaddr != NULL) { if (dstaddr->ifa_ifp == ifp) { ifa_free(dstaddr); @@ -957,7 +957,7 @@ nd6_is_new_addr_neighbor(struct sockaddr_in6 *addr, 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 llentry *lle; int rc = 0; @@ -1808,7 +1808,7 @@ nd6_slowtimo(void *arg) int nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0, - struct sockaddr_in6 *dst, struct rtentry *rt0) + const struct sockaddr_in6 *dst, struct rtentry *rt0) { return (nd6_output_lle(ifp, origifp, m0, dst, rt0, NULL, NULL)); @@ -1827,7 +1827,7 @@ nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0, int nd6_output_lle(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0, - struct sockaddr_in6 *dst, struct rtentry *rt0, struct llentry *lle, + const struct sockaddr_in6 *dst, struct rtentry *rt0, struct llentry *lle, struct mbuf **chain) { struct mbuf *m = m0; @@ -1867,7 +1867,8 @@ nd6_output_lle(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0, if (ln == NULL) { retry: IF_AFDATA_LOCK(ifp); - ln = lla_lookup(LLTABLE6(ifp), flags, (struct sockaddr *)dst); + ln = lla_lookup(LLTABLE6(ifp), flags, + (const struct sockaddr *)dst); IF_AFDATA_UNLOCK(ifp); if ((ln == NULL) && nd6_is_addr_neighbor(dst, ifp)) { /* @@ -2063,10 +2064,10 @@ nd6_output_lle(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0, /* Reset layer specific mbuf flags to avoid confusing lower layers. */ m->m_flags &= ~(M_PROTOFLAGS); if ((ifp->if_flags & IFF_LOOPBACK) != 0) { - return ((*ifp->if_output)(origifp, m, (struct sockaddr *)dst, - NULL)); + return ((*ifp->if_output)(origifp, m, + (const struct sockaddr *)dst, NULL)); } - error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, NULL); + error = (*ifp->if_output)(ifp, m, (const struct sockaddr *)dst, NULL); return (error); bad: diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h index 25d8c5d..728734e 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -391,11 +391,11 @@ void nd6_destroy(void); #endif 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 llentry *nd6_lookup(struct in6_addr *, int, struct ifnet *); +struct llentry *nd6_lookup(const struct in6_addr *, int, struct ifnet *); void nd6_setmtu(struct ifnet *); void nd6_llinfo_settimer(struct llentry *, long); void nd6_llinfo_settimer_locked(struct llentry *, long); @@ -409,9 +409,9 @@ int nd6_ioctl(u_long, caddr_t, struct ifnet *); struct llentry *nd6_cache_lladdr(struct ifnet *, struct in6_addr *, char *, int, int, int); int nd6_output(struct ifnet *, struct ifnet *, struct mbuf *, - struct sockaddr_in6 *, struct rtentry *); + const struct sockaddr_in6 *, struct rtentry *); int nd6_output_lle(struct ifnet *, struct ifnet *, struct mbuf *, - struct sockaddr_in6 *, struct rtentry *, struct llentry *, + const struct sockaddr_in6 *, struct rtentry *, struct llentry *, struct mbuf **); int nd6_output_flush(struct ifnet *, struct ifnet *, struct mbuf *, struct sockaddr_in6 *, struct route *);