From 547bd856b3aefa801c25796cc7f187126a88b0b8 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Wed, 22 Jul 2020 00:29:01 +0000 Subject: add code to coordinate how bridges attach to ethernet interfaces. this is the first step in refactoring how ethernet frames are demuxed by virtual interfaces, and also in deprecating interface input list handling. we now have drivers for three types of virtual bridges, bridge(4), switch(4), and tpmr(4), and it doesn't make sense for any of them to be enabled on the same "port" interfaces at the same time. currently you can add a port interface to multiple types of bridge, but which one gets to steal the packets depends on the order in which they were attached. this creates an ether_brport structure that holds an input function for the bridge, and optionally some per port state that the bridge can use. arpcom has a single pointer to one of these structs that will be used during normal ether_input processing to see if a packet should be passed to a bridge, and will be used instead of an if input handler. because it is a single pointer, it will make sure only one bridge of any type is attached to a port at any one time. this has been in snaps as part of a larger diff for over a week. --- sys/netinet/if_ether.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'sys/netinet/if_ether.h') diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h index 934bbc97de8..5ae7228509f 100644 --- a/sys/netinet/if_ether.h +++ b/sys/netinet/if_ether.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.h,v 1.76 2019/07/17 16:46:18 mpi Exp $ */ +/* $OpenBSD: if_ether.h,v 1.77 2020/07/22 00:29:00 dlg Exp $ */ /* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */ /* @@ -199,6 +199,11 @@ do { \ #include /* for "struct ifnet" */ +struct ether_brport { + struct mbuf *(*eb_input)(struct ifnet *, struct mbuf *, void *); + void *eb_port; +}; + /* * Structure shared between the ethernet driver modules and * the address resolution code. For example, each ec_softc or il_softc @@ -213,6 +218,7 @@ struct arpcom { int ac_multirangecnt; /* number of mcast ranges */ void *ac_trunkport; + const struct ether_brport *ac_brport; }; extern int arpt_keep; /* arp resolved cache expire */ @@ -258,6 +264,13 @@ int ether_output(struct ifnet *, struct mbuf *, struct sockaddr *, void ether_rtrequest(struct ifnet *, int, struct rtentry *); char *ether_sprintf(u_char *); +int ether_brport_isset(struct ifnet *); +void ether_brport_set(struct ifnet *, const struct ether_brport *); +void ether_brport_clr(struct ifnet *); +const struct ether_brport * + ether_brport_get(struct ifnet *); +const struct ether_brport * + ether_brport_get_locked(struct ifnet *); /* * Ethernet multicast address structure. There is one of these for each -- cgit v1.2.3