diff options
author | glebius <glebius@FreeBSD.org> | 2005-02-12 14:54:19 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2005-02-12 14:54:19 +0000 |
commit | f36bba96f5e5614dcc392eb6e43a8fa8342a8b9c (patch) | |
tree | 94e87c9322455be2391a1d57f1f3099858041e79 | |
parent | 33ab2b5cf1b439bfe17ec30e222008c8a28fd665 (diff) | |
download | FreeBSD-src-f36bba96f5e5614dcc392eb6e43a8fa8342a8b9c.zip FreeBSD-src-f36bba96f5e5614dcc392eb6e43a8fa8342a8b9c.tar.gz |
When netgraph(4) was converted to use mbuf_tags(9) instead of meta-data
a definite setup was broken: two ng_ksockets are connected to each other,
connect()ed to different remote hosts, and bind()ed to different local
interfaces. In this case one ng_ksocket is fooled with tag from the other
one.
Put node id into tag. In rcvdata method utilize tag only if it has our
own id inside or id equals zero. The latter case is added to support
packets send by some third, not ng_ksocket node.
MFC after: 1 week
-rw-r--r-- | sys/netgraph/ng_ksocket.c | 12 | ||||
-rw-r--r-- | sys/netgraph/ng_ksocket.h | 1 |
2 files changed, 10 insertions, 3 deletions
diff --git a/sys/netgraph/ng_ksocket.c b/sys/netgraph/ng_ksocket.c index 7f2a654..023d7cc 100644 --- a/sys/netgraph/ng_ksocket.c +++ b/sys/netgraph/ng_ksocket.c @@ -908,9 +908,14 @@ ng_ksocket_rcvdata(hook_p hook, item_p item) NGI_GET_M(item, m); NG_FREE_ITEM(item); - /* Look if socket address is stored in packet tags */ - if ((stag = (struct sa_tag *)m_tag_locate(m, NGM_KSOCKET_COOKIE, - NG_KSOCKET_TAG_SOCKADDR, NULL)) != NULL) + /* + * Look if socket address is stored in packet tags. + * If sockaddr is ours, or provided by a third party (zero id), + * then we accept it. + */ + if (((stag = (struct sa_tag *)m_tag_locate(m, NGM_KSOCKET_COOKIE, + NG_KSOCKET_TAG_SOCKADDR, NULL)) != NULL) && + (stag->id == NG_NODE_ID(node) || stag->id == 0)) sa = &stag->sa; /* Send packet */ @@ -1121,6 +1126,7 @@ ng_ksocket_incoming2(node_p node, hook_p hook, void *arg1, int waitflag) } bcopy(sa, &stag->sa, sa->sa_len); FREE(sa, M_SONAME); + stag->id = NG_NODE_ID(node); m_tag_prepend(m, &stag->tag); } diff --git a/sys/netgraph/ng_ksocket.h b/sys/netgraph/ng_ksocket.h index 3eaa0f9..953486f 100644 --- a/sys/netgraph/ng_ksocket.h +++ b/sys/netgraph/ng_ksocket.h @@ -100,6 +100,7 @@ enum { /* Structure for sockaddr tag */ struct sa_tag { struct m_tag tag; + ng_ID_t id; struct sockaddr sa; }; |