Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Introduce in6_selecthlim_rt to consolidate an idiom for ...
details: https://anonhg.NetBSD.org/src/rev/c2df1bc25219
branches: trunk
changeset: 337771:c2df1bc25219
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Mon Apr 27 02:59:44 2015 +0000
description:
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
diffstat:
sys/netinet/dccp_usrreq.c | 11 +++--------
sys/netinet/tcp_input.c | 8 +++-----
sys/netinet/tcp_output.c | 8 +++-----
sys/netinet/tcp_subr.c | 25 ++++++-------------------
sys/netinet6/in6_pcb.c | 12 ++++++------
sys/netinet6/in6_pcb.h | 3 ++-
sys/netinet6/in6_src.c | 19 +++++++++++++++++--
sys/netinet6/udp6_output.c | 10 +++-------
8 files changed, 43 insertions(+), 53 deletions(-)
diffs (truncated from 322 to 300 lines):
diff -r c76e0dc1d2c3 -r c2df1bc25219 sys/netinet/dccp_usrreq.c
--- a/sys/netinet/dccp_usrreq.c Mon Apr 27 00:33:46 2015 +0000
+++ b/sys/netinet/dccp_usrreq.c Mon Apr 27 02:59:44 2015 +0000
@@ -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 @@
#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 @@
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 @@
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;
}
diff -r c76e0dc1d2c3 -r c2df1bc25219 sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c Mon Apr 27 00:33:46 2015 +0000
+++ b/sys/netinet/tcp_input.c Mon Apr 27 02:59:44 2015 +0000
@@ -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 @@
#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 @@
#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;
diff -r c76e0dc1d2c3 -r c2df1bc25219 sys/netinet/tcp_output.c
--- a/sys/netinet/tcp_output.c Mon Apr 27 00:33:46 2015 +0000
+++ b/sys/netinet/tcp_output.c Mon Apr 27 02:59:44 2015 +0000
@@ -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 @@
* 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) */
diff -r c76e0dc1d2c3 -r c2df1bc25219 sys/netinet/tcp_subr.c
--- a/sys/netinet/tcp_subr.c Mon Apr 27 00:33:46 2015 +0000
+++ b/sys/netinet/tcp_subr.c Mon Apr 27 02:59:44 2015 +0000
@@ -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 @@
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 @@
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 @@
struct tcpcb *
tcp_newtcpcb(int family, void *aux)
{
-#ifdef INET6
- struct rtentry *rt;
-#endif
struct tcpcb *tp;
int i;
@@ -1076,10 +1066,7 @@
{
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;
diff -r c76e0dc1d2c3 -r c2df1bc25219 sys/netinet6/in6_pcb.c
--- a/sys/netinet6/in6_pcb.c Mon Apr 27 00:33:46 2015 +0000
+++ b/sys/netinet6/in6_pcb.c Mon Apr 27 02:59:44 2015 +0000
@@ -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 @@
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 @@
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,
diff -r c76e0dc1d2c3 -r c2df1bc25219 sys/netinet6/in6_pcb.h
--- a/sys/netinet6/in6_pcb.h Mon Apr 27 00:33:46 2015 +0000
+++ b/sys/netinet6/in6_pcb.h Mon Apr 27 02:59:44 2015 +0000
@@ -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 @@
/* 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 *
diff -r c76e0dc1d2c3 -r c2df1bc25219 sys/netinet6/in6_src.c
--- a/sys/netinet6/in6_src.c Mon Apr 27 00:33:46 2015 +0000
+++ b/sys/netinet6/in6_src.c Mon Apr 27 02:59:44 2015 +0000
@@ -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 @@
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.
*/
diff -r c76e0dc1d2c3 -r c2df1bc25219 sys/netinet6/udp6_output.c
--- a/sys/netinet6/udp6_output.c Mon Apr 27 00:33:46 2015 +0000
+++ b/sys/netinet6/udp6_output.c Mon Apr 27 02:59:44 2015 +0000
@@ -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 @@
#include <sys/domain.h>
#include <net/if.h>
-#include <net/route.h>
Home |
Main Index |
Thread Index |
Old Index