aboutsummaryrefslogtreecommitdiff
path: root/sys/net/route/route_var.h
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2020-06-01 20:32:02 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2020-06-01 20:32:02 +0000
commit79674562b8883beff69f81cc9163044f8c029474 (patch)
tree2387c551ef282fa5023096d5eac13cfeb7d2ee22 /sys/net/route/route_var.h
parent30dc2aebd7e88d43d620bba765edd21fcd20f3be (diff)
downloadsrc-79674562b8883beff69f81cc9163044f8c029474.tar.gz
src-79674562b8883beff69f81cc9163044f8c029474.zip
* Add rib_<add|del|change>_route() functions to manipulate the routing table.
The main driver for the change is the need to improve notification mechanism. Currently callers guess the operation data based on the rtentry structure returned in case of successful operation result. There are two problems with this appoach. First is that it doesn't provide enough information for the upcoming multipath changes, where rtentry refers to a new nexthop group, and there is no way of guessing which paths were added during the change. Second is that some rtentry fields can change during notification and protecting from it by requiring customers to unlock rtentry is not desired. Additionally, as the consumers such as rtsock do know which operation they request in advance, making explicit add/change/del versions of the functions makes sense, especially given the functions don't share a lot of code. With that in mind, introduce rib_cmd_info notification structure and rib_<add|del|change>_route() functions, with mandatory rib_cmd_info pointer. It will be used in upcoming generalized notifications. * Move definitions of the new functions and some other functions/structures used for the routing table manipulation to a separate header file, net/route/route_ctl.h. net/route.h is a frequently used file included in ~140 places in kernel, and 90% of the users don't need these definitions. Reviewed by: ae Differential Revision: https://reviews.freebsd.org/D25067
Notes
Notes: svn path=/head/; revision=361704
Diffstat (limited to 'sys/net/route/route_var.h')
-rw-r--r--sys/net/route/route_var.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/net/route/route_var.h b/sys/net/route/route_var.h
index 176084372609..4427ac046ee8 100644
--- a/sys/net/route/route_var.h
+++ b/sys/net/route/route_var.h
@@ -35,6 +35,7 @@
#ifndef RNF_NORMAL
#include <net/radix.h>
#endif
+#include <sys/ck.h>
#include <sys/epoch.h>
#include <netinet/in.h> /* struct sockaddr_in */
#include <sys/counter.h>
@@ -63,6 +64,7 @@ struct rib_head {
struct callout expire_callout; /* Callout for expiring dynamic routes */
time_t next_expire; /* Next expire run ts */
struct nh_control *nh_control; /* nexthop subsystem data */
+ CK_STAILQ_HEAD(, rib_subscription) rnh_subscribers;/* notification subscribers */
};
#define RIB_RLOCK_TRACKER struct rm_priotracker _rib_tracker
@@ -110,12 +112,13 @@ void rt_setmetrics(const struct rt_addrinfo *info, struct rtentry *rt);
struct radix_node *rt_mpath_unlink(struct rib_head *rnh,
struct rt_addrinfo *info, struct rtentry *rto, int *perror);
#endif
+struct rib_cmd_info;
int add_route(struct rib_head *rnh, struct rt_addrinfo *info,
- struct rtentry **ret_nrt);
+ struct rib_cmd_info *rc);
int del_route(struct rib_head *rnh, struct rt_addrinfo *info,
- struct rtentry **ret_nrt);
+ struct rib_cmd_info *rc);
int change_route(struct rib_head *, struct rt_addrinfo *,
- struct rtentry **);
+ struct rib_cmd_info *rc);
VNET_PCPUSTAT_DECLARE(struct rtstat, rtstat);
#define RTSTAT_ADD(name, val) \