Date: Sun, 27 Apr 2014 10:43:48 +0000 (UTC) From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265011 - head/sys/net Message-ID: <201404271043.s3RAhm31084755@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: melifaro Date: Sun Apr 27 10:43:48 2014 New Revision: 265011 URL: http://svnweb.freebsd.org/changeset/base/265011 Log: Remove useless zeroing of RTAX_DST on error. Cleanup a bit. MFC after: 1 month Modified: head/sys/net/rtsock.c Modified: head/sys/net/rtsock.c ============================================================================== --- head/sys/net/rtsock.c Sun Apr 27 10:20:37 2014 (r265010) +++ head/sys/net/rtsock.c Sun Apr 27 10:43:48 2014 (r265011) @@ -542,32 +542,38 @@ route_output(struct mbuf *m, struct sock panic("route_output"); len = m->m_pkthdr.len; if (len < sizeof(*rtm) || - len != mtod(m, struct rt_msghdr *)->rtm_msglen) { - info.rti_info[RTAX_DST] = NULL; + len != mtod(m, struct rt_msghdr *)->rtm_msglen) senderr(EINVAL); - } + R_Malloc(rtm, struct rt_msghdr *, len); - if (rtm == NULL) { - info.rti_info[RTAX_DST] = NULL; + if (rtm == NULL) senderr(ENOBUFS); - } m_copydata(m, 0, len, (caddr_t)rtm); + bzero(&info, sizeof(info)); + if (rtm->rtm_version != RTM_VERSION) { - info.rti_info[RTAX_DST] = NULL; + /* Do not touch message since format is unknown */ + Free(rtm); + rtm = NULL; senderr(EPROTONOSUPPORT); } + + /* + * Starting from here, it is possible + * to alter original message and insert + * caller PID and error value. + */ + rtm->rtm_pid = curproc->p_pid; - bzero(&info, sizeof(info)); info.rti_addrs = rtm->rtm_addrs; /* * rt_xaddrs() performs s6_addr[2] := sin6_scope_id for AF_INET6 * link-local address because rtrequest requires addresses with * embedded scope id. */ - if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) { - info.rti_info[RTAX_DST] = NULL; + if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) senderr(EINVAL); - } + info.rti_flags = rtm->rtm_flags; if (info.rti_info[RTAX_DST] == NULL || info.rti_info[RTAX_DST]->sa_family >= AF_MAX ||
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404271043.s3RAhm31084755>