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
This commit is contained in:
parent
47b4ab9c85
commit
b07785ef50
@ -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);
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,7 @@ enum {
|
||||
/* Structure for sockaddr tag */
|
||||
struct sa_tag {
|
||||
struct m_tag tag;
|
||||
ng_ID_t id;
|
||||
struct sockaddr sa;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user