summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2014-01-03 12:28:33 +0000
committerglebius <glebius@FreeBSD.org>2014-01-03 12:28:33 +0000
commitb1d31e28109c70d3cf066cc72e027163f211add7 (patch)
treee03f22153fefdc58999a198673d3dab34c6a8b0b
parentac5822de6e30a4f8b1caa4c3e3d3e2a985d891dd (diff)
downloadFreeBSD-src-b1d31e28109c70d3cf066cc72e027163f211add7.zip
FreeBSD-src-b1d31e28109c70d3cf066cc72e027163f211add7.tar.gz
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
-rw-r--r--sys/netgraph/ng_ksocket.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/sys/netgraph/ng_ksocket.c b/sys/netgraph/ng_ksocket.c
index de22773..5c0ae67 100644
--- a/sys/netgraph/ng_ksocket.c
+++ b/sys/netgraph/ng_ksocket.c
@@ -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 hook, void *arg1, int arg2)
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 hook, void *arg1, int arg2)
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);
OpenPOWER on IntegriCloud