From nobody Mon Mar 28 15:25:58 2022 X-Original-To: dev-commits-src-all@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 C3D5F1A31918; Mon, 28 Mar 2022 15:25:59 +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 4KRxNl1s6vz3QQh; Mon, 28 Mar 2022 15:25:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648481159; 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=hM7xDsGilgXEYM1tEgs7RIxIjzmUsLNjOFUYPT86dM4=; b=TtY3ZueMug0cf+FMabHRtQw8CuHZloYdnY/nNyP1NuqZgiVNBGQhUYcGyJ++d1FPFHrejr +Qt35EbIMCtnraFk2cSc1t7mERLIo2K57htQk7dWje+71wbL/PPHoq50bj1xZujj719KsH ZI4xkY/m9lz04LpuS4ZGD9zaHZMmDtM8cxUB3nKReMvXgP3eEie/on6tRC+IKOoXmop9p1 +n2Wr4jT4yBA5qzEEiVS4WKzak7iRynofqpYUjL9ig/85BZipOx2Fr2gMxpz72hScZWbBY mMoVT+5ZFBirKd0Ifr3C7qX/CEYlbKn2ewB+Tb4w8v7MAQT68IxO4F5QZGrq9Q== 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 F154545C2; Mon, 28 Mar 2022 15:25:58 +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 22SFPwXo086865; Mon, 28 Mar 2022 15:25:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22SFPwUU086864; Mon, 28 Mar 2022 15:25:58 GMT (envelope-from git) Date: Mon, 28 Mar 2022 15:25:58 GMT Message-Id: <202203281525.22SFPwUU086864@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: fdd84c360842 - releng/13.1 - [lltable] Add per-family lltable getters. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/releng/13.1 X-Git-Reftype: branch X-Git-Commit: fdd84c3608425e769e478ff18759f8a6870e160a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648481159; 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=hM7xDsGilgXEYM1tEgs7RIxIjzmUsLNjOFUYPT86dM4=; b=xy7BYscHLw3mWhezelMChEblJdWtInCtypD3jAFmGaDFOVigMNIFG9t/6pVC9vz3X5Bb2Y 6X+pcjS7qCZdwqekcArGpReN97riovCePga902GPJRLv2/LSPN31CmV0xZ4Dr+GqAy4WQM Ylk62gCdo1OUI4CFcJ5lcF0L6SjtVkTwm6BaBEBbJf5e1nrYmEh/jFEqxqYPSTLRBfxJr9 hX3IepU/TAI2fSBbJeYI+OaEn4AYAe3ChVDeu6vj55nkVJSplGqv3oBnT24Pnhi65c3HO+ 85sMSEC2Oq7Z7JylsePeTXYzx5xO2gSmGttuh/em8OmGZ4sQs+E5rxzWAPtn7A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648481159; a=rsa-sha256; cv=none; b=f6hO/3Wlp7ILyDv+8+1DGyZikXkv5Mek13iMMNo+A/mSzhWfGPwv/zXw4tsk9/u+W2NNsg W7VE435kWxeSGNc5TzDtnz5henhaIto3tYF9wf7b6mElMuYhcHl7sXVuI4TlkcDcbSBuNU U/rKu5A08vPC6Faft+cpolYKsxjO4UYQnF40xH8J8eRTXv3MwhpsNrwAwOVXRZh3P/plTM AziMlcOWCLDIZg9tP8GzZ11VHjvuB4t0ECoNXgnfaly99pdbyXf+GchJradqDQmhh+ovrn KjXiOM0hUPrxtmt0Loo/IT6cO4vgVVgHpcjyPJMcs2fVTGEJ18ZDu7GiPjfK3A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.1 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=fdd84c3608425e769e478ff18759f8a6870e160a commit fdd84c3608425e769e478ff18759f8a6870e160a Author: Alexander V. Chernikov AuthorDate: 2021-12-26 12:39:26 +0000 Commit: Alexander V. Chernikov CommitDate: 2022-03-28 15:25:02 +0000 [lltable] Add per-family lltable getters. Introduce a new function, lltable_get(), to retrieve lltable pointer for the specified interface and family. Use it to avoid all-iftable list traversal when adding or deleting ARP/ND records. Differential Revision: https://reviews.freebsd.org/D33660 Approved by: re(gjb) MFC after: 2 weeks (cherry picked from commit ff3a85d32411cdd7894f932b1d3d7ce01ec7a648) (cherry picked from commit ffcca53561ed0b3d4755dbd2ce1d9942ea4a468e) --- sys/net/if_llatbl.c | 26 ++++++++++++++++++-------- sys/net/if_llatbl.h | 4 ++++ sys/netinet/in.c | 11 +++++++++++ sys/netinet6/in6.c | 11 +++++++++++ 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/sys/net/if_llatbl.c b/sys/net/if_llatbl.c index e4dfc45705a8..10d555b1bd86 100644 --- a/sys/net/if_llatbl.c +++ b/sys/net/if_llatbl.c @@ -712,6 +712,22 @@ lltable_unlink(struct lltable *llt) } +/* + * Gets interface @ifp lltable for the specified @family + */ +struct lltable * +lltable_get(struct ifnet *ifp, int family) +{ + switch (family) { + case AF_INET: + return (in_lltable_get(ifp)); + case AF_INET6: + return (in6_lltable_get(ifp)); + } + + return (NULL); +} + /* * External methods used by lltable consumers */ @@ -823,14 +839,8 @@ lla_rt_output(struct rt_msghdr *rtm, struct rt_addrinfo *info) return EINVAL; } - /* XXX linked list may be too expensive */ - LLTABLE_LIST_RLOCK(); - SLIST_FOREACH(llt, &V_lltables, llt_link) { - if (llt->llt_af == dst->sa_family && - llt->llt_ifp == ifp) - break; - } - LLTABLE_LIST_RUNLOCK(); + llt = lltable_get(ifp, dst->sa_family); + if (llt == NULL) return (ESRCH); diff --git a/sys/net/if_llatbl.h b/sys/net/if_llatbl.h index 7ad9d59a1a0e..dfb5e13a9436 100644 --- a/sys/net/if_llatbl.h +++ b/sys/net/if_llatbl.h @@ -222,6 +222,10 @@ void lltable_prefix_free(int, struct sockaddr *, struct sockaddr *, u_int); int lltable_sysctl_dumparp(int, struct sysctl_req *); +struct lltable *in_lltable_get(struct ifnet *ifp); +struct lltable *in6_lltable_get(struct ifnet *ifp); +struct lltable *lltable_get(struct ifnet *ifp, int family); + size_t llentry_free(struct llentry *); /* helper functions */ diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 5448c3b5fccd..2303a8f10aa4 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1695,6 +1695,17 @@ in_lltattach(struct ifnet *ifp) return (llt); } +struct lltable * +in_lltable_get(struct ifnet *ifp) +{ + struct lltable *llt = NULL; + + void *afdata_ptr = ifp->if_afdata[AF_INET]; + if (afdata_ptr != NULL) + llt = ((struct in_ifinfo *)afdata_ptr)->ii_llt; + return (llt); +} + void * in_domifattach(struct ifnet *ifp) { diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index d54aba58edb6..41b05ae2ca53 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -2462,6 +2462,17 @@ in6_lltattach(struct ifnet *ifp) return (llt); } +struct lltable * +in6_lltable_get(struct ifnet *ifp) +{ + struct lltable *llt = NULL; + + void *afdata_ptr = ifp->if_afdata[AF_INET6]; + if (afdata_ptr != NULL) + llt = ((struct in6_ifextra *)afdata_ptr)->lltable; + return (llt); +} + void * in6_domifattach(struct ifnet *ifp) {