Date: Mon, 27 Aug 2001 11:18:55 +0900 From: Keiichi SHIMA <keiichi@iij.ad.jp> To: net@freebsd.org Cc: users@ipv6.org, core@kame.net Subject: Re: IPV6/KAME/protosw integration cleanup Message-ID: <86itfajldc.wl@keiichi01.osaka.iij.ad.jp> In-Reply-To: <3B76330E.86A0B689@elischer.org> References: <3B76330E.86A0B689@elischer.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Hi,
KAME had removed ipprotosw.h from the KAME source repositry (for
FreeBSD4). Though this do not clean up the varargs functions, we
still think this is a better (or not worst at least) comprimise in a
current situation.
Also, I had made a patch for FreeBSD-CURRENT for the same purpose.
Please see and review the attached patch. If it looks OK, I will
commit it to the CURRENT tree.
Thanks,
---
Keiichi SHIMA <keiichi@iij.ad.jp>
IIJ Research Laboratory / KAME Project
ZGlmZiAtdXIgc3lzLm9yaWcvbmV0L2lmX2dpZi5jIHN5cy9uZXQvaWZfZ2lmLmMKLS0tIHN5
[-- Attachment #2 --]
diff -ur sys.orig/net/if_gif.c sys/net/if_gif.c
--- sys.orig/net/if_gif.c Tue Jul 3 06:02:05 2001
+++ sys/net/if_gif.c Mon Aug 27 10:08:28 2001
@@ -62,7 +62,6 @@
#include <netinet/in_var.h>
#include <netinet/in_gif.h>
#include <netinet/ip_var.h>
-#include <netinet/ipprotosw.h>
#endif /* INET */
#ifdef INET6
@@ -101,7 +100,7 @@
#ifdef INET
extern struct domain inetdomain;
-struct ipprotosw in_gif_protosw =
+struct protosw in_gif_protosw =
{ SOCK_RAW, &inetdomain, 0/*IPPROTO_IPV[46]*/, PR_ATOMIC|PR_ADDR,
in_gif_input, rip_output, 0, rip_ctloutput,
0,
diff -ur sys.orig/net/if_stf.c sys/net/if_stf.c
--- sys.orig/net/if_stf.c Tue Jul 3 06:02:05 2001
+++ sys/net/if_stf.c Mon Aug 27 10:09:15 2001
@@ -98,7 +98,6 @@
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
-#include <netinet/ipprotosw.h>
#include <netinet/ip_var.h>
#include <netinet/in_var.h>
@@ -134,7 +133,7 @@
static int ip_stf_ttl = 40;
extern struct domain inetdomain;
-struct ipprotosw in_stf_protosw =
+struct protosw in_stf_protosw =
{ SOCK_RAW, &inetdomain, IPPROTO_IPV6, PR_ATOMIC|PR_ADDR,
in_stf_input, rip_output, 0, rip_ctloutput,
0,
@@ -550,7 +549,7 @@
va_start(ap, m);
off = va_arg(ap, int);
- proto = va_arg(ap, int);
+ proto = mtod(m, struct ip *)->ip_p;
va_end(ap);
if (proto != IPPROTO_IPV6) {
diff -ur sys.orig/netinet/igmp.c sys/netinet/igmp.c
--- sys.orig/netinet/igmp.c Sun Jun 24 02:17:58 2001
+++ sys/netinet/igmp.c Mon Aug 27 10:09:40 2001
@@ -148,9 +148,9 @@
}
void
-igmp_input(m, off, proto)
+igmp_input(m, off)
register struct mbuf *m;
- int off, proto;
+ int off;
{
register int iphlen = off;
register struct igmp *igmp;
diff -ur sys.orig/netinet/igmp_var.h sys/netinet/igmp_var.h
--- sys.orig/netinet/igmp_var.h Wed Dec 29 13:40:59 1999
+++ sys/netinet/igmp_var.h Mon Aug 27 10:09:48 2001
@@ -86,7 +86,7 @@
#define IGMP_AGE_THRESHOLD 540
void igmp_init __P((void));
-void igmp_input __P((struct mbuf *, int, int));
+void igmp_input __P((struct mbuf *, int));
void igmp_joingroup __P((struct in_multi *));
void igmp_leavegroup __P((struct in_multi *));
void igmp_fasttimo __P((void));
diff -ur sys.orig/netinet/in_gif.c sys/netinet/in_gif.c
--- sys.orig/netinet/in_gif.c Tue Jul 3 06:02:07 2001
+++ sys/netinet/in_gif.c Mon Aug 27 10:12:14 2001
@@ -202,17 +202,18 @@
}
void
-in_gif_input(m, off, proto)
+in_gif_input(m, off)
struct mbuf *m;
int off;
- int proto;
{
struct ifnet *gifp = NULL;
struct ip *ip;
int af;
u_int8_t otos;
+ int proto;
ip = mtod(m, struct ip *);
+ proto = ip->ip_p;
gifp = (struct ifnet *)encap_getarg(m);
diff -ur sys.orig/netinet/in_gif.h sys/netinet/in_gif.h
--- sys.orig/netinet/in_gif.h Tue Jul 3 06:02:07 2001
+++ sys/netinet/in_gif.h Mon Aug 27 10:10:53 2001
@@ -37,7 +37,7 @@
extern int ip_gif_ttl;
-void in_gif_input __P((struct mbuf *, int off, int proto));
+void in_gif_input __P((struct mbuf *, int off));
int in_gif_output __P((struct ifnet *, int, struct mbuf *, struct rtentry *));
int gif_encapcheck4 __P((const struct mbuf *, int, int, void *));
diff -ur sys.orig/netinet/in_proto.c sys/netinet/in_proto.c
--- sys.orig/netinet/in_proto.c Tue Jul 3 06:02:07 2001
+++ sys/netinet/in_proto.c Mon Aug 27 10:13:01 2001
@@ -63,8 +63,6 @@
#include <netinet/udp_var.h>
#include <netinet/ip_encap.h>
-#include <netinet/ipprotosw.h>
-
/*
* TCP/IP protocol family: IP, ICMP, UDP, TCP.
*/
@@ -90,7 +88,7 @@
extern struct domain inetdomain;
static struct pr_usrreqs nousrreqs;
-struct ipprotosw inetsw[] = {
+struct protosw inetsw[] = {
{ 0, &inetdomain, 0, 0,
0, 0, 0, 0,
0,
@@ -207,8 +205,8 @@
struct domain inetdomain =
{ AF_INET, "internet", 0, 0, 0,
- (struct protosw *)inetsw,
- (struct protosw *)&inetsw[sizeof(inetsw)/sizeof(inetsw[0])], 0,
+ inetsw,
+ &inetsw[sizeof(inetsw)/sizeof(inetsw[0])], 0,
in_inithead, 32, sizeof(struct sockaddr_in)
};
diff -ur sys.orig/netinet/ip_divert.c sys/netinet/ip_divert.c
--- sys.orig/netinet/ip_divert.c Fri Jul 27 04:19:48 2001
+++ sys/netinet/ip_divert.c Mon Aug 27 10:13:17 2001
@@ -128,7 +128,7 @@
* with that protocol number to enter the system from the outside.
*/
void
-div_input(struct mbuf *m, int off, int proto)
+div_input(struct mbuf *m, int off)
{
ipstat.ips_noproto++;
m_freem(m);
diff -ur sys.orig/netinet/ip_encap.c sys/netinet/ip_encap.c
--- sys.orig/netinet/ip_encap.c Thu Jul 26 05:15:49 2001
+++ sys/netinet/ip_encap.c Mon Aug 27 10:15:24 2001
@@ -77,7 +77,6 @@
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/ip_encap.h>
-#include <netinet/ipprotosw.h>
#ifdef INET6
#include <netinet/ip6.h>
@@ -138,17 +137,17 @@
int off, proto;
struct ip *ip;
struct sockaddr_in s, d;
- const struct ipprotosw *psw;
+ const struct protosw *psw;
struct encaptab *ep, *match;
va_list ap;
int prio, matchprio;
va_start(ap, m);
off = va_arg(ap, int);
- proto = va_arg(ap, int);
va_end(ap);
ip = mtod(m, struct ip *);
+ proto = ip->ip_p;
bzero(&s, sizeof(s));
s.sin_family = AF_INET;
@@ -205,17 +204,23 @@
if (match) {
/* found a match, "match" has the best one */
- psw = (const struct ipprotosw *)match->psw;
+ psw = match->psw;
if (psw && psw->pr_input) {
encap_fillarg(m, match);
- (*psw->pr_input)(m, off, proto);
+ (*psw->pr_input)(m, off);
} else
m_freem(m);
return;
}
+ /* for backward compatibility - messy... */
+ if (proto == IPPROTO_IPV4) {
+ ipip_input(m, off);
+ return;
+ }
+
/* last resort: inject to raw socket */
- rip_input(m, off, proto);
+ rip_input(m, off);
}
#endif
diff -ur sys.orig/netinet/ip_icmp.c sys/netinet/ip_icmp.c
--- sys.orig/netinet/ip_icmp.c Sun Jun 24 02:17:58 2001
+++ sys/netinet/ip_icmp.c Mon Aug 27 10:15:46 2001
@@ -230,9 +230,9 @@
* Process a received ICMP message.
*/
void
-icmp_input(m, off, proto)
+icmp_input(m, off)
register struct mbuf *m;
- int off, proto;
+ int off;
{
int hlen = off;
register struct icmp *icp;
@@ -576,7 +576,7 @@
}
raw:
- rip_input(m, off, proto);
+ rip_input(m, off);
return;
freeit:
diff -ur sys.orig/netinet/ip_icmp.h sys/netinet/ip_icmp.h
--- sys.orig/netinet/ip_icmp.h Wed Dec 29 13:41:01 1999
+++ sys/netinet/ip_icmp.h Mon Aug 27 10:15:58 2001
@@ -186,7 +186,7 @@
#ifdef _KERNEL
void icmp_error __P((struct mbuf *, int, int, n_long, struct ifnet *));
-void icmp_input __P((struct mbuf *, int, int));
+void icmp_input __P((struct mbuf *, int));
#endif
#endif
diff -ur sys.orig/netinet/ip_input.c sys/netinet/ip_input.c
--- sys.orig/netinet/ip_input.c Sun Jun 24 02:17:58 2001
+++ sys/netinet/ip_input.c Mon Aug 27 10:17:01 2001
@@ -75,8 +75,6 @@
#include <netinet/ip_icmp.h>
#include <machine/in_cksum.h>
-#include <netinet/ipprotosw.h>
-
#include <sys/socketvar.h>
#include <netinet/ip_fw.h>
@@ -153,7 +151,7 @@
#endif
extern struct domain inetdomain;
-extern struct ipprotosw inetsw[];
+extern struct protosw inetsw[];
u_char ip_protox[IPPROTO_MAX];
static int ipqmaxlen = IFQ_MAXLEN;
struct in_ifaddrhead in_ifaddrhead; /* first inet address */
@@ -236,17 +234,17 @@
void
ip_init()
{
- register struct ipprotosw *pr;
+ register struct protosw *pr;
register int i;
TAILQ_INIT(&in_ifaddrhead);
- pr = (struct ipprotosw *)pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
+ pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
if (pr == 0)
panic("ip_init");
for (i = 0; i < IPPROTO_MAX; i++)
ip_protox[i] = pr - inetsw;
- for (pr = (struct ipprotosw *)inetdomain.dom_protosw;
- pr < (struct ipprotosw *)inetdomain.dom_protoswNPROTOSW; pr++)
+ for (pr = inetdomain.dom_protosw;
+ pr < inetdomain.dom_protoswNPROTOSW; pr++)
if (pr->pr_domain->dom_family == PF_INET &&
pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
ip_protox[pr->pr_protocol] = pr - inetsw;
@@ -819,9 +817,9 @@
*/
ipstat.ips_delivered++;
{
- int off = hlen, nh = ip->ip_p;
+ int off = hlen;
- (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, off, nh);
+ (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, off);
#ifdef IPFIREWALL_FORWARD
ip_fw_fwd_addr = NULL; /* tcp needed it */
#endif
diff -ur sys.orig/netinet/ip_mroute.c sys/netinet/ip_mroute.c
--- sys.orig/netinet/ip_mroute.c Thu Jul 26 05:15:49 2001
+++ sys/netinet/ip_mroute.c Mon Aug 27 10:18:41 2001
@@ -37,7 +37,6 @@
#include <netinet/igmp.h>
#include <netinet/ip_encap.h>
#include <netinet/ip_mroute.h>
-#include <netinet/ipprotosw.h>
#include <netinet/udp.h>
#include <machine/in_cksum.h>
@@ -108,10 +107,9 @@
int (*mrt_ioctl)(int, caddr_t) = _mrt_ioctl;
void
-rsvp_input(m, off, proto) /* XXX must fixup manually */
+rsvp_input(m, off) /* XXX must fixup manually */
struct mbuf *m;
int off;
- int proto;
{
/* Can still get packets with rsvp_on = 0 if there is a local member
* of the group to which the RSVP packet is addressed. But in this
@@ -125,15 +123,15 @@
if (ip_rsvpd != NULL) {
if (rsvpdebug)
printf("rsvp_input: Sending packet up old-style socket\n");
- rip_input(m, off, proto);
+ rip_input(m, off);
return;
}
/* Drop the packet */
m_freem(m);
}
-void ipip_input(struct mbuf *m, int off, int proto) { /* XXX must fixup manually */
- rip_input(m, off, proto);
+void ipip_input(struct mbuf *m, int off) { /* XXX must fixup manually */
+ rip_input(m, off);
}
int (*legal_vif_num)(int) = 0;
@@ -708,7 +706,7 @@
* claimed).
*/
static void
-mroute_encap_input(struct mbuf *m, int off, int proto)
+mroute_encap_input(struct mbuf *m, int off)
{
struct ip *ip = mtod(m, struct ip *);
int hlen = ip->ip_hl << 2;
@@ -732,7 +730,7 @@
}
extern struct domain inetdomain;
-static struct ipprotosw mroute_encap_protosw =
+static struct protosw mroute_encap_protosw =
{ SOCK_RAW, &inetdomain, IPPROTO_IPV4, PR_ATOMIC|PR_ADDR,
mroute_encap_input, 0, 0, rip_ctloutput,
0,
@@ -2108,10 +2106,9 @@
}
void
-rsvp_input(m, off, proto)
+rsvp_input(m, off)
struct mbuf *m;
int off;
- int proto;
{
int vifi;
register struct ip *ip = mtod(m, struct ip *);
@@ -2156,7 +2153,7 @@
if (ip_rsvpd != NULL) {
if (rsvpdebug)
printf("rsvp_input: Sending packet up old-style socket\n");
- rip_input(m, off, proto); /* xxx */
+ rip_input(m, off); /* xxx */
} else {
if (rsvpdebug && vifi == numvifs)
printf("rsvp_input: Can't find vif for packet.\n");
diff -ur sys.orig/netinet/ip_var.h sys/netinet/ip_var.h
--- sys.orig/netinet/ip_var.h Tue Jun 12 03:41:57 2001
+++ sys/netinet/ip_var.h Mon Aug 27 10:19:12 2001
@@ -177,10 +177,10 @@
int rip_ctloutput __P((struct socket *, struct sockopt *));
void rip_ctlinput __P((int, struct sockaddr *, void *));
void rip_init __P((void));
-void rip_input __P((struct mbuf *, int, int));
+void rip_input __P((struct mbuf *, int));
int rip_output __P((struct mbuf *, struct socket *, u_long));
-void ipip_input __P((struct mbuf *, int, int));
-void rsvp_input __P((struct mbuf *, int, int));
+void ipip_input __P((struct mbuf *, int));
+void rsvp_input __P((struct mbuf *, int));
int ip_rsvp_init __P((struct socket *));
int ip_rsvp_done __P((void));
int ip_rsvp_vif_init __P((struct socket *, struct sockopt *));
@@ -189,7 +189,7 @@
#ifdef IPDIVERT
void div_init __P((void));
-void div_input __P((struct mbuf *, int, int));
+void div_input __P((struct mbuf *, int));
void divert_packet __P((struct mbuf *, int, int));
extern struct pr_usrreqs div_usrreqs;
extern u_int16_t ip_divert_cookie;
diff -ur sys.orig/netinet/raw_ip.c sys/netinet/raw_ip.c
--- sys.orig/netinet/raw_ip.c Fri Jul 27 04:19:48 2001
+++ sys/netinet/raw_ip.c Mon Aug 27 10:19:40 2001
@@ -112,14 +112,15 @@
* mbuf chain.
*/
void
-rip_input(m, off, proto)
+rip_input(m, off)
struct mbuf *m;
- int off, proto;
+ int off;
{
register struct ip *ip = mtod(m, struct ip *);
register struct inpcb *inp;
struct inpcb *last = 0;
struct mbuf *opts = 0;
+ int proto = ip->ip_p;
ripsrc.sin_addr = ip->ip_src;
LIST_FOREACH(inp, &ripcb, inp_list) {
diff -ur sys.orig/netinet/tcp_input.c sys/netinet/tcp_input.c
--- sys.orig/netinet/tcp_input.c Fri Aug 24 07:34:29 2001
+++ sys/netinet/tcp_input.c Mon Aug 27 10:20:03 2001
@@ -322,15 +322,15 @@
return IPPROTO_DONE;
}
- tcp_input(m, *offp, proto);
+ tcp_input(m, *offp);
return IPPROTO_DONE;
}
#endif
void
-tcp_input(m, off0, proto)
+tcp_input(m, off0)
register struct mbuf *m;
- int off0, proto;
+ int off0;
{
register struct tcphdr *th;
register struct ip *ip = NULL;
diff -ur sys.orig/netinet/tcp_var.h sys/netinet/tcp_var.h
--- sys.orig/netinet/tcp_var.h Wed Aug 22 09:58:16 2001
+++ sys/netinet/tcp_var.h Mon Aug 27 10:20:14 2001
@@ -384,7 +384,7 @@
struct rmxp_tao *
tcp_gettaocache __P((struct inpcb *));
void tcp_init __P((void));
-void tcp_input __P((struct mbuf *, int, int));
+void tcp_input __P((struct mbuf *, int));
void tcp_mss __P((struct tcpcb *, int));
int tcp_mssopt __P((struct tcpcb *));
void tcp_drop_syn_sent __P((struct inpcb *, int));
diff -ur sys.orig/netinet/udp_usrreq.c sys/netinet/udp_usrreq.c
--- sys.orig/netinet/udp_usrreq.c Fri Jul 27 04:19:48 2001
+++ sys/netinet/udp_usrreq.c Mon Aug 27 10:20:31 2001
@@ -149,9 +149,9 @@
}
void
-udp_input(m, off, proto)
+udp_input(m, off)
register struct mbuf *m;
- int off, proto;
+ int off;
{
int iphlen = off;
register struct ip *ip;
diff -ur sys.orig/netinet/udp_var.h sys/netinet/udp_var.h
--- sys.orig/netinet/udp_var.h Sun Feb 18 16:10:03 2001
+++ sys/netinet/udp_var.h Mon Aug 27 10:20:41 2001
@@ -105,7 +105,7 @@
void udp_ctlinput __P((int, struct sockaddr *, void *));
void udp_init __P((void));
-void udp_input __P((struct mbuf *, int, int));
+void udp_input __P((struct mbuf *, int));
void udp_notify __P((struct inpcb *inp, int errno));
int udp_shutdown __P((struct socket *so));
diff -ur sys.orig/netinet6/ah_input.c sys/netinet6/ah_input.c
--- sys.orig/netinet6/ah_input.c Mon Jun 11 21:39:04 2001
+++ sys/netinet6/ah_input.c Mon Aug 27 10:21:48 2001
@@ -94,8 +94,7 @@
#define IPLEN_FLIPPED
#ifdef INET
-#include <netinet/ipprotosw.h>
-extern struct ipprotosw inetsw[];
+extern struct protosw inetsw[];
void
#if __STDC__
@@ -122,7 +121,7 @@
va_start(ap, m);
off = va_arg(ap, int);
- proto = va_arg(ap, int);
+ proto = mtod(m, struct ip *)->ip_p;
va_end(ap);
#ifndef PULLDOWN_TEST
@@ -550,7 +549,7 @@
ipsecstat.in_polvio++;
goto fail;
}
- (*inetsw[ip_protox[nxt]].pr_input)(m, off, nxt);
+ (*inetsw[ip_protox[nxt]].pr_input)(m, off);
} else
m_freem(m);
m = NULL;
diff -ur sys.orig/netinet6/esp_input.c sys/netinet6/esp_input.c
--- sys.orig/netinet6/esp_input.c Mon Jun 11 21:39:05 2001
+++ sys/netinet6/esp_input.c Mon Aug 27 10:22:32 2001
@@ -97,8 +97,7 @@
? sizeof(struct newesp) : sizeof(struct esp))
#ifdef INET
-#include <netinet/ipprotosw.h>
-extern struct ipprotosw inetsw[];
+extern struct protosw inetsw[];
void
#if __STDC__
@@ -125,7 +124,7 @@
va_start(ap, m);
off = va_arg(ap, int);
- proto = va_arg(ap, int);
+ proto = mtod(m, struct ip *)->ip_p;
va_end(ap);
/* sanity check for alignment. */
@@ -445,7 +444,7 @@
ipsecstat.in_polvio++;
goto bad;
}
- (*inetsw[ip_protox[nxt]].pr_input)(m, off, nxt);
+ (*inetsw[ip_protox[nxt]].pr_input)(m, off);
} else
m_freem(m);
m = NULL;
diff -ur sys.orig/netinet6/ipcomp_input.c sys/netinet6/ipcomp_input.c
--- sys.orig/netinet6/ipcomp_input.c Mon Jun 11 21:39:06 2001
+++ sys/netinet6/ipcomp_input.c Mon Aug 27 10:23:47 2001
@@ -83,8 +83,7 @@
#define IPLEN_FLIPPED
#ifdef INET
-#include <netinet/ipprotosw.h>
-extern struct ipprotosw inetsw[];
+extern struct protosw inetsw[];
void
#if __STDC__
@@ -110,7 +109,7 @@
va_start(ap, m);
off = va_arg(ap, int);
- proto = va_arg(ap, int);
+ proto = mtod(m, struct ip *)->ip_p;
va_end(ap);
if (m->m_pkthdr.len < off + sizeof(struct ipcomp)) {
@@ -231,7 +230,7 @@
ipsecstat.in_polvio++;
goto fail;
}
- (*inetsw[ip_protox[nxt]].pr_input)(m, off, nxt);
+ (*inetsw[ip_protox[nxt]].pr_input)(m, off);
} else
m_freem(m);
m = NULL;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86itfajldc.wl>
