From db0794b3755abf7b8c38593134d1c6fe635430b1 Mon Sep 17 00:00:00 2001 From: Andy Bavier Date: Fri, 25 Jul 2008 18:35:40 +0000 Subject: [PATCH] Support adding value of mark to priority field, so that classifying packets to HTBs works on PlanetLab --- extensions/libipt_CLASSIFY.c | 13 +++++++++++++ include/linux/netfilter_ipv4/ipt_CLASSIFY.h | 1 + 2 files changed, 14 insertions(+) diff --git a/extensions/libipt_CLASSIFY.c b/extensions/libipt_CLASSIFY.c index 07c9b25..bcedaa4 100644 --- a/extensions/libipt_CLASSIFY.c +++ b/extensions/libipt_CLASSIFY.c @@ -17,12 +17,14 @@ help(void) printf( "CLASSIFY target v%s options:\n" " --set-class [MAJOR:MINOR] Set skb->priority value\n" +" --add-mark Add value of skb->mark to skb->priority (PlanetLab specific)\n" "\n", IPTABLES_VERSION); } static struct option opts[] = { { "set-class", 1, 0, '1' }, + { "add-mark", 0, 0, '2' }, { 0 } }; @@ -53,6 +55,8 @@ parse(int c, char **argv, int invert, unsigned int *flags, struct ipt_classify_target_info *clinfo = (struct ipt_classify_target_info *)(*target)->data; + clinfo->add_mark = 0; + switch (c) { case '1': if (string_to_priority(optarg, &clinfo->priority)) @@ -64,6 +68,10 @@ parse(int c, char **argv, int invert, unsigned int *flags, *flags = 1; break; + case '2': + clinfo->add_mark = 1; + break; + default: return 0; } @@ -95,6 +103,8 @@ print(const struct ipt_ip *ip, (const struct ipt_classify_target_info *)target->data; printf("CLASSIFY set "); print_class(clinfo->priority, numeric); + if (clinfo->add_mark) + printf ("add-mark "); } /* Saves the union ipt_targinfo in parsable form to stdout. */ @@ -106,6 +116,9 @@ save(const struct ipt_ip *ip, const struct ipt_entry_target *target) printf("--set-class %.4x:%.4x ", TC_H_MAJ(clinfo->priority)>>16, TC_H_MIN(clinfo->priority)); + + if (clinfo->add_mark) + printf("--add-mark "); } static struct iptables_target classify = { diff --git a/include/linux/netfilter_ipv4/ipt_CLASSIFY.h b/include/linux/netfilter_ipv4/ipt_CLASSIFY.h index 7596e3d..eab9bda 100644 --- a/include/linux/netfilter_ipv4/ipt_CLASSIFY.h +++ b/include/linux/netfilter_ipv4/ipt_CLASSIFY.h @@ -3,6 +3,7 @@ struct ipt_classify_target_info { u_int32_t priority; + u_int8_t add_mark; }; #endif /*_IPT_CLASSIFY_H */ -- 2.47.0