Introduce in6_selecthlim_rt to consolidate an idiom for rt->rt_ifp
It consolidates a scattered routine: (rt = rtcache_validate(&in6p->in6p_route)) != NULL ? rt->rt_ifp : NULL
This commit is contained in:
parent
f0b45a5b6d
commit
2373b55abc
@ -1,5 +1,5 @@
|
||||
/* $KAME: dccp_usrreq.c,v 1.67 2005/11/03 16:05:04 nishida Exp $ */
|
||||
/* $NetBSD: dccp_usrreq.c,v 1.4 2015/04/26 21:40:49 rtr Exp $ */
|
||||
/* $NetBSD: dccp_usrreq.c,v 1.5 2015/04/27 02:59:44 ozaki-r Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Joacim Häggmark, Magnus Erixzon, Nils-Erik Mattsson
|
||||
@ -67,7 +67,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.4 2015/04/26 21:40:49 rtr Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.5 2015/04/27 02:59:44 ozaki-r Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_dccp.h"
|
||||
@ -91,7 +91,6 @@ __KERNEL_RCSID(0, "$NetBSD: dccp_usrreq.c,v 1.4 2015/04/26 21:40:49 rtr Exp $");
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
@ -2308,9 +2307,6 @@ dccp_newdccpcb(int family, void *aux)
|
||||
struct inpcb *inp;
|
||||
struct in6pcb *in6p;
|
||||
struct dccpcb *dp;
|
||||
#ifdef INET6
|
||||
struct rtentry *rt;
|
||||
#endif
|
||||
|
||||
DCCP_DEBUG((LOG_INFO, "Creating a new dccpcb!\n"));
|
||||
|
||||
@ -2362,8 +2358,7 @@ dccp_newdccpcb(int family, void *aux)
|
||||
case PF_INET6:
|
||||
in6p = (struct in6pcb *)aux;
|
||||
dp->d_in6pcb = in6p;
|
||||
rt = rtcache_validate(&in6p->in6p_route);
|
||||
in6p->in6p_ip6.ip6_hlim = in6_selecthlim(in6p, (rt != NULL) ? rt->rt_ifp : NULL);
|
||||
in6p->in6p_ip6.ip6_hlim = in6_selecthlim_rt(in6p);
|
||||
in6p->in6p_ppcb = dp;
|
||||
break;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tcp_input.c,v 1.337 2015/03/14 02:08:16 rtr Exp $ */
|
||||
/* $NetBSD: tcp_input.c,v 1.338 2015/04/27 02:59:44 ozaki-r Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -148,7 +148,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.337 2015/03/14 02:08:16 rtr Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.338 2015/04/27 02:59:44 ozaki-r Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
@ -174,7 +174,6 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.337 2015/03/14 02:08:16 rtr Exp $");
|
||||
#include <sys/cprng.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/if_types.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
@ -4797,8 +4796,7 @@ syn_cache_respond(struct syn_cache *sc, struct mbuf *m)
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
ip6->ip6_hlim = in6_selecthlim(NULL,
|
||||
(rt = rtcache_validate(ro)) != NULL ? rt->rt_ifp
|
||||
: NULL);
|
||||
(rt = rtcache_validate(ro)) != NULL ? rt->rt_ifp : NULL);
|
||||
|
||||
error = ip6_output(m, NULL /*XXX*/, ro, 0, NULL, so, NULL);
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tcp_output.c,v 1.180 2015/02/14 12:57:53 he Exp $ */
|
||||
/* $NetBSD: tcp_output.c,v 1.181 2015/04/27 02:59:44 ozaki-r Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -135,7 +135,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.180 2015/02/14 12:57:53 he Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.181 2015/04/27 02:59:44 ozaki-r Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
@ -1579,9 +1579,7 @@ timer:
|
||||
* setsockopt. Also, desired default hop limit might
|
||||
* be changed via Neighbor Discovery.
|
||||
*/
|
||||
ip6->ip6_hlim = in6_selecthlim(tp->t_in6pcb,
|
||||
(rt = rtcache_validate(ro)) != NULL ? rt->rt_ifp
|
||||
: NULL);
|
||||
ip6->ip6_hlim = in6_selecthlim_rt(tp->t_in6pcb);
|
||||
}
|
||||
ip6->ip6_flow |= htonl(ecn_tos << 20);
|
||||
/* ip6->ip6_flow = ??? (from template) */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tcp_subr.c,v 1.259 2015/04/13 15:51:00 riastradh Exp $ */
|
||||
/* $NetBSD: tcp_subr.c,v 1.260 2015/04/27 02:59:44 ozaki-r Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
@ -91,7 +91,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.259 2015/04/13 15:51:00 riastradh Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.260 2015/04/27 02:59:44 ozaki-r Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
@ -637,9 +637,6 @@ int
|
||||
tcp_respond(struct tcpcb *tp, struct mbuf *mtemplate, struct mbuf *m,
|
||||
struct tcphdr *th0, tcp_seq ack, tcp_seq seq, int flags)
|
||||
{
|
||||
#ifdef INET6
|
||||
struct rtentry *rt;
|
||||
#endif
|
||||
struct route *ro;
|
||||
int error, tlen, win = 0;
|
||||
int hlen;
|
||||
@ -878,13 +875,9 @@ tcp_respond(struct tcpcb *tp, struct mbuf *mtemplate, struct mbuf *m,
|
||||
th->th_sum = in6_cksum(m, IPPROTO_TCP, sizeof(struct ip6_hdr),
|
||||
tlen);
|
||||
ip6->ip6_plen = htons(tlen);
|
||||
if (tp && tp->t_in6pcb) {
|
||||
struct ifnet *oifp;
|
||||
ro = &tp->t_in6pcb->in6p_route;
|
||||
oifp = (rt = rtcache_validate(ro)) != NULL ? rt->rt_ifp
|
||||
: NULL;
|
||||
ip6->ip6_hlim = in6_selecthlim(tp->t_in6pcb, oifp);
|
||||
} else
|
||||
if (tp && tp->t_in6pcb)
|
||||
ip6->ip6_hlim = in6_selecthlim_rt(tp->t_in6pcb);
|
||||
else
|
||||
ip6->ip6_hlim = ip6_defhlim;
|
||||
ip6->ip6_flow &= ~IPV6_FLOWINFO_MASK;
|
||||
if (ip6_auto_flowlabel) {
|
||||
@ -1035,9 +1028,6 @@ tcp_tcpcb_template(void)
|
||||
struct tcpcb *
|
||||
tcp_newtcpcb(int family, void *aux)
|
||||
{
|
||||
#ifdef INET6
|
||||
struct rtentry *rt;
|
||||
#endif
|
||||
struct tcpcb *tp;
|
||||
int i;
|
||||
|
||||
@ -1076,10 +1066,7 @@ tcp_newtcpcb(int family, void *aux)
|
||||
{
|
||||
struct in6pcb *in6p = (struct in6pcb *)aux;
|
||||
|
||||
in6p->in6p_ip6.ip6_hlim = in6_selecthlim(in6p,
|
||||
(rt = rtcache_validate(&in6p->in6p_route)) != NULL
|
||||
? rt->rt_ifp
|
||||
: NULL);
|
||||
in6p->in6p_ip6.ip6_hlim = in6_selecthlim_rt(in6p);
|
||||
in6p->in6p_ppcb = (void *)tp;
|
||||
|
||||
tp->t_in6pcb = in6p;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in6_pcb.c,v 1.137 2015/04/26 16:45:50 rtr Exp $ */
|
||||
/* $NetBSD: in6_pcb.c,v 1.138 2015/04/27 02:59:44 ozaki-r Exp $ */
|
||||
/* $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -62,7 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.137 2015/04/26 16:45:50 rtr Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.138 2015/04/27 02:59:44 ozaki-r Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
@ -426,7 +426,6 @@ in6_pcbbind(void *v, struct sockaddr_in6 *sin6, struct lwp *l)
|
||||
int
|
||||
in6_pcbconnect(void *v, struct mbuf *nam, struct lwp *l)
|
||||
{
|
||||
struct rtentry *rt;
|
||||
struct in6pcb *in6p = v;
|
||||
struct in6_addr *in6a = NULL;
|
||||
struct sockaddr_in6 *sin6 = mtod(nam, struct sockaddr_in6 *);
|
||||
@ -526,10 +525,11 @@ in6_pcbconnect(void *v, struct mbuf *nam, struct lwp *l)
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
if (ifp == NULL && (rt = rtcache_validate(&in6p->in6p_route)) != NULL)
|
||||
ifp = rt->rt_ifp;
|
||||
|
||||
in6p->in6p_ip6.ip6_hlim = (u_int8_t)in6_selecthlim(in6p, ifp);
|
||||
if (ifp != NULL)
|
||||
in6p->in6p_ip6.ip6_hlim = (u_int8_t)in6_selecthlim(in6p, ifp);
|
||||
else
|
||||
in6p->in6p_ip6.ip6_hlim = (u_int8_t)in6_selecthlim_rt(in6p);
|
||||
|
||||
if (in6_pcblookup_connect(in6p->in6p_table, &sin6->sin6_addr,
|
||||
sin6->sin6_port,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in6_pcb.h,v 1.43 2015/04/24 22:32:37 rtr Exp $ */
|
||||
/* $NetBSD: in6_pcb.h,v 1.44 2015/04/27 02:59:44 ozaki-r Exp $ */
|
||||
/* $KAME: in6_pcb.h,v 1.45 2001/02/09 05:59:46 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -174,6 +174,7 @@ void in6_setsockaddr(struct in6pcb *, struct sockaddr_in6 *);
|
||||
|
||||
/* in in6_src.c */
|
||||
int in6_selecthlim(struct in6pcb *, struct ifnet *);
|
||||
int in6_selecthlim_rt(struct in6pcb *);
|
||||
int in6_pcbsetport(struct sockaddr_in6 *, struct in6pcb *, struct lwp *);
|
||||
|
||||
extern struct rtentry *
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: in6_src.c,v 1.56 2015/01/20 21:27:36 roy Exp $ */
|
||||
/* $NetBSD: in6_src.c,v 1.57 2015/04/27 02:59:44 ozaki-r Exp $ */
|
||||
/* $KAME: in6_src.c,v 1.159 2005/10/19 01:40:32 t-momose Exp $ */
|
||||
|
||||
/*
|
||||
@ -66,7 +66,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.56 2015/01/20 21:27:36 roy Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.57 2015/04/27 02:59:44 ozaki-r Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
|
||||
@ -788,6 +788,21 @@ in6_selecthlim(struct in6pcb *in6p, struct ifnet *ifp)
|
||||
return (ip6_defhlim);
|
||||
}
|
||||
|
||||
int
|
||||
in6_selecthlim_rt(struct in6pcb *in6p)
|
||||
{
|
||||
struct rtentry *rt;
|
||||
|
||||
if (in6p == NULL)
|
||||
return in6_selecthlim(in6p, NULL);
|
||||
|
||||
rt = rtcache_validate(&in6p->in6p_route);
|
||||
if (rt != NULL)
|
||||
return in6_selecthlim(in6p, rt->rt_ifp);
|
||||
else
|
||||
return in6_selecthlim(in6p, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find an empty port and set it to the specified PCB.
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: udp6_output.c,v 1.47 2014/12/05 18:45:37 seanb Exp $ */
|
||||
/* $NetBSD: udp6_output.c,v 1.48 2015/04/27 02:59:44 ozaki-r Exp $ */
|
||||
/* $KAME: udp6_output.c,v 1.43 2001/10/15 09:19:52 itojun Exp $ */
|
||||
|
||||
/*
|
||||
@ -62,7 +62,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: udp6_output.c,v 1.47 2014/12/05 18:45:37 seanb Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: udp6_output.c,v 1.48 2015/04/27 02:59:44 ozaki-r Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
|
||||
@ -80,7 +80,6 @@ __KERNEL_RCSID(0, "$NetBSD: udp6_output.c,v 1.47 2014/12/05 18:45:37 seanb Exp $
|
||||
#include <sys/domain.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/if_types.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
@ -115,7 +114,6 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
|
||||
struct mbuf * const addr6, struct mbuf * const control,
|
||||
struct lwp * const l)
|
||||
{
|
||||
struct rtentry *rt;
|
||||
u_int32_t ulen = m->m_pkthdr.len;
|
||||
u_int32_t plen = sizeof(struct udphdr) + ulen;
|
||||
struct ip6_hdr *ip6;
|
||||
@ -358,9 +356,7 @@ udp6_output(struct in6pcb * const in6p, struct mbuf *m,
|
||||
ip6->ip6_plen = htons((u_int16_t)plen);
|
||||
#endif
|
||||
ip6->ip6_nxt = IPPROTO_UDP;
|
||||
ip6->ip6_hlim = in6_selecthlim(in6p,
|
||||
(rt = rtcache_validate(&in6p->in6p_route)) != NULL
|
||||
? rt->rt_ifp : NULL);
|
||||
ip6->ip6_hlim = in6_selecthlim_rt(in6p);
|
||||
ip6->ip6_src = *laddr;
|
||||
ip6->ip6_dst = *faddr;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user