Add fibnum, family and vnet pointer to each rib head.
Having metadata such as fibnum or vnet in the struct rib_head is handy as it eases building functionality in the routing space. This change is required to properly bring back route redirect support. Reviewed by: bz MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D23047
This commit is contained in:
parent
0b4da9c8e4
commit
ead85fe415
@ -290,17 +290,17 @@ rtalloc_mpath_fib(struct route *ro, uint32_t hash, u_int fibnum)
|
||||
RT_UNLOCK(ro->ro_rt);
|
||||
}
|
||||
|
||||
extern int in6_inithead(void **head, int off);
|
||||
extern int in_inithead(void **head, int off);
|
||||
extern int in6_inithead(void **head, int off, u_int fibnum);
|
||||
extern int in_inithead(void **head, int off, u_int fibnum);
|
||||
|
||||
#ifdef INET
|
||||
int
|
||||
rn4_mpath_inithead(void **head, int off)
|
||||
rn4_mpath_inithead(void **head, int off, u_int fibnum)
|
||||
{
|
||||
struct rib_head *rnh;
|
||||
|
||||
hashjitter = arc4random();
|
||||
if (in_inithead(head, off) == 1) {
|
||||
if (in_inithead(head, off, fibnum) == 1) {
|
||||
rnh = (struct rib_head *)*head;
|
||||
rnh->rnh_multipath = 1;
|
||||
return 1;
|
||||
@ -311,12 +311,12 @@ rn4_mpath_inithead(void **head, int off)
|
||||
|
||||
#ifdef INET6
|
||||
int
|
||||
rn6_mpath_inithead(void **head, int off)
|
||||
rn6_mpath_inithead(void **head, int off, u_int fibnum)
|
||||
{
|
||||
struct rib_head *rnh;
|
||||
|
||||
hashjitter = arc4random();
|
||||
if (in6_inithead(head, off) == 1) {
|
||||
if (in6_inithead(head, off, fibnum) == 1) {
|
||||
rnh = (struct rib_head *)*head;
|
||||
rnh->rnh_multipath = 1;
|
||||
return 1;
|
||||
|
@ -57,8 +57,8 @@ int rt_mpath_conflict(struct rib_head *, struct rtentry *,
|
||||
void rtalloc_mpath_fib(struct route *, u_int32_t, u_int);
|
||||
struct rtentry *rt_mpath_select(struct rtentry *, uint32_t);
|
||||
int rt_mpath_deldup(struct rtentry *, struct rtentry *);
|
||||
int rn4_mpath_inithead(void **, int);
|
||||
int rn6_mpath_inithead(void **, int);
|
||||
int rn4_mpath_inithead(void **, int, u_int);
|
||||
int rn6_mpath_inithead(void **, int, u_int);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -304,7 +304,7 @@ vnet_route_init(const void *unused __unused)
|
||||
rnh = rt_tables_get_rnh_ptr(table, fam);
|
||||
if (rnh == NULL)
|
||||
panic("%s: rnh NULL", __func__);
|
||||
dom->dom_rtattach((void **)rnh, 0);
|
||||
dom->dom_rtattach((void **)rnh, 0, table);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -345,7 +345,7 @@ VNET_SYSUNINIT(vnet_route_uninit, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST,
|
||||
#endif
|
||||
|
||||
struct rib_head *
|
||||
rt_table_init(int offset)
|
||||
rt_table_init(int offset, int family, u_int fibnum)
|
||||
{
|
||||
struct rib_head *rh;
|
||||
|
||||
@ -357,6 +357,13 @@ rt_table_init(int offset)
|
||||
rn_inithead_internal(&rh->rmhead.head, rh->rmhead.mask_nodes, 0);
|
||||
rh->head.rnh_masks = &rh->rmhead;
|
||||
|
||||
/* Save metadata associated with this routing table. */
|
||||
rh->rib_family = family;
|
||||
rh->rib_fibnum = fibnum;
|
||||
#ifdef VIMAGE
|
||||
rh->rib_vnet = curvnet;
|
||||
#endif
|
||||
|
||||
/* Init locks */
|
||||
RIB_LOCK_INIT(rh);
|
||||
|
||||
|
@ -455,7 +455,7 @@ int rt_routemsg_info(int, struct rt_addrinfo *, int);
|
||||
void rt_newmaddrmsg(int, struct ifmultiaddr *);
|
||||
int rt_setgate(struct rtentry *, struct sockaddr *, struct sockaddr *);
|
||||
void rt_maskedcopy(struct sockaddr *, struct sockaddr *, struct sockaddr *);
|
||||
struct rib_head *rt_table_init(int);
|
||||
struct rib_head *rt_table_init(int, int, u_int);
|
||||
void rt_table_destroy(struct rib_head *);
|
||||
u_int rt_tables_get_gen(int table, int fam);
|
||||
|
||||
|
@ -46,6 +46,9 @@ struct rib_head {
|
||||
struct radix_node rnh_nodes[3]; /* empty tree for common case */
|
||||
struct rmlock rib_lock; /* config/data path lock */
|
||||
struct radix_mask_head rmhead; /* masks radix head */
|
||||
struct vnet *rib_vnet; /* vnet pointer */
|
||||
int rib_family; /* AF of the rtable */
|
||||
u_int rib_fibnum; /* fib number */
|
||||
};
|
||||
|
||||
#define RIB_RLOCK_TRACKER struct rm_priotracker _rib_tracker
|
||||
|
@ -297,7 +297,7 @@ IPPROTOSPACER,
|
||||
},
|
||||
};
|
||||
|
||||
extern int in_inithead(void **, int);
|
||||
extern int in_inithead(void **, int, u_int);
|
||||
extern int in_detachhead(void **, int);
|
||||
|
||||
struct domain inetdomain = {
|
||||
|
@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <netinet/ip_icmp.h>
|
||||
#include <netinet/ip_var.h>
|
||||
|
||||
extern int in_inithead(void **head, int off);
|
||||
extern int in_inithead(void **head, int off, u_int fibnum);
|
||||
#ifdef VIMAGE
|
||||
extern int in_detachhead(void **head, int off);
|
||||
#endif
|
||||
@ -116,11 +116,11 @@ static int _in_rt_was_here;
|
||||
* Initialize our routing tree.
|
||||
*/
|
||||
int
|
||||
in_inithead(void **head, int off)
|
||||
in_inithead(void **head, int off, u_int fibnum)
|
||||
{
|
||||
struct rib_head *rh;
|
||||
|
||||
rh = rt_table_init(32);
|
||||
rh = rt_table_init(32, AF_INET, fibnum);
|
||||
if (rh == NULL)
|
||||
return (0);
|
||||
|
||||
|
@ -336,7 +336,7 @@ IP6PROTOSPACER,
|
||||
},
|
||||
};
|
||||
|
||||
extern int in6_inithead(void **, int);
|
||||
extern int in6_inithead(void **, int, u_int);
|
||||
#ifdef VIMAGE
|
||||
extern int in6_detachhead(void **, int);
|
||||
#endif
|
||||
|
@ -96,7 +96,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <netinet/tcp_timer.h>
|
||||
#include <netinet/tcp_var.h>
|
||||
|
||||
extern int in6_inithead(void **head, int off);
|
||||
extern int in6_inithead(void **head, int off, u_int fibnum);
|
||||
#ifdef VIMAGE
|
||||
extern int in6_detachhead(void **head, int off);
|
||||
#endif
|
||||
@ -157,11 +157,12 @@ in6_addroute(void *v_arg, void *n_arg, struct radix_head *head,
|
||||
*/
|
||||
|
||||
int
|
||||
in6_inithead(void **head, int off)
|
||||
in6_inithead(void **head, int off, u_int fibnum)
|
||||
{
|
||||
struct rib_head *rh;
|
||||
|
||||
rh = rt_table_init(offsetof(struct sockaddr_in6, sin6_addr) << 3);
|
||||
rh = rt_table_init(offsetof(struct sockaddr_in6, sin6_addr) << 3,
|
||||
AF_INET6, fibnum);
|
||||
if (rh == NULL)
|
||||
return (0);
|
||||
|
||||
|
@ -60,7 +60,7 @@ struct domain {
|
||||
struct protosw *dom_protosw, *dom_protoswNPROTOSW;
|
||||
struct domain *dom_next;
|
||||
int (*dom_rtattach) /* initialize routing table */
|
||||
(void **, int);
|
||||
(void **, int, u_int);
|
||||
int (*dom_rtdetach) /* clean up routing table */
|
||||
(void **, int);
|
||||
void *(*dom_ifattach)(struct ifnet *);
|
||||
|
Loading…
Reference in New Issue
Block a user