diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if_trunk.c | 77 | ||||
-rw-r--r-- | sys/net/if_trunk.h | 6 |
2 files changed, 80 insertions, 3 deletions
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 } \ } |