~james-page/ubuntu/saucy/openvswitch/1.12-snapshot

« back to all changes in this revision

Viewing changes to lib/classifier.h

  • Committer: James Page
  • Date: 2013-08-21 10:16:57 UTC
  • mfrom: (1.1.20)
  • Revision ID: james.page@canonical.com-20130821101657-3o0z0qeiv5zkwlzi
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
struct classifier {
42
42
    int n_rules;                /* Total number of rules. */
43
43
    struct hmap tables;         /* Contains "struct cls_table"s.  */
 
44
    struct list tables_priority; /* Tables in descending priority order */
44
45
};
45
46
 
46
47
/* A set of rules that all have the same fields wildcarded. */
47
48
struct cls_table {
48
49
    struct hmap_node hmap_node; /* Within struct classifier 'tables' hmap. */
 
50
    struct list list_node;      /* Within classifier 'tables_priority_list' */
49
51
    struct hmap rules;          /* Contains "struct cls_rule"s. */
50
52
    struct minimask mask;       /* Wildcards for fields. */
51
53
    int n_table_rules;          /* Number of rules, including duplicates. */
 
54
    unsigned int max_priority;  /* Max priority of any rule in the table. */
 
55
    unsigned int max_count;     /* Count of max_priority rules. */
52
56
};
53
57
 
54
58
/* Returns true if 'table' is a "catch-all" table that will match every
92
96
struct cls_rule *classifier_replace(struct classifier *, struct cls_rule *);
93
97
void classifier_remove(struct classifier *, struct cls_rule *);
94
98
struct cls_rule *classifier_lookup(const struct classifier *,
95
 
                                   const struct flow *);
 
99
                                   const struct flow *,
 
100
                                   struct flow_wildcards *);
96
101
bool classifier_rule_overlaps(const struct classifier *,
97
102
                              const struct cls_rule *);
98
103
 
119
124
 
120
125
#define CLS_CURSOR_FOR_EACH(RULE, MEMBER, CURSOR)                       \
121
126
    for (ASSIGN_CONTAINER(RULE, cls_cursor_first(CURSOR), MEMBER);      \
122
 
         &(RULE)->MEMBER != NULL;                                       \
 
127
         RULE != OBJECT_CONTAINING(NULL, RULE, MEMBER);                 \
123
128
         ASSIGN_CONTAINER(RULE, cls_cursor_next(CURSOR, &(RULE)->MEMBER), \
124
129
                          MEMBER))
125
130
 
126
131
#define CLS_CURSOR_FOR_EACH_SAFE(RULE, NEXT, MEMBER, CURSOR)            \
127
132
    for (ASSIGN_CONTAINER(RULE, cls_cursor_first(CURSOR), MEMBER);      \
128
 
         (&(RULE)->MEMBER != NULL                                       \
 
133
         (RULE != OBJECT_CONTAINING(NULL, RULE, MEMBER)                 \
129
134
          ? ASSIGN_CONTAINER(NEXT, cls_cursor_next(CURSOR, &(RULE)->MEMBER), \
130
 
                             MEMBER)                                    \
 
135
                             MEMBER), 1                                 \
131
136
          : 0);                                                         \
132
137
         (RULE) = (NEXT))
133
138