| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ip_output.c,v 1.247 2015/09/02 11:35:11 ozaki-r Exp $ */ | | 1 | /* $NetBSD: ip_output.c,v 1.248 2016/01/20 22:12:22 riastradh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | | 4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -81,27 +81,27 @@ | | | @@ -81,27 +81,27 @@ |
81 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 81 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
82 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 82 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
83 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 83 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
84 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 84 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
85 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 85 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
86 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 86 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
87 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 87 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
88 | * SUCH DAMAGE. | | 88 | * SUCH DAMAGE. |
89 | * | | 89 | * |
90 | * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 | | 90 | * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 |
91 | */ | | 91 | */ |
92 | | | 92 | |
93 | #include <sys/cdefs.h> | | 93 | #include <sys/cdefs.h> |
94 | __KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.247 2015/09/02 11:35:11 ozaki-r Exp $"); | | 94 | __KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.248 2016/01/20 22:12:22 riastradh Exp $"); |
95 | | | 95 | |
96 | #ifdef _KERNEL_OPT | | 96 | #ifdef _KERNEL_OPT |
97 | #include "opt_inet.h" | | 97 | #include "opt_inet.h" |
98 | #include "opt_ipsec.h" | | 98 | #include "opt_ipsec.h" |
99 | #include "opt_mrouting.h" | | 99 | #include "opt_mrouting.h" |
100 | #include "opt_net_mpsafe.h" | | 100 | #include "opt_net_mpsafe.h" |
101 | #include "opt_mpls.h" | | 101 | #include "opt_mpls.h" |
102 | #endif | | 102 | #endif |
103 | | | 103 | |
104 | #include <sys/param.h> | | 104 | #include <sys/param.h> |
105 | #include <sys/kmem.h> | | 105 | #include <sys/kmem.h> |
106 | #include <sys/mbuf.h> | | 106 | #include <sys/mbuf.h> |
107 | #include <sys/protosw.h> | | 107 | #include <sys/protosw.h> |
| @@ -322,66 +322,55 @@ exit: | | | @@ -322,66 +322,55 @@ exit: |
322 | | | 322 | |
323 | return error; | | 323 | return error; |
324 | | | 324 | |
325 | #undef RTFREE_IF_NEEDED | | 325 | #undef RTFREE_IF_NEEDED |
326 | } | | 326 | } |
327 | | | 327 | |
328 | /* | | 328 | /* |
329 | * IP output. The packet in mbuf chain m contains a skeletal IP | | 329 | * IP output. The packet in mbuf chain m contains a skeletal IP |
330 | * header (with len, off, ttl, proto, tos, src, dst). | | 330 | * header (with len, off, ttl, proto, tos, src, dst). |
331 | * The mbuf chain containing the packet will be freed. | | 331 | * The mbuf chain containing the packet will be freed. |
332 | * The mbuf opt, if present, will not be freed. | | 332 | * The mbuf opt, if present, will not be freed. |
333 | */ | | 333 | */ |
334 | int | | 334 | int |
335 | ip_output(struct mbuf *m0, ...) | | 335 | ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags, |
| | | 336 | struct ip_moptions *imo, struct socket *so) |
336 | { | | 337 | { |
337 | struct rtentry *rt; | | 338 | struct rtentry *rt; |
338 | struct ip *ip; | | 339 | struct ip *ip; |
339 | struct ifnet *ifp; | | 340 | struct ifnet *ifp; |
340 | struct mbuf *m = m0; | | 341 | struct mbuf *m = m0; |
341 | int hlen = sizeof (struct ip); | | 342 | int hlen = sizeof (struct ip); |
342 | int len, error = 0; | | 343 | int len, error = 0; |
343 | struct route iproute; | | 344 | struct route iproute; |
344 | const struct sockaddr_in *dst; | | 345 | const struct sockaddr_in *dst; |
345 | struct in_ifaddr *ia; | | 346 | struct in_ifaddr *ia; |
346 | int isbroadcast; | | 347 | int isbroadcast; |
347 | struct mbuf *opt; | | 348 | int sw_csum; |
348 | struct route *ro; | | | |
349 | int flags, sw_csum; | | | |
350 | u_long mtu; | | 349 | u_long mtu; |
351 | struct ip_moptions *imo; | | | |
352 | struct socket *so; | | | |
353 | va_list ap; | | | |
354 | #ifdef IPSEC | | 350 | #ifdef IPSEC |
355 | struct secpolicy *sp = NULL; | | 351 | struct secpolicy *sp = NULL; |
356 | #endif | | 352 | #endif |
357 | bool natt_frag = false; | | 353 | bool natt_frag = false; |
358 | bool rtmtu_nolock; | | 354 | bool rtmtu_nolock; |
359 | union { | | 355 | union { |
360 | struct sockaddr dst; | | 356 | struct sockaddr dst; |
361 | struct sockaddr_in dst4; | | 357 | struct sockaddr_in dst4; |
362 | } u; | | 358 | } u; |
363 | struct sockaddr *rdst = &u.dst; /* real IP destination, as opposed | | 359 | struct sockaddr *rdst = &u.dst; /* real IP destination, as opposed |
364 | * to the nexthop | | 360 | * to the nexthop |
365 | */ | | 361 | */ |
366 | | | 362 | |
367 | len = 0; | | 363 | len = 0; |
368 | va_start(ap, m0); | | | |
369 | opt = va_arg(ap, struct mbuf *); | | | |
370 | ro = va_arg(ap, struct route *); | | | |
371 | flags = va_arg(ap, int); | | | |
372 | imo = va_arg(ap, struct ip_moptions *); | | | |
373 | so = va_arg(ap, struct socket *); | | | |
374 | va_end(ap); | | | |
375 | | | 364 | |
376 | MCLAIM(m, &ip_tx_mowner); | | 365 | MCLAIM(m, &ip_tx_mowner); |
377 | | | 366 | |
378 | KASSERT((m->m_flags & M_PKTHDR) != 0); | | 367 | KASSERT((m->m_flags & M_PKTHDR) != 0); |
379 | KASSERT((m->m_pkthdr.csum_flags & (M_CSUM_TCPv6|M_CSUM_UDPv6)) == 0); | | 368 | KASSERT((m->m_pkthdr.csum_flags & (M_CSUM_TCPv6|M_CSUM_UDPv6)) == 0); |
380 | KASSERT((m->m_pkthdr.csum_flags & (M_CSUM_TCPv4|M_CSUM_UDPv4)) != | | 369 | KASSERT((m->m_pkthdr.csum_flags & (M_CSUM_TCPv4|M_CSUM_UDPv4)) != |
381 | (M_CSUM_TCPv4|M_CSUM_UDPv4)); | | 370 | (M_CSUM_TCPv4|M_CSUM_UDPv4)); |
382 | | | 371 | |
383 | if (opt) { | | 372 | if (opt) { |
384 | m = ip_insertoptions(m, opt, &len); | | 373 | m = ip_insertoptions(m, opt, &len); |
385 | if (len >= sizeof(struct ip)) | | 374 | if (len >= sizeof(struct ip)) |
386 | hlen = len; | | 375 | hlen = len; |
387 | } | | 376 | } |