Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet6 correct MLD API. (binary backward compatibility...
details: https://anonhg.NetBSD.org/src/rev/9552cbbe1389
branches: trunk
changeset: 486339:9552cbbe1389
user: itojun <itojun%NetBSD.org@localhost>
date: Fri May 19 10:39:43 2000 +0000
description:
correct MLD API. (binary backward compatibility is kept)
commit to usr.sbin/pim6* will follow.
diffstat:
sys/netinet6/ip6_mroute.c | 261 +++++++++++++++++++++++++++++----------------
sys/netinet6/ip6_mroute.h | 52 +++++++--
2 files changed, 206 insertions(+), 107 deletions(-)
diffs (truncated from 724 to 300 lines):
diff -r 93db0742a7f9 -r 9552cbbe1389 sys/netinet6/ip6_mroute.c
--- a/sys/netinet6/ip6_mroute.c Fri May 19 10:23:36 2000 +0000
+++ b/sys/netinet6/ip6_mroute.c Fri May 19 10:39:43 2000 +0000
@@ -1,9 +1,10 @@
-/* $NetBSD: ip6_mroute.c,v 1.11 2000/03/23 07:03:30 thorpej Exp $ */
+/* $NetBSD: ip6_mroute.c,v 1.12 2000/05/19 10:39:43 itojun Exp $ */
+/* $KAME: ip6_mroute.c,v 1.24 2000/05/19 07:37:05 jinmei Exp $ */
/*
* Copyright (C) 1998 WIDE Project.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -15,7 +16,7 @@
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -96,6 +97,7 @@
* except for netstat or debugging purposes.
*/
struct socket *ip6_mrouter = NULL;
+int ip6_mrouter_ver = 0;
int ip6_mrtproto = IPPROTO_PIM; /* for netstat only */
struct mrt6stat mrt6stat;
@@ -123,7 +125,7 @@
#ifdef MROUTING
extern struct socket *ip_mrouter;
#endif
-#endif
+#endif
/*
* 'Interfaces' associated with decapsulator (so we can tell
@@ -164,7 +166,7 @@
* Quality of service parameter to be added in the future!!!
*/
-#define MF6CFIND(o, g, rt) { \
+#define MF6CFIND(o, g, rt) do { \
register struct mf6c *_rt = mf6ctable[MF6CHASH(o,g)]; \
rt = NULL; \
mrt6stat.mrt6s_mfc_lookups++; \
@@ -180,13 +182,13 @@
if (rt == NULL) { \
mrt6stat.mrt6s_mfc_misses++; \
} \
-}
+} while (0)
/*
* Macros to compute elapsed time efficiently
* Borrowed from Van Jacobson's scheduling code
*/
-#define TV_DELTA(a, b, delta) { \
+#define TV_DELTA(a, b, delta) do { \
register int xxs; \
\
delta = (a).tv_usec - (b).tv_usec; \
@@ -202,7 +204,7 @@
delta += (1000000 * xxs); \
} \
} \
-}
+} while (0)
#define TV_LT(a, b) (((a).tv_usec < (b).tv_usec && \
(a).tv_sec <= (b).tv_sec) || (a).tv_sec < (b).tv_sec)
@@ -215,7 +217,7 @@
static int get_sg_cnt __P((struct sioc_sg_req6 *));
static int get_mif6_cnt __P((struct sioc_mif_req6 *));
-static int ip6_mrouter_init __P((struct socket *, struct mbuf *));
+static int ip6_mrouter_init __P((struct socket *, struct mbuf *, int));
static int add_m6if __P((struct mif6ctl *));
static int del_m6if __P((mifi_t *));
static int add_m6fc __P((struct mf6cctl *));
@@ -236,7 +238,8 @@
return EACCES;
switch (cmd) {
- case MRT6_INIT: return ip6_mrouter_init(so, m);
+ case MRT6_OINIT: return ip6_mrouter_init(so, m, cmd);
+ case MRT6_INIT: return ip6_mrouter_init(so, m, cmd);
case MRT6_DONE: return ip6_mrouter_done();
case MRT6_ADD_MIF: return add_m6if(mtod(m, struct mif6ctl *));
case MRT6_DEL_MIF: return del_m6if(mtod(m, mifi_t *));
@@ -315,7 +318,7 @@
return(ESRCH);
#if 0
req->pktcnt = req->bytecnt = req->wrong_if = 0xffffffff;
-#endif
+#endif
return 0;
}
@@ -372,9 +375,10 @@
* Enable multicast routing
*/
static int
-ip6_mrouter_init(so, m)
+ip6_mrouter_init(so, m, cmd)
struct socket *so;
struct mbuf *m;
+ int cmd;
{
int *v;
@@ -399,6 +403,7 @@
if (ip6_mrouter != NULL) return EADDRINUSE;
ip6_mrouter = so;
+ ip6_mrouter_ver = cmd;
bzero((caddr_t)mf6ctable, sizeof(mf6ctable));
bzero((caddr_t)nexpire, sizeof(nexpire));
@@ -446,7 +451,7 @@
*/
if (!ip_mrouter)
#endif
-#endif
+#endif
{
for (mifi = 0; mifi < nummifs; mifi++) {
if (mif6table[mifi].m6_ifp &&
@@ -462,7 +467,7 @@
#ifdef notyet
bzero((caddr_t)qtable, sizeof(qtable));
bzero((caddr_t)tbftable, sizeof(tbftable));
-#endif
+#endif
bzero((caddr_t)mif6table, sizeof(mif6table));
nummifs = 0;
@@ -497,8 +502,9 @@
* Reset de-encapsulation cache
*/
reg_mif_num = -1;
-
+
ip6_mrouter = NULL;
+ ip6_mrouter_ver = 0;
splx(s);
@@ -525,7 +531,7 @@
int error, s;
#ifdef notyet
struct tbf *m_tbf = tbftable + mifcp->mif6c_mifi;
-#endif
+#endif
if (mifcp->mif6c_mifi >= MAXMIFS)
return EINVAL;
@@ -572,7 +578,7 @@
#ifdef notyet
/* scaling up here allows division by 1024 in critical code */
mifp->m6_rate_limit = mifcp->mif6c_rate_limit * 1024 / 1000;
-#endif
+#endif
/* initialize per mif pkt counters */
mifp->m6_pkt_in = 0;
mifp->m6_pkt_out = 0;
@@ -630,7 +636,7 @@
#ifdef notyet
bzero((caddr_t)qtable[*mifip], sizeof(qtable[*mifip]));
bzero((caddr_t)mifp->m6_tbf, sizeof(*(mifp->m6_tbf)));
-#endif
+#endif
bzero((caddr_t)mifp, sizeof (*mifp));
/* Adjust nummifs down */
@@ -682,7 +688,7 @@
return 0;
}
- /*
+ /*
* Find the entry for which the upcall was made and update
*/
s = splsoftnet();
@@ -753,7 +759,7 @@
#endif
for (rt = mf6ctable[hash]; rt; rt = rt->mf6c_next) {
-
+
if (IN6_ARE_ADDR_EQUAL(&rt->mf6c_origin.sin6_addr,
&mfccp->mf6cc_origin.sin6_addr)&&
IN6_ARE_ADDR_EQUAL(&rt->mf6c_mcastgrp.sin6_addr,
@@ -780,7 +786,7 @@
splx(s);
return ENOBUFS;
}
-
+
/* insert new entry at head of hash chain */
rt->mf6c_origin = mfccp->mf6cc_origin;
rt->mf6c_mcastgrp = mfccp->mf6cc_mcastgrp;
@@ -791,7 +797,7 @@
rt->mf6c_wrong_if = 0;
rt->mf6c_expire = 0;
rt->mf6c_stall = NULL;
-
+
/* link into table */
rt->mf6c_next = mf6ctable[hash];
mf6ctable[hash] = rt;
@@ -803,7 +809,7 @@
#ifdef UPCALL_TIMING
/*
- * collect delay statistics on the upcalls
+ * collect delay statistics on the upcalls
*/
static void
collate(t)
@@ -812,9 +818,9 @@
register u_long d;
register struct timeval tp;
register u_long delta;
-
+
GET_TIME(tp);
-
+
if (TV_LT(*t, tp))
{
TV_DELTA(tp, *t, delta);
@@ -994,7 +1000,7 @@
splx(s);
return ENOBUFS;
}
-
+
/* is there an upcall waiting for this packet? */
hash = MF6CHASH(ip6->ip6_src, ip6->ip6_dst);
for (rt = mf6ctable[hash]; rt; rt = rt->mf6c_next) {
@@ -1008,6 +1014,7 @@
if (rt == NULL) {
struct mrt6msg *im;
+ struct omrt6msg *oim;
/* no upcall, so make a new entry */
rt = (struct mf6c *)malloc(sizeof(*rt), M_MRTABLE,
@@ -1032,14 +1039,31 @@
return ENOBUFS;
}
- /*
+ /*
* Send message to routing daemon
*/
sin6.sin6_addr = ip6->ip6_src;
-
- im = mtod(mm, struct mrt6msg *);
- im->im6_msgtype = MRT6MSG_NOCACHE;
- im->im6_mbz = 0;
+
+ im = NULL;
+ oim = NULL;
+ switch (ip6_mrouter_ver) {
+ case MRT6_OINIT:
+ oim = mtod(mm, struct omrt6msg *);
+ oim->im6_msgtype = MRT6MSG_NOCACHE;
+ oim->im6_mbz = 0;
+ break;
+ case MRT6_INIT:
+ im = mtod(mm, struct mrt6msg *);
+ im->im6_msgtype = MRT6MSG_NOCACHE;
+ im->im6_mbz = 0;
+ break;
+ default:
+ free(rte, M_MRTABLE);
+ m_freem(mb0);
+ free(rt, M_MRTABLE);
+ splx(s);
+ return EINVAL;
+ }
#ifdef MRT6DEBUG
if (mrt6debug & DEBUG_FORWARD)
@@ -1052,7 +1076,14 @@
mifp++, mifi++)
;
- im->im6_mif = mifi;
+ switch (ip6_mrouter_ver) {
+ case MRT6_OINIT:
+ oim->im6_mif = mifi;
+ break;
Home |
Main Index |
Thread Index |
Old Index