From nobody Mon Aug 29 10:23:50 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MGRP30mQ5z4Znvt; Mon, 29 Aug 2022 10:23:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MGRP26g2Tz3tmB; Mon, 29 Aug 2022 10:23:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661768631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wOuiqAddrxQ4xiTZnptK3MakgM4FrEYoFPogVxQ5rP4=; b=gCZAaTvvIbpTEBuDdOZGcf1usAfOp6dCz2aCthwfidodk3szgizTkEI6lrvEsYPHZOmeaq dUhyiJeF673GbMknVyJKTjJCdjq2b0/x814Wmkuie3yzKSZSGiIWAX0tn793ajwF1/EDM3 6rvMNA+ELYK97w0xcb8SYzdr7GhDgy7q9LuWRjYhY/ZEzOqBWrmWE+g+JcJweoXKcAPXTL bxd2hcmSI6ueH7SK5uW5R4V+XgPmJ+ifAgrjvop+YWWnUX5KT9ARi8Dh+JEMdHpS4gKqUB QZ4wyX4Qf/07aYcM4J6ohrD5CvXhROc/oeD717JMka9ah4Yqg+II41XYv42taQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MGRP25bM9zPGr; Mon, 29 Aug 2022 10:23:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27TANo6o015089; Mon, 29 Aug 2022 10:23:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27TANoOB015088; Mon, 29 Aug 2022 10:23:50 GMT (envelope-from git) Date: Mon, 29 Aug 2022 10:23:50 GMT Message-Id: <202208291023.27TANoOB015088@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 6d4f6e4c704d - main - routing: make rib_add_redirect() use new nhop-based KPI List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6d4f6e4c704d17084144ac3fe0c8507015f1357f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661768631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wOuiqAddrxQ4xiTZnptK3MakgM4FrEYoFPogVxQ5rP4=; b=cxnhJN+zQdOCraEaLqFz8Kq8S+29qDqXzxUs5/LrtxapvNSRQjjWLak4uJcL70btDJHJ1Z 09S+I8n6KhX0niZTdM3dmKykBrSWx74XCHezmY+h0xQXrEkXEu3y+SFyTt7WPXZ+laTYLk wQXykQsnqOnwpaAepi1+5a0hk2TKvH9I3n6H/9Br1+DJTY4/ODvckTNE5rimw+yKFkqNWW liMcKw4dDPPqM/c++wGgkFENjIyeyvTdbdyudjRZSyd2+Kxi/dD+FEnJmbr+OMtI4EdvZq MoJECz446MVaEIfbVNy8FOxqRaVkhD4lJ+XWx3/SE8r0ZV1ul/smnEd2o/FFYQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661768631; a=rsa-sha256; cv=none; b=I6Ev/mkz6R/UOeh862bxZGaa/aN8v+CRZ1j58Iylp606Al7y/7hKS+zEqeV84ID/mFuSOr pNpzN3ekurMNmRl1a1dhrpCJ16U5rutsXw3pE9CeMAXDUeJpLXzIHmauJi8wc/rniJIm7y nDeMWN6k5IEO6Ja+TueOXVMIbnlb7Mq/Ze/tvzJfRt89ujmuUs3gqyUpCzPNZ1mHh8Mqmi l5IbOhTDJfBGsAYq3+0WXSwG0maHalipbzuDYOGuDrN+3VpdWOGBb9uo5/KpY21jUFZgKG fIQ0eazNPv+Z6RBNZKt4hNdmZrw9eiJMiqlsl7XoGDXZlckiFKRy+A02dyKnkA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=6d4f6e4c704d17084144ac3fe0c8507015f1357f commit 6d4f6e4c704d17084144ac3fe0c8507015f1357f Author: Alexander V. Chernikov AuthorDate: 2022-08-09 11:45:59 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-08-29 10:23:26 +0000 routing: make rib_add_redirect() use new nhop-based KPI MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D36169 --- sys/net/route.c | 44 ++++++++++++++++++++++---------------------- sys/netinet6/nd6.c | 7 ++----- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/sys/net/route.c b/sys/net/route.c index 2ea8d4ab5c47..08cee070847f 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -188,11 +188,10 @@ int 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 @@ rib_add_redirect(u_int fibnum, struct sockaddr *dst, struct sockaddr *gateway, 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 @@ rib_add_redirect(u_int fibnum, struct sockaddr *dst, struct sockaddr *gateway, 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 index 0ab629c7fcd0..0382b1525d4a 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1575,18 +1575,15 @@ nd6_free_redirect(const struct llentry *ln) { 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); }