Deleted Added
sdiff udiff text old ( 190964 ) new ( 191672 )
full compact
1/*-
2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 46 unchanged lines hidden (view full) ---

55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * SUCH DAMAGE.
58 *
59 * @(#)raw_ip.c 8.2 (Berkeley) 1/4/94
60 */
61
62#include <sys/cdefs.h>
63__FBSDID("$FreeBSD: head/sys/netinet6/raw_ip6.c 190964 2009-04-12 13:22:33Z rwatson $");
64
65#include "opt_ipsec.h"
66#include "opt_inet6.h"
67#include "opt_route.h"
68
69#include <sys/param.h>
70#include <sys/errno.h>
71#include <sys/jail.h>

--- 51 unchanged lines hidden (view full) ---

123extern struct inpcbinfo ripcbinfo;
124struct rip6stat rip6stat;
125#endif
126
127extern u_long rip_sendspace;
128extern u_long rip_recvspace;
129
130/*
131 * Hooks for multicast forwarding.
132 */
133struct socket *ip6_mrouter = NULL;
134int (*ip6_mrouter_set)(struct socket *, struct sockopt *);
135int (*ip6_mrouter_get)(struct socket *, struct sockopt *);
136int (*ip6_mrouter_done)(void);
137int (*ip6_mforward)(struct ip6_hdr *, struct ifnet *, struct mbuf *);
138int (*mrt6_ioctl)(int, caddr_t);
139
140/*
141 * Setup generic address and protocol structures for raw_input routine, then
142 * pass them along with mbuf chain.
143 */
144int
145rip6_input(struct mbuf **mp, int *offp, int proto)
146{
147 INIT_VNET_INET(curvnet);
148 INIT_VNET_INET6(curvnet);
149#ifdef IPSEC
150 INIT_VNET_IPSEC(curvnet);
151#endif
152 struct mbuf *m = *mp;
153 register struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
154 register struct inpcb *in6p;
155 struct inpcb *last = 0;
156 struct mbuf *opts = NULL;
157 struct sockaddr_in6 fromsa;
158
159 V_rip6stat.rip6s_ipackets++;
160
161 if (faithprefix_p != NULL && (*faithprefix_p)(&ip6->ip6_dst)) {
162 /* XXX Send icmp6 host/port unreach? */
163 m_freem(m);
164 return (IPPROTO_DONE);
165 }
166
167 init_sin6(&fromsa, m); /* general init */
168
169 INP_INFO_RLOCK(&V_ripcbinfo);
170 LIST_FOREACH(in6p, &V_ripcb, inp_list) {
171 /* XXX inp locking */
172 if ((in6p->inp_vflag & INP_IPV6) == 0)
173 continue;
174 if (in6p->inp_ip_p &&
175 in6p->inp_ip_p != proto)
176 continue;
177 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) &&
178 !IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &ip6->ip6_dst))
179 continue;
180 if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr) &&
181 !IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr, &ip6->ip6_src))
182 continue;
183 if (prison_check_ip6(in6p->inp_cred, &ip6->ip6_dst) != 0)
184 continue;
185 INP_RLOCK(in6p);
186 if (in6p->in6p_cksum != -1) {
187 V_rip6stat.rip6s_isum++;
188 if (in6_cksum(m, proto, *offp,
189 m->m_pkthdr.len - *offp)) {
190 INP_RUNLOCK(in6p);
191 V_rip6stat.rip6s_badsum++;
192 continue;
193 }
194 }
195 if (last != NULL) {
196 struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);
197
198#ifdef IPSEC
199 /*
200 * Check AH/ESP integrity.
201 */
202 if (n && ipsec6_in_reject(n, last)) {

--- 396 unchanged lines hidden (view full) ---

599 ICMP6_FILTER_SETPASSALL(inp->in6p_icmp6filt);
600 INP_WUNLOCK(inp);
601 return (0);
602}
603
604static void
605rip6_detach(struct socket *so)
606{
607 INIT_VNET_INET(so->so_vnet);
608 struct inpcb *inp;
609
610 inp = sotoinpcb(so);
611 KASSERT(inp != NULL, ("rip6_detach: inp == NULL"));
612
613 if (so == ip6_mrouter && ip6_mrouter_done)
614 ip6_mrouter_done();
615 /* xxx: RSVP */
616 INP_INFO_WLOCK(&V_ripcbinfo);
617 INP_WLOCK(inp);
618 free(inp->in6p_icmp6filt, M_PCB);
619 in_pcbdetach(inp);
620 in_pcbfree(inp);
621 INP_INFO_WUNLOCK(&V_ripcbinfo);

--- 228 unchanged lines hidden ---