From nobody Thu Aug 11 20:37: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 4M3dsp6DJgz4YrlP; Thu, 11 Aug 2022 20:37:50 +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 4M3dsp5cCjz3QCt; Thu, 11 Aug 2022 20:37:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660250270; 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=g4aYpnaWNbJ3etOfRteFt2xu3IZjiDMhirkdbjdZbXU=; b=b2d7n+ePWaGyC25G5aXsmXYp+JvRsm2sovklv/Qu4qFJcZjJ+inEmnJkfQGUsDf/NRG3sn YWYrNmuSPqsWpmlin8G8fj1uCYmU/YF9IjRw9wSxUUkbI47aYjJzhKFQakyPJud6LUWw3a XehWySz4mBiu6Ze5j/9VaDDYpLdYSTwztQXhFO5ZCWDv/yvDROqF7uRlIcwhIZwfj8/niE AHS1WexiIxQS/ukEFh9Q9MMNIz/0aMZ+FcQ6AzWHW44Dfh2xtSVM1cKcTXizwz7SoQMdv1 XAuUI4qxQ/i4sMg5qYDcd89P0J6DeOX89dzOsPsTgfGsw5+nltY0fUKYH+4ouA== 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 4M3dsp4Nqrz1509; Thu, 11 Aug 2022 20:37: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 27BKbodp094948; Thu, 11 Aug 2022 20:37:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27BKboO1094947; Thu, 11 Aug 2022 20:37:50 GMT (envelope-from git) Date: Thu, 11 Aug 2022 20:37:50 GMT Message-Id: <202208112037.27BKboO1094947@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: d8b42ddcac5c - main - rtsock: subscribe to ifnet eventhandlers instead of direct calls. 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: d8b42ddcac5cb86af679968d09c45c9a7cc3e4fb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660250270; 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=g4aYpnaWNbJ3etOfRteFt2xu3IZjiDMhirkdbjdZbXU=; b=d++UjtjchCUWb692Q9to8XrTd2e2O7COfbTEk1F+l4HqHOyXhAw/nPtotjbLS45soLX1Md qFNpk7yc78k7dowYU5T5TNemljejwBO8o1qlbPHMQG5ginD+7ddxQiCVlxC53PmDXUgxOx zi1yEJ8gRH598y2kzALJIS+SkM2N3Pa/5MeVkVXM66m+UfzHlwZMBWmVcWtCsQoZgCpgcN EMtCJz1H2VetpJmj1a9ZgoCCWM18C6RaZcLNYnnLubFi8tVCX8jVv5WKQvqTBS3NcsXo2i 6LZYb7+9TFKsQLOfrVwqEabr+kkYrKYWvZDFjwjVdvMMvAb/BLiKJyvuUZdf3g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660250270; a=rsa-sha256; cv=none; b=jm1CcCtOAtXFn6r93zsPJA/1xd2NAN5B5QgoZh2Tk5Wf+ftLIJiZh0ncjzwh6/H3yPKGBB 2b8lCL3vw6hgRK3ktiJPRq1xUR1t01d8P9q7cSH9WGCvB0C/JESU+1Xy/t0Hof3DVzw7OX f5RKQJg1LaU6kWSopR2o+A0Q89YyH6ZE5US6yywu8e9VfTy50qEA7T3/FCMlGknpCp4Ph2 LCOeO1itxNIBDIP80cvj6yTJOJCtvf+fh8yfPgAb7yQAb7JvgggslNEUzW8BNySkcmccFO tZiNk4mE0DJbeD6zG2GxsZzJatpkZV42YggP1D3o03PFBwDFH4AkYO2ew72jwg== 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=d8b42ddcac5cb86af679968d09c45c9a7cc3e4fb commit d8b42ddcac5cb86af679968d09c45c9a7cc3e4fb Author: Alexander V. Chernikov AuthorDate: 2022-08-11 20:09:45 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-08-11 20:36:59 +0000 rtsock: subscribe to ifnet eventhandlers instead of direct calls. Stop treating rtsock as a "special" consumer and use already-provided ifaddr arrival/departure notifications. MFC after: 2 weeks Test Plan: ``` 21:05 [0] m@devel0 route -n monitor -> ifconfig vtnet0.2 create got message of size 24 on Tue Aug 9 21:05:44 2022 RTM_IFANNOUNCE: interface arrival/departure: len 24, if# 3, what: arrival got message of size 168 on Tue Aug 9 21:05:54 2022 RTM_IFINFO: iface status change: len 168, if# 3, link: up, flags: -> ifconfig vtnet0.2 destroy got message of size 24 on Tue Aug 9 21:05:54 2022 RTM_IFANNOUNCE: interface arrival/departure: len 24, if# 3, what: departure ``` Reviewed By: glebius Differential Revision: https://reviews.freebsd.org/D36095 MFC after: 2 weeks --- sys/net/if.c | 9 --------- sys/net/route.h | 1 - sys/net/rtsock.c | 17 ++++++++++++++++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 906f2256dd54..79995e3b9ea4 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -957,9 +957,6 @@ if_attach_internal(struct ifnet *ifp, bool vmove) EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp); if (IS_DEFAULT_VNET(curvnet)) devctl_notify("IFNET", ifp->if_xname, "ATTACH", NULL); - - /* Announce the interface. */ - rt_ifannouncemsg(ifp, IFAN_ARRIVAL); } static void @@ -1210,8 +1207,6 @@ if_detach_internal(struct ifnet *ifp, bool vmove) #endif if_purgemaddrs(ifp); - /* Announce that the interface is gone. */ - rt_ifannouncemsg(ifp, IFAN_DEPARTURE); EVENTHANDLER_INVOKE(ifnet_departure_event, ifp); if (IS_DEFAULT_VNET(curvnet)) devctl_notify("IFNET", ifp->if_xname, "DETACH", NULL); @@ -2773,8 +2768,6 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) */ ifp->if_flags |= IFF_RENAMING; - /* Announce the departure of the interface. */ - rt_ifannouncemsg(ifp, IFAN_DEPARTURE); EVENTHANDLER_INVOKE(ifnet_departure_event, ifp); if_printf(ifp, "changing name to '%s'\n", new_name); @@ -2804,8 +2797,6 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) IF_ADDR_WUNLOCK(ifp); EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp); - /* Announce the return of the interface. */ - rt_ifannouncemsg(ifp, IFAN_ARRIVAL); ifp->if_flags &= ~IFF_RENAMING; diff --git a/sys/net/route.h b/sys/net/route.h index 931b284b664d..47e4773b4700 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -415,7 +415,6 @@ struct ifmultiaddr; struct rib_head; void rt_ieee80211msg(struct ifnet *, int, void *, size_t); -void rt_ifannouncemsg(struct ifnet *, int); void rt_ifmsg(struct ifnet *); void rt_missmsg(int, struct rt_addrinfo *, int, int); void rt_missmsg_fib(int, struct rt_addrinfo *, int, int, int); diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index c9b521eed9ca..0c6c5f067dd3 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -207,6 +207,7 @@ static int sysctl_ifmalist(int af, struct walkarg *w); static void rt_getmetrics(const struct rtentry *rt, const struct nhop_object *nh, struct rt_metrics *out); static void rt_dispatch(struct mbuf *, sa_family_t); +static void rt_ifannouncemsg(struct ifnet *ifp, int what); static int handle_rtm_get(struct rt_addrinfo *info, u_int fibnum, struct rt_msghdr *rtm, struct rib_cmd_info *rc); static int update_rtm_from_rc(struct rt_addrinfo *info, @@ -272,6 +273,20 @@ VNET_SYSUNINIT(vnet_rts_uninit, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, vnet_rts_uninit, 0); #endif +static void +rts_handle_ifnet_arrival(void *arg __unused, struct ifnet *ifp) +{ + rt_ifannouncemsg(ifp, IFAN_ARRIVAL); +} +EVENTHANDLER_DEFINE(ifnet_arrival_event, rts_handle_ifnet_arrival, NULL, 0); + +static void +rts_handle_ifnet_departure(void *arg __unused, struct ifnet *ifp) +{ + rt_ifannouncemsg(ifp, IFAN_DEPARTURE); +} +EVENTHANDLER_DEFINE(ifnet_departure_event, rts_handle_ifnet_departure, NULL, 0); + static void rts_append_data(struct socket *so, struct mbuf *m) { @@ -2112,7 +2127,7 @@ rt_ieee80211msg(struct ifnet *ifp, int what, void *data, size_t data_len) * This is called to generate routing socket messages indicating * network interface arrival and departure. */ -void +static void rt_ifannouncemsg(struct ifnet *ifp, int what) { struct mbuf *m;