diff options
author | Gleb Smirnoff <glebius@FreeBSD.org> | 2005-02-12 14:54:19 +0000 |
---|---|---|
committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2005-02-12 14:54:19 +0000 |
commit | b07785ef50b7e2d51bef0f0dd002550f7c0111d5 (patch) | |
tree | 94e87c9322455be2391a1d57f1f3099858041e79 /sys/netgraph | |
parent | 47b4ab9c8518b2e1eda943ce6a0e4a6cb806dfc1 (diff) | |
download | src-b07785ef50b7e2d51bef0f0dd002550f7c0111d5.tar.gz src-b07785ef50b7e2d51bef0f0dd002550f7c0111d5.zip |
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
Notes
Notes:
svn path=/head/; revision=141728
Diffstat (limited to 'sys/netgraph')
-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 7f2a654b7c10..023d7ccbe513 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 3eaa0f97fe7b..953486f09864 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; }; |