@@ -287,8 +287,8 @@ iptables_fw_init(void)
287
287
iptables_do_command ("-t mangle -I POSTROUTING 1 -o %s -j " CHAIN_INCOMING , config -> gw_interface );
288
288
289
289
for (p = config -> trustedmaclist ; p != NULL ; p = p -> next )
290
- iptables_do_command ("-t mangle -A " CHAIN_TRUSTED " -m mac --mac-source %s -j MARK --set-mark %d " , p -> mac ,
291
- FW_MARK_KNOWN );
290
+ iptables_do_command ("-t mangle -A " CHAIN_TRUSTED " -m mac --mac-source %s -j MARK --set-mark 0x%x " , p -> mac ,
291
+ FW_MARK_KNOWN << config -> markoffsetbits );
292
292
293
293
/*
294
294
*
@@ -317,22 +317,32 @@ iptables_fw_init(void)
317
317
if ((proxy_port = config_get_config ()-> proxy_port ) != 0 ) {
318
318
debug (LOG_DEBUG , "Proxy port set, setting proxy rule" );
319
319
iptables_do_command ("-t nat -A " CHAIN_TO_INTERNET
320
- " -p tcp --dport 80 -m mark --mark 0x%u -j REDIRECT --to-port %u" , FW_MARK_KNOWN ,
320
+ " -p tcp --dport 80 -m mark --mark 0x%x/0x%x -j REDIRECT --to-port %u" ,
321
+ FW_MARK_KNOWN << config -> markoffsetbits ,
322
+ FW_MARK_KNOWN << config -> markoffsetbits ,
321
323
proxy_port );
322
324
iptables_do_command ("-t nat -A " CHAIN_TO_INTERNET
323
- " -p tcp --dport 80 -m mark --mark 0x%u -j REDIRECT --to-port %u" , FW_MARK_PROBATION ,
325
+ " -p tcp --dport 80 -m mark --mark 0x%x/0x%x -j REDIRECT --to-port %u" ,
326
+ FW_MARK_PROBATION << config -> markoffsetbits ,
327
+ FW_MARK_PROBATION << config -> markoffsetbits ,
324
328
proxy_port );
325
329
}
326
330
327
- iptables_do_command ("-t nat -A " CHAIN_TO_INTERNET " -m mark --mark 0x%u -j ACCEPT" , FW_MARK_KNOWN );
328
- iptables_do_command ("-t nat -A " CHAIN_TO_INTERNET " -m mark --mark 0x%u -j ACCEPT" , FW_MARK_PROBATION );
331
+ iptables_do_command ("-t nat -A " CHAIN_TO_INTERNET " -m mark --mark 0x%x/0x%x -j ACCEPT" ,
332
+ FW_MARK_KNOWN << config -> markoffsetbits ,
333
+ FW_MARK_KNOWN << config -> markoffsetbits );
334
+ iptables_do_command ("-t nat -A " CHAIN_TO_INTERNET " -m mark --mark 0x%x/0x%x -j ACCEPT" ,
335
+ FW_MARK_PROBATION << config -> markoffsetbits ,
336
+ FW_MARK_PROBATION << config -> markoffsetbits );
329
337
iptables_do_command ("-t nat -A " CHAIN_TO_INTERNET " -j " CHAIN_UNKNOWN );
330
338
331
339
iptables_do_command ("-t nat -A " CHAIN_UNKNOWN " -j " CHAIN_AUTHSERVERS );
332
340
iptables_do_command ("-t nat -A " CHAIN_UNKNOWN " -j " CHAIN_GLOBAL );
333
341
if (got_authdown_ruleset ) {
334
342
iptables_do_command ("-t nat -A " CHAIN_UNKNOWN " -j " CHAIN_AUTH_IS_DOWN );
335
- iptables_do_command ("-t nat -A " CHAIN_AUTH_IS_DOWN " -m mark --mark 0x%u -j ACCEPT" , FW_MARK_AUTH_IS_DOWN );
343
+ iptables_do_command ("-t nat -A " CHAIN_AUTH_IS_DOWN " -m mark --mark 0x%x/0x%x -j ACCEPT" ,
344
+ FW_MARK_AUTH_IS_DOWN << config -> markoffsetbits ,
345
+ FW_MARK_AUTH_IS_DOWN << config -> markoffsetbits );
336
346
}
337
347
iptables_do_command ("-t nat -A " CHAIN_UNKNOWN " -p tcp --dport 80 -j REDIRECT --to-ports %d" , gw_port );
338
348
@@ -374,22 +384,29 @@ iptables_fw_init(void)
374
384
iptables_do_command ("-t filter -A " CHAIN_TO_INTERNET " -j " CHAIN_AUTHSERVERS );
375
385
iptables_fw_set_authservers ();
376
386
377
- iptables_do_command ("-t filter -A " CHAIN_TO_INTERNET " -m mark --mark 0x%u -j " CHAIN_LOCKED , FW_MARK_LOCKED );
387
+ iptables_do_command ("-t filter -A " CHAIN_TO_INTERNET " -m mark --mark 0x%x/0x%x -j " CHAIN_LOCKED ,
388
+ FW_MARK_LOCKED << config -> markoffsetbits ,
389
+ FW_MARK_LOCKED << config -> markoffsetbits );
378
390
iptables_load_ruleset ("filter" , FWRULESET_LOCKED_USERS , CHAIN_LOCKED );
379
391
380
392
iptables_do_command ("-t filter -A " CHAIN_TO_INTERNET " -j " CHAIN_GLOBAL );
381
393
iptables_load_ruleset ("filter" , FWRULESET_GLOBAL , CHAIN_GLOBAL );
382
394
iptables_load_ruleset ("nat" , FWRULESET_GLOBAL , CHAIN_GLOBAL );
383
395
384
- iptables_do_command ("-t filter -A " CHAIN_TO_INTERNET " -m mark --mark 0x%u -j " CHAIN_VALIDATE , FW_MARK_PROBATION );
396
+ iptables_do_command ("-t filter -A " CHAIN_TO_INTERNET " -m mark --mark 0x%x/0x%x -j " CHAIN_VALIDATE ,
397
+ FW_MARK_PROBATION << config -> markoffsetbits ,
398
+ FW_MARK_PROBATION << config -> markoffsetbits );
385
399
iptables_load_ruleset ("filter" , FWRULESET_VALIDATING_USERS , CHAIN_VALIDATE );
386
400
387
- iptables_do_command ("-t filter -A " CHAIN_TO_INTERNET " -m mark --mark 0x%u -j " CHAIN_KNOWN , FW_MARK_KNOWN );
401
+ iptables_do_command ("-t filter -A " CHAIN_TO_INTERNET " -m mark --mark 0x%x/0x%x -j " CHAIN_KNOWN ,
402
+ FW_MARK_KNOWN << config -> markoffsetbits ,
403
+ FW_MARK_KNOWN << config -> markoffsetbits );
388
404
iptables_load_ruleset ("filter" , FWRULESET_KNOWN_USERS , CHAIN_KNOWN );
389
405
390
406
if (got_authdown_ruleset ) {
391
- iptables_do_command ("-t filter -A " CHAIN_TO_INTERNET " -m mark --mark 0x%u -j " CHAIN_AUTH_IS_DOWN ,
392
- FW_MARK_AUTH_IS_DOWN );
407
+ iptables_do_command ("-t filter -A " CHAIN_TO_INTERNET " -m mark --mark 0x%x/0x%x -j " CHAIN_AUTH_IS_DOWN ,
408
+ FW_MARK_AUTH_IS_DOWN << config -> markoffsetbits ,
409
+ FW_MARK_AUTH_IS_DOWN << config -> markoffsetbits );
393
410
iptables_load_ruleset ("filter" , FWRULESET_AUTH_IS_DOWN , CHAIN_AUTH_IS_DOWN );
394
411
}
395
412
@@ -554,20 +571,21 @@ iptables_fw_destroy_mention(const char *table, const char *chain, const char *me
554
571
int
555
572
iptables_fw_access (fw_access_t type , const char * ip , const char * mac , int tag )
556
573
{
574
+ const s_config * config = config_get_config ();
557
575
int rc ;
558
576
559
577
fw_quiet = 0 ;
560
578
561
579
switch (type ) {
562
580
case FW_ACCESS_ALLOW :
563
- iptables_do_command ("-t mangle -A " CHAIN_OUTGOING " -s %s -m mac --mac-source %s -j MARK --set-mark %d " , ip ,
564
- mac , tag );
581
+ iptables_do_command ("-t mangle -A " CHAIN_OUTGOING " -s %s -m mac --mac-source %s -j MARK --set-mark 0x%x " , ip ,
582
+ mac , tag << config -> markoffsetbits );
565
583
rc = iptables_do_command ("-t mangle -A " CHAIN_INCOMING " -d %s -j ACCEPT" , ip );
566
584
break ;
567
585
case FW_ACCESS_DENY :
568
586
/* XXX Add looping to really clear? */
569
- iptables_do_command ("-t mangle -D " CHAIN_OUTGOING " -s %s -m mac --mac-source %s -j MARK --set-mark %d " , ip ,
570
- mac , tag );
587
+ iptables_do_command ("-t mangle -D " CHAIN_OUTGOING " -s %s -m mac --mac-source %s -j MARK --set-mark 0x%x " , ip ,
588
+ mac , tag << config -> markoffsetbits );
571
589
rc = iptables_do_command ("-t mangle -D " CHAIN_INCOMING " -d %s -j ACCEPT" , ip );
572
590
break ;
573
591
default :
@@ -606,9 +624,11 @@ iptables_fw_access_host(fw_access_t type, const char *host)
606
624
int
607
625
iptables_fw_auth_unreachable (int tag )
608
626
{
627
+ const s_config * config = config_get_config ();
609
628
int got_authdown_ruleset = NULL == get_ruleset (FWRULESET_AUTH_IS_DOWN ) ? 0 : 1 ;
610
629
if (got_authdown_ruleset )
611
- return iptables_do_command ("-t mangle -A " CHAIN_AUTH_IS_DOWN " -j MARK --set-mark 0x%u" , tag );
630
+ return iptables_do_command ("-t mangle -A " CHAIN_AUTH_IS_DOWN " -j MARK --set-mark 0x%x" ,
631
+ tag << config -> markoffsetbits );
612
632
else
613
633
return 1 ;
614
634
}
0 commit comments