kern/63864: [patch] new control message for ng_iface(4) -
getifindex
Gleb Smirnoff
glebius at cell.sick.ru
Tue Mar 9 11:00:04 PST 2004
On Tue, Mar 09, 2004 at 08:53:56AM +0200, Ruslan Ermilov wrote:
R> On Tue, Mar 09, 2004 at 12:48:20AM +0300, Gleb Smirnoff wrote:
R> > On Mon, Mar 08, 2004 at 11:29:39PM +0200, Ruslan Ermilov wrote:
R> > R> > I have one more idea. Currently we have got 3 interface nodes: ng_ether, ng_iface,
R> > R> > ng_eiface. 2 of them already support "getifindex" message, imagine I (or someone else) send
R> > R> > you patch tomorrow, which adds support to ng_eiface. OK, now all three support. May be
R> > R> > in future some new interface nodes will be developed.
R> > R> >
R> > R> > Imagine the following: you have node, which is connected to some generic
R> > R> > interface (it doesn't know which node type exactly). This node wants to
R> > R> > determine interface index of attached interfac. It would send 3 "getifindex" messages with 3
R> > R> > different cookies. Two of messages will always fail, and one return. This is not nice.
R> > R> >
R> > R> > What I suggest: create a new semi-generic cookie NGM_GENERICIFACE_COOKIE, which will be
R> > R> > supported by all interface nodes. Put NGM_GENERICIFACE_GETIFINDEX message under
R> > R> > NGM_GENERICIFACE_COOKIE case brackets. If you like this idea, please reply me. And I'll send
R> > R> > patches.
R> > R> >
R> > R> How do you think "ngctl msg ng0: getifindex" works? ;)
R> >
R> > So, you suggest to use ASCII message in situation described above? IMHO, ASCII messages were
R> > invented for human interface purposes, not for node interaction.
R> >
R> OK, how about sending a NGM_NODEINFO message to the node, and
R> picking up XXX for (NGM_XXX_COOKIE, NGM_XXX_GET_IFNAME) based
R> on the returned type?
First, this requires some dialog-like message interchange (as well as ASCII message).
Netgraph does not provide nice API for this. I see the only way to implement:
1) send out NGM_NODEINFO message from some node method
2) catch reply in xxx_rcvmsg(), construct new message and send it
3) catch second reply in xxx_rcvmsg()
Second, this will work only with a certain number of nodes. The code of xxx_rcvmsg()
will look like:
if (msg->header.flags & NGF_RESP) {
switch (msg->header.typecookie) {
case NGM_GENERIC_COOKIE:
switch (msg->header.cmd) {
case NGM_NODEINFO:
{
struct nodeinfo *info =
(struct nodeinfo *)msg->data;
if (strcmp(info->type, NG_IFACE_NODE_TYPE, strlen(NG_IFACE_NODE_TYPE)) {
xxxxx
} else
if (strcmp(info->type, NG_ETHER_NODE_TYPE ..... {
yyyyyy
This won't be generic solution. Whenever, a new interface node is implemented (e.g. ng_atm),
our imaginary node needs a patch and ng_atm.h to be included.
My proposal brings a generic solution for any new interface node type.
--
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE
More information about the freebsd-net
mailing list