[Midnightbsd-cvs] src [8574] trunk/sys/netinet6/ip6_output.c: make dst_sa init only when needed.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Mon Sep 19 12:12:49 EDT 2016
Revision: 8574
http://svnweb.midnightbsd.org/src/?rev=8574
Author: laffer1
Date: 2016-09-19 12:12:49 -0400 (Mon, 19 Sep 2016)
Log Message:
-----------
make dst_sa init only when needed.
Modified Paths:
--------------
trunk/sys/netinet6/ip6_output.c
Modified: trunk/sys/netinet6/ip6_output.c
===================================================================
--- trunk/sys/netinet6/ip6_output.c 2016-09-19 16:12:03 UTC (rev 8573)
+++ trunk/sys/netinet6/ip6_output.c 2016-09-19 16:12:49 UTC (rev 8574)
@@ -257,7 +257,7 @@
int segleft_org = 0;
struct secpolicy *sp = NULL;
#endif /* IPSEC */
- struct m_tag *fwd_tag;
+ struct m_tag *fwd_tag = NULL;
ip6 = mtod(m, struct ip6_hdr *);
if (ip6 == NULL) {
@@ -636,26 +636,23 @@
/* adjust pointer */
ip6 = mtod(m, struct ip6_hdr *);
- bzero(&dst_sa, sizeof(dst_sa));
- dst_sa.sin6_family = AF_INET6;
- dst_sa.sin6_len = sizeof(dst_sa);
- dst_sa.sin6_addr = ip6->ip6_dst;
- if (ro->ro_rt) {
+ if (ro->ro_rt && fwd_tag == NULL) {
rt = ro->ro_rt;
ifp = ro->ro_rt->rt_ifp;
- } else if ((error = in6_selectroute_fib(&dst_sa, opt, im6o, ro,
- &ifp, &rt, inp ? inp->inp_inc.inc_fibnum : M_GETFIB(m))) != 0) {
- switch (error) {
- case EHOSTUNREACH:
- V_ip6stat.ip6s_noroute++;
- break;
- case EADDRNOTAVAIL:
- default:
- break; /* XXX statistics? */
+ } else {
+ if (fwd_tag == NULL) {
+ bzero(&dst_sa, sizeof(dst_sa));
+ dst_sa.sin6_family = AF_INET6;
+ dst_sa.sin6_len = sizeof(dst_sa);
+ dst_sa.sin6_addr = ip6->ip6_dst;
}
- if (ifp != NULL)
- in6_ifstat_inc(ifp, ifs6_out_discard);
- goto bad;
+ error = in6_selectroute_fib(&dst_sa, opt, im6o, ro, &ifp,
+ &rt, inp ? inp->inp_inc.inc_fibnum : M_GETFIB(m));
+ if (error != 0) {
+ if (ifp != NULL)
+ in6_ifstat_inc(ifp, ifs6_out_discard);
+ goto bad;
+ }
}
if (rt == NULL) {
/*
@@ -933,7 +930,7 @@
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, sizeof(struct sockaddr_in6));
+ bcopy((fwd_tag+1), &dst_sa, sizeof(struct sockaddr_in6));
m->m_flags |= M_SKIP_FIREWALL;
m->m_flags &= ~M_IP6_NEXTHOP;
m_tag_delete(m, fwd_tag);
More information about the Midnightbsd-cvs
mailing list