From nobody Wed Dec 29 21:30:32 2021 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 8C25E190D24B; Wed, 29 Dec 2021 21:30:32 +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 4JPPhS2Bywz3FCf; Wed, 29 Dec 2021 21:30:32 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 2B5F8402A; Wed, 29 Dec 2021 21:30:32 +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 1BTLUWo4063677; Wed, 29 Dec 2021 21:30:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BTLUWx8063676; Wed, 29 Dec 2021 21:30:32 GMT (envelope-from git) Date: Wed, 29 Dec 2021 21:30:32 GMT Message-Id: <202112292130.1BTLUWx8063676@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: ff3a85d32411 - main - [lltable] Add per-family lltable getters. 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: ff3a85d32411cdd7894f932b1d3d7ce01ec7a648 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640813432; 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=Jg/5wh7kf70l60KUjrfsgf37lHzJMVrKcWiFTIYx5dg=; b=LNpMtNfXuPe2WAE1yKzKzvOTYYmuNMO5/ztbWUAvgzPy4+lnrJvE7O5XBXrqa+3IoJiB68 aF3tavu+20P4pGUbYdx5puD2baCX4VPWZDoh90P7bieDaTnB6woAhTufS63B8Kt9G8ss47 Em81d5lWvNaFDJgk3JYvGf75KWe29v/jV/A70DK9cUppAwM+xlbfpLTcOcMIZrwMuKXMqC RUrMEix42JdMlFwBOjZ1qagUaAKawRXo4kmTb3co609Bdz0YQe02jN5EZbALeQDsSYX+Si IRM7n+FpI3I425YNtIdUXd3dcSi+s2Bilpe6O6Ub/OZcYHyC7Kmi94holFG6SQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640813432; a=rsa-sha256; cv=none; b=C2+qDwzZhtX8PaT/nK9cuO0y3voamoDoB7o1mUfYYX9Ll6wcXZe9OIddHfBkj4rNOMlEEg 3yuX3J2vO9IukHJItcVH+RYUR5XWH1v9jIcwhkZhCFK/9PZgEoZvT0fXpL/glk9bzZDAwC xmTBGylwjrDQ0x06o6RgSwxOFnOEQ4WOr/6E2cZpcx22aArFRHbojo6upiXkCzNWJy+GQx 4oCuQnaXNYnM6ZcV/fsO/UTKbf0vFwrFdm1E3tl5l3zuqfBK05C56xfgZKNdPVbiTg0crp svkclkLGqi+nOEQgccxbhuFdd6E4w+FFpq8zR6dVdRZOYoF6b3aHSpN8trgy7g== 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=ff3a85d32411cdd7894f932b1d3d7ce01ec7a648 commit ff3a85d32411cdd7894f932b1d3d7ce01ec7a648 Author: Alexander V. Chernikov AuthorDate: 2021-12-26 12:39:26 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-12-29 20:57:15 +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 MFC after: 2 weeks --- 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 914ca57dee38..a504f54a026e 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1704,6 +1704,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 feee4f3f64a5..3c03c2996d9b 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -2483,6 +2483,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) {