From 51f53f0bcf4aecf7ca159e0094ddad4dda67c68f Mon Sep 17 00:00:00 2001 From: thompsa Date: Mon, 8 Sep 2008 03:28:26 +0000 Subject: Put the bridge mac inheritance behind a sysctl with the default off as this still needs all the edge cases fixed. Submitted by: Eygene Ryabinkin --- share/man/man4/if_bridge.4 | 16 ++++++++++++++++ sys/net/if_bridge.c | 9 +++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/share/man/man4/if_bridge.4 b/share/man/man4/if_bridge.4 index 3701acd..9eebe98 100644 --- a/share/man/man4/if_bridge.4 +++ b/share/man/man4/if_bridge.4 @@ -92,6 +92,22 @@ the same link addresses. The address can be changed by assigning the desired link address using .Xr ifconfig 8 . .Pp +If +.Xr sysctl 8 +node +.Va net.link.bridge.inherit_mac +has non-zero value, newly created bridge will inherit MAC address +from its first member instead of choosing random link-level address. +This will provide more predictable bridge MAC without any +additional configuration, but currently this feature is known +to break some L2 protocols, for example PPPoE that is provided +by +.Xr ng_pppoe 4 +and +.Xr ppp 8 . +Now this feature is considered as experimental and is turned off +by-default. +.Pp A bridge can be used to provide several services, such as a simple 802.11-to-Ethernet bridge for wireless hosts, and traffic isolation. .Pp diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 88eda1d..4e124d2 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -347,6 +347,7 @@ static int pfil_ipfw_arp = 0; /* layer2 filter with ipfw */ static int pfil_local_phys = 0; /* run pfil hooks on the physical interface for locally destined packets */ static int log_stp = 0; /* log STP state changes */ +static int bridge_inherit_mac = 0; /* share MAC with first bridge member */ SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_onlyip, CTLFLAG_RW, &pfil_onlyip, 0, "Only pass IP packets when pfil is enabled"); SYSCTL_INT(_net_link_bridge, OID_AUTO, ipfw_arp, CTLFLAG_RW, @@ -360,6 +361,9 @@ SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_local_phys, CTLFLAG_RW, "Packet filter on the physical interface for locally destined packets"); SYSCTL_INT(_net_link_bridge, OID_AUTO, log_stp, CTLFLAG_RW, &log_stp, 0, "Log STP state changes"); +SYSCTL_INT(_net_link_bridge, OID_AUTO, inherit_mac, CTLFLAG_RW, + &bridge_inherit_mac, 0, + "Inherit MAC address from the first bridge member"); struct bridge_control { int (*bc_func)(struct bridge_softc *, void *); @@ -923,7 +927,8 @@ bridge_delete_member(struct bridge_softc *sc, struct bridge_iflist *bif, * the mac address of the bridge to the address of the next member, or * to its default address if no members are left. */ - if (!memcmp(IF_LLADDR(sc->sc_ifp), IF_LLADDR(ifs), ETHER_ADDR_LEN)) { + if (bridge_inherit_mac && + !memcmp(IF_LLADDR(sc->sc_ifp), IF_LLADDR(ifs), ETHER_ADDR_LEN)) { if (LIST_EMPTY(&sc->sc_iflist)) bcopy(sc->sc_defaddr, IF_LLADDR(sc->sc_ifp), ETHER_ADDR_LEN); @@ -1030,7 +1035,7 @@ bridge_ioctl_add(struct bridge_softc *sc, void *arg) * member and the MAC address of the bridge has not been changed from * the default randomly generated one. */ - if (LIST_EMPTY(&sc->sc_iflist) && + if (bridge_inherit_mac && LIST_EMPTY(&sc->sc_iflist) && !memcmp(IF_LLADDR(sc->sc_ifp), sc->sc_defaddr, ETHER_ADDR_LEN)) bcopy(IF_LLADDR(ifs), IF_LLADDR(sc->sc_ifp), ETHER_ADDR_LEN); -- cgit v1.1