summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Yves Ritschard <pyr@cvs.openbsd.org>2007-10-22 14:48:53 +0000
committerPierre-Yves Ritschard <pyr@cvs.openbsd.org>2007-10-22 14:48:53 +0000
commit226dcc4ee855ea70f9228f9ef18ec67930b8efbd (patch)
tree6da20dbc314f2269ecd57c768870364c13b5f887
parentb8b3845bea1fa0069aa71d6f59864c5f72ed3883 (diff)
Add a broadcast mode to trunk(4). This mode sends frames on all
ports and receives frame on any port. This allows interaction with some L2 configurations. with input and ok reyk@
-rw-r--r--share/man/man4/trunk.48
-rw-r--r--sys/net/if_trunk.c77
-rw-r--r--sys/net/if_trunk.h6
3 files changed, 86 insertions, 5 deletions
diff --git a/share/man/man4/trunk.4 b/share/man/man4/trunk.4
index 7b26f124c57..395981809ba 100644
--- a/share/man/man4/trunk.4
+++ b/share/man/man4/trunk.4
@@ -1,4 +1,4 @@
-.\" $OpenBSD: trunk.4,v 1.19 2007/05/31 19:19:52 jmc Exp $
+.\" $OpenBSD: trunk.4,v 1.20 2007/10/22 14:48:52 pyr Exp $
.\"
.\" Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 31 2007 $
+.Dd $Mdocdate: October 22 2007 $
.Dt TRUNK 4
.Os
.Sh NAME
@@ -49,6 +49,7 @@ The driver currently supports the trunk protocols
(the default),
.Ic failover ,
.Ic loadbalance ,
+.Ic broadcast ,
and
.Ic none .
The protocols determine which ports are used for outgoing traffic
@@ -72,6 +73,9 @@ protocol header information and accepts incoming traffic from
any active port.
The hash includes the Ethernet source and destination address, and, if
available, the VLAN tag, and the IP source and destination address.
+.It Ic broadcast
+Sends frames to all ports of the trunk and receives frames on any
+port of the trunk.
.It Ic none
This protocol is intended to do nothing: it disables any traffic without
disabling the
diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c
index 6dbba168e12..0afac165f80 100644
--- a/sys/net/if_trunk.c
+++ b/sys/net/if_trunk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_trunk.c,v 1.36 2007/09/15 16:43:51 henning Exp $ */
+/* $OpenBSD: if_trunk.c,v 1.37 2007/10/22 14:48:52 pyr Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -119,6 +119,13 @@ int trunk_lb_input(struct trunk_softc *, struct trunk_port *,
int trunk_lb_porttable(struct trunk_softc *, struct trunk_port *);
const void *trunk_lb_gethdr(struct mbuf *, u_int, u_int, void *);
+/* Broadcast mode */
+int trunk_bcast_attach(struct trunk_softc *);
+int trunk_bcast_detach(struct trunk_softc *);
+int trunk_bcast_start(struct trunk_softc *, struct mbuf *);
+int trunk_bcast_input(struct trunk_softc *, struct trunk_port *,
+ struct ether_header *, struct mbuf *);
+
/* Trunk protocol table */
static const struct {
enum trunk_proto ti_proto;
@@ -127,6 +134,7 @@ static const struct {
{ TRUNK_PROTO_ROUNDROBIN, trunk_rr_attach },
{ TRUNK_PROTO_FAILOVER, trunk_fail_attach },
{ TRUNK_PROTO_LOADBALANCE, trunk_lb_attach },
+ { TRUNK_PROTO_BROADCAST, trunk_bcast_attach },
{ TRUNK_PROTO_NONE, NULL }
};
@@ -1426,3 +1434,70 @@ trunk_lb_input(struct trunk_softc *tr, struct trunk_port *tp,
return (0);
}
+
+/*
+ * Broadcast mode
+ */
+
+int
+trunk_bcast_attach(struct trunk_softc *tr)
+{
+ tr->tr_detach = trunk_bcast_detach;
+ tr->tr_start = trunk_bcast_start;
+ tr->tr_input = trunk_bcast_input;
+ tr->tr_init = NULL;
+ tr->tr_stop = NULL;
+ tr->tr_port_create = NULL;
+ tr->tr_port_destroy = NULL;
+ tr->tr_linkstate = NULL;
+
+ return (0);
+}
+
+int
+trunk_bcast_detach(struct trunk_softc *tr)
+{
+ return (0);
+}
+
+int
+trunk_bcast_start(struct trunk_softc *tr, struct mbuf *m)
+{
+ int active_ports = 0;
+ int errors = 0;
+ int ret;
+ struct trunk_port *tp;
+ struct mbuf *newbuf;
+
+ SLIST_FOREACH(tp, &tr->tr_ports, tp_entries) {
+ if (TRUNK_PORTACTIVE(tp)) {
+ /*
+ * copy the mbuf everytime.
+ */
+ newbuf = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
+ if (newbuf == NULL) {
+ m_free(m);
+ return (ENOBUFS);
+ }
+ active_ports++;
+ if ((ret = trunk_enqueue(tp->tp_if, newbuf)))
+ errors++;
+ }
+ }
+ m_free(m);
+ if (active_ports == 0)
+ return (ENOENT);
+ if (errors == active_ports)
+ return (ret);
+ return (0);
+}
+
+int
+trunk_bcast_input(struct trunk_softc *tr, struct trunk_port *tp,
+ struct ether_header *eh, struct mbuf *m)
+{
+ struct ifnet *ifp = &tr->tr_ac.ac_if;
+
+ m->m_pkthdr.rcvif = ifp;
+ return (0);
+}
diff --git a/sys/net/if_trunk.h b/sys/net/if_trunk.h
index 221d49674f3..b86d47b76e6 100644
--- a/sys/net/if_trunk.h
+++ b/sys/net/if_trunk.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_trunk.h,v 1.13 2007/09/06 16:22:55 reyk Exp $ */
+/* $OpenBSD: if_trunk.h,v 1.14 2007/10/22 14:48:52 pyr Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -42,7 +42,8 @@ enum trunk_proto {
TRUNK_PROTO_ROUNDROBIN = 1, /* simple round robin */
TRUNK_PROTO_FAILOVER = 2, /* active failover */
TRUNK_PROTO_LOADBALANCE = 3, /* loadbalance */
- TRUNK_PROTO_MAX = 4
+ TRUNK_PROTO_BROADCAST = 4, /* broadcast */
+ TRUNK_PROTO_MAX = 5
};
struct trunk_protos {
@@ -55,6 +56,7 @@ struct trunk_protos {
{ "roundrobin", TRUNK_PROTO_ROUNDROBIN }, \
{ "failover", TRUNK_PROTO_FAILOVER }, \
{ "loadbalance", TRUNK_PROTO_LOADBALANCE }, \
+ { "broadcast", TRUNK_PROTO_BROADCAST }, \
{ "none", TRUNK_PROTO_NONE }, \
{ "default", TRUNK_PROTO_DEFAULT } \
}