Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F143874321
D36169.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D36169.diff
View Options
diff --git a/sys/net/route.c b/sys/net/route.c
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -188,11 +188,10 @@
rib_add_redirect(u_int fibnum, struct sockaddr *dst, struct sockaddr *gateway,
struct sockaddr *author, struct ifnet *ifp, int flags, int lifetime_sec)
{
+ struct route_nhop_data rnd = { .rnd_weight = RT_DEFAULT_WEIGHT };
struct rib_cmd_info rc;
- int error;
- struct rt_addrinfo info;
- struct rt_metrics rti_rmx;
struct ifaddr *ifa;
+ int error;
NET_EPOCH_ASSERT();
@@ -208,21 +207,21 @@
if ((ifa = ifaof_ifpforaddr(gateway, ifp)) == NULL)
return (ENETUNREACH);
- bzero(&info, sizeof(info));
- info.rti_info[RTAX_DST] = dst;
- info.rti_info[RTAX_GATEWAY] = gateway;
- info.rti_ifa = ifa;
- info.rti_ifp = ifp;
- info.rti_flags = flags;
-
- /* Setup route metrics to define expire time. */
- bzero(&rti_rmx, sizeof(rti_rmx));
- /* Set expire time as absolute. */
- rti_rmx.rmx_expire = lifetime_sec + time_second;
- info.rti_mflags |= RTV_EXPIRE;
- info.rti_rmx = &rti_rmx;
-
- error = rib_action(fibnum, RTM_ADD, &info, &rc);
+ struct nhop_object *nh = nhop_alloc(fibnum, dst->sa_family);
+ if (nh == NULL)
+ return (ENOMEM);
+
+ nhop_set_gw(nh, gateway, flags & RTF_GATEWAY);
+ nhop_set_transmit_ifp(nh, ifp);
+ nhop_set_src(nh, ifa);
+ nhop_set_pxtype_flag(nh, NHF_HOST);
+ nhop_set_expire(nh, lifetime_sec + time_uptime);
+ nhop_set_redirect(nh, true);
+ rnd.rnd_nhop = nhop_get_nhop(nh, &error);
+ if (error == 0) {
+ error = rib_add_route_px(fibnum, dst, -1,
+ &rnd, RTM_F_CREATE, &rc);
+ }
if (error != 0) {
/* TODO: add per-fib redirect stats. */
@@ -232,10 +231,11 @@
RTSTAT_INC(rts_dynamic);
/* Send notification of a route addition to userland. */
- bzero(&info, sizeof(info));
- info.rti_info[RTAX_DST] = dst;
- info.rti_info[RTAX_GATEWAY] = gateway;
- info.rti_info[RTAX_AUTHOR] = author;
+ struct rt_addrinfo info = {
+ .rti_info[RTAX_DST] = dst,
+ .rti_info[RTAX_GATEWAY] = gateway,
+ .rti_info[RTAX_AUTHOR] = author,
+ };
rt_missmsg_fib(RTM_REDIRECT, &info, flags | RTF_UP, error, fibnum);
return (0);
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1575,18 +1575,15 @@
{
int fibnum;
struct sockaddr_in6 sin6;
- struct rt_addrinfo info;
struct rib_cmd_info rc;
struct epoch_tracker et;
lltable_fill_sa_entry(ln, (struct sockaddr *)&sin6);
- memset(&info, 0, sizeof(info));
- info.rti_info[RTAX_DST] = (struct sockaddr *)&sin6;
- info.rti_filter = nd6_isdynrte;
NET_EPOCH_ENTER(et);
for (fibnum = 0; fibnum < rt_numfibs; fibnum++)
- rib_action(fibnum, RTM_DELETE, &info, &rc);
+ rib_del_route_px(fibnum, (struct sockaddr *)&sin6, 128,
+ nd6_isdynrte, NULL, 0, &rc);
NET_EPOCH_EXIT(et);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 2, 8:49 AM (17 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28411467
Default Alt Text
D36169.diff (2 KB)
Attached To
Mode
D36169: routing: make rib_add_redirect() use new nhop-based KPI
Attached
Detach File
Event Timeline
Log In to Comment