summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2013-10-23 19:57:51 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2013-10-23 19:57:51 +0000
commit383971453455794b3c815551394c28120c470038 (patch)
tree908419dd11d893922fe9b568f82819701b872b5a /sys
parent9fe31fae04b30b41593a6aa57aba418ca04d2ece (diff)
Back when some NRL code was merged into KAME to create the *BSD IPV6
stack (factoid: by a bunch of people in my living room), some compatibility #define's were created to shim incompatible inpcb access methods. There was an understanding they would eventually be removed. Since they are error prone, and 1999 is a long time ago, now they die. ok mikeb claudio mpi
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/in_pcb.c4
-rw-r--r--sys/netinet/in_pcb.h13
-rw-r--r--sys/netinet6/icmp6.c83
-rw-r--r--sys/netinet6/in6_src.c26
-rw-r--r--sys/netinet6/ip6_input.c20
-rw-r--r--sys/netinet6/ip6_output.c6
-rw-r--r--sys/netinet6/raw_ip6.c147
-rw-r--r--sys/netinet6/udp6_output.c61
8 files changed, 136 insertions, 224 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 20585c892b8..bf1a5208c8b 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.c,v 1.144 2013/10/20 22:28:58 bluhm Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.145 2013/10/23 19:57:49 deraadt Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@@ -209,7 +209,7 @@ in_pcballoc(struct socket *so, struct inpcbtable *table)
*/
if (sotopf(so) == PF_INET6)
inp->inp_flags = INP_IPV6;
- inp->in6p_cksum = -1;
+ inp->inp_cksum6 = -1;
#endif /* INET6 */
return (0);
}
diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h
index 40b53761a85..fe0745c5dd4 100644
--- a/sys/netinet/in_pcb.h
+++ b/sys/netinet/in_pcb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.h,v 1.80 2013/10/20 11:03:00 phessler Exp $ */
+/* $OpenBSD: in_pcb.h,v 1.81 2013/10/23 19:57:50 deraadt Exp $ */
/* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */
/*
@@ -142,9 +142,9 @@ struct inpcb {
struct ipsec_ref *inp_ipsec_remoteauth;
#define inp_flowinfo inp_hu.hu_ipv6.ip6_flow
- int in6p_cksum;
+ int inp_cksum6;
#ifndef _KERNEL
-#define inp_csumoffset in6p_cksum
+#define inp_csumoffset inp_cksum6
#endif
struct icmp6_filter *inp_icmp6filt;
struct pf_state_key *inp_pf_sk;
@@ -190,12 +190,8 @@ struct inpcbtable {
*/
#define INP_IPV6 0x100 /* sotopf(inp->inp_socket) == PF_INET6 */
-#if 1 /*KAME*/
/*
- * Flags in in6p_flags
- * We define KAME's original flags in higher 16 bits as much as possible
- * for compatibility with *bsd*s.
- * XXX: Should IN6P_HIGHPORT and IN6P_LOWPORT be moved as well?
+ * Flags in inp_flags for IPV6
*/
#define IN6P_HIGHPORT INP_HIGHPORT /* user wants "high" port */
#define IN6P_LOWPORT INP_LOWPORT /* user wants "low" port */
@@ -219,7 +215,6 @@ struct inpcbtable {
IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS|\
IN6P_TCLASS|IN6P_AUTOFLOWLABEL|IN6P_RFC2292|\
IN6P_MTU|IN6P_RECVDSTPORT)
-#endif
#define INPLOOKUP_WILDCARD 1
#define INPLOOKUP_SETLOCAL 2
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c
index 71c8abb8868..ca5ffbd420c 100644
--- a/sys/netinet6/icmp6.c
+++ b/sys/netinet6/icmp6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: icmp6.c,v 1.133 2013/10/21 12:27:14 deraadt Exp $ */
+/* $OpenBSD: icmp6.c,v 1.134 2013/10/23 19:57:50 deraadt Exp $ */
/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
/*
@@ -102,33 +102,6 @@
#include <net/pfvar.h>
#endif
-/* inpcb members */
-#define in6pcb inpcb
-#define in6p_laddr inp_laddr6
-#define in6p_faddr inp_faddr6
-#define in6p_icmp6filt inp_icmp6filt
-#define in6p_route inp_route
-#define in6p_socket inp_socket
-#define in6p_flags inp_flags
-#define in6p_moptions inp_moptions6
-#define in6p_outputopts inp_outputopts6
-#define in6p_ip6 inp_ipv6
-#define in6p_flowinfo inp_flowinfo
-#define in6p_sp inp_sp
-#define in6p_next inp_next
-#define in6p_prev inp_prev
-/* macro names */
-#define sotoin6pcb sotoinpcb
-/* function names */
-#define in6_pcbdetach in_pcbdetach
-#define in6_rtchange in_rtchange
-
-/*
- * for KAME src sync over BSD*'s. XXX: FreeBSD (>=3) are VERY different from
- * others...
- */
-#define in6p_ip6_nxt inp_ipv6.ip6_nxt
-
struct icmp6stat icmp6stat;
extern struct inpcbtable rawin6pcbtable;
@@ -1883,8 +1856,8 @@ icmp6_rip6_input(struct mbuf **mp, int off)
{
struct mbuf *m = *mp;
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
- struct in6pcb *in6p;
- struct in6pcb *last = NULL;
+ struct inpcb *in6p;
+ struct inpcb *last = NULL;
struct sockaddr_in6 rip6src;
struct icmp6_hdr *icmp6;
struct mbuf *opts = NULL;
@@ -1902,9 +1875,9 @@ icmp6_rip6_input(struct mbuf **mp, int off)
(void)in6_recoverscope(&rip6src, &ip6->ip6_src, m->m_pkthdr.rcvif);
CIRCLEQ_FOREACH(in6p, &rawin6pcbtable.inpt_queue, inp_queue) {
- if (!(in6p->in6p_flags & INP_IPV6))
+ if (!(in6p->inp_flags & INP_IPV6))
continue;
- if (in6p->in6p_ip6_nxt != IPPROTO_ICMPV6)
+ if (in6p->inp_ipv6.ip6_nxt != IPPROTO_ICMPV6)
continue;
#if NPF > 0
if (m->m_pkthdr.pf.flags & PF_TAG_DIVERTED) {
@@ -1913,53 +1886,53 @@ icmp6_rip6_input(struct mbuf **mp, int off)
/* XXX rdomain support */
if ((divert = pf_find_divert(m)) == NULL)
continue;
- if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr,
+ if (!IN6_ARE_ADDR_EQUAL(&in6p->inp_laddr6,
&divert->addr.v6))
continue;
} else
#endif
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) &&
- !IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &ip6->ip6_dst))
+ if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->inp_laddr6) &&
+ !IN6_ARE_ADDR_EQUAL(&in6p->inp_laddr6, &ip6->ip6_dst))
continue;
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr) &&
- !IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr, &ip6->ip6_src))
+ if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->inp_faddr6) &&
+ !IN6_ARE_ADDR_EQUAL(&in6p->inp_faddr6, &ip6->ip6_src))
continue;
- if (in6p->in6p_icmp6filt
+ if (in6p->inp_icmp6filt
&& ICMP6_FILTER_WILLBLOCK(icmp6->icmp6_type,
- in6p->in6p_icmp6filt))
+ in6p->inp_icmp6filt))
continue;
if (last) {
struct mbuf *n;
if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
- if (last->in6p_flags & IN6P_CONTROLOPTS)
+ if (last->inp_flags & IN6P_CONTROLOPTS)
ip6_savecontrol(last, n, &opts);
/* strip intermediate headers */
m_adj(n, off);
- if (sbappendaddr(&last->in6p_socket->so_rcv,
+ if (sbappendaddr(&last->inp_socket->so_rcv,
sin6tosa(&rip6src), n, opts) == 0) {
/* should notify about lost packet */
m_freem(n);
if (opts)
m_freem(opts);
} else
- sorwakeup(last->in6p_socket);
+ sorwakeup(last->inp_socket);
opts = NULL;
}
}
last = in6p;
}
if (last) {
- if (last->in6p_flags & IN6P_CONTROLOPTS)
+ if (last->inp_flags & IN6P_CONTROLOPTS)
ip6_savecontrol(last, m, &opts);
/* strip intermediate headers */
m_adj(m, off);
- if (sbappendaddr(&last->in6p_socket->so_rcv,
+ if (sbappendaddr(&last->inp_socket->so_rcv,
sin6tosa(&rip6src), m, opts) == 0) {
m_freem(m);
if (opts)
m_freem(opts);
} else
- sorwakeup(last->in6p_socket);
+ sorwakeup(last->inp_socket);
} else {
m_freem(m);
ip6stat.ip6s_delivered--;
@@ -2642,11 +2615,6 @@ fail:
m_freem(m0);
}
-/* NRL PCB */
-#define sotoin6pcb sotoinpcb
-#define in6pcb inpcb
-#define in6p_icmp6filt inp_icmp6filt
-
/*
* ICMPv6 socket option processing.
*/
@@ -2655,7 +2623,7 @@ icmp6_ctloutput(int op, struct socket *so, int level, int optname,
struct mbuf **mp)
{
int error = 0;
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *in6p = sotoinpcb(so);
struct mbuf *m = *mp;
if (level != IPPROTO_ICMPV6) {
@@ -2676,11 +2644,11 @@ icmp6_ctloutput(int op, struct socket *so, int level, int optname,
break;
}
p = mtod(m, struct icmp6_filter *);
- if (!p || !in6p->in6p_icmp6filt) {
+ if (!p || !in6p->inp_icmp6filt) {
error = EINVAL;
break;
}
- bcopy(p, in6p->in6p_icmp6filt,
+ bcopy(p, in6p->inp_icmp6filt,
sizeof(struct icmp6_filter));
error = 0;
break;
@@ -2700,14 +2668,14 @@ icmp6_ctloutput(int op, struct socket *so, int level, int optname,
{
struct icmp6_filter *p;
- if (!in6p->in6p_icmp6filt) {
+ if (!in6p->inp_icmp6filt) {
error = EINVAL;
break;
}
*mp = m = m_get(M_WAIT, MT_SOOPTS);
m->m_len = sizeof(struct icmp6_filter);
p = mtod(m, struct icmp6_filter *);
- bcopy(in6p->in6p_icmp6filt, p,
+ bcopy(in6p->inp_icmp6filt, p,
sizeof(struct icmp6_filter));
error = 0;
break;
@@ -2723,11 +2691,6 @@ icmp6_ctloutput(int op, struct socket *so, int level, int optname,
return (error);
}
-/* NRL PCB */
-#undef sotoin6pcb
-#undef in6pcb
-#undef in6p_icmp6filt
-
/*
* Perform rate limit check.
* Returns 0 if it is okay to send the icmp6 packet.
diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c
index 49d334a3d6e..2b6eb5c8f1a 100644
--- a/sys/netinet6/in6_src.c
+++ b/sys/netinet6/in6_src.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_src.c,v 1.34 2013/10/21 08:42:25 phessler Exp $ */
+/* $OpenBSD: in6_src.c,v 1.35 2013/10/23 19:57:50 deraadt Exp $ */
/* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */
/*
@@ -572,20 +572,16 @@ in6_selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts,
* hop limit of the interface specified by router advertisement.
* 3. The system default hoplimit.
*/
-#define in6pcb inpcb
-#define in6p_hops inp_hops
int
-in6_selecthlim(struct in6pcb *in6p, struct ifnet *ifp)
+in6_selecthlim(struct inpcb *in6p, struct ifnet *ifp)
{
- if (in6p && in6p->in6p_hops >= 0)
- return (in6p->in6p_hops);
+ if (in6p && in6p->inp_hops >= 0)
+ return (in6p->inp_hops);
else if (ifp)
return (ND_IFINFO(ifp)->chlim);
else
return (ip6_defhlim);
}
-#undef in6pcb
-#undef in6p_hops
/*
* generate kernel-internal form (scopeid embedded into s6_addr16[1]).
@@ -607,8 +603,6 @@ in6_embedscope(in6, sin6, in6p, ifpp)
struct in6_addr *in6;
const struct sockaddr_in6 *sin6;
struct inpcb *in6p;
-#define in6p_outputopts inp_outputopts6
-#define in6p_moptions inp_moptions6
struct ifnet **ifpp;
{
struct ifnet *ifp = NULL;
@@ -631,17 +625,17 @@ in6_embedscope(in6, sin6, in6p, ifpp)
* KAME assumption: link id == interface id
*/
- if (in6p && in6p->in6p_outputopts &&
- (pi = in6p->in6p_outputopts->ip6po_pktinfo) &&
+ if (in6p && in6p->inp_outputopts6 &&
+ (pi = in6p->inp_outputopts6->ip6po_pktinfo) &&
pi->ipi6_ifindex) {
ifp = if_get(pi->ipi6_ifindex);
if (ifp == NULL)
return ENXIO; /* XXX EINVAL? */
in6->s6_addr16[1] = htons(pi->ipi6_ifindex);
} else if (in6p && IN6_IS_ADDR_MULTICAST(in6) &&
- in6p->in6p_moptions &&
- in6p->in6p_moptions->im6o_multicast_ifp) {
- ifp = in6p->in6p_moptions->im6o_multicast_ifp;
+ in6p->inp_moptions6 &&
+ in6p->inp_moptions6->im6o_multicast_ifp) {
+ ifp = in6p->inp_moptions6->im6o_multicast_ifp;
in6->s6_addr16[1] = htons(ifp->if_index);
} else if (scopeid) {
ifp = if_get(scopeid);
@@ -657,8 +651,6 @@ in6_embedscope(in6, sin6, in6p, ifpp)
return 0;
}
-#undef in6p_outputopts
-#undef in6p_moptions
/*
* generate standard sockaddr_in6 from embedded form.
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index 3ed6bd301b9..068218e4f1b 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_input.c,v 1.117 2013/10/21 12:27:16 deraadt Exp $ */
+/* $OpenBSD: ip6_input.c,v 1.118 2013/10/23 19:57:50 deraadt Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -925,8 +925,7 @@ ip6_unknown_opt(u_int8_t *optp, struct mbuf *m, int off)
void
ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
{
-#define IS2292(x, y) ((in6p->in6p_flags & IN6P_RFC2292) ? (x) : (y))
-# define in6p_flags inp_flags
+#define IS2292(x, y) ((in6p->inp_flags & IN6P_RFC2292) ? (x) : (y))
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
#ifdef SO_TIMESTAMP
@@ -942,7 +941,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
#endif
/* RFC 2292 sec. 5 */
- if ((in6p->in6p_flags & IN6P_PKTINFO) != 0) {
+ if ((in6p->inp_flags & IN6P_PKTINFO) != 0) {
struct in6_pktinfo pi6;
bcopy(&ip6->ip6_dst, &pi6.ipi6_addr, sizeof(struct in6_addr));
if (IN6_IS_SCOPE_EMBED(&pi6.ipi6_addr))
@@ -956,7 +955,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
mp = &(*mp)->m_next;
}
- if ((in6p->in6p_flags & IN6P_HOPLIMIT) != 0) {
+ if ((in6p->inp_flags & IN6P_HOPLIMIT) != 0) {
int hlim = ip6->ip6_hlim & 0xff;
*mp = sbcreatecontrol((caddr_t) &hlim, sizeof(int),
IS2292(IPV6_2292HOPLIMIT, IPV6_HOPLIMIT), IPPROTO_IPV6);
@@ -964,7 +963,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
mp = &(*mp)->m_next;
}
- if ((in6p->in6p_flags & IN6P_TCLASS) != 0) {
+ if ((in6p->inp_flags & IN6P_TCLASS) != 0) {
u_int32_t flowinfo;
int tclass;
@@ -985,7 +984,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
* returned to normal user.
* See also RFC 2292 section 6 (or RFC 3542 section 8).
*/
- if ((in6p->in6p_flags & IN6P_HOPOPTS) != 0) {
+ if ((in6p->inp_flags & IN6P_HOPOPTS) != 0) {
/*
* Check if a hop-by-hop options header is contatined in the
* received packet, and if so, store the options as ancillary
@@ -1030,7 +1029,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
}
/* IPV6_DSTOPTS and IPV6_RTHDR socket options */
- if ((in6p->in6p_flags & (IN6P_RTHDR | IN6P_DSTOPTS)) != 0) {
+ if ((in6p->inp_flags & (IN6P_RTHDR | IN6P_DSTOPTS)) != 0) {
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
int nxt = ip6->ip6_nxt, off = sizeof(struct ip6_hdr);
@@ -1078,7 +1077,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
switch (nxt) {
case IPPROTO_DSTOPTS:
- if (!(in6p->in6p_flags & IN6P_DSTOPTS))
+ if (!(in6p->inp_flags & IN6P_DSTOPTS))
break;
*mp = sbcreatecontrol((caddr_t)ip6e, elen,
@@ -1089,7 +1088,7 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
break;
case IPPROTO_ROUTING:
- if (!(in6p->in6p_flags & IN6P_RTHDR))
+ if (!(in6p->inp_flags & IN6P_RTHDR))
break;
*mp = sbcreatecontrol((caddr_t)ip6e, elen,
@@ -1125,7 +1124,6 @@ ip6_savecontrol(struct inpcb *in6p, struct mbuf *m, struct mbuf **mp)
loopend:
;
}
-# undef in6p_flags
}
/*
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index e24b41ddbf8..5882598f092 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_output.c,v 1.147 2013/10/21 12:40:39 deraadt Exp $ */
+/* $OpenBSD: ip6_output.c,v 1.148 2013/10/23 19:57:50 deraadt Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
@@ -2034,14 +2034,14 @@ ip6_raw_ctloutput(int op, struct socket *so, int level, int optname,
if (optval != icmp6off)
error = EINVAL;
} else
- inp->in6p_cksum = optval;
+ inp->inp_cksum6 = optval;
break;
case PRCO_GETOPT:
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6)
optval = icmp6off;
else
- optval = inp->in6p_cksum;
+ optval = inp->inp_cksum6;
*mp = m = m_get(M_WAIT, MT_SOOPTS);
m->m_len = sizeof(int);
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index 5f3e75d7698..c037815376d 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip6.c,v 1.60 2013/10/20 11:03:03 phessler Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.61 2013/10/23 19:57:50 deraadt Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
@@ -100,26 +100,6 @@
/*
* Raw interface to IP6 protocol.
*/
-/* inpcb members */
-#define in6pcb inpcb
-#define in6p_laddr inp_laddr6
-#define in6p_faddr inp_faddr6
-#define in6p_icmp6filt inp_icmp6filt
-#define in6p_route inp_route6
-#define in6p_socket inp_socket
-#define in6p_flags inp_flags
-#define in6p_moptions inp_moptions6
-#define in6p_outputopts inp_outputopts6
-#define in6p_ip6 inp_ipv6
-#define in6p_flowinfo inp_flowinfo
-#define in6p_sp inp_sp
-#define in6p_next inp_next
-#define in6p_prev inp_prev
-/* macro names */
-#define sotoin6pcb sotoinpcb
-/* function names */
-#define in6_pcbdetach in_pcbdetach
-#define in6_rtchange in_rtchange
struct inpcbtable rawin6pcbtable;
@@ -145,8 +125,8 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
{
struct mbuf *m = *mp;
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
- struct in6pcb *in6p;
- struct in6pcb *last = NULL;
+ struct inpcb *in6p;
+ struct inpcb *last = NULL;
struct sockaddr_in6 rip6src;
struct mbuf *opts = NULL;
@@ -167,12 +147,12 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
(void)in6_recoverscope(&rip6src, &ip6->ip6_src, m->m_pkthdr.rcvif);
CIRCLEQ_FOREACH(in6p, &rawin6pcbtable.inpt_queue, inp_queue) {
- if (in6p->in6p_socket->so_state & SS_CANTRCVMORE)
+ if (in6p->inp_socket->so_state & SS_CANTRCVMORE)
continue;
- if (!(in6p->in6p_flags & INP_IPV6))
+ if (!(in6p->inp_flags & INP_IPV6))
continue;
- if (in6p->in6p_ip6.ip6_nxt &&
- in6p->in6p_ip6.ip6_nxt != proto)
+ if (in6p->inp_ipv6.ip6_nxt &&
+ in6p->inp_ipv6.ip6_nxt != proto)
continue;
#if NPF > 0
if (m->m_pkthdr.pf.flags & PF_TAG_DIVERTED) {
@@ -181,18 +161,18 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
/* XXX rdomain support */
if ((divert = pf_find_divert(m)) == NULL)
continue;
- if (!IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr,
+ if (!IN6_ARE_ADDR_EQUAL(&in6p->inp_laddr6,
&divert->addr.v6))
continue;
} else
#endif
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_laddr) &&
- !IN6_ARE_ADDR_EQUAL(&in6p->in6p_laddr, &ip6->ip6_dst))
+ if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->inp_laddr6) &&
+ !IN6_ARE_ADDR_EQUAL(&in6p->inp_laddr6, &ip6->ip6_dst))
continue;
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr) &&
- !IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr, &ip6->ip6_src))
+ if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->inp_faddr6) &&
+ !IN6_ARE_ADDR_EQUAL(&in6p->inp_faddr6, &ip6->ip6_src))
continue;
- if (in6p->in6p_cksum != -1) {
+ if (in6p->inp_cksum6 != -1) {
rip6stat.rip6s_isum++;
if (in6_cksum(m, proto, *offp,
m->m_pkthdr.len - *offp)) {
@@ -203,11 +183,11 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
if (last) {
struct mbuf *n;
if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {
- if (last->in6p_flags & IN6P_CONTROLOPTS)
+ if (last->inp_flags & IN6P_CONTROLOPTS)
ip6_savecontrol(last, n, &opts);
/* strip intermediate headers */
m_adj(n, *offp);
- if (sbappendaddr(&last->in6p_socket->so_rcv,
+ if (sbappendaddr(&last->inp_socket->so_rcv,
sin6tosa(&rip6src), n, opts) == 0) {
/* should notify about lost packet */
m_freem(n);
@@ -215,25 +195,25 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
m_freem(opts);
rip6stat.rip6s_fullsock++;
} else
- sorwakeup(last->in6p_socket);
+ sorwakeup(last->inp_socket);
opts = NULL;
}
}
last = in6p;
}
if (last) {
- if (last->in6p_flags & IN6P_CONTROLOPTS)
+ if (last->inp_flags & IN6P_CONTROLOPTS)
ip6_savecontrol(last, m, &opts);
/* strip intermediate headers */
m_adj(m, *offp);
- if (sbappendaddr(&last->in6p_socket->so_rcv,
+ if (sbappendaddr(&last->inp_socket->so_rcv,
sin6tosa(&rip6src), m, opts) == 0) {
m_freem(m);
if (opts)
m_freem(opts);
rip6stat.rip6s_fullsock++;
} else
- sorwakeup(last->in6p_socket);
+ sorwakeup(last->inp_socket);
} else {
rip6stat.rip6s_nosock++;
if (m->m_flags & M_MCAST)
@@ -260,7 +240,7 @@ rip6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d)
struct sockaddr_in6 *sa6 = satosin6(sa);
const struct sockaddr_in6 *sa6_src = NULL;
void *cmdarg;
- void (*notify)(struct in6pcb *, int) = in6_rtchange;
+ void (*notify)(struct inpcb *, int) = in_rtchange;
int nxt;
if (sa->sa_family != AF_INET6 ||
@@ -270,7 +250,7 @@ rip6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d)
if ((unsigned)cmd >= PRC_NCMDS)
return;
if (PRC_IS_REDIRECT(cmd))
- notify = in6_rtchange, d = NULL;
+ notify = in_rtchange, d = NULL;
else if (cmd == PRC_HOSTDEAD)
d = NULL;
else if (cmd == PRC_MSGSIZE)
@@ -294,7 +274,7 @@ rip6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d)
if (ip6 && cmd == PRC_MSGSIZE) {
int valid = 0;
- struct in6pcb *in6p;
+ struct inpcb *in6p;
/*
* Check to see if we have a valid raw IPv6 socket
@@ -303,7 +283,6 @@ rip6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d)
* XXX chase extension headers, or pass final nxt value
* from icmp6_notify_error()
*/
- in6p = NULL;
in6p = in6_pcbhashlookup(&rawin6pcbtable, &sa6->sin6_addr, 0,
&sa6_src->sin6_addr, 0, rdomain);
#if 0
@@ -322,8 +301,8 @@ rip6_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *d)
}
#endif
- if (in6p && in6p->in6p_ip6.ip6_nxt &&
- in6p->in6p_ip6.ip6_nxt == nxt)
+ if (in6p && in6p->inp_ipv6.ip6_nxt &&
+ in6p->inp_ipv6.ip6_nxt == nxt)
valid++;
/*
@@ -360,7 +339,7 @@ rip6_output(struct mbuf *m, ...)
struct mbuf *control;
struct in6_addr *dst;
struct ip6_hdr *ip6;
- struct in6pcb *in6p;
+ struct inpcb *in6p;
u_int plen = m->m_pkthdr.len;
int error = 0;
struct ip6_pktopts opt, *optp = NULL, *origoptp;
@@ -376,7 +355,7 @@ rip6_output(struct mbuf *m, ...)
control = va_arg(ap, struct mbuf *);
va_end(ap);
- in6p = sotoin6pcb(so);
+ in6p = sotoinpcb(so);
priv = 0;
if ((so->so_state & SS_PRIV) != 0)
@@ -384,12 +363,12 @@ rip6_output(struct mbuf *m, ...)
dst = &dstsock->sin6_addr;
if (control) {
if ((error = ip6_setpktopts(control, &opt,
- in6p->in6p_outputopts,
+ in6p->inp_outputopts6,
priv, so->so_proto->pr_protocol)) != 0)
goto bad;
optp = &opt;
} else
- optp = in6p->in6p_outputopts;
+ optp = in6p->inp_outputopts6;
/*
* For an ICMPv6 packet, we should know its type and code
@@ -420,13 +399,13 @@ rip6_output(struct mbuf *m, ...)
ip6->ip6_dst = *dst;
/* KAME hack: embed scopeid */
- origoptp = in6p->in6p_outputopts;
- in6p->in6p_outputopts = optp;
+ origoptp = in6p->inp_outputopts6;
+ in6p->inp_outputopts6 = optp;
if (in6_embedscope(&ip6->ip6_dst, dstsock, in6p, &oifp) != 0) {
error = EINVAL;
goto bad;
}
- in6p->in6p_outputopts = origoptp;
+ in6p->inp_outputopts6 = origoptp;
/*
* Source address selection.
@@ -434,30 +413,30 @@ rip6_output(struct mbuf *m, ...)
{
struct in6_addr *in6a;
- if ((in6a = in6_selectsrc(dstsock, optp, in6p->in6p_moptions,
- &in6p->in6p_route, &in6p->in6p_laddr, &error,
+ if ((in6a = in6_selectsrc(dstsock, optp, in6p->inp_moptions6,
+ &in6p->inp_route6, &in6p->inp_laddr6, &error,
in6p->inp_rtableid)) == 0) {
if (error == 0)
error = EADDRNOTAVAIL;
goto bad;
}
ip6->ip6_src = *in6a;
- if (in6p->in6p_route.ro_rt &&
- in6p->in6p_route.ro_rt->rt_flags & RTF_UP)
- oifp = in6p->in6p_route.ro_rt->rt_ifp;
+ if (in6p->inp_route6.ro_rt &&
+ in6p->inp_route6.ro_rt->rt_flags & RTF_UP)
+ oifp = in6p->inp_route6.ro_rt->rt_ifp;
}
- ip6->ip6_flow = in6p->in6p_flowinfo & IPV6_FLOWINFO_MASK;
+ ip6->ip6_flow = in6p->inp_flowinfo & IPV6_FLOWINFO_MASK;
ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
ip6->ip6_vfc |= IPV6_VERSION;
#if 0 /* ip6_plen will be filled in ip6_output. */
ip6->ip6_plen = htons((u_short)plen);
#endif
- ip6->ip6_nxt = in6p->in6p_ip6.ip6_nxt;
+ ip6->ip6_nxt = in6p->inp_ipv6.ip6_nxt;
ip6->ip6_hlim = in6_selecthlim(in6p, oifp);
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 ||
- in6p->in6p_cksum != -1) {
+ in6p->inp_cksum6 != -1) {
struct mbuf *n;
int off;
u_int16_t *sump;
@@ -467,7 +446,7 @@ rip6_output(struct mbuf *m, ...)
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6)
off = offsetof(struct icmp6_hdr, icmp6_cksum);
else
- off = in6p->in6p_cksum;
+ off = in6p->inp_cksum6;
if (plen < off + 1) {
error = EINVAL;
goto bad;
@@ -486,14 +465,14 @@ rip6_output(struct mbuf *m, ...)
}
flags = 0;
- if (in6p->in6p_flags & IN6P_MINMTU)
+ if (in6p->inp_flags & IN6P_MINMTU)
flags |= IPV6_MINMTU;
/* force routing domain */
m->m_pkthdr.rdomain = in6p->inp_rtableid;
- error = ip6_output(m, optp, &in6p->in6p_route, flags,
- in6p->in6p_moptions, &oifp, in6p);
+ error = ip6_output(m, optp, &in6p->inp_route6, flags,
+ in6p->inp_moptions6, &oifp, in6p);
if (so->so_proto->pr_protocol == IPPROTO_ICMPV6) {
if (oifp)
icmp6_ifoutstat_inc(oifp, type, code);
@@ -607,7 +586,7 @@ int
rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
struct mbuf *control, struct proc *p)
{
- struct in6pcb *in6p = sotoin6pcb(so);
+ struct inpcb *in6p = sotoinpcb(so);
int error = 0;
int s;
int priv;
@@ -639,18 +618,18 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
break;
}
splx(s);
- in6p = sotoin6pcb(so);
- in6p->in6p_ip6.ip6_nxt = (long)nam;
- in6p->in6p_cksum = -1;
+ in6p = sotoinpcb(so);
+ in6p->inp_ipv6.ip6_nxt = (long)nam;
+ in6p->inp_cksum6 = -1;
- in6p->in6p_icmp6filt = malloc(sizeof(struct icmp6_filter),
+ in6p->inp_icmp6filt = malloc(sizeof(struct icmp6_filter),
M_PCB, M_NOWAIT);
- if (in6p->in6p_icmp6filt == NULL) {
- in6_pcbdetach(in6p);
+ if (in6p->inp_icmp6filt == NULL) {
+ in_pcbdetach(in6p);
error = ENOMEM;
break;
}
- ICMP6_FILTER_SETPASSALL(in6p->in6p_icmp6filt);
+ ICMP6_FILTER_SETPASSALL(in6p->inp_icmp6filt);
break;
case PRU_DISCONNECT:
@@ -658,7 +637,7 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
error = ENOTCONN;
break;
}
- in6p->in6p_faddr = in6addr_any;
+ in6p->inp_faddr6 = in6addr_any;
so->so_state &= ~SS_ISCONNECTED; /* XXX */
break;
@@ -672,11 +651,11 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
if (so == ip6_mrouter)
ip6_mrouter_done();
#endif
- if (in6p->in6p_icmp6filt) {
- free(in6p->in6p_icmp6filt, M_PCB);
- in6p->in6p_icmp6filt = NULL;
+ if (in6p->inp_icmp6filt) {
+ free(in6p->inp_icmp6filt, M_PCB);
+ in6p->inp_icmp6filt = NULL;
}
- in6_pcbdetach(in6p);
+ in_pcbdetach(in6p);
break;
case PRU_BIND:
@@ -720,7 +699,7 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
error = EADDRNOTAVAIL;
break;
}
- in6p->in6p_laddr = addr->sin6_addr;
+ in6p->inp_laddr6 = addr->sin6_addr;
break;
}
@@ -743,16 +722,16 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
}
/* Source address selection. XXX: need pcblookup? */
- in6a = in6_selectsrc(addr, in6p->in6p_outputopts,
- in6p->in6p_moptions, &in6p->in6p_route,
- &in6p->in6p_laddr, &error, in6p->inp_rtableid);
+ in6a = in6_selectsrc(addr, in6p->inp_outputopts6,
+ in6p->inp_moptions6, &in6p->inp_route6,
+ &in6p->inp_laddr6, &error, in6p->inp_rtableid);
if (in6a == NULL) {
if (error == 0)
error = EADDRNOTAVAIL;
break;
}
- in6p->in6p_laddr = *in6a;
- in6p->in6p_faddr = addr->sin6_addr;
+ in6p->inp_laddr6 = *in6a;
+ in6p->inp_faddr6 = addr->sin6_addr;
soisconnected(so);
break;
}
@@ -786,7 +765,7 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
bzero(&tmp, sizeof(tmp));
tmp.sin6_family = AF_INET6;
tmp.sin6_len = sizeof(struct sockaddr_in6);
- bcopy(&in6p->in6p_faddr, &tmp.sin6_addr,
+ bcopy(&in6p->inp_faddr6, &tmp.sin6_addr,
sizeof(struct in6_addr));
dst = &tmp;
} else {
diff --git a/sys/netinet6/udp6_output.c b/sys/netinet6/udp6_output.c
index a4be49ac045..12fac31a331 100644
--- a/sys/netinet6/udp6_output.c
+++ b/sys/netinet6/udp6_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp6_output.c,v 1.22 2013/10/22 15:08:55 naddy Exp $ */
+/* $OpenBSD: udp6_output.c,v 1.23 2013/10/23 19:57:50 deraadt Exp $ */
/* $KAME: udp6_output.c,v 1.21 2001/02/07 11:51:54 itojun Exp $ */
/*
@@ -91,23 +91,8 @@
* UDP protocol inplementation.
* Per RFC 768, August, 1980.
*/
-
-#define in6pcb inpcb
-#define in6p_outputopts inp_outputopts6
-#define in6p_socket inp_socket
-#define in6p_faddr inp_faddr6
-#define in6p_laddr inp_laddr6
-#define in6p_fport inp_fport
-#define in6p_lport inp_lport
-#define in6p_flags inp_flags
-#define in6p_moptions inp_moptions6
-#define in6p_route inp_route6
-#define in6p_flowinfo inp_flowinfo
-#define udp6stat udpstat
-#define udp6s_opackets udps_opackets
-
int
-udp6_output(struct in6pcb *in6p, struct mbuf *m, struct mbuf *addr6,
+udp6_output(struct inpcb *in6p, struct mbuf *m, struct mbuf *addr6,
struct mbuf *control)
{
u_int32_t ulen = m->m_pkthdr.len;
@@ -122,15 +107,15 @@ udp6_output(struct in6pcb *in6p, struct mbuf *m, struct mbuf *addr6,
struct ifnet *ifp;
u_short fport;
- if ((in6p->in6p_socket->so_state & SS_PRIV) != 0)
+ if ((in6p->inp_socket->so_state & SS_PRIV) != 0)
priv = 1;
if (control) {
if ((error = ip6_setpktopts(control, &opt,
- in6p->in6p_outputopts, priv, IPPROTO_UDP)) != 0)
+ in6p->inp_outputopts6, priv, IPPROTO_UDP)) != 0)
goto release;
optp = &opt;
} else
- optp = in6p->in6p_outputopts;
+ optp = in6p->inp_outputopts6;
if (addr6) {
/*
@@ -156,7 +141,7 @@ udp6_output(struct in6pcb *in6p, struct mbuf *m, struct mbuf *addr6,
goto release;
}
- if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
+ if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->inp_faddr6)) {
error = EISCONN;
goto release;
}
@@ -176,26 +161,26 @@ udp6_output(struct in6pcb *in6p, struct mbuf *m, struct mbuf *addr6,
if (1) { /* we don't support IPv4 mapped address */
laddr = in6_selectsrc(sin6, optp,
- in6p->in6p_moptions, &in6p->in6p_route,
- &in6p->in6p_laddr, &error, in6p->inp_rtableid);
+ in6p->inp_moptions6, &in6p->inp_route6,
+ &in6p->inp_laddr6, &error, in6p->inp_rtableid);
} else
- laddr = &in6p->in6p_laddr; /*XXX*/
+ laddr = &in6p->inp_laddr6; /*XXX*/
if (laddr == NULL) {
if (error == 0)
error = EADDRNOTAVAIL;
goto release;
}
- if (in6p->in6p_lport == 0 &&
+ if (in6p->inp_lport == 0 &&
(error = in6_pcbsetport(laddr, in6p, p)) != 0)
goto release;
} else {
- if (IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr)) {
+ if (IN6_IS_ADDR_UNSPECIFIED(&in6p->inp_faddr6)) {
error = ENOTCONN;
goto release;
}
- laddr = &in6p->in6p_laddr;
- faddr = &in6p->in6p_faddr;
- fport = in6p->in6p_fport;
+ laddr = &in6p->inp_laddr6;
+ faddr = &in6p->inp_faddr6;
+ fport = in6p->inp_fport;
}
if (1) { /* we don't support IPv4 mapped address */
@@ -220,7 +205,7 @@ udp6_output(struct in6pcb *in6p, struct mbuf *m, struct mbuf *addr6,
* Stuff checksum and output datagram.
*/
udp6 = (struct udphdr *)(mtod(m, caddr_t) + hlen);
- udp6->uh_sport = in6p->in6p_lport; /* lport is always set in the PCB */
+ udp6->uh_sport = in6p->inp_lport; /* lport is always set in the PCB */
udp6->uh_dport = fport;
if (plen <= 0xffff)
udp6->uh_ulen = htons((u_short)plen);
@@ -231,7 +216,7 @@ udp6_output(struct in6pcb *in6p, struct mbuf *m, struct mbuf *addr6,
switch (af) {
case AF_INET6:
ip6 = mtod(m, struct ip6_hdr *);
- ip6->ip6_flow = in6p->in6p_flowinfo & IPV6_FLOWINFO_MASK;
+ ip6->ip6_flow = in6p->inp_flowinfo & IPV6_FLOWINFO_MASK;
ip6->ip6_vfc &= ~IPV6_VERSION_MASK;
ip6->ip6_vfc |= IPV6_VERSION;
#if 0 /* ip6_plen will be filled in ip6_output. */
@@ -239,9 +224,9 @@ udp6_output(struct in6pcb *in6p, struct mbuf *m, struct mbuf *addr6,
#endif
ip6->ip6_nxt = IPPROTO_UDP;
ifp = NULL;
- if (in6p->in6p_route.ro_rt &&
- in6p->in6p_route.ro_rt->rt_flags & RTF_UP)
- ifp = in6p->in6p_route.ro_rt->rt_ifp;
+ if (in6p->inp_route6.ro_rt &&
+ in6p->inp_route6.ro_rt->rt_flags & RTF_UP)
+ ifp = in6p->inp_route6.ro_rt->rt_ifp;
ip6->ip6_hlim = in6_selecthlim(in6p, ifp);
ip6->ip6_src = *laddr;
ip6->ip6_dst = *faddr;
@@ -249,16 +234,16 @@ udp6_output(struct in6pcb *in6p, struct mbuf *m, struct mbuf *addr6,
m->m_pkthdr.csum_flags |= M_UDP_CSUM_OUT;
flags = 0;
- if (in6p->in6p_flags & IN6P_MINMTU)
+ if (in6p->inp_flags & IN6P_MINMTU)
flags |= IPV6_MINMTU;
- udp6stat.udp6s_opackets++;
+ udpstat.udps_opackets++;
/* force routing domain */
m->m_pkthdr.rdomain = in6p->inp_rtableid;
- error = ip6_output(m, optp, &in6p->in6p_route,
- flags, in6p->in6p_moptions, NULL, in6p);
+ error = ip6_output(m, optp, &in6p->inp_route6,
+ flags, in6p->inp_moptions6, NULL, in6p);
break;
case AF_INET:
error = EAFNOSUPPORT;