From nobody Thu Aug 11 16:20:11 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 4M3X8X1FKTz4YqKX; Thu, 11 Aug 2022 16:20:12 +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 4M3X8X0TJ7z3lGK; Thu, 11 Aug 2022 16:20:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660234812; 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=ke+KDxBXi/joW2JjW6lsW5WM7NaemDmC+FNqVItMdDg=; b=ltR2uPVrQBkIVCc6faSrBTY09dndCxrqzESMT5Eo/2yxuAzQSFS12eYaXk4Lpnm9lAWomY 3C6wJwdeGMOBUIOeCBKW1H2tp4B7YMvk1zpWc0VSQ62vLK06v6V2e7UuheWIIGyk7HGkjb +blRLUXW+NPvoQ2oG7SPl/RPyXEeY+VyJ+/qTSfzpHKfpmSySe1KELY+onxJ04Co8I9c7t +rU9zYs5ANcPDwaZr+Xj4/6dY0lqXXo7kgIVCNGFQ6u34l0kpClu6DVMh8KJtS+Aa5X5z8 UERcI8Se0RIapT3lKqyXBXvka6Nc1iRprNzYgrvjTJxU17pdqMK0ofJMKprgVQ== 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 4M3X8W6PlfzxyD; Thu, 11 Aug 2022 16:20:11 +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 27BGKBwj045491; Thu, 11 Aug 2022 16:20:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27BGKB2e045486; Thu, 11 Aug 2022 16:20:11 GMT (envelope-from git) Date: Thu, 11 Aug 2022 16:20:11 GMT Message-Id: <202208111620.27BGKB2e045486@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: d94ec7490d31 - main - rtsock: do not allocate mbufs_tags(9) just to store a 8-bit value 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: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d94ec7490d3182ef3ad0b572acf0feb9c0a6827f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660234812; 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=ke+KDxBXi/joW2JjW6lsW5WM7NaemDmC+FNqVItMdDg=; b=B2sQBQgE83b3rf5VG+OLMBt+2PEYpJAx2DZjSgMkM0HDSfcgoItOE3NSqgDYUIMNqp06AP 2Z92IEKh4TR2v07M7Yy1oKnYMQFD7m5qr/q/Rz27aOAO97RhILqW5+CZTZXtwX76vToRqG 4gciAb2w8HjjFoKNkyQEuEkd4BN6qNIlroERSLukPF6edPgJqQZzEXgH1lcf6mnxCqz8UJ zNfbSj2SSzv8oRSeTnNph+SMVfKODNORBg0KuJHxQVZ1fz3MDb1F6GJbkWdtNzEndZQYqJ 7RYqEBFWCLpgktGwbAwhhm834GRxUHTiEah+fwY2rMfoH+zz7YsbOBhHuqLMhQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660234812; a=rsa-sha256; cv=none; b=AS17tK02hAD6c2ylQ48+LyvAPzSBno/icfYbUrBo/H3ME3Semer/bXvR2d8ivravQWxcQN eWrlyr5h6yn55fX6Xg26qKr6I+eY1+9Rc2vKbu5f/8M0I18ti4Yj1xpht0WFU0vq/79v8c 1nbbH4+Az0DDD3prtaPzIdX7OzNBNUiaXZnmb/s1LzrbJplyum6SNpq4umi0F7FaC/s4N9 TycQTaMmBkiYImDfX08v7wW1k2LBV5LuGBE8KQ9yXqSMltS2lQWbUZtEXYeDo2iAUyhmV0 WexwAAd3DzLO3Ud3w3EKTq/gf0oVjIp46VhMUYsO3h7mIm+RTN2IUbAn69kfOQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=d94ec7490d3182ef3ad0b572acf0feb9c0a6827f commit d94ec7490d3182ef3ad0b572acf0feb9c0a6827f Author: Gleb Smirnoff AuthorDate: 2022-08-11 16:19:36 +0000 Commit: Gleb Smirnoff CommitDate: 2022-08-11 16:19:36 +0000 rtsock: do not allocate mbufs_tags(9) just to store a 8-bit value Use local storage of the mbuf packet header instead. Reviewed by: melifaro Differential revision: https://reviews.freebsd.org/D36121 --- sys/net/rtsock.c | 33 ++++++++------------------------- sys/sys/mbuf.h | 2 +- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index cbec7d351bd5..837491a3821b 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -154,6 +154,10 @@ int (*carp_get_vhid_p)(struct ifaddr *); * notification to a socket bound to a particular FIB. */ #define RTS_FILTER_FIB M_PROTO8 +/* + * Used to store address family of the notification. + */ +#define m_rtsock_family m_pkthdr.PH_loc.eight[0] typedef struct { int ip_count; /* attached w/ AF_INET */ @@ -292,17 +296,9 @@ static void rts_input(struct mbuf *m) { struct sockproto route_proto; - unsigned short *family; - struct m_tag *tag; route_proto.sp_family = PF_ROUTE; - tag = m_tag_find(m, PACKET_TAG_RTSOCKFAM, NULL); - if (tag != NULL) { - family = (unsigned short *)(tag + 1); - route_proto.sp_protocol = *family; - m_tag_delete(m, tag); - } else - route_proto.sp_protocol = 0; + route_proto.sp_protocol = m->m_rtsock_family; raw_input_ext(m, &route_proto, &route_src, raw_input_rts_cb); } @@ -2183,23 +2179,10 @@ rt_ifannouncemsg(struct ifnet *ifp, int what) static void rt_dispatch(struct mbuf *m, sa_family_t saf) { - struct m_tag *tag; - /* - * Preserve the family from the sockaddr, if any, in an m_tag for - * use when injecting the mbuf into the routing socket buffer from - * the netisr. - */ - if (saf != AF_UNSPEC) { - tag = m_tag_get(PACKET_TAG_RTSOCKFAM, sizeof(unsigned short), - M_NOWAIT); - if (tag == NULL) { - m_freem(m); - return; - } - *(unsigned short *)(tag + 1) = saf; - m_tag_prepend(m, tag); - } + M_ASSERTPKTHDR(m); + + m->m_rtsock_family = saf; if (V_loif) m->m_pkthdr.rcvif = V_loif; else { diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 48ed63ef67b8..9e50a640eac0 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1385,7 +1385,7 @@ extern bool mb_use_ext_pgs; /* Use ext_pgs for sendfile */ #define PACKET_TAG_IPFORWARD 18 /* ipforward info */ #define PACKET_TAG_MACLABEL (19 | MTAG_PERSISTENT) /* MAC label */ #define PACKET_TAG_PF 21 /* PF/ALTQ information */ -#define PACKET_TAG_RTSOCKFAM 25 /* rtsock sa family */ +/* was PACKET_TAG_RTSOCKFAM 25 rtsock sa family */ #define PACKET_TAG_IPOPTIONS 27 /* Saved IP options */ #define PACKET_TAG_CARP 28 /* CARP info */ #define PACKET_TAG_IPSEC_NAT_T_PORTS 29 /* two uint16_t */