Support adding value of mark to priority field, so that classifying packets to HTBs...
authorAndy Bavier <acb@cs.princeton.edu>
Fri, 25 Jul 2008 18:35:40 +0000 (18:35 +0000)
committerAndy Bavier <acb@cs.princeton.edu>
Fri, 25 Jul 2008 18:35:40 +0000 (18:35 +0000)
extensions/libipt_CLASSIFY.c
include/linux/netfilter_ipv4/ipt_CLASSIFY.h

index 07c9b25..bcedaa4 100644 (file)
@@ -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 = { 
index 7596e3d..eab9bda 100644 (file)
@@ -3,6 +3,7 @@
 
 struct ipt_classify_target_info {
        u_int32_t priority;
+       u_int8_t add_mark;
 };
 
 #endif /*_IPT_CLASSIFY_H */