mark: the rule's connections send with a mark (#846)

mark <number> extends the allow or deny rule above it, as nolog and
weight do: a connection the rule lets through carries the mark on its
outgoing sockets, towards the destination and towards the parents, so
policy routing and firewall rules can tell its packets apart (SO_MARK
of Linux, SO_USER_COOKIE of FreeBSD; on a system with no mark the
command sets it to nothing). The UDP sockets of a session towards a
destination are marked the same, the SOCKS UDP ASSOCIATE relays among
them, for the rule that let the session through is looked up for each
destination. A mark with no rule above it, or not a number, is refused.
This commit is contained in:
Vladimir Dubrovin committed 2026-11-21 16:40:51 +03:00
1 parent eec09dc4e9
commit 51cbdb2fad
9 files changed
+127 -9

No files matched your search

+30 -9
View File
@@ -1302,15 +1302,35 @@ static int h_http(int argc, unsigned char **argv){
static int h_nolog(int argc, unsigned char **argv){
struct ace *acl = NULL;
acl = conf->acl;
if(!acl) {
fprintf(stderr, "Chaining error: last ACL entry was not \"allow/deny\" on line %d\n", linenum);
return(1);
}
while(acl->next) acl = acl->next;
if(argc == 1) acl->nolog = 1;
else acl->weight = atoi((char*)argv[1]);
return 0;
acl = conf->acl;
if(!acl) {
fprintf(stderr, "Chaining error: last ACL entry was not \"allow/deny\" on line %d\n", linenum);
return(1);
}
while(acl->next) acl = acl->next;
if(argc == 1) acl->nolog = 1;
else acl->weight = atoi((char*)argv[1]);
return 0;
}
/* mark <number>: the rule above sends with this mark, on its sockets
towards the destination and the parents, where the system has one */
static int h_mark(int argc, unsigned char **argv){
struct ace *acl = NULL;
char *end;
acl = conf->acl;
if(!acl) {
fprintf(stderr, "Chaining error: last ACL entry was not \"allow/deny\" on line %d\n", linenum);
return(1);
}
while(acl->next) acl = acl->next;
acl->mark = (int)strtol((char *)argv[1], &end, 0);
if(end == (char *)argv[1] || *end) {
fprintf(stderr, "Wrong mark, line %d\n", linenum);
return(1);
}
return 0;
}
int scanipl(unsigned char *arg, struct iplist *dst){
@@ -2177,6 +2197,7 @@ struct commands commandhandlers[]={
{NULL, "filtermaxsize", h_filtermaxsize, 2, 2},
{NULL, "nolog", h_nolog, 1, 1},
{NULL, "weight", h_nolog, 2, 2},
{NULL, "mark", h_mark, 2, 2},
{NULL, "authcache", h_authcache, 2, 4},
{NULL, "smtpp", h_proxy, 1, 0},
{NULL, "delimchar",h_delimchar, 2, 2},