Revision 62e64905 nest/rt-attr.c
nest/rt-attr.c | ||
---|---|---|
150 | 150 |
for (; x; x = x->next) |
151 | 151 |
{ |
152 | 152 |
h ^= ipa_hash(x->gw) ^ (h << 5) ^ (h >> 9); |
153 |
for (int i=0; i<x->labels; i++) |
|
153 |
|
|
154 |
for (int i = 0; i < x->labels; i++) |
|
154 | 155 |
h ^= x->label[i] ^ (h << 6) ^ (h >> 7); |
155 | 156 |
} |
156 | 157 |
|
... | ... | |
164 | 165 |
{ |
165 | 166 |
if (!ipa_equal(x->gw, y->gw) || (x->iface != y->iface) || (x->weight != y->weight) || (x->labels != y->labels)) |
166 | 167 |
return 0; |
167 |
for (int i=0; i<x->labels; i++) |
|
168 |
|
|
169 |
for (int i = 0; i < x->labels; i++) |
|
168 | 170 |
if (x->label[i] != y->label[i]) |
169 | 171 |
return 0; |
170 | 172 |
} |
171 | 173 |
|
172 |
return 1;
|
|
174 |
return x == y;
|
|
173 | 175 |
} |
174 | 176 |
|
175 | 177 |
static int |
... | ... | |
195 | 197 |
if (r) |
196 | 198 |
return r; |
197 | 199 |
|
198 |
for (int i=0; i<y->labels; i++)
|
|
200 |
for (int i = 0; i < y->labels; i++)
|
|
199 | 201 |
{ |
200 | 202 |
r = ((int) y->label[i]) - ((int) x->label[i]); |
201 | 203 |
if (r) |
... | ... | |
271 | 273 |
} |
272 | 274 |
|
273 | 275 |
void |
274 |
nexthop_insert(struct nexthop *n, struct nexthop *x) |
|
276 |
nexthop_insert(struct nexthop **n, struct nexthop *x)
|
|
275 | 277 |
{ |
276 |
struct nexthop tmp; |
|
277 |
memcpy(&tmp, n, sizeof(struct nexthop)); |
|
278 |
if (nexthop_compare_node(n, x) > 0) /* Insert to the included nexthop */ |
|
279 |
{ |
|
280 |
memcpy(n, x, sizeof(struct nexthop)); |
|
281 |
memcpy(x, &tmp, sizeof(struct nexthop)); |
|
282 |
n->next = x; |
|
283 |
return; |
|
284 |
} |
|
285 |
|
|
286 |
for (struct nexthop **nn = &(n->next); *nn; nn = &((*nn)->next)) |
|
278 |
for (; *n; n = &((*n)->next)) |
|
287 | 279 |
{ |
288 |
int cmp = nexthop_compare_node(*nn, x);
|
|
280 |
int cmp = nexthop_compare_node(*n, x); |
|
289 | 281 |
|
290 | 282 |
if (cmp < 0) |
291 | 283 |
continue; |
292 |
|
|
293 |
if (cmp > 0) |
|
294 |
{ |
|
295 |
x->next = *nn; |
|
296 |
*nn = x; |
|
297 |
} |
|
298 |
|
|
299 |
return; |
|
284 |
else if (cmp > 0) |
|
285 |
break; |
|
286 |
else |
|
287 |
return; |
|
300 | 288 |
} |
301 | 289 |
|
290 |
x->next = *n; |
|
291 |
*n = x; |
|
302 | 292 |
} |
303 | 293 |
|
304 | 294 |
int |
... | ... | |
314 | 304 |
static inline slab * |
315 | 305 |
nexthop_slab(struct nexthop *nh) |
316 | 306 |
{ |
317 |
return nexthop_slab_[nh->labels > 2 ? 3 : nh->labels];
|
|
307 |
return nexthop_slab_[MIN(nh->labels, 3)];
|
|
318 | 308 |
} |
319 | 309 |
|
320 | 310 |
static struct nexthop * |
Also available in: Unified diff