mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-15 10:17:20 +00:00
Make ng_source to work with non-ethernet interfaces. We do this by
introducing a START_NOW command. This command does not send and GET_IFINDEX message downstream (to wait for the response from the ETHERNET node), but directly starts the sending process. This allows one to generate traffic as input for any hook on any node.
This commit is contained in:
parent
2cafef3ea4
commit
f5d15522f7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125033
@ -189,6 +189,13 @@ static const struct ng_cmdlist ng_source_cmds[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
NGM_SOURCE_COOKIE,
|
||||||
|
NGM_SOURCE_START_NOW,
|
||||||
|
"start_now",
|
||||||
|
&ng_parse_uint64_type,
|
||||||
|
NULL
|
||||||
|
},
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -317,6 +324,30 @@ ng_source_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
|||||||
ng_source_start(sc);
|
ng_source_start(sc);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case NGM_SOURCE_START_NOW:
|
||||||
|
{
|
||||||
|
u_int64_t packets = *(u_int64_t *)msg->data;
|
||||||
|
if (sc->output.hook == NULL) {
|
||||||
|
printf("%s: start on node with no output hook\n"
|
||||||
|
, __FUNCTION__);
|
||||||
|
error = EINVAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (sc->node->nd_flags & NG_SOURCE_ACTIVE) {
|
||||||
|
error = EBUSY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* TODO validation of packets */
|
||||||
|
sc->packets = packets;
|
||||||
|
sc->output_ifp = NULL;
|
||||||
|
|
||||||
|
sc->node->nd_flags |= NG_SOURCE_ACTIVE;
|
||||||
|
timevalclear(&sc->stats.elapsedTime);
|
||||||
|
timevalclear(&sc->stats.endTime);
|
||||||
|
getmicrotime(&sc->stats.startTime);
|
||||||
|
sc->intr_ch = timeout(ng_source_intr, sc, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case NGM_SOURCE_STOP:
|
case NGM_SOURCE_STOP:
|
||||||
ng_source_stop(sc);
|
ng_source_stop(sc);
|
||||||
break;
|
break;
|
||||||
@ -600,8 +631,12 @@ ng_source_intr (void *arg)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifq = &sc->output_ifp->if_snd;
|
if (sc->output_ifp != NULL) {
|
||||||
packets = ifq->ifq_maxlen - ifq->ifq_len;
|
ifq = &sc->output_ifp->if_snd;
|
||||||
|
packets = ifq->ifq_maxlen - ifq->ifq_len;
|
||||||
|
} else
|
||||||
|
packets = sc->snd_queue.ifq_len;
|
||||||
|
|
||||||
ng_source_send(sc, packets, NULL);
|
ng_source_send(sc, packets, NULL);
|
||||||
if (sc->packets == 0) {
|
if (sc->packets == 0) {
|
||||||
int s = splnet();
|
int s = splnet();
|
||||||
|
Loading…
Reference in New Issue
Block a user