Fixed a bug in the /info parser. Issue #240
Some checks failed
CIFuzz / Fuzzing (address) (push) Has been cancelled
CIFuzz / Fuzzing (memory) (push) Has been cancelled
CIFuzz / Fuzzing (undefined) (push) Has been cancelled

The protocol identifier must begin with "0x" and be specified in hexadecimal form.
This commit is contained in:
Vitaly Lavrov 2026-04-06 14:57:45 +03:00
parent 4c1a23b053
commit 624b5be593
2 changed files with 22 additions and 12 deletions

View file

@ -222,7 +222,7 @@ LEAF=sfq
modprobe xt_ndpi
# default class 1:30
echo "all 10030/ffffff" >/proc/net/xt_ndpi/proto
for i in ssh mail_pop mail_imap mail_smtp mail_pops mail_smtps mail_imaps dns; do
for i in ssh pop3 imap smtp pops smtps imaps dns; do
# high speed class 1:10
echo "$i 10010" >/proc/net/xt_ndpi/proto
done
@ -314,6 +314,10 @@ set_magic_ct: Set new MAGIC_CT value. Default: 0xa55a. Set 0 for random MAGIC_CT
"echo init >/proc/net/xt_ndpi/proto" enable all protocols and set mark by ID and mask 0xff.
The 'protoid' must be starting from '0x'.
"bfd" is protocol name.
"0xbfd" is protocol id.
Change mark/mask for protocols:
"echo '(protoid|protoname|all|any) mark[/mask]' >/proc/net/xt_ndpi/proto"

View file

@ -707,10 +707,12 @@ int parse_ndpi_proto(struct ndpi_net *n,char *cmd) {
v = cmd;
if(!*v) return 0;
/*
* hexID hexmark/mask name
* hexID debug 0..3
* hexID disable
* hexID enable
* hexID start from 0x
*
* (hexID|name) hexmark/mask name
* (hexID|name) debug 0..3
* (hexID|name) disable
* (hexID|name) enable
* add_custom name
* netns name
*/
@ -799,22 +801,26 @@ int parse_ndpi_proto(struct ndpi_net *n,char *cmd) {
if(_DBG_TRACE_SPROC)
pr_info("NDPI: add custom protocol %x\n",e_proto);
n->mark[e_proto].mark = e_proto;
n->mark[e_proto].mask = 0x1ff;
n->mark[e_proto].mask = 0x3ff;
return 0;
}
if(!any && !all) {
if(kstrtoint(hid,16,&id)) {
if(hid[0] == '0' && (hid[1] == 'x' || hid[1] == 'X')) {
if(kstrtoint(hid+2,16,&id)) {
pr_err("NDPI: bad id '%s'\n",hid);
return 1;
}
} else {
id = ndpi_get_proto_by_name(ndpi_str,hid);
if(id == NDPI_PROTOCOL_UNKNOWN &&
strcasecmp(ndpi_str->proto_defaults[id].protoName,hid)) {
pr_err("NDPI: '%s' unknown protocol or not hexID\n",hid);
return 1;
}
} else {
if(id < 0 || id >= NDPI_MAX_NUM_STATIC_BITMAP) {
pr_err("NDPI: bad id %d\n",id);
id = -1;
}
}
if(id < 0 || id >= NDPI_MAX_NUM_STATIC_BITMAP) {
pr_err("NDPI: bad id %d\n",id);
return 1;
}
}
if(!strncmp(v,"debug",5)) {