Date: Sat, 24 Aug 2013 12:24:59 +0000 (UTC) From: Andre Oppermann <andre@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254779 - head/sys/kern Message-ID: <201308241224.r7OCOx9l069850@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andre Date: Sat Aug 24 12:24:58 2013 New Revision: 254779 URL: http://svnweb.freebsd.org/changeset/base/254779 Log: Avoid code duplication for mbuf initialization and use m_init() instead in mb_ctor_mbuf() and mb_ctor_pack(). Modified: head/sys/kern/kern_mbuf.c Modified: head/sys/kern/kern_mbuf.c ============================================================================== --- head/sys/kern/kern_mbuf.c Sat Aug 24 12:10:11 2013 (r254778) +++ head/sys/kern/kern_mbuf.c Sat Aug 24 12:24:58 2013 (r254779) @@ -410,18 +410,14 @@ mb_ctor_mbuf(void *mem, int size, void * { struct mbuf *m; struct mb_args *args; -#ifdef MAC int error; -#endif int flags; short type; #ifdef INVARIANTS trash_ctor(mem, size, arg, how); #endif - m = (struct mbuf *)mem; args = (struct mb_args *)arg; - flags = args->flags; type = args->type; /* @@ -431,32 +427,12 @@ mb_ctor_mbuf(void *mem, int size, void * if (type == MT_NOINIT) return (0); - m->m_next = NULL; - m->m_nextpkt = NULL; - m->m_len = 0; - m->m_flags = flags; - m->m_type = type; - if (flags & M_PKTHDR) { - m->m_data = m->m_pktdat; - m->m_pkthdr.rcvif = NULL; - m->m_pkthdr.header = NULL; - m->m_pkthdr.len = 0; - m->m_pkthdr.csum_flags = 0; - m->m_pkthdr.csum_data = 0; - m->m_pkthdr.tso_segsz = 0; - m->m_pkthdr.ether_vtag = 0; - m->m_pkthdr.flowid = 0; - m->m_pkthdr.fibnum = 0; - SLIST_INIT(&m->m_pkthdr.tags); -#ifdef MAC - /* If the label init fails, fail the alloc */ - error = mac_mbuf_init(m, how); - if (error) - return (error); -#endif - } else - m->m_data = m->m_dat; - return (0); + m = (struct mbuf *)mem; + flags = args->flags; + + error = m_init(m, NULL, size, how, type, flags); + + return (error); } /* @@ -656,34 +632,14 @@ mb_ctor_pack(void *mem, int size, void * #ifdef INVARIANTS trash_ctor(m->m_ext.ext_buf, MCLBYTES, arg, how); #endif - m->m_next = NULL; - m->m_nextpkt = NULL; - m->m_data = m->m_ext.ext_buf; - m->m_len = 0; - m->m_flags = (flags | M_EXT); - m->m_type = type; - - if (flags & M_PKTHDR) { - m->m_pkthdr.rcvif = NULL; - m->m_pkthdr.len = 0; - m->m_pkthdr.header = NULL; - m->m_pkthdr.csum_flags = 0; - m->m_pkthdr.csum_data = 0; - m->m_pkthdr.tso_segsz = 0; - m->m_pkthdr.ether_vtag = 0; - m->m_pkthdr.flowid = 0; - m->m_pkthdr.fibnum = 0; - SLIST_INIT(&m->m_pkthdr.tags); -#ifdef MAC - /* If the label init fails, fail the alloc */ - error = mac_mbuf_init(m, how); - if (error) - return (error); -#endif - } + + error = m_init(m, NULL, size, how, type, flags); + /* m_ext is already initialized. */ + m->m_data = m->m_ext.ext_buf; + m->m_flags = (flags | M_EXT); - return (0); + return (error); } int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308241224.r7OCOx9l069850>