Commit 55cd34af authored by 's avatar
Browse files

bpf_compiler: Fixed bug in DAG always_match code, dagdsm_bpf_xprintf

extended to return the string error message.         
                                                     
Fixed serious bug in dagdsm_build_bpffilter appearing for non-trivial
combinations of BPF_FILTER.

Fixed DAG DSM hardware available filter count from 8 to 7. 


git-svn-id: file:///home/svn/mapi/trunk@1312 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent c557ce8d
......@@ -31,7 +31,8 @@ disable_dsm_xml_remove=0
# Note that VLAN ID is 12 bit number, MPLS LABEL is 20 bit wide.
#
# Please note that currently this really applies only to hardware based
# BPF_FILTER function, not the stdflib one that may follow, which is
# considerable flaw.
# BPF_FILTER function. The stdflib's one (that may follow in the flow)
# must contain VLAN/MPLS constructs in the BPF expression and the underlying
# pcap library also must support these.
#ethernet_vlan_frames=
#ethernet_mpls_frames=
......@@ -5,7 +5,7 @@ bpf2dagdsm \- convert the set of BPF expressions to Endace DSM filter XML specif
.ad l
.hy 0
.HP 10
\fBbpf2dagdsm\fR [\fI--max-filters=<number>\fR] [\fI--always-match\fR] <bpf_expressions_file >config.xml
\fBbpf2dagdsm\fR --num-ports=<num-ports> [\fI--max-filters=<number>\fR] [\fI--always-match\fR] <bpf_expressions_file >config.xml
.ad
.hy
......@@ -54,6 +54,12 @@ to pass all packets matching at least one hardware filter to DAG stream 0
.SH "OPTIONS"
.TP
\fB--num-ports=<num-ports>\fR
The number of DAG card ports (interfaces), must be greater than zero.
The XML interface element is generated for each interface. See
\fB--always-match\fR below for how the number is used.
.TP
\fB--max-filters=<number>\fR
When the caller knows the number of hardware filters supported by the DAG card
......@@ -69,8 +75,7 @@ detection of such error and skipping the bogus call of \fIdsm_loader\fR.
.TP
\fB--always-match\fR
This options merely adds one final OR-ed condition to the partials hardware
lookup table: the negation of the first defined filter.
This options merely adds one OR'ed partial element for each existing interface.
As result, all packets (even those not matching the previous filters) are
also accepted (not filtered out by the DAG card). The triggered filters can
......
......@@ -32,8 +32,8 @@ have where to fallback.
For IPF filtering, the DAG version 4.3GE (with coprocessor) is currently
supported. DSM filtering is enabled for all DAG cards claiming DSM support
(e.g. DAG 6.2). The number of hardware filters is hardwired to 8. For more
information on DSM, see the
(e.g. DAG 6.2). The number of hardware filters is hardwired to 8, but one is
reserved as the hot-swap filter. For more information on DSM, see the
.BR bpf2dagdsm (1)
manpage from this package or Endace documentation.
......@@ -181,7 +181,7 @@ Type of results: 2 * \fBunsigned long long\fP.
Data Stream Management (DSM) is a hardware filtering/classification feature
provided by certain models of DAG capturing cards made by Endace. The DSM
module provides 8 independent bitmasking filters; they match first 64 bytes
module provides 7 independent bitmasking filters; they match first 64 bytes
of captured network frames in parallel. Every filter yields the boolean
value that can be further processed by the hardware lookup table forming
trivial or complex logical expressions.
......@@ -215,7 +215,7 @@ software. Interesting means that at least one active MAPI flow expressed the
interest. This requires special handling:
Case one: The sum of all successfully initialized dagflib \fBBPF_FILTER\fR
functions in all flows fit to 8 hardware filters as well as no flow
functions in all flows fit to 7 hardware filters as well as no flow
begins with a function requiring \fIentire\fR traffic. Then the DAG
capturing card is in the \fIfiltering\fR mode, providing only packets
matching any of the \fBBPF_FILTER\fR's \fIexpression\fR. Every function then
......
......@@ -64,18 +64,21 @@ void fatal(const char *fmt, ...)
void usage(char *progname)
{
fprintf(stderr, "Usage: %s [--max-filters=<number>] [--always-match]\n", progname);
fprintf(stderr, "Usage: %s --num-ports=<num-ports> [--max-filters=<number>] [--always-match]\n", progname);
exit(100);
}
void parse_args(int argc, char **argv, int *max_filters, int *always_match)
void parse_args(int argc, char **argv, int *max_filters, int *always_match, int *num_ports)
{
int i;
*always_match = 0;
*max_filters = INT_MAX;
*num_ports = 0;
for (i=1; i<argc; i++) {
if (!strncmp("--max-filters=", argv[i], 14)) {
if (!strncmp("--num-ports=", argv[i], 12)) {
*num_ports = atoi(argv[i] + 12);
} else if (!strncmp("--max-filters=", argv[i], 14)) {
*max_filters = atoi(argv[i] + 14);
if (*max_filters < 1)
usage(argv[0]);
......@@ -86,15 +89,17 @@ void parse_args(int argc, char **argv, int *max_filters, int *always_match)
} else
fatal("%s: Unknown or misformatted parameter '%s'. Use --help for help.\n", argv[0], argv[i]);
}
if (*num_ports <= 0)
usage(argv[0]);
}
int main(int argc, char **argv)
{
char errbuf[BPF_ERRBUF_SIZE], inbuf[4096], *output;
int lineno = 0, max_filters, always_match, filter_count;
int lineno = 0, max_filters, always_match, filter_count, num_ports;
dagdsm_bpf_filter_t *filter = NULL;
parse_args(argc, argv, &max_filters, &always_match);
parse_args(argc, argv, &max_filters, &always_match, &num_ports);
while (fgets(inbuf, sizeof(inbuf), stdin)) {
char *p = strchr(inbuf, '\n');
......@@ -120,13 +125,17 @@ int main(int argc, char **argv)
fatal("%s: The number of filters needed (%d) exceeds the given limit (%d).\n", argv[0], filter_count, max_filters);
/* Write the filter to DAGDSM configuration output file. */
output = dagdsm_bpf_xprintf(filter, always_match, BALANCE_NONE);
output = dagdsm_bpf_xprintf(filter, always_match, num_ports, BALANCE_NONE, errbuf);
/* Free resources allocated for the filter. */
if (filter != NULL)
dagdsm_bpf_free(filter);
printf(output);
if (output)
printf(output);
else
fatal("%s: Compilation error on input line %d: %s\n", argv[0], lineno, errbuf);
free(output);
return EXIT_SUCCESS;
......
......@@ -312,7 +312,7 @@ dagdsm_bpf_filter_t *dagdsm_bpf_compile(dagdsm_bpf_filter_t *bpf_filter, char *b
int filter_cnt;
if (buf == NULL) {
BPF_DEBUG_CMD(fprintf(stderr, "dagdsm_bpf_compile: BPF expression is NULL.\n"));
strcpy(errbuf, "dagdsm_bpf_compile: BPF expression is NULL.\n");
return NULL;
}
......@@ -394,29 +394,36 @@ void dagdsm_set_vlan_mpls(int _vlan_enable_id, int _mpls_enable_label)
mpls_enable_label = _mpls_enable_label;
}
/*
* Write filter to buffer, the buffer must be freed afterwards!
*/
char *dagdsm_bpf_xprintf(dagdsm_bpf_filter_t *bpf_filter, int always_match, bal_t load_balancing)
char *dagdsm_bpf_xprintf(dagdsm_bpf_filter_t *bpf_filter, int always_match,
int num_dag_interfaces, bal_t load_balancing, char *errbuf)
{
dstring_t s;
char *retval, *ethelem;
int f, ff, r, first_cnt, cnt = 0;
if (bpf_filter == NULL) {
BPF_DEBUG_CMD(fprintf(stderr, "dagdsm_bpf_xprintf: NULL argument.\n"));
strcpy(errbuf, "dagdsm_bpf_xprintf: NULL argument.");
return NULL;
}
if (((vlan_enable_id != -2) && (mpls_enable_label != -2))
|| (vlan_enable_id < -2) || (vlan_enable_id > 4095)
|| (mpls_enable_label < -2) || (mpls_enable_label > 1048575)) {
BPF_DEBUG_CMD(fprintf(stderr, "dagdsm_bpf_xprintf: Indalid values"
" of vlan_enable_id/mpls_enable_label or both enabled.\n"));
strcpy(errbuf, "dagdsm_bpf_xprintf: Indalid values of vlan_enable_id/mpls_enable_label or both enabled.");
return NULL;
}
if (num_dag_interfaces < 0)
num_dag_interfaces = 0;
if ((load_balancing == BALANCE_INTERFACE) && (num_dag_interfaces < 2)) {
strcpy(errbuf, "Interface balancing is possible only on cards having at least 2 interfaces.");
return NULL;
}
ethelem = (vlan_enable_id != -2) ? "ethernet-vlan" :
(mpls_enable_label != -2) ? "ethernet-mpls" : "ethernet";
......@@ -462,6 +469,13 @@ char *dagdsm_bpf_xprintf(dagdsm_bpf_filter_t *bpf_filter, int always_match, bal_
dsprintf(&s, "\t\n bpf-expression:%s\n -->\n\n", bpf_filter->filters[f]->bpf);
}
for (f=0; f<num_dag_interfaces; f++) {
dsprintf(&s, " <interface>\n"
" <name>iface%d</name>\n"
" <number>%d</number>\n"
" </interface>\n", f, f);
}
dsprintf(&s, " <partial>\n"
" <name>all-filters</name>\n");
for (f=0; f < cnt; f++) {
......@@ -469,11 +483,9 @@ char *dagdsm_bpf_xprintf(dagdsm_bpf_filter_t *bpf_filter, int always_match, bal_
}
if (always_match) {
if (cnt == 0) {
printf("bpfcompiler: Specified always-match feature, but there are no filters to bypass!\n");
} else {
dsprintf(&s, " <partial-component invert=\"true\">filter0</partial-component>"
" <!-- This component ensures all packets are accepted to the stream (classification only mode). -->\n");
dsprintf(&s, " <!-- The following interface components ensure that all packets are accepted to the stream (classification only mode). -->\n");
for (f=0; f<num_dag_interfaces; f++) {
dsprintf(&s, " <partial-component>iface%d</partial-component>\n", f);
}
}
......@@ -510,15 +522,7 @@ char *dagdsm_bpf_xprintf(dagdsm_bpf_filter_t *bpf_filter, int always_match, bal_
} else { /* BALANCE_INTERFACE */
dsprintf(&s, " <interface>\n"
" <name>iface0</name>\n"
" <number>0</number>\n"
" </interface>\n"
" <interface>\n"
" <name>iface1</name>\n"
" <number>1</number>\n"
" </interface>\n"
" <partial>\n"
dsprintf(&s, " <partial>\n"
" <name>partial-iface0</name>\n"
" <partial-component>iface0</partial-component>\n"
" </partial>\n"
......
......@@ -67,7 +67,8 @@ void dagdsm_set_vlan_mpls(int vlan_enable_id, int mpls_enable_label);
* Write filter to the text format
*/
char *combo6_bpf_xprintf(combo6_bpf_filter_t *filter);
char *dagdsm_bpf_xprintf(dagdsm_bpf_filter_t *filter, int always_match, bal_t load_balancing);
char *dagdsm_bpf_xprintf(dagdsm_bpf_filter_t *bpf_filter, int always_match,
int num_dag_interfaces, bal_t load_balancing, char *errbuf);
/*
* Other functions
......
......@@ -94,7 +94,7 @@ void test_combo6(char *bpf)
free(buf);
}
void test_dagdsm(char *bpf, int always_match)
void test_dagdsm(char *bpf, int always_match, int num_ports)
{
dagdsm_bpf_filter_t *filter;
char *output, errbuf[BPF_ERRBUF_SIZE];
......@@ -108,13 +108,16 @@ void test_dagdsm(char *bpf, int always_match)
fprintf(stderr, "DAG DSM filter:\n");
/* Translate filter to DAGDSM configuration. */
output = dagdsm_bpf_xprintf(filter, always_match, BALANCE_NONE);
output = dagdsm_bpf_xprintf(filter, always_match, num_ports, BALANCE_NONE, errbuf);
/* Free resources allocated for the filter */
dagdsm_bpf_free(filter);
/* Print the output XML. */
printf(output);
if (output)
printf(output);
else
fprintf(stderr, "Error: %s\n", errbuf);
free(output);
}
......@@ -122,8 +125,9 @@ int main(int argc, char *argv[])
{
if (argc < 3) {
fprintf(stderr, "Usage:\n"
"\t%s combo6 \"BPF\"\n"
"\t%s dagdsm [--always-match] [--vlan-id=-1..4095] [--mpls-label=-1..1048575] \"BPF\"\n",
"\t%s combo6 \"BPF EXPRESSION\"\n"
"\t%s dagdsm --num-ports=<num-ports> [--always-match] [--vlan-id=-1..4095] [--mpls-label=-1..1048575] \"BPF EXPRESSION\"\n"
"WARNING: Option order is important!\n",
argv[0], argv[0]);
return 100;
}
......@@ -133,7 +137,16 @@ int main(int argc, char *argv[])
test_combo6(argv[2]);
} else if (!strcmp(argv[1], "dagdsm")) {
int bpf_idx = 2, always_match, vlan_id = -2, mpls_label = -2;
int bpf_idx = 2, always_match, num_ports = 0, vlan_id = -2, mpls_label = -2;
if (!strncmp(argv[bpf_idx], "--num-ports=", 12)) {
num_ports = atoi(argv[bpf_idx] + 12);
bpf_idx++;
}
if (num_ports <= 0) {
fprintf(stderr, "Must specify the number of DAG ports (interfaces) greater that zero.\n");
exit(1);
}
always_match = !strcmp(argv[bpf_idx], "--always-match");
if (always_match) bpf_idx++;
......@@ -152,7 +165,7 @@ int main(int argc, char *argv[])
dagdsm_set_vlan_mpls(vlan_id, mpls_label);
test_dagdsm(argv[bpf_idx], always_match);
test_dagdsm(argv[bpf_idx], always_match, num_ports);
} else {
fprintf(stderr, "%s: Select the mode of operation.\n", argv[0]);
......
......@@ -58,7 +58,7 @@ typedef struct dag_instance {
} dag_instance_t;
#ifdef PRECLASSIFICATION
int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, dag_instance_t *dag_instance);
int dagdsm_build_bpffilter(int check_for_flow_fd, char *new_filter_string, dag_instance_t *dag_instance);
#endif
#define DAGSTR "dag"
......@@ -110,7 +110,7 @@ mapidrv_apply_function (int devid,int fd, int flags, char* function, mapiFunctAr
rc_err = MFUNCT_COULD_NOT_APPLY_FUNCT;
}
if (!rc_err && (0 != dagdsm_build_bpffilter(TRUE, filter_string, i)))
if (!rc_err && (0 != dagdsm_build_bpffilter(fd, filter_string, i)))
rc_err = MFUNCT_COULD_NOT_APPLY_FUNCT;
if (rc_err) {
......@@ -657,8 +657,7 @@ mapidrv_create_flow (int devid, int fd, char **devtype)
di->is_dsm_filtering = dagdsm_is_dsm_supported(i->dagfd);
switch (di->is_dsm_filtering) {
case 1:
/* It seems that there are 8 hw filters for all DSM DAGs. */
di->dsm_filter_count = 8;
di->dsm_filter_count = DSM_FILTER_COUNT;
DEBUG_CMD(Debug_Message("DAG: Data Stream Management (DSM) supported for BPF_FILTER functions"));
if ((di->dsm_config = dagdsm_create_configuration(i->dagfd)) != NULL) {
......@@ -713,7 +712,7 @@ mapidrv_connect (int devid,int fd)
{
dag_adapterinfo_t *di = i->hwinfo.adapterinfo;
if (di->is_dsm_filtering)
dagdsm_build_bpffilter(FALSE, NULL, i); /* build the preclassification scheme */
dagdsm_build_bpffilter(0, NULL, i); /* build the preclassification scheme */
}
#endif
......@@ -766,7 +765,7 @@ mapidrv_close_flow (int devid,int fd)
{
dag_adapterinfo_t *di = i->hwinfo.adapterinfo;
if (di->is_dsm_filtering)
dagdsm_build_bpffilter(FALSE, NULL, i); /* rebuild the preclassification scheme */
dagdsm_build_bpffilter(0, NULL, i); /* rebuild the preclassification scheme */
}
#endif
......@@ -825,19 +824,18 @@ void relocate_dsm_counters(u_int32_t oldmask, u_int32_t newmask, dag_adapterinfo
* hardware should be either in the Filter or in the Preclassification mode
* (always_match variable).
* 2) Compiles and builds the DSM filter for all dagflib:BPF_FILTER instances.
* 3) When check_only is FALSE, the masks are assigned to functions and
* subprocess dsm_loader is called to activate the filter.
* When check_only is TRUE, the read-only run is conducted & the new
* 3) When check_for_flow_fd == 0, the subprocess dsm_loader is called to
* activate the filter.
* When check_for_flow_fd != 0, the read-only run is conducted & the new
* dagflib:BPF_FILTER instance's fitness is detected and returned.
*/
int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, dag_instance_t *dag_instance)
int dagdsm_build_bpffilter(int check_for_flow_fd, char *new_filter_string, dag_instance_t *dag_instance)
{
int index = 1, rc_err = 0, filter_count;
char errbuf[BPF_ERRBUF_SIZE];
flist_node_t *flow, *fnode;
flist_t *functions;
dag_adapterinfo_t *di = dag_instance->hwinfo.adapterinfo;
mapidflib_function_instance_t *funct;
dagdsm_bpf_filter_t *filter = NULL; /* compiled filter */
/* Whether there is any leading flow function that wants to accept all captured
......@@ -856,26 +854,29 @@ int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, dag_in
if (NULL != (functions=((mapid_flow_info_t *)flist_data(flow))->flist)) {
u_int32_t preclassification_mask = 0;
for(fnode=flist_head(functions); fnode; fnode=flist_next(fnode)) {
funct=((mapidflib_function_t *)flist_data(fnode))->instance;
boolean_t filter_in_flow = FALSE;
for (fnode=flist_head(functions); fnode; fnode=flist_next(fnode)) {
mapidflib_function_t *flibf = flist_data(fnode);
mapidflib_function_instance_t *funct=flibf->instance;
if (strcmp(funct->def->devtype, MAPI_DEVICE_DAG)) {
if (preclassification_mask == 0) { /* only before dagflib:BPF_FILTER */
always_match = TRUE; /* found a non-DAG function, turn off hw filter */
if (!check_only) {
if (!check_for_flow_fd && !always_match) {
DEBUG_CMD(Debug_Message("DAG DSM: Hardware filter turned into a classifier, because non-DAG leading function '%s' found",funct->def->name));
}
always_match = TRUE; /* found a non-DAG function, turn off hw filter */
}
} else {
//printf("\tFOUND DAGFUNC %s fid=%d %p mask %x\n",
// funct->def->name, flibf->fid, funct, funct->preclassification_mask);
if (!strcmp(funct->def->name, "BPF_FILTER")) { /* function using preclassification */
mapiFunctArg *fargs=funct->args;
char *bpf_filter_string = getargstr(&fargs); /* get the string BPF expr */
if (preclassification_mask != 0) { /* multiple dagflib:BPF_FILTER in one flow */
rc_err = MFUNCT_COULD_NOT_APPLY_FUNCT;
break;
}
filter_in_flow = TRUE;
if ((filter = dagdsm_bpf_compile(filter, bpf_filter_string, index++, errbuf)) == NULL) {
DEBUG_CMD(Debug_Message("ERROR: dagdsm_build_bpffilter: Strange! Compilation error in previous BPF expression '%s': %s",
......@@ -887,14 +888,17 @@ int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, dag_in
/* We determine, what DAG hardware filters were used by the last
* compiled expression. */
preclassification_mask = 0x80000000 | dagdsm_bpf_get_last_usage_mask(filter);
if (!check_only) {
if (!check_for_flow_fd) {
DEBUG_CMD(Debug_Message("Initializing function %s\tfid=%d, mask=0x%02x", \
funct->def->name, flibf->fid, preclassification_mask & ~0x80000000));
/* When we are recomputing already existing preclassification
* scheme and the hardware filter occupation mask have changed,
* we also have to relocate global DSM counters for the case
* some BPF_FILTER function from preceding flow was unapplied.
*/
if ((funct->preclassification_mask & 0x80000000)
if ((funct->preclassification_mask & 0x80000000)
&& (funct->preclassification_mask != preclassification_mask))
relocate_dsm_counters(funct->preclassification_mask & ~0x80000000,
preclassification_mask & ~0x80000000,
......@@ -902,6 +906,16 @@ int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, dag_in
}
}
/* Unallowed multiple dagflib:BPF_FILTER in one flow -- we did not
* implement AND'ing of hardware filters for two successive
* BPF_FILTERs.
*/
if ((check_for_flow_fd == flist_id(flow)) && filter_in_flow) {
DEBUG_CMD(Debug_Message("NOTICE: dagdsm_build_bpffilter: Refusing multiple dagflib:BPF_FILTER in one flow."));
rc_err = MFUNCT_COULD_NOT_APPLY_FUNCT;
break;
}
/* Hardware filtering does not interfere with these functions:
* DAG *_COUNTER functions suck data from the hardware directly,
* DAG INTERFACE function just restricts packets more.
......@@ -911,25 +925,22 @@ int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, dag_in
&& strcmp(funct->def->name, "PKTBYTE_COUNTER")
&& strcmp(funct->def->name, "INTERFACE")) {
if (preclassification_mask == 0) { /* only before dagflib:BPF_FILTER */
always_match = TRUE;
if (!check_only) {
if (!check_for_flow_fd && !always_match) {
DEBUG_CMD(Debug_Message("DAG DSM: Hardware filter turned into a classifier, because sensitive DAG leading function '%s' found",
funct->def->name));
}
always_match = TRUE;
}
}
if (!check_only) {
/* In the init phase we assign the dagflib:BPF_FILTER's mask
* to this function and all the following DAG ones. */
funct->preclassification_mask = preclassification_mask;
}
}
/* Not mandatory, but it's good to save the hardware filters as
* we don't have many of them.
*/
if (always_match)
break; /* check the next flow */
//printf("\tSETTING MASK FOR FUNC %s %p: %x <- %x\n",
// funct->def->name, funct, funct->preclassification_mask, preclassification_mask);
/* We assign the dagflib:BPF_FILTER's mask
* to this function and all the following DAG ones.
*/
funct->preclassification_mask = preclassification_mask;
}
}
}
}
......@@ -950,7 +961,7 @@ int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, dag_in
rc_err = MFUNCT_COULD_NOT_APPLY_FUNCT; /* too many hardware filters */
}
if (!rc_err && !check_only) {
if (!rc_err && !check_for_flow_fd) {
if (filter_count > 0) {
bal_t baltype = BALANCE_NONE;
char *reason = "unknown", *binpath = NULL, *xml_filter;
......@@ -982,7 +993,7 @@ int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, dag_in
DEBUG_CMD(Debug_Message("ERROR: dagdsm_build_bpffilter: Unknown setting of dsm_load_balancing, defaulting to 'none'"));
} else baltypestr = NULL;
if (baltypestr) {
DEBUG_CMD(fprintf(stderr, "dagdsm_build_bpffilter: Setting load balancing by %s.\n", baltypestr));
DEBUG_CMD(Debug_Message("dagdsm_build_bpffilter: Setting load balancing by %s.\n", baltypestr));
}
}
......@@ -1002,7 +1013,7 @@ int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, dag_in
dagdsm_set_vlan_mpls(vlan_enable_id, mpls_enable_label);
if ((xml_filter = dagdsm_bpf_xprintf(filter, always_match, baltype)) != NULL) {
if ((xml_filter = dagdsm_bpf_xprintf(filter, always_match, di->portcnt, baltype, errbuf)) != NULL) {
int tmpfd;
if ((tmpfd = mkstemp(tmpfn)) != -1) {
......@@ -1031,7 +1042,7 @@ int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, dag_in
unlink(tmpfn);
} else reason = "could not create a temporary file in /tmp";
free(xml_filter);
} else reason = "problem generating the XML filter";
} else reason = errbuf;
} else reason = "missing or invalid path dsm_loader_bin (category [dag]) in the configuration file";
pc_close();
} else reason = "problem opening the mapid configuration file";
......@@ -1043,8 +1054,8 @@ int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, dag_in
}
} else { /* filter_count <= 0 */
DEBUG_CMD(Debug_Message("dagdsm_build_bpffilter: No hardware filters requested, bypassing the DSM"));
dagdsm_bypass_dsm (di->dagfd, 1);
DEBUG_CMD(Debug_Message("dagdsm_build_bpffilter: No hardware filters requested, bypassing the DSM (rc=%d)",
dagdsm_bypass_dsm (di->dagfd, 1)));
}
}
......@@ -1054,6 +1065,8 @@ int dagdsm_build_bpffilter(boolean_t check_only, char *new_filter_string, dag_in
return rc_err;
}
#endif /* PRECLASSIFICATION */
int
mapidrv_stats (int devid, char **devtype, struct mapi_stat *stats)
{
......@@ -1071,7 +1084,3 @@ mapidrv_stats (int devid, char **devtype, struct mapi_stat *stats)
return MAPI_STATS_ERROR;
}
#endif
......@@ -3,6 +3,9 @@
typedef unsigned long long dag_counter_t; /* Main data type for counters. */
#define DSM_FILTER_COUNT 7 /* DSM DAG have 8 filters minus one swap filter */
typedef struct dag_adapterinfo {
char *name; /* /dev/dag0 */
int dagfd, dagstream;
......@@ -14,14 +17,14 @@ typedef struct dag_adapterinfo {
int portcnt; /* number of ports on the card */
int is_dsm_filtering; /* DSM filtering available */
int dsm_filter_count; /* Number of DSM hardware filters (usually 8) */
int dsm_filter_count; /* Number of DSM hardware filters */
DsmConfigH dsm_config; /* handle to DAG DSM configuration */
/* allocated array of counters for ports and kinds (bytes, packets) */
dag_counter_t *port_counters;
/* array for hardware DSM filter counters */
dag_counter_t dsm_counters[8];
dag_counter_t dsm_counters[DSM_FILTER_COUNT];
} dag_adapterinfo_t;
#endif /*MAPIDAGDRV_H_*/
......@@ -154,6 +154,26 @@ cat > "$FOUT_E1" <<__EOF__
bpf-expression:((src host 1.1.1.1 || tcp dst port 80) || (dst host 4.4.4.4)) && ((dst host 2.2.2.2) && (tcp dst port 80))
-->
<interface>
<name>iface0</name>
<number>0</number>
</interface>
<interface>
<name>iface1</name>
<number>1</number>
</interface>
<interface>
<name>iface2</name>
<number>2</number>
</interface>
<interface>
<name>iface3</name>
<number>3</number>
</interface>
<interface>
<name>iface4</name>
<number>4</number>
</interface>
<partial>
<name>all-filters</name>
<partial-component>filter0</partial-component>
......@@ -291,6 +311,26 @@ cat > "$FOUT_E2" <<__EOF__
bpf-expression:((src host 1.1.1.1 || tcp dst port 80) || (dst host 4.4.4.4)) && ((dst host 2.2.2.2) && (tcp dst port 80))
-->
<interface>
<name>iface0</name>
<number>0</number>
</interface>
<interface>
<name>iface1</name>
<number>1</number>
</interface>
<interface>
<name>iface2</name>
<number>2</number>
</interface>
<interface>