svn commit: r243436 - stable/9/sys/net

Gleb Smirnoff glebius at FreeBSD.org
Fri Nov 23 08:23:53 UTC 2012


Author: glebius
Date: Fri Nov 23 08:23:53 2012
New Revision: 243436
URL: http://svnweb.freebsd.org/changeset/base/243436

Log:
  Sync lagg(4) with head, merging r240742, r241619:
  
    r240742 | glebius | 2012-09-20 14:05:10 +0400 (чт, 20 сен 2012) | 4 lines
  
    Convert lagg(4) to use if_transmit instead of if_start.
  
    In collaboration with:  thompsa, sbruno, fabient
  
    r241619 | emax | 2012-10-17 02:43:14 +0400 (ср, 17 окт 2012) | 5 lines
  
    report total number of ports for each lagg(4) interface
    via net.link.lagg.X.count sysctl

Modified:
  stable/9/sys/net/if_lagg.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/net/if_lagg.c
==============================================================================
--- stable/9/sys/net/if_lagg.c	Fri Nov 23 08:22:06 2012	(r243435)
+++ stable/9/sys/net/if_lagg.c	Fri Nov 23 08:23:53 2012	(r243436)
@@ -110,7 +110,8 @@ static int	lagg_ether_cmdmulti(struct la
 static	int	lagg_setflag(struct lagg_port *, int, int,
 		    int (*func)(struct ifnet *, int));
 static	int	lagg_setflags(struct lagg_port *, int status);
-static void	lagg_start(struct ifnet *);
+static int	lagg_transmit(struct ifnet *, struct mbuf *);
+static void	lagg_qflush(struct ifnet *);
 static int	lagg_media_change(struct ifnet *);
 static void	lagg_media_status(struct ifnet *, struct ifmediareq *);
 static struct lagg_port *lagg_link_active(struct lagg_softc *,
@@ -284,6 +285,9 @@ lagg_clone_create(struct if_clone *ifc, 
 	SYSCTL_ADD_INT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
 		"use_flowid", CTLTYPE_INT|CTLFLAG_RW, &sc->use_flowid, sc->use_flowid,
 		"Use flow id for load sharing");
+	SYSCTL_ADD_INT(&sc->ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
+		"count", CTLTYPE_INT|CTLFLAG_RD, &sc->sc_count, sc->sc_count,
+		"Total number of ports");
 	/* Hash all layers by default */
 	sc->sc_flags = LAGG_F_HASHL2|LAGG_F_HASHL3|LAGG_F_HASHL4;
 
@@ -312,15 +316,12 @@ lagg_clone_create(struct if_clone *ifc, 
 	if_initname(ifp, ifc->ifc_name, unit);
 	ifp->if_type = IFT_ETHER;
 	ifp->if_softc = sc;
-	ifp->if_start = lagg_start;
+	ifp->if_transmit = lagg_transmit;
+	ifp->if_qflush = lagg_qflush;
 	ifp->if_init = lagg_init;
 	ifp->if_ioctl = lagg_ioctl;
 	ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
 
-	IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen);
-	ifp->if_snd.ifq_drv_maxlen = ifqmaxlen;
-	IFQ_SET_READY(&ifp->if_snd);
-
 	/*
 	 * Attach as an ordinary ethernet device, childs will be attached
 	 * as special device IFT_IEEE8023ADLAG.
@@ -1222,35 +1223,45 @@ lagg_setflags(struct lagg_port *lp, int 
 	return (0);
 }
 
-static void
-lagg_start(struct ifnet *ifp)
+static int
+lagg_transmit(struct ifnet *ifp, struct mbuf *m)
 {
 	struct lagg_softc *sc = (struct lagg_softc *)ifp->if_softc;
-	struct mbuf *m;
-	int error = 0;
+	int error, len, mcast;
+
+	len = m->m_pkthdr.len;
+	mcast = (m->m_flags & (M_MCAST | M_BCAST)) ? 1 : 0;
 
 	LAGG_RLOCK(sc);
 	/* We need a Tx algorithm and at least one port */
 	if (sc->sc_proto == LAGG_PROTO_NONE || sc->sc_count == 0) {
-		IF_DRAIN(&ifp->if_snd);
 		LAGG_RUNLOCK(sc);
-		return;
+		m_freem(m);
+		ifp->if_oerrors++;
+		return (ENXIO);
 	}
 
-	for (;; error = 0) {
-		IFQ_DEQUEUE(&ifp->if_snd, m);
-		if (m == NULL)
-			break;
-
-		ETHER_BPF_MTAP(ifp, m);
+	ETHER_BPF_MTAP(ifp, m);
 
-		error = (*sc->sc_start)(sc, m);
-		if (error == 0)
-			ifp->if_opackets++;
-		else
-			ifp->if_oerrors++;
-	}
+	error = (*sc->sc_start)(sc, m);
 	LAGG_RUNLOCK(sc);
+
+	if (error == 0) {
+		ifp->if_opackets++;
+		ifp->if_omcasts += mcast;
+		ifp->if_obytes += len;
+	} else
+		ifp->if_oerrors++;
+
+	return (error);
+}
+
+/*
+ * The ifp->if_qflush entry point for lagg(4) is no-op.
+ */
+static void
+lagg_qflush(struct ifnet *ifp __unused)
+{
 }
 
 static struct mbuf *


More information about the svn-src-stable-9 mailing list