summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2010-07-08 08:40:30 +0000
committerYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2010-07-08 08:40:30 +0000
commit336ef4ecd2905dd5021f3d42af117efacf59e6d4 (patch)
tree9f1b7617ced9b9b29ada8f62e0315ad1e83dac00 /sys
parente8c4f92166a70573af608433f8d8b8e749ef160f (diff)
pipex didn't work on output. Fixed following problems:
- pipex failed to lookup the radix tree because address and netmask were not initialized. - pipex used wrong place as a ip header because it didn't adjust 32bit address family header that are added at tun_output.
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if_tun.c9
-rw-r--r--sys/net/pipex.c48
-rw-r--r--sys/net/pipex.h5
-rw-r--r--sys/net/pipex_local.h3
4 files changed, 32 insertions, 33 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 844f9542826..2e4b3ee9391 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.106 2010/05/06 13:06:40 claudio Exp $ */
+/* $OpenBSD: if_tun.c,v 1.107 2010/07/08 08:40:29 yasuoka Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -574,9 +574,6 @@ tun_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
struct tun_softc *tp = ifp->if_softc;
int s, len, error;
u_int32_t *af;
-#ifdef PIPEX
- struct pipex_session *session;
-#endif
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) {
m_freem(m0);
@@ -609,8 +606,8 @@ tun_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
bpf_mtap(ifp->if_bpf, m0, BPF_DIRECTION_OUT);
#endif
#ifdef PIPEX
- if ((session = pipex_ip_lookup_session(m0, &tp->pipex_iface)) != NULL) {
- pipex_ip_output(m0, session);
+ if ((m0 = pipex_output(m0, dst->sa_family, sizeof(u_int32_t),
+ &tp->pipex_iface)) == NULL) {
splx(s);
return (0);
}
diff --git a/sys/net/pipex.c b/sys/net/pipex.c
index 3a0c1dc3b3b..e7586eb4c70 100644
--- a/sys/net/pipex.c
+++ b/sys/net/pipex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pipex.c,v 1.5 2010/07/03 00:16:07 yasuoka Exp $ */
+/* $OpenBSD: pipex.c,v 1.6 2010/07/08 08:40:29 yasuoka Exp $ */
/*-
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -537,9 +537,12 @@ pipex_lookup_by_ip_address(struct in_addr addr)
struct pipex_session *session;
struct sockaddr_in pipex_in4, pipex_in4mask;
+ bzero(&pipex_in4, sizeof(pipex_in4));
pipex_in4.sin_addr = addr;
pipex_in4.sin_family = AF_INET;
pipex_in4.sin_len = sizeof(pipex_in4);
+
+ bzero(&pipex_in4mask, sizeof(pipex_in4mask));
pipex_in4mask.sin_addr.s_addr = htonl(0xFFFFFFFFL);
pipex_in4mask.sin_family = AF_INET;
pipex_in4mask.sin_len = sizeof(pipex_in4mask);
@@ -773,38 +776,37 @@ pipex_timer(void *ignored_arg)
/***********************************************************************
* Common network I/O functions. (tunnel protocol independent)
***********************************************************************/
-struct pipex_session *
-pipex_ip_lookup_session(struct mbuf *m0,
+struct mbuf *
+pipex_output(struct mbuf *m0, int af, int off,
struct pipex_iface_context *pipex_iface)
{
struct pipex_session *session;
struct ip ip;
- /* length check */
- if (m0->m_pkthdr.len < sizeof(struct ip)) {
- PIPEX_DBG((NULL, LOG_DEBUG,
- "<%s> packet length is too short", __func__));
- return (NULL);
- }
-
- /* copy ip header info */
- m_copydata(m0, 0, sizeof(struct ip), (caddr_t)&ip);
-
- if (IN_MULTICAST(ip.ip_dst.s_addr) && pipex_iface != NULL)
- return (pipex_iface->multicast_session);
+ session = NULL;
+ switch (af) {
+ case AF_INET:
+ if (m0->m_pkthdr.len >= sizeof(struct ip) + off) {
+ m_copydata(m0, off, sizeof(struct ip), (caddr_t)&ip);
+ if (IN_MULTICAST(ip.ip_dst.s_addr))
+ session = pipex_iface->multicast_session;
+ else
+ session = pipex_lookup_by_ip_address(ip.ip_dst);
+ }
+ if (session != NULL) {
+ if (off > 0)
+ m_adj(m0, off);
- /* lookup pipex session table */
- session = pipex_lookup_by_ip_address(ip.ip_dst);
- if (session == NULL) {
- PIPEX_DBG((NULL, LOG_DEBUG, "<%s> session not found.",
- __func__));
- return (NULL);
+ pipex_ip_output(m0, session);
+ return (NULL);
+ }
+ break;
}
- return (session);
+ return (m0);
}
-void
+Static void
pipex_ip_output(struct mbuf *m0, struct pipex_session *session)
{
int is_idle;
diff --git a/sys/net/pipex.h b/sys/net/pipex.h
index 35426e67e06..2d064f29719 100644
--- a/sys/net/pipex.h
+++ b/sys/net/pipex.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pipex.h,v 1.3 2010/07/03 00:16:07 yasuoka Exp $ */
+/* $OpenBSD: pipex.h,v 1.4 2010/07/08 08:40:29 yasuoka Exp $ */
/*
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -152,8 +152,7 @@ void pipex_iface_stop (struct pipex_iface_context *);
int pipex_notify_close_session(struct pipex_session *session);
int pipex_notify_close_session_all(void);
-struct pipex_session *pipex_ip_lookup_session (struct mbuf *, struct pipex_iface_context *);
-void pipex_ip_output (struct mbuf *, struct pipex_session *);
+struct mbuf *pipex_output (struct mbuf *, int, int, struct pipex_iface_context *);
struct pipex_session *pipex_pppoe_lookup_session (struct mbuf *);
struct mbuf *pipex_pppoe_input (struct mbuf *, struct pipex_session *);
struct pipex_session *pipex_pptp_lookup_session (struct mbuf *);
diff --git a/sys/net/pipex_local.h b/sys/net/pipex_local.h
index c3f1caabba5..9580ab16a66 100644
--- a/sys/net/pipex_local.h
+++ b/sys/net/pipex_local.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pipex_local.h,v 1.5 2010/07/03 00:16:07 yasuoka Exp $ */
+/* $OpenBSD: pipex_local.h,v 1.6 2010/07/08 08:40:29 yasuoka Exp $ */
/*
* Copyright (c) 2009 Internet Initiative Japan Inc.
@@ -277,6 +277,7 @@ Static int pipex_get_closed (struct pipex_session_list_req *);
Static int pipex_destroy_session (struct pipex_session *);
Static struct pipex_session *pipex_lookup_by_ip_address (struct in_addr);
Static struct pipex_session *pipex_lookup_by_session_id (int, int);
+Static void pipex_ip_output (struct mbuf *, struct pipex_session *);
Static void pipex_ppp_output (struct mbuf *, struct pipex_session *, int);
Static inline int pipex_ppp_proto (struct mbuf *, struct pipex_session *, int, int *);
Static void pipex_ppp_input (struct mbuf *, struct pipex_session *, int);