Checkign in new iproute2
[iproute2.git] / tc / em_meta.c
index bd1e151..ee6034f 100644 (file)
@@ -34,9 +34,8 @@ static void meta_print_usage(FILE *fd)
            "       META_ID := id [ shift SHIFT ] [ mask MASK ]\n" \
            "\n" \
            "Example: meta(nfmark gt 24)\n" \
-           "         meta(indev shift 1 eq \"ppp\"\n" \
+           "         meta(indev shift 1 eq \"ppp\")\n" \
            "         meta(tcindex mask 0xf0 eq 0xf0)\n" \
-           "         meta(dev eq indev)\n" \
            "\n" \
            "For a list of meta identifiers, use meta(list).\n");
 }
@@ -89,6 +88,7 @@ struct meta_entry {
                                "Routing ClassID (cls_route)"),
        __A(RTIIF,              "rt_iif",       "i",
                                "Incoming interface index"),
+       __A(VLAN_TAG,           "vlan",         "i",    "Vlan tag"),
 
        __A(SECTION,            "Sockets", "", ""),
        __A(SK_FAMILY,          "sk_family",    "i",    "Address family"),
@@ -131,7 +131,7 @@ static struct meta_entry * lookup_meta_entry(struct bstr *kind)
                if (!bstrcmp(kind, meta_table[i].kind) &&
                    meta_table[i].id != 0)
                        return &meta_table[i];
-       
+
        return NULL;
 }
 
@@ -142,7 +142,7 @@ static struct meta_entry * lookup_meta_entry_byid(int id)
        for (i = 0; i < (sizeof(meta_table)/sizeof(meta_table[0])); i++)
                if (meta_table[i].id == id)
                        return &meta_table[i];
-       
+
        return NULL;
 }
 
@@ -171,12 +171,12 @@ static inline int is_compatible(struct tcf_meta_val *what,
 {
        char *p;
        struct meta_entry *entry;
-       
+
        entry = lookup_meta_entry_byid(TCF_META_ID(what->kind));
 
        if (entry == NULL)
                return 0;
-       
+
        for (p = entry->mask; p; p++)
                if (map_type(*p) == TCF_META_TYPE(needed->kind))
                        return 1;
@@ -244,7 +244,7 @@ static inline int overwrite_type(struct tcf_meta_val *src,
 {
        return (TCF_META_TYPE(dst->kind) << 12) | TCF_META_ID(src->kind);
 }
-       
+
 
 static inline struct bstr *
 parse_object(struct bstr *args, struct bstr *arg, struct tcf_meta_val *obj,
@@ -262,7 +262,7 @@ parse_object(struct bstr *args, struct bstr *arg, struct tcf_meta_val *obj,
        }
 
        num = bstrtoul(arg);
-       if (num != LONG_MAX) {
+       if (num != ULONG_MAX) {
                obj->kind = TCF_META_TYPE_INT << 12;
                obj->kind |= TCF_META_ID_VALUE;
                *dst = (unsigned long) num;
@@ -280,7 +280,7 @@ parse_object(struct bstr *args, struct bstr *arg, struct tcf_meta_val *obj,
 
        if (left) {
                struct tcf_meta_val *right = obj;
-               
+
                if (TCF_META_TYPE(right->kind) == TCF_META_TYPE(left->kind))
                        goto compatible;
 
@@ -301,7 +301,7 @@ parse_object(struct bstr *args, struct bstr *arg, struct tcf_meta_val *obj,
                                right->kind = overwrite_type(right, left);
                        else
                                goto not_compatible;
-               } else 
+               } else
                        goto not_compatible;
        }
 
@@ -318,9 +318,9 @@ compatible:
                                return PARSE_FAILURE;
                        }
                        a = bstr_next(a);
-                       
+
                        shift = bstrtoul(a);
-                       if (shift == LONG_MAX) {
+                       if (shift == ULONG_MAX) {
                                PARSE_ERR(a, "meta: invalid shift, must " \
                                    "be numeric");
                                return PARSE_FAILURE;
@@ -336,9 +336,9 @@ compatible:
                                return PARSE_FAILURE;
                        }
                        a = bstr_next(a);
-                       
+
                        mask = bstrtoul(a);
-                       if (mask == LONG_MAX) {
+                       if (mask == ULONG_MAX) {
                                PARSE_ERR(a, "meta: invalid mask, must be " \
                                    "numeric");
                                return PARSE_FAILURE;
@@ -400,17 +400,14 @@ static int meta_parse_eopt(struct nlmsghdr *n, struct tcf_ematch_hdr *hdr,
                return -1;
        else if (a != NULL)
                return PARSE_ERR(a, "meta: unexpected trailer");
-       
+
 
        addraw_l(n, MAX_MSG, hdr, sizeof(*hdr));
 
        addattr_l(n, MAX_MSG, TCA_EM_META_HDR, &meta_hdr, sizeof(meta_hdr));
 
-       if (lvalue)
-               dump_value(n, TCA_EM_META_LVALUE, lvalue, &meta_hdr.left);
-
-       if (rvalue)
-               dump_value(n, TCA_EM_META_RVALUE, rvalue, &meta_hdr.right);
+       dump_value(n, TCA_EM_META_LVALUE, lvalue, &meta_hdr.left);
+       dump_value(n, TCA_EM_META_RVALUE, rvalue, &meta_hdr.right);
 
        return 0;
 }