Date: Fri, 3 Jan 2014 12:28:33 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r260226 - stable/10/sys/netgraph Message-ID: <201401031228.s03CSXY2043942@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Fri Jan 3 12:28:33 2014 New Revision: 260226 URL: http://svnweb.freebsd.org/changeset/base/260226 Log: Merge r259681 from head: Changes: - Reinit uio_resid and flags before every call to soreceive(). - Set maximum acceptable size of packet to IP_MAXPACKET. As for now the module doesn't support INET6. - Properly handle MSG_TRUNC return from soreceive(). PR: 184601 Modified: stable/10/sys/netgraph/ng_ksocket.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netgraph/ng_ksocket.c ============================================================================== --- stable/10/sys/netgraph/ng_ksocket.c Fri Jan 3 12:06:54 2014 (r260225) +++ stable/10/sys/netgraph/ng_ksocket.c Fri Jan 3 12:28:33 2014 (r260226) @@ -66,6 +66,7 @@ #include <netgraph/ng_ksocket.h> #include <netinet/in.h> +#include <netinet/ip.h> #include <netatalk/at.h> #ifdef NG_SEPARATE_MALLOC @@ -1043,8 +1044,7 @@ ng_ksocket_incoming2(node_p node, hook_p struct socket *so = arg1; const priv_p priv = NG_NODE_PRIVATE(node); struct ng_mesg *response; - struct uio auio; - int flags, error; + int error; KASSERT(so == priv->so, ("%s: wrong socket", __func__)); @@ -1093,20 +1093,27 @@ ng_ksocket_incoming2(node_p node, hook_p if (priv->hook == NULL) return; - /* Read and forward available mbuf's */ - auio.uio_td = NULL; - auio.uio_resid = MJUMPAGESIZE; /* XXXGL: sane limit? */ - flags = MSG_DONTWAIT; + /* Read and forward available mbufs. */ while (1) { - struct sockaddr *sa = NULL; + struct uio uio; + struct sockaddr *sa; struct mbuf *m; + int flags; - /* Try to get next packet from socket */ + /* Try to get next packet from socket. */ + uio.uio_td = NULL; + uio.uio_resid = IP_MAXPACKET; + flags = MSG_DONTWAIT; + sa = NULL; if ((error = soreceive(so, (so->so_state & SS_ISCONNECTED) ? - NULL : &sa, &auio, &m, NULL, &flags)) != 0) + NULL : &sa, &uio, &m, NULL, &flags)) != 0) break; - /* See if we got anything */ + /* See if we got anything. */ + if (flags & MSG_TRUNC) { + m_freem(m); + m = NULL; + } if (m == NULL) { if (sa != NULL) free(sa, M_SONAME);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401031228.s03CSXY2043942>