]>
git.ipfire.org Git - thirdparty/bird.git/blob - nest/rt-attr.c
2 * BIRD -- Route Attribute Cache
4 * (c) 1998--2000 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
10 * DOC: Route attribute cache
12 * Each route entry carries a set of route attributes. Several of them
13 * vary from route to route, but most attributes are usually common
14 * for a large number of routes. To conserve memory, we've decided to
15 * store only the varying ones directly in the &rte and hold the rest
16 * in a special structure called &rta which is shared among all the
17 * &rte's with these attributes.
19 * Each &rta contains all the static attributes of the route (i.e.,
20 * those which are always present) as structure members and a list of
21 * dynamic attributes represented by a linked list of &ea_list
22 * structures, each of them consisting of an array of &eattr's containing
23 * the individual attributes. An attribute can be specified more than once
24 * in the &ea_list chain and in such case the first occurrence overrides
25 * the others. This semantics is used especially when someone (for example
26 * a filter) wishes to alter values of several dynamic attributes, but
27 * it wants to preserve the original attribute lists maintained by
30 * Each &eattr contains an attribute identifier (split to protocol ID and
31 * per-protocol attribute ID), protocol dependent flags, a type code (consisting
32 * of several bit fields describing attribute characteristics) and either an
33 * embedded 32-bit value or a pointer to a &adata structure holding attribute
36 * There exist two variants of &rta's -- cached and un-cached ones. Un-cached
37 * &rta's can have arbitrarily complex structure of &ea_list's and they
38 * can be modified by any module in the route processing chain. Cached
39 * &rta's have their attribute lists normalized (that means at most one
40 * &ea_list is present and its values are sorted in order to speed up
41 * searching), they are stored in a hash table to make fast lookup possible
42 * and they are provided with a use count to allow sharing.
44 * Routing tables always contain only cached &rta's.
47 #include "nest/bird.h"
48 #include "nest/route.h"
49 #include "nest/protocol.h"
50 #include "nest/iface.h"
52 #include "nest/attrs.h"
53 #include "lib/alloca.h"
54 #include "lib/resource.h"
55 #include "lib/string.h"
59 static slab
*rta_slab
;
60 static slab
*mpnh_slab
;
61 static slab
*rte_src_slab
;
63 /* rte source ID bitmap */
65 static u32 src_id_size
, src_id_used
, src_id_pos
;
66 #define SRC_ID_SIZE_DEF 4
69 static struct rte_src
**src_table
;
70 static u32 src_hash_order
, src_hash_size
, src_hash_count
;
71 #define SRC_HASH_ORDER_DEF 6
72 #define SRC_HASH_ORDER_MAX 18
73 #define SRC_HASH_ORDER_MIN 10
75 struct protocol
*attr_class_to_protocol
[EAP_MAX
];
81 rte_src_slab
= sl_new(rta_pool
, sizeof(struct rte_src
));
84 src_id_size
= SRC_ID_SIZE_DEF
;
85 src_ids
= mb_allocz(rta_pool
, src_id_size
* sizeof(u32
));
87 /* ID 0 is reserved */
92 src_hash_order
= SRC_HASH_ORDER_DEF
;
93 src_hash_size
= 1 << src_hash_order
;
94 src_table
= mb_allocz(rta_pool
, src_hash_size
* sizeof(struct rte_src
*));
97 static inline int u32_cto(unsigned int x
) { return ffs(~x
) - 1; }
100 rte_src_alloc_id(void)
103 for (i
= src_id_pos
; i
< src_id_size
; i
++)
104 if (src_ids
[i
] != 0xffffffff)
107 /* If we are at least 7/8 full, expand */
108 if (src_id_used
> (src_id_size
* 28))
111 src_ids
= mb_realloc(src_ids
, src_id_size
* sizeof(u32
));
112 bzero(src_ids
+ i
, (src_id_size
- i
) * sizeof(u32
));
116 for (i
= 0; i
< src_id_pos
; i
++)
117 if (src_ids
[i
] != 0xffffffff)
123 ASSERT(i
< 0x8000000);
126 j
= u32_cto(src_ids
[i
]);
128 src_ids
[i
] |= (1 << j
);
134 rte_src_free_id(u32 id
)
139 ASSERT((i
< src_id_size
) && (src_ids
[i
] & (1 << j
)));
140 src_ids
[i
] &= ~(1 << j
);
144 static inline u32
rte_src_hash(struct proto
*p
, u32 x
, u32 order
)
145 { return (x
* 2902958171u) >> (32 - order
); }
148 rte_src_rehash(int step
)
150 struct rte_src
**old_tab
, *src
, *src_next
;
151 u32 old_size
, hash
, i
;
154 old_size
= src_hash_size
;
156 src_hash_order
+= step
;
157 src_hash_size
= 1 << src_hash_order
;
158 src_table
= mb_allocz(rta_pool
, src_hash_size
* sizeof(struct rte_src
*));
160 for (i
= 0; i
< old_size
; i
++)
161 for (src
= old_tab
[i
]; src
; src
= src_next
)
163 src_next
= src
->next
;
164 hash
= rte_src_hash(src
->proto
, src
->private_id
, src_hash_order
);
165 src
->next
= src_table
[hash
];
166 src_table
[hash
] = src
;
173 rt_find_source(struct proto
*p
, u32 id
)
176 u32 hash
= rte_src_hash(p
, id
, src_hash_order
);
178 for (src
= src_table
[hash
]; src
; src
= src
->next
)
179 if ((src
->proto
== p
) && (src
->private_id
== id
))
186 rt_get_source(struct proto
*p
, u32 id
)
189 u32 hash
= rte_src_hash(p
, id
, src_hash_order
);
191 for (src
= src_table
[hash
]; src
; src
= src
->next
)
192 if ((src
->proto
== p
) && (src
->private_id
== id
))
195 src
= sl_alloc(rte_src_slab
);
197 src
->private_id
= id
;
198 src
->global_id
= rte_src_alloc_id();
201 src
->next
= src_table
[hash
];
202 src_table
[hash
] = src
;
205 if ((src_hash_count
> src_hash_size
) && (src_hash_order
< SRC_HASH_ORDER_MAX
))
212 rt_remove_source(struct rte_src
**sp
)
214 struct rte_src
*src
= *sp
;
217 rte_src_free_id(src
->global_id
);
218 sl_free(rte_src_slab
, src
);
223 rt_prune_sources(void)
228 for (i
= 0; i
< src_hash_size
; i
++)
234 rt_remove_source(sp
);
240 while ((src_hash_count
< (src_hash_size
/ 4)) && (src_hash_order
> SRC_HASH_ORDER_MIN
))
249 static inline unsigned int
250 mpnh_hash(struct mpnh
*x
)
253 for (; x
; x
= x
->next
)
254 h
^= ipa_hash(x
->gw
);
260 mpnh__same(struct mpnh
*x
, struct mpnh
*y
)
262 for (; x
&& y
; x
= x
->next
, y
= y
->next
)
263 if (!ipa_equal(x
->gw
, y
->gw
) || (x
->iface
!= y
->iface
) || (x
->weight
!= y
->weight
))
270 mpnh_copy(struct mpnh
*o
)
272 struct mpnh
*first
= NULL
;
273 struct mpnh
**last
= &first
;
275 for (; o
; o
= o
->next
)
277 struct mpnh
*n
= sl_alloc(mpnh_slab
);
281 n
->weight
= o
->weight
;
291 mpnh_free(struct mpnh
*o
)
298 sl_free(mpnh_slab
, o
);
305 * Extended Attributes
308 static inline eattr
*
309 ea__find(ea_list
*e
, unsigned id
)
316 if (e
->flags
& EALF_BISECT
)
333 for(m
=0; m
<e
->count
; m
++)
334 if (e
->attrs
[m
].id
== id
)
342 * ea_find - find an extended attribute
343 * @e: attribute list to search in
344 * @id: attribute ID to search for
346 * Given an extended attribute list, ea_find() searches for a first
347 * occurrence of an attribute with specified ID, returning either a pointer
348 * to its &eattr structure or %NULL if no such attribute exists.
351 ea_find(ea_list
*e
, unsigned id
)
353 eattr
*a
= ea__find(e
, id
& EA_CODE_MASK
);
355 if (a
&& (a
->type
& EAF_TYPE_MASK
) == EAF_TYPE_UNDEF
&&
356 !(id
& EA_ALLOW_UNDEF
))
362 * ea_get_int - fetch an integer attribute
365 * @def: default value
367 * This function is a shortcut for retrieving a value of an integer attribute
368 * by calling ea_find() to find the attribute, extracting its value or returning
369 * a provided default if no such attribute is present.
372 ea_get_int(ea_list
*e
, unsigned id
, int def
)
374 eattr
*a
= ea_find(e
, id
);
381 ea_do_sort(ea_list
*e
)
383 unsigned n
= e
->count
;
385 eattr
*b
= alloca(n
* sizeof(eattr
));
388 /* We need to use a stable sorting algorithm, hence mergesort */
394 eattr
*p
, *q
, *lo
, *hi
;
398 while (s
< n
&& p
[-1].id
<= a
[s
].id
)
404 while (s
< n
&& p
[-1].id
<= a
[s
].id
)
409 while (lo
< q
&& hi
< p
)
410 if (lo
->id
<= hi
->id
)
425 ea_do_prune(ea_list
*e
)
427 eattr
*s
, *d
, *l
, *s0
;
430 /* Discard duplicates and undefs. Do you remember sorting was stable? */
432 l
= e
->attrs
+ e
->count
;
436 while (s
< l
&& s
->id
== s
[-1].id
)
438 /* s0 is the most recent version, s[-1] the oldest one */
439 if ((s0
->type
& EAF_TYPE_MASK
) != EAF_TYPE_UNDEF
)
442 d
->type
= (d
->type
& ~EAF_ORIGINATED
) | (s
[-1].type
& EAF_ORIGINATED
);
451 * ea_sort - sort an attribute list
452 * @e: list to be sorted
454 * This function takes a &ea_list chain and sorts the attributes
455 * within each of its entries.
457 * If an attribute occurs multiple times in a single &ea_list,
458 * ea_sort() leaves only the first (the only significant) occurrence.
465 if (!(e
->flags
& EALF_SORTED
))
469 e
->flags
|= EALF_SORTED
;
472 e
->flags
|= EALF_BISECT
;
478 * ea_scan - estimate attribute list size
481 * This function calculates an upper bound of the size of
482 * a given &ea_list after merging with ea_merge().
494 return sizeof(ea_list
) + sizeof(eattr
)*cnt
;
498 * ea_merge - merge segments of an attribute list
500 * @t: buffer to store the result to
502 * This function takes a possibly multi-segment attribute list
503 * and merges all of its segments to one.
505 * The primary use of this function is for &ea_list normalization:
506 * first call ea_scan() to determine how much memory will the result
507 * take, then allocate a buffer (usually using alloca()), merge the
508 * segments with ea_merge() and finally sort and prune the result
509 * by calling ea_sort().
512 ea_merge(ea_list
*e
, ea_list
*t
)
521 memcpy(d
, e
->attrs
, sizeof(eattr
)*e
->count
);
522 t
->count
+= e
->count
;
529 * ea_same - compare two &ea_list's
533 * ea_same() compares two normalized attribute lists @x and @y and returns
534 * 1 if they contain the same attributes, 0 otherwise.
537 ea_same(ea_list
*x
, ea_list
*y
)
543 ASSERT(!x
->next
&& !y
->next
);
544 if (x
->count
!= y
->count
)
546 for(c
=0; c
<x
->count
; c
++)
548 eattr
*a
= &x
->attrs
[c
];
549 eattr
*b
= &y
->attrs
[c
];
551 if (a
->id
!= b
->id
||
552 a
->flags
!= b
->flags
||
553 a
->type
!= b
->type
||
554 ((a
->type
& EAF_EMBEDDED
) ? a
->u
.data
!= b
->u
.data
: !adata_same(a
->u
.ptr
, b
->u
.ptr
)))
560 static inline ea_list
*
561 ea_list_copy(ea_list
*o
)
569 len
= sizeof(ea_list
) + sizeof(eattr
) * o
->count
;
570 n
= mb_alloc(rta_pool
, len
);
572 n
->flags
|= EALF_CACHED
;
573 for(i
=0; i
<o
->count
; i
++)
575 eattr
*a
= &n
->attrs
[i
];
576 if (!(a
->type
& EAF_EMBEDDED
))
578 unsigned size
= sizeof(struct adata
) + a
->u
.ptr
->length
;
579 struct adata
*d
= mb_alloc(rta_pool
, size
);
580 memcpy(d
, a
->u
.ptr
, size
);
595 for(i
=0; i
<o
->count
; i
++)
597 eattr
*a
= &o
->attrs
[i
];
598 if (!(a
->type
& EAF_EMBEDDED
))
606 get_generic_attr(eattr
*a
, byte
**buf
, int buflen UNUSED
)
608 if (a
->id
== EA_GEN_IGP_METRIC
)
610 *buf
+= bsprintf(*buf
, "igp_metric");
618 opaque_format(struct adata
*ad
, byte
*buf
, unsigned int size
)
620 byte
*bound
= buf
+ size
- 10;
623 for(i
= 0; i
< ad
->length
; i
++)
633 buf
+= bsprintf(buf
, "%02x", ad
->data
[i
]);
641 ea_show_int_set(struct cli
*c
, struct adata
*ad
, int way
, byte
*pos
, byte
*buf
, byte
*end
)
643 int i
= int_set_format(ad
, way
, 0, pos
, end
- pos
);
644 cli_printf(c
, -1012, "\t%s", buf
);
647 i
= int_set_format(ad
, way
, i
, buf
, end
- buf
- 1);
648 cli_printf(c
, -1012, "\t\t%s", buf
);
653 ea_show_ec_set(struct cli
*c
, struct adata
*ad
, byte
*pos
, byte
*buf
, byte
*end
)
655 int i
= ec_set_format(ad
, 0, pos
, end
- pos
);
656 cli_printf(c
, -1012, "\t%s", buf
);
659 i
= ec_set_format(ad
, i
, buf
, end
- buf
- 1);
660 cli_printf(c
, -1012, "\t\t%s", buf
);
665 * ea_show - print an &eattr to CLI
666 * @c: destination CLI
667 * @e: attribute to be printed
669 * This function takes an extended attribute represented by its &eattr
670 * structure and prints it to the CLI according to the type information.
672 * If the protocol defining the attribute provides its own
673 * get_attr() hook, it's consulted first.
676 ea_show(struct cli
*c
, eattr
*e
)
679 int status
= GA_UNKNOWN
;
680 struct adata
*ad
= (e
->type
& EAF_EMBEDDED
) ? NULL
: e
->u
.ptr
;
681 byte buf
[CLI_MSG_SIZE
];
682 byte
*pos
= buf
, *end
= buf
+ sizeof(buf
);
684 if (p
= attr_class_to_protocol
[EA_PROTO(e
->id
)])
686 pos
+= bsprintf(pos
, "%s.", p
->name
);
688 status
= p
->get_attr(e
, pos
, end
- pos
);
691 else if (EA_PROTO(e
->id
))
692 pos
+= bsprintf(pos
, "%02x.", EA_PROTO(e
->id
));
694 status
= get_generic_attr(e
, &pos
, end
- pos
);
696 if (status
< GA_NAME
)
697 pos
+= bsprintf(pos
, "%02x", EA_ID(e
->id
));
698 if (status
< GA_FULL
)
702 switch (e
->type
& EAF_TYPE_MASK
)
705 bsprintf(pos
, "%u", e
->u
.data
);
707 case EAF_TYPE_OPAQUE
:
708 opaque_format(ad
, pos
, end
- pos
);
710 case EAF_TYPE_IP_ADDRESS
:
711 bsprintf(pos
, "%I", *(ip_addr
*) ad
->data
);
713 case EAF_TYPE_ROUTER_ID
:
714 bsprintf(pos
, "%R", e
->u
.data
);
716 case EAF_TYPE_AS_PATH
:
717 as_path_format(ad
, pos
, end
- pos
);
719 case EAF_TYPE_INT_SET
:
720 ea_show_int_set(c
, ad
, 1, pos
, buf
, end
);
722 case EAF_TYPE_EC_SET
:
723 ea_show_ec_set(c
, ad
, pos
, buf
, end
);
727 bsprintf(pos
, "<type %02x>", e
->type
);
730 cli_printf(c
, -1012, "\t%s", buf
);
734 * ea_dump - dump an extended attribute
735 * @e: attribute to be dumped
737 * ea_dump() dumps contents of the extended attribute given to
753 (e
->flags
& EALF_SORTED
) ? 'S' : 's',
754 (e
->flags
& EALF_BISECT
) ? 'B' : 'b',
755 (e
->flags
& EALF_CACHED
) ? 'C' : 'c');
756 for(i
=0; i
<e
->count
; i
++)
758 eattr
*a
= &e
->attrs
[i
];
759 debug(" %02x:%02x.%02x", EA_PROTO(a
->id
), EA_ID(a
->id
), a
->flags
);
760 if (a
->type
& EAF_TEMP
)
762 debug("=%c", "?iO?I?P???S?????" [a
->type
& EAF_TYPE_MASK
]);
763 if (a
->type
& EAF_ORIGINATED
)
765 if (a
->type
& EAF_EMBEDDED
)
766 debug(":%08x", a
->u
.data
);
769 int j
, len
= a
->u
.ptr
->length
;
772 debug("%02x", a
->u
.ptr
->data
[j
]);
781 * ea_hash - calculate an &ea_list hash key
784 * ea_hash() takes an extended attribute list and calculated a hopefully
785 * uniformly distributed hash value from its contents.
793 if (e
) /* Assuming chain of length 1 */
795 for(i
=0; i
<e
->count
; i
++)
797 struct eattr
*a
= &e
->attrs
[i
];
799 if (a
->type
& EAF_EMBEDDED
)
803 struct adata
*d
= a
->u
.ptr
;
804 int size
= d
->length
;
813 h
= (h
>> 24) ^ (h
<< 8) ^ *z
++;
824 * ea_append - concatenate &ea_list's
825 * @to: destination list (can be %NULL)
826 * @what: list to be appended (can be %NULL)
828 * This function appends the &ea_list @what at the end of
829 * &ea_list @to and returns a pointer to the resulting list.
832 ea_append(ea_list
*to
, ea_list
*what
)
849 static unsigned int rta_cache_count
;
850 static unsigned int rta_cache_size
= 32;
851 static unsigned int rta_cache_limit
;
852 static unsigned int rta_cache_mask
;
853 static rta
**rta_hash_table
;
858 rta_hash_table
= mb_allocz(rta_pool
, sizeof(rta
*) * rta_cache_size
);
859 if (rta_cache_size
< 32768)
860 rta_cache_limit
= rta_cache_size
* 2;
862 rta_cache_limit
= ~0;
863 rta_cache_mask
= rta_cache_size
- 1;
866 static inline unsigned int
869 return (((unsigned) a
->src
) ^ ipa_hash(a
->gw
) ^
870 mpnh_hash(a
->nexthops
) ^ ea_hash(a
->eattrs
)) & 0xffff;
874 rta_same(rta
*x
, rta
*y
)
876 return (x
->src
== y
->src
&&
877 x
->source
== y
->source
&&
878 x
->scope
== y
->scope
&&
879 x
->cast
== y
->cast
&&
880 x
->dest
== y
->dest
&&
881 x
->flags
== y
->flags
&&
882 x
->igp_metric
== y
->igp_metric
&&
883 ipa_equal(x
->gw
, y
->gw
) &&
884 ipa_equal(x
->from
, y
->from
) &&
885 x
->iface
== y
->iface
&&
886 x
->hostentry
== y
->hostentry
&&
887 mpnh_same(x
->nexthops
, y
->nexthops
) &&
888 ea_same(x
->eattrs
, y
->eattrs
));
894 rta
*r
= sl_alloc(rta_slab
);
896 memcpy(r
, o
, sizeof(rta
));
898 r
->nexthops
= mpnh_copy(o
->nexthops
);
899 r
->eattrs
= ea_list_copy(o
->eattrs
);
906 unsigned int h
= r
->hash_key
& rta_cache_mask
;
907 r
->next
= rta_hash_table
[h
];
909 r
->next
->pprev
= &r
->next
;
910 r
->pprev
= &rta_hash_table
[h
];
911 rta_hash_table
[h
] = r
;
917 unsigned int ohs
= rta_cache_size
;
920 rta
**oht
= rta_hash_table
;
922 rta_cache_size
= 2*rta_cache_size
;
923 DBG("Rehashing rta cache from %d to %d entries.\n", ohs
, rta_cache_size
);
926 for(r
=oht
[h
]; r
; r
=n
)
935 * rta_lookup - look up a &rta in attribute cache
936 * @o: a un-cached &rta
938 * rta_lookup() gets an un-cached &rta structure and returns its cached
939 * counterpart. It starts with examining the attribute cache to see whether
940 * there exists a matching entry. If such an entry exists, it's returned and
941 * its use count is incremented, else a new entry is created with use count
944 * The extended attribute lists attached to the &rta are automatically
945 * converted to the normalized form.
953 ASSERT(!(o
->aflags
& RTAF_CACHED
));
956 if (o
->eattrs
->next
) /* Multiple ea_list's, need to merge them */
958 ea_list
*ml
= alloca(ea_scan(o
->eattrs
));
959 ea_merge(o
->eattrs
, ml
);
966 for(r
=rta_hash_table
[h
& rta_cache_mask
]; r
; r
=r
->next
)
967 if (r
->hash_key
== h
&& rta_same(r
, o
))
972 r
->aflags
= RTAF_CACHED
;
973 rt_lock_source(r
->src
);
974 rt_lock_hostentry(r
->hostentry
);
977 if (++rta_cache_count
> rta_cache_limit
)
986 ASSERT(rta_cache_count
&& (a
->aflags
& RTAF_CACHED
));
990 a
->next
->pprev
= a
->pprev
;
991 a
->aflags
= 0; /* Poison the entry */
992 rt_unlock_hostentry(a
->hostentry
);
993 rt_unlock_source(a
->src
);
994 mpnh_free(a
->nexthops
);
996 sl_free(rta_slab
, a
);
1000 * rta_dump - dump route attributes
1001 * @a: attribute structure to dump
1003 * This function takes a &rta and dumps its contents to the debug output.
1008 static char *rts
[] = { "RTS_DUMMY", "RTS_STATIC", "RTS_INHERIT", "RTS_DEVICE",
1009 "RTS_STAT_DEV", "RTS_REDIR", "RTS_RIP",
1010 "RTS_OSPF", "RTS_OSPF_IA", "RTS_OSPF_EXT1",
1011 "RTS_OSPF_EXT2", "RTS_BGP" };
1012 static char *rtc
[] = { "", " BC", " MC", " AC" };
1013 static char *rtd
[] = { "", " DEV", " HOLE", " UNREACH", " PROHIBIT" };
1015 debug("p=%s uc=%d %s %s%s%s h=%04x",
1016 a
->src
->proto
->name
, a
->uc
, rts
[a
->source
], ip_scope_text(a
->scope
), rtc
[a
->cast
],
1017 rtd
[a
->dest
], a
->hash_key
);
1018 if (!(a
->aflags
& RTAF_CACHED
))
1020 debug(" <-%I", a
->from
);
1021 if (a
->dest
== RTD_ROUTER
)
1022 debug(" ->%I", a
->gw
);
1023 if (a
->dest
== RTD_DEVICE
|| a
->dest
== RTD_ROUTER
)
1024 debug(" [%s]", a
->iface
? a
->iface
->name
: "???" );
1033 * rta_dump_all - dump attribute cache
1035 * This function dumps the whole contents of route attribute cache
1036 * to the debug output.
1044 debug("Route attribute cache (%d entries, rehash at %d):\n", rta_cache_count
, rta_cache_limit
);
1045 for(h
=0; h
<rta_cache_size
; h
++)
1046 for(a
=rta_hash_table
[h
]; a
; a
=a
->next
)
1056 rta_show(struct cli
*c
, rta
*a
, ea_list
*eal
)
1058 static char *src_names
[] = { "dummy", "static", "inherit", "device", "static-device", "redirect",
1059 "RIP", "OSPF", "OSPF-IA", "OSPF-E1", "OSPF-E2", "BGP", "pipe" };
1060 static char *cast_names
[] = { "unicast", "broadcast", "multicast", "anycast" };
1063 cli_printf(c
, -1008, "\tType: %s %s %s", src_names
[a
->source
], cast_names
[a
->cast
], ip_scope_text(a
->scope
));
1066 for(; eal
; eal
=eal
->next
)
1067 for(i
=0; i
<eal
->count
; i
++)
1068 ea_show(c
, &eal
->attrs
[i
]);
1072 * rta_init - initialize route attribute cache
1074 * This function is called during initialization of the routing
1075 * table module to set up the internals of the attribute cache.
1080 rta_pool
= rp_new(&root_pool
, "Attributes");
1081 rta_slab
= sl_new(rta_pool
, sizeof(rta
));
1082 mpnh_slab
= sl_new(rta_pool
, sizeof(struct mpnh
));
1088 * Documentation for functions declared inline in route.h
1093 * rta_clone - clone route attributes
1094 * @r: a &rta to be cloned
1096 * rta_clone() takes a cached &rta and returns its identical cached
1097 * copy. Currently it works by just returning the original &rta with
1098 * its use count incremented.
1100 static inline rta
*rta_clone(rta
*r
)
1104 * rta_free - free route attributes
1105 * @r: a &rta to be freed
1107 * If you stop using a &rta (for example when deleting a route which uses
1108 * it), you need to call rta_free() to notify the attribute cache the
1109 * attribute is no longer in use and can be freed if you were the last
1110 * user (which rta_free() tests by inspecting the use count).
1112 static inline void rta_free(rta
*r
)