diff options
author | glebius <glebius@FreeBSD.org> | 2013-03-15 12:52:59 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2013-03-15 12:52:59 +0000 |
commit | 76306b34651c9b81d0d3bf6b97757c7373d3d636 (patch) | |
tree | fed5508f460792a3916b0389c9e2244b1f6567ea /sys/net | |
parent | 79cb402edbb474fc00a40f3fc46c9b5c2304d461 (diff) | |
download | FreeBSD-src-76306b34651c9b81d0d3bf6b97757c7373d3d636.zip FreeBSD-src-76306b34651c9b81d0d3bf6b97757c7373d3d636.tar.gz |
- Use m_getcl() instead of hand allocating.
- Convert panic() to KASSERT.
- Remove superfluous cleaning of mbuf fields after allocation.
- Add comment on possible use of m_get2() here.
Sponsored by: Nginx, Inc.
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/rtsock.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 9a08a76..c3781d5 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1118,20 +1118,17 @@ rt_msg1(int type, struct rt_addrinfo *rtinfo) default: len = sizeof(struct rt_msghdr); } - if (len > MCLBYTES) - panic("rt_msg1"); - m = m_gethdr(M_NOWAIT, MT_DATA); - if (m && len > MHLEN) { - MCLGET(m, M_NOWAIT); - if ((m->m_flags & M_EXT) == 0) { - m_free(m); - m = NULL; - } - } + + /* XXXGL: can we use MJUMPAGESIZE cluster here? */ + KASSERT(len <= MCLBYTES, ("%s: message too big", __func__)); + if (len > MHLEN) + m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); + else + m = m_gethdr(M_NOWAIT, MT_DATA); if (m == NULL) return (m); + m->m_pkthdr.len = m->m_len = len; - m->m_pkthdr.rcvif = NULL; rtm = mtod(m, struct rt_msghdr *); bzero((caddr_t)rtm, len); for (i = 0; i < RTAX_MAX; i++) { |