ip6_output.c (236170) | ip6_output.c (236332) |
---|---|
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 --- 47 unchanged lines hidden (view full) --- 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * SUCH DAMAGE. 59 * 60 * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 61 */ 62 63#include <sys/cdefs.h> | 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 --- 47 unchanged lines hidden (view full) --- 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * SUCH DAMAGE. 59 * 60 * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 61 */ 62 63#include <sys/cdefs.h> |
64__FBSDID("$FreeBSD: head/sys/netinet6/ip6_output.c 236170 2012-05-28 09:30:13Z bz $"); | 64__FBSDID("$FreeBSD: head/sys/netinet6/ip6_output.c 236332 2012-05-30 20:56:07Z tuexen $"); |
65 66#include "opt_inet.h" 67#include "opt_inet6.h" 68#include "opt_ipfw.h" 69#include "opt_ipsec.h" 70#include "opt_sctp.h" 71#include "opt_route.h" 72 --- 430 unchanged lines hidden (view full) --- 503 } 504 ro_pmtu = ro; 505 if (opt && opt->ip6po_rthdr) 506 ro = &opt->ip6po_route; 507 dst = (struct sockaddr_in6 *)&ro->ro_dst; 508#ifdef FLOWTABLE 509 if (ro == &ip6route) { 510 struct flentry *fle; | 65 66#include "opt_inet.h" 67#include "opt_inet6.h" 68#include "opt_ipfw.h" 69#include "opt_ipsec.h" 70#include "opt_sctp.h" 71#include "opt_route.h" 72 --- 430 unchanged lines hidden (view full) --- 503 } 504 ro_pmtu = ro; 505 if (opt && opt->ip6po_rthdr) 506 ro = &opt->ip6po_route; 507 dst = (struct sockaddr_in6 *)&ro->ro_dst; 508#ifdef FLOWTABLE 509 if (ro == &ip6route) { 510 struct flentry *fle; |
511 | 511 |
512 /* 513 * The flow table returns route entries valid for up to 30 514 * seconds; we rely on the remainder of ip_output() taking no 515 * longer than that long for the stability of ro_rt. The 516 * flow ID assignment must have happened before this point. 517 */ 518 if ((fle = flowtable_lookup_mbuf(V_ip6_ft, m, AF_INET6)) != NULL) { 519 flow_to_route_in6(fle, ro); 520 if (ro->ro_rt != NULL && ro->ro_lle != NULL) 521 flevalid = 1; 522 } 523 } | 512 /* 513 * The flow table returns route entries valid for up to 30 514 * seconds; we rely on the remainder of ip_output() taking no 515 * longer than that long for the stability of ro_rt. The 516 * flow ID assignment must have happened before this point. 517 */ 518 if ((fle = flowtable_lookup_mbuf(V_ip6_ft, m, AF_INET6)) != NULL) { 519 flow_to_route_in6(fle, ro); 520 if (ro->ro_rt != NULL && ro->ro_lle != NULL) 521 flevalid = 1; 522 } 523 } |
524#endif | 524#endif |
525again: 526 /* 527 * if specified, try to fill in the traffic class field. 528 * do not override if a non-zero value is already set. 529 * we check the diffserv field and the ecn field separately. 530 */ 531 if (opt && opt->ip6po_tclass >= 0) { 532 int mask = 0; --- 129 unchanged lines hidden (view full) --- 662 if (rt != NULL) { 663 ia = (struct in6_ifaddr *)(rt->rt_ifa); 664 rt->rt_use++; 665 } 666 667 668 /* 669 * The outgoing interface must be in the zone of source and | 525again: 526 /* 527 * if specified, try to fill in the traffic class field. 528 * do not override if a non-zero value is already set. 529 * we check the diffserv field and the ecn field separately. 530 */ 531 if (opt && opt->ip6po_tclass >= 0) { 532 int mask = 0; --- 129 unchanged lines hidden (view full) --- 662 if (rt != NULL) { 663 ia = (struct in6_ifaddr *)(rt->rt_ifa); 664 rt->rt_use++; 665 } 666 667 668 /* 669 * The outgoing interface must be in the zone of source and |
670 * destination addresses. | 670 * destination addresses. |
671 */ 672 origifp = ifp; 673 674 src0 = ip6->ip6_src; 675 if (in6_setscope(&src0, origifp, &zone)) 676 goto badscope; 677 bzero(&src_sa, sizeof(src_sa)); 678 src_sa.sin6_family = AF_INET6; --- 9 unchanged lines hidden (view full) --- 688 bzero(&dst_sa, sizeof(dst_sa)); 689 dst_sa.sin6_family = AF_INET6; 690 dst_sa.sin6_len = sizeof(dst_sa); 691 dst_sa.sin6_addr = ip6->ip6_dst; 692 if (sa6_recoverscope(&dst_sa) || zone != dst_sa.sin6_scope_id) { 693 goto badscope; 694 } 695 | 671 */ 672 origifp = ifp; 673 674 src0 = ip6->ip6_src; 675 if (in6_setscope(&src0, origifp, &zone)) 676 goto badscope; 677 bzero(&src_sa, sizeof(src_sa)); 678 src_sa.sin6_family = AF_INET6; --- 9 unchanged lines hidden (view full) --- 688 bzero(&dst_sa, sizeof(dst_sa)); 689 dst_sa.sin6_family = AF_INET6; 690 dst_sa.sin6_len = sizeof(dst_sa); 691 dst_sa.sin6_addr = ip6->ip6_dst; 692 if (sa6_recoverscope(&dst_sa) || zone != dst_sa.sin6_scope_id) { 693 goto badscope; 694 } 695 |
696 /* We should use ia_ifp to support the case of | 696 /* We should use ia_ifp to support the case of |
697 * sending packets to an address of our own. 698 */ 699 if (ia != NULL && ia->ia_ifp) 700 ifp = ia->ia_ifp; 701 702 /* scope check is done. */ 703 goto routefound; 704 --- 181 unchanged lines hidden (view full) --- 886 if (m->m_pkthdr.rcvif == NULL) 887 m->m_pkthdr.rcvif = V_loif; 888 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { 889 m->m_pkthdr.csum_flags |= 890 CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; 891 m->m_pkthdr.csum_data = 0xffff; 892 } 893#ifdef SCTP | 697 * sending packets to an address of our own. 698 */ 699 if (ia != NULL && ia->ia_ifp) 700 ifp = ia->ia_ifp; 701 702 /* scope check is done. */ 703 goto routefound; 704 --- 181 unchanged lines hidden (view full) --- 886 if (m->m_pkthdr.rcvif == NULL) 887 m->m_pkthdr.rcvif = V_loif; 888 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { 889 m->m_pkthdr.csum_flags |= 890 CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; 891 m->m_pkthdr.csum_data = 0xffff; 892 } 893#ifdef SCTP |
894 if (m->m_pkthdr.csum_flags & CSUM_SCTP) | 894 if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) |
895 m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; 896#endif 897 error = netisr_queue(NETISR_IPV6, m); 898 goto done; 899 } else 900 goto again; /* Redo the routing table lookup. */ 901 } 902 903#ifdef IPFIREWALL_FORWARD 904 /* See if local, if yes, send it to netisr. */ 905 if (m->m_flags & M_FASTFWD_OURS) { 906 if (m->m_pkthdr.rcvif == NULL) 907 m->m_pkthdr.rcvif = V_loif; 908 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { 909 m->m_pkthdr.csum_flags |= 910 CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; 911 m->m_pkthdr.csum_data = 0xffff; 912 } 913#ifdef SCTP | 895 m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; 896#endif 897 error = netisr_queue(NETISR_IPV6, m); 898 goto done; 899 } else 900 goto again; /* Redo the routing table lookup. */ 901 } 902 903#ifdef IPFIREWALL_FORWARD 904 /* See if local, if yes, send it to netisr. */ 905 if (m->m_flags & M_FASTFWD_OURS) { 906 if (m->m_pkthdr.rcvif == NULL) 907 m->m_pkthdr.rcvif = V_loif; 908 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { 909 m->m_pkthdr.csum_flags |= 910 CSUM_DATA_VALID_IPV6 | CSUM_PSEUDO_HDR; 911 m->m_pkthdr.csum_data = 0xffff; 912 } 913#ifdef SCTP |
914 if (m->m_pkthdr.csum_flags & CSUM_SCTP) | 914 if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) |
915 m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; | 915 m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; |
916#endif | 916#endif |
917 error = netisr_queue(NETISR_IPV6, m); 918 goto done; 919 } 920 /* Or forward to some other address? */ 921 fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL); 922 if (fwd_tag) { 923 dst = (struct sockaddr_in6 *)&ro->ro_dst; 924 bcopy((fwd_tag+1), dst, sizeof(struct sockaddr_in6)); --- 35 unchanged lines hidden (view full) --- 960 * XXX-BZ Need a framework to know when the NIC can handle it, even 961 * with ext. hdrs. 962 */ 963 if (sw_csum & CSUM_DELAY_DATA_IPV6) { 964 sw_csum &= ~CSUM_DELAY_DATA_IPV6; 965 in6_delayed_cksum(m, plen, sizeof(struct ip6_hdr)); 966 } 967#ifdef SCTP | 917 error = netisr_queue(NETISR_IPV6, m); 918 goto done; 919 } 920 /* Or forward to some other address? */ 921 fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL); 922 if (fwd_tag) { 923 dst = (struct sockaddr_in6 *)&ro->ro_dst; 924 bcopy((fwd_tag+1), dst, sizeof(struct sockaddr_in6)); --- 35 unchanged lines hidden (view full) --- 960 * XXX-BZ Need a framework to know when the NIC can handle it, even 961 * with ext. hdrs. 962 */ 963 if (sw_csum & CSUM_DELAY_DATA_IPV6) { 964 sw_csum &= ~CSUM_DELAY_DATA_IPV6; 965 in6_delayed_cksum(m, plen, sizeof(struct ip6_hdr)); 966 } 967#ifdef SCTP |
968 if (sw_csum & CSUM_SCTP) { 969 sw_csum &= ~CSUM_SCTP; | 968 if (sw_csum & CSUM_SCTP_IPV6) { 969 sw_csum &= ~CSUM_SCTP_IPV6; |
970 sctp_delayed_cksum(m, sizeof(struct ip6_hdr)); 971 } 972#endif 973 m->m_pkthdr.csum_flags &= ifp->if_hwassist; 974 tlen = m->m_pkthdr.len; 975 976 if ((opt && (opt->ip6po_flags & IP6PO_DONTFRAG)) || tso) 977 dontfrag = 1; --- 98 unchanged lines hidden (view full) --- 1076 * fragmented packets, then do it here. 1077 * XXX-BZ handle the hw offloading case. Need flags. 1078 */ 1079 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { 1080 in6_delayed_cksum(m, plen, hlen); 1081 m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; 1082 } 1083#ifdef SCTP | 970 sctp_delayed_cksum(m, sizeof(struct ip6_hdr)); 971 } 972#endif 973 m->m_pkthdr.csum_flags &= ifp->if_hwassist; 974 tlen = m->m_pkthdr.len; 975 976 if ((opt && (opt->ip6po_flags & IP6PO_DONTFRAG)) || tso) 977 dontfrag = 1; --- 98 unchanged lines hidden (view full) --- 1076 * fragmented packets, then do it here. 1077 * XXX-BZ handle the hw offloading case. Need flags. 1078 */ 1079 if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) { 1080 in6_delayed_cksum(m, plen, hlen); 1081 m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA_IPV6; 1082 } 1083#ifdef SCTP |
1084 if (m->m_pkthdr.csum_flags & CSUM_SCTP) { | 1084 if (m->m_pkthdr.csum_flags & CSUM_SCTP_IPV6) { |
1085 sctp_delayed_cksum(m, hlen); | 1085 sctp_delayed_cksum(m, hlen); |
1086 m->m_pkthdr.csum_flags &= ~CSUM_SCTP; | 1086 m->m_pkthdr.csum_flags &= ~CSUM_SCTP_IPV6; |
1087 } 1088#endif 1089 mnext = &m->m_nextpkt; 1090 1091 /* 1092 * Change the next header field of the last header in the 1093 * unfragmentable part. 1094 */ --- 1983 unchanged lines hidden --- | 1087 } 1088#endif 1089 mnext = &m->m_nextpkt; 1090 1091 /* 1092 * Change the next header field of the last header in the 1093 * unfragmentable part. 1094 */ --- 1983 unchanged lines hidden --- |