Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src/sys/netinet Pull up following revision(s) (requested by b...



details:   https://anonhg.NetBSD.org/src/rev/1fcf94e43344
branches:  netbsd-6
changeset: 776603:1fcf94e43344
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Fri Apr 11 08:52:14 2014 +0000

description:
Pull up following revision(s) (requested by bouyer in ticket #1043):
        sys/netinet/ip_carp.c: revision 1.53
Proper MBUFTRACE handling. Without it, ec_tx_mowner, ec_rx_mowner and
ifp->if_mowner would be used uninitialised.

diffstat:

 sys/netinet/ip_carp.c |  35 +++++++++++++++++++++++++++++++++--
 1 files changed, 33 insertions(+), 2 deletions(-)

diffs (100 lines):

diff -r 539461cb67f5 -r 1fcf94e43344 sys/netinet/ip_carp.c
--- a/sys/netinet/ip_carp.c     Fri Apr 11 08:45:18 2014 +0000
+++ b/sys/netinet/ip_carp.c     Fri Apr 11 08:52:14 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_carp.c,v 1.47.4.1 2012/04/02 18:25:35 riz Exp $     */
+/*     $NetBSD: ip_carp.c,v 1.47.4.2 2014/04/11 08:52:14 msaitoh Exp $ */
 /*     $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $   */
 
 /*
@@ -28,9 +28,10 @@
  */
 
 #include "opt_inet.h"
+#include "opt_mbuftrace.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.47.4.1 2012/04/02 18:25:35 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.47.4.2 2014/04/11 08:52:14 msaitoh Exp $");
 
 /*
  * TODO:
@@ -159,6 +160,13 @@
 
 #define        CARP_STATINC(x)         _NET_STATINC(carpstat_percpu, x)
 
+#ifdef MBUFTRACE
+static struct mowner carp_proto_mowner_rx = MOWNER_INIT("carp", "rx");
+static struct mowner carp_proto_mowner_tx = MOWNER_INIT("carp", "tx");
+static struct mowner carp_proto6_mowner_rx = MOWNER_INIT("carp6", "rx");
+static struct mowner carp_proto6_mowner_tx = MOWNER_INIT("carp6", "tx");
+#endif
+
 struct carp_if {
        TAILQ_HEAD(, carp_softc) vhif_vrs;
        int vhif_nvrs;
@@ -465,6 +473,7 @@
        va_end(ap);
 
        CARP_STATINC(CARP_STAT_IPACKETS);
+       MCLAIM(m, &carp_proto_mowner_rx);
 
        if (!carp_opts[CARPCTL_ALLOW]) {
                m_freem(m);
@@ -534,6 +543,7 @@
        u_int len;
 
        CARP_STATINC(CARP_STAT_IPACKETS6);
+       MCLAIM(m, &carp_proto6_mowner_rx);
 
        if (!carp_opts[CARPCTL_ALLOW]) {
                m_freem(m);
@@ -802,6 +812,19 @@
        carp_set_enaddr(sc);
        LIST_INIT(&sc->sc_ac.ec_multiaddrs);
        bpf_attach(ifp, DLT_EN10MB, ETHER_HDR_LEN);
+#ifdef MBUFTRACE
+       strlcpy(sc->sc_ac.ec_tx_mowner.mo_name, ifp->if_xname,
+           sizeof(sc->sc_ac.ec_tx_mowner.mo_name));
+       strlcpy(sc->sc_ac.ec_tx_mowner.mo_descr, "tx",
+           sizeof(sc->sc_ac.ec_tx_mowner.mo_descr));
+       strlcpy(sc->sc_ac.ec_rx_mowner.mo_name, ifp->if_xname,
+           sizeof(sc->sc_ac.ec_rx_mowner.mo_name));
+       strlcpy(sc->sc_ac.ec_rx_mowner.mo_descr, "rx",
+           sizeof(sc->sc_ac.ec_rx_mowner.mo_descr));
+       MOWNER_ATTACH(&sc->sc_ac.ec_tx_mowner);
+       MOWNER_ATTACH(&sc->sc_ac.ec_rx_mowner);
+       ifp->if_mowner = &sc->sc_ac.ec_tx_mowner;
+#endif
        return (0);
 }
 
@@ -967,6 +990,7 @@
                        /* XXX maybe less ? */
                        goto retry_later;
                }
+               MCLAIM(m, &carp_proto_mowner_tx);
                len = sizeof(*ip) + sizeof(ch);
                m->m_pkthdr.len = len;
                m->m_pkthdr.rcvif = NULL;
@@ -1047,6 +1071,7 @@
                        /* XXX maybe less ? */
                        goto retry_later;
                }
+               MCLAIM(m, &carp_proto6_mowner_tx);
                len = sizeof(*ip6) + sizeof(ch);
                m->m_pkthdr.len = len;
                m->m_pkthdr.rcvif = NULL;
@@ -2238,6 +2263,12 @@
 {
 
        sysctl_net_inet_carp_setup(NULL);
+#ifdef MBUFTRACE
+       MOWNER_ATTACH(&carp_proto_mowner_rx);
+       MOWNER_ATTACH(&carp_proto_mowner_tx);
+       MOWNER_ATTACH(&carp_proto6_mowner_rx);
+       MOWNER_ATTACH(&carp_proto6_mowner_tx);
+#endif
 }
 
 static void



Home | Main Index | Thread Index | Old Index