routing: add rt_tables_get_rnh_safe() that doesn't panic when af/fib is
incorrect. MFC after: 2 weeks
This commit is contained in:
parent
6f96b5487f
commit
fd1aa866eb
@ -35,6 +35,8 @@
|
||||
#ifndef _NET_ROUTE_ROUTE_CTL_H_
|
||||
#define _NET_ROUTE_ROUTE_CTL_H_
|
||||
|
||||
struct rib_head *rt_tables_get_rnh_safe(uint32_t table, sa_family_t family);
|
||||
|
||||
struct rib_cmd_info {
|
||||
uint8_t rc_cmd; /* RTM_ADD|RTM_DEL|RTM_CHANGE */
|
||||
uint8_t spare[3];
|
||||
|
@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <net/vnet.h>
|
||||
#include <net/route.h>
|
||||
#include <net/route/route_ctl.h>
|
||||
#include <net/route/route_var.h>
|
||||
|
||||
/* Kernel config default option. */
|
||||
@ -387,6 +388,16 @@ rt_tables_get_rnh(uint32_t table, sa_family_t family)
|
||||
return (rt_tables_get_rnh_ptr(table, family));
|
||||
}
|
||||
|
||||
struct rib_head *
|
||||
rt_tables_get_rnh_safe(uint32_t table, sa_family_t family)
|
||||
{
|
||||
if (__predict_false(table >= V_rt_numfibs))
|
||||
return (NULL);
|
||||
if (__predict_false(family >= (AF_MAX + 1)))
|
||||
return (NULL);
|
||||
return (rt_tables_get_rnh_ptr(table, family));
|
||||
}
|
||||
|
||||
u_int
|
||||
rt_tables_get_gen(uint32_t table, sa_family_t family)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user