summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorEsben Norby <norby@cvs.openbsd.org>2005-10-05 17:32:23 +0000
committerEsben Norby <norby@cvs.openbsd.org>2005-10-05 17:32:23 +0000
commit61e444f728104a653b73be88df3c8692e9c54e90 (patch)
treefe79f628e8094f6f155a567b1a88d346a6aa58e1 /sys
parentad523639dec8963db2b7a055aba8bcf4b2132f1d (diff)
Add multicast routing to GENERIC.
It is now possible to enable multicast routing in the kernel with the sysctl option net.inet.ip.mforwarding=1 Based on intial work by msf@ help claudio@ ok claudio@ deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/conf/GENERIC4
-rw-r--r--sys/netinet/in.h7
-rw-r--r--sys/netinet/ip_input.c6
-rw-r--r--sys/netinet/ip_output.c8
4 files changed, 15 insertions, 10 deletions
diff --git a/sys/conf/GENERIC b/sys/conf/GENERIC
index 6b124fdeb63..0578234fdc4 100644
--- a/sys/conf/GENERIC
+++ b/sys/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.119 2005/06/08 04:52:45 henning Exp $
+# $OpenBSD: GENERIC,v 1.120 2005/10/05 17:32:22 norby Exp $
#
# Machine-independent option; used by all architectures for their
# GENERIC kernel
@@ -68,7 +68,7 @@ option IPSEC # IPsec
#option NETATALK # AppleTalk
option PPP_BSDCOMP # PPP BSD compression
option PPP_DEFLATE
-#option MROUTING # Multicast router
+option MROUTING # Multicast router
#option PIM # Protocol Independent Multicast
pseudo-device pf # packet filter
diff --git a/sys/netinet/in.h b/sys/netinet/in.h
index 4ed07fe2eed..a24968ca1e4 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.h,v 1.67 2005/06/06 04:49:10 henning Exp $ */
+/* $OpenBSD: in.h,v 1.68 2005/10/05 17:32:22 norby Exp $ */
/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
@@ -476,7 +476,8 @@ struct ip_mreq {
#define IPCTL_MTUDISCTIMEOUT 28 /* allow path MTU discovery */
#define IPCTL_IPSEC_IPCOMP_ALGORITHM 29
#define IPCTL_IFQUEUE 30
-#define IPCTL_MAXID 31
+#define IPCTL_MFORWARDING 31
+#define IPCTL_MAXID 32
#define IPCTL_NAMES { \
{ 0, 0 }, \
@@ -510,6 +511,7 @@ struct ip_mreq {
{ "mtudisctimeout", CTLTYPE_INT }, \
{ "ipsec-comp-alg", CTLTYPE_STRING }, \
{ "ifq", CTLTYPE_NODE }, \
+ { "mforwarding", CTLTYPE_INT }, \
}
#define IPCTL_VARS { \
NULL, \
@@ -543,6 +545,7 @@ struct ip_mreq {
NULL, \
NULL, \
NULL, \
+ &ipmforwarding, \
}
/* INET6 stuff */
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 898272a0d9e..4058f537758 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.133 2005/09/19 01:48:05 deraadt Exp $ */
+/* $OpenBSD: ip_input.c,v 1.134 2005/10/05 17:32:22 norby Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -86,6 +86,7 @@ char ipsec_def_comp[20];
/* values controllable via sysctl */
int ipforwarding = 0;
+int ipmforwarding = 0;
int ipsendredirects = 1;
int ip_dosourceroute = 0;
int ip_defttl = IPDEFTTL;
@@ -410,8 +411,7 @@ ipv4_input(m)
}
ip = mtod(m, struct ip *);
}
-
- if (ip_mrouter) {
+ if (ipmforwarding && ip_mrouter) {
/*
* If we are acting as a multicast router, all
* incoming multicast packets are passed to the
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index f1eb4f209b2..dae7a979b9e 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_output.c,v 1.172 2005/06/10 15:53:07 markus Exp $ */
+/* $OpenBSD: ip_output.c,v 1.173 2005/10/05 17:32:22 norby Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
@@ -78,6 +78,7 @@ extern int ipsec_esp_trans_default_level;
extern int ipsec_esp_network_default_level;
extern int ipsec_ipcomp_default_level;
extern int ipforwarding;
+extern int ipmforwarding;
#endif /* IPSEC */
static struct mbuf *ip_insertoptions(struct mbuf *, struct mbuf *, int *);
@@ -501,7 +502,8 @@ ip_output(struct mbuf *m0, ...)
*/
extern struct socket *ip_mrouter;
- if (ip_mrouter && (flags & IP_FORWARDING) == 0) {
+ if (ipmforwarding && ip_mrouter &&
+ (flags & IP_FORWARDING) == 0) {
if (ip_mforward(m, ifp) != 0) {
m_freem(m);
goto done;
@@ -1509,7 +1511,7 @@ ip_ctloutput(op, so, level, optname, mp)
error = ENOBUFS;
break;
}
-
+
}
m->m_len = len;
*mtod(m, u_int16_t *) = ipr->ref_type;